├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── net
│ │ │ └── qiujuer
│ │ │ └── lame
│ │ │ └── sample
│ │ │ ├── helper
│ │ │ ├── AudioPlayHelper.java
│ │ │ └── AudioRecordHelper.java
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── net
│ │ │ └── qiujuer
│ │ │ └── lame
│ │ │ └── sample
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── net
│ │ └── qiujuer
│ │ └── lame
│ │ └── sample
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── lame
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ ├── cpp
│ │ │ ├── libmp3lame
│ │ │ │ ├── lameerror.h
│ │ │ │ ├── newmdct.h
│ │ │ │ ├── vbrquantize.h
│ │ │ │ ├── reservoir.h
│ │ │ │ ├── fft.h
│ │ │ │ ├── quantize.h
│ │ │ │ ├── bitstream.h
│ │ │ │ ├── id3tag.h
│ │ │ │ ├── psymodel.h
│ │ │ │ ├── version.h
│ │ │ │ ├── l3side.h
│ │ │ │ ├── tables.h
│ │ │ │ ├── set_get.h
│ │ │ │ ├── VbrTag.h
│ │ │ │ ├── lame-analysis.h
│ │ │ │ ├── gain_analysis.h
│ │ │ │ ├── encoder.h
│ │ │ │ ├── quantize_pvt.h
│ │ │ │ ├── machine.h
│ │ │ │ ├── version.c
│ │ │ │ ├── lame_global_flags.h
│ │ │ │ ├── fft.c
│ │ │ │ ├── reservoir.c
│ │ │ │ ├── mpglib_interface.c
│ │ │ │ ├── presets.c
│ │ │ │ └── encoder.c
│ │ │ ├── net_qiujuer_lame_Lame.h
│ │ │ └── net_qiujuer_lame_Lame.cpp
│ │ └── java
│ │ │ └── net
│ │ │ └── qiujuer
│ │ │ └── lame
│ │ │ ├── LameOutputStream.java
│ │ │ ├── LameAsyncEncoder.java
│ │ │ └── Lame.java
│ ├── test
│ │ └── java
│ │ │ └── net
│ │ │ └── qiujuer
│ │ │ └── lame
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── net
│ │ └── qiujuer
│ │ └── lame
│ │ └── ExampleInstrumentedTest.java
├── gradle.properties
├── CMakeLists.txt
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── README.md
├── art
├── mp3 bit rates.png
└── mp3 sampling rates.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── script
├── make-jar.gradle
└── gradle-jcenter-push.gradle
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lame/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':lame'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LameAndroid
2 | Lame mp3 converter with android.
3 |
--------------------------------------------------------------------------------
/art/mp3 bit rates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/art/mp3 bit rates.png
--------------------------------------------------------------------------------
/art/mp3 sampling rates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/art/mp3 sampling rates.png
--------------------------------------------------------------------------------
/lame/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Lame
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LameAndroid
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/lame/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_BINTRAY_NAME=net.qiujuer.lame:lame
2 | POM_DESCRIPTION=Lame mp3 converter with android.
3 | POM_ARTIFACT_ID=lame
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiujuer/LameAndroid/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jan 22 14:26:10 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/lame/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/script/make-jar.gradle:
--------------------------------------------------------------------------------
1 | task clearJar(type: Delete) {
2 | delete 'release/' + POM_ARTIFACT_ID + '_' + VERSION_NAME + '.jar'
3 | }
4 |
5 | task makeJar(type: Copy) {
6 | from('build/intermediates/bundles/release/')
7 | into('release/')
8 | include('classes.jar')
9 | rename('classes.jar', POM_ARTIFACT_ID + '_' + VERSION_NAME + '.jar')
10 | }
11 | makeJar.dependsOn(clearJar, build)
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/lame/src/test/java/net/qiujuer/lame/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.qiujuer.lame;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/test/java/net/qiujuer/lame/sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.qiujuer.lame.sample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/lame/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.4.1)
2 |
3 | #设置变量SRC_DIR为libmp3lame的所在路径
4 | set(SRC_DIR src/main/cpp/libmp3lame)
5 |
6 | #指定头文件所在,可以多次调用,指定多个路径
7 | include_directories(src/main/cpp/libmp3lame)
8 |
9 | #设定一个目录
10 | aux_source_directory(src/main/cpp/libmp3lame SRC_LIST)
11 |
12 | add_library( mp3lame-lib
13 |
14 | SHARED
15 |
16 | src/main/cpp/net_qiujuer_lame_Lame.cpp
17 |
18 | ${SRC_LIST})
19 |
20 | find_library( log-lib
21 | log)
22 |
23 | target_link_libraries( mp3lame-lib
24 |
25 | ${log-lib} )
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 |
39 | # Keystore files
40 | *.jks
41 |
42 | /local.properties/
43 | .idea/
44 | .DS_Store
45 | /build
46 | /captures
47 | .externalNativeBuild
48 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/lameerror.h:
--------------------------------------------------------------------------------
1 | /*
2 | * A collection of LAME Error Codes
3 | *
4 | * Please use the constants defined here instead of some arbitrary
5 | * values. Currently the values starting at -10 to avoid intersection
6 | * with the -1, -2, -3 and -4 used in the current code.
7 | *
8 | * May be this should be a part of the include/lame.h.
9 | */
10 |
11 | typedef enum {
12 | LAME_OKAY = 0,
13 | LAME_NOERROR = 0,
14 | LAME_GENERICERROR = -1,
15 | LAME_NOMEM = -10,
16 | LAME_BADBITRATE = -11,
17 | LAME_BADSAMPFREQ = -12,
18 | LAME_INTERNALERROR = -13,
19 |
20 | FRONTEND_READERROR = -80,
21 | FRONTEND_WRITEERROR = -81,
22 | FRONTEND_FILETOOLARGE = -82,
23 |
24 | } lame_errorcodes_t;
25 |
26 | /* end of lameerror.h */
27 |
--------------------------------------------------------------------------------
/lame/src/androidTest/java/net/qiujuer/lame/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.qiujuer.lame;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.qiujuer.lame.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/net/qiujuer/lame/sample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.qiujuer.lame.sample;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.qiujuer.lame.sample", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/qiujuer/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/lame/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/qiujuer/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/newmdct.h:
--------------------------------------------------------------------------------
1 | /*
2 | * New Modified DCT include file
3 | *
4 | * Copyright (c) 1999 Takehiro TOMINAGA
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_NEWMDCT_H
23 | #define LAME_NEWMDCT_H
24 |
25 | void mdct_sub48(lame_internal_flags * gfc, const sample_t * w0, const sample_t * w1);
26 |
27 | #endif /* LAME_NEWMDCT_H */
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/vbrquantize.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 VBR quantization
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VBRQUANTIZE_H
23 | #define LAME_VBRQUANTIZE_H
24 |
25 | int VBR_encode_frame(lame_internal_flags * gfc, const FLOAT xr34orig[2][2][576],
26 | const FLOAT l3_xmin[2][2][SFBMAX], const int maxbits[2][2]);
27 |
28 | #endif /* LAME_VBRQUANTIZE_H */
29 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion ANDROID_BUILD_SDK_VERSION as int
5 | buildToolsVersion ANDROID_BUILD_TOOLS_VERSION
6 |
7 | defaultConfig {
8 | applicationId "net.qiujuer.lame.sample"
9 | minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION
10 | targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION
11 | versionCode rootProject.ext.versionCode
12 | versionName VERSION_NAME
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(include: ['*.jar'], dir: 'libs')
25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
26 | exclude group: 'com.android.support', module: 'support-annotations'
27 | })
28 | compile 'com.android.support:appcompat-v7:25.3.0'
29 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
30 | testCompile 'junit:junit:4.12'
31 | compile project(':lame')
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/reservoir.h:
--------------------------------------------------------------------------------
1 | /*
2 | * bit reservoir include file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_RESERVOIR_H
23 | #define LAME_RESERVOIR_H
24 |
25 | int ResvFrameBegin(lame_internal_flags * gfc, int *mean_bits);
26 | void ResvMaxBits(lame_internal_flags * gfc, int mean_bits, int *targ_bits, int *max_bits,
27 | int cbr);
28 | void ResvAdjust(lame_internal_flags * gfc, gr_info const *gi);
29 | void ResvFrameEnd(lame_internal_flags * gfc, int mean_bits);
30 |
31 | #endif /* LAME_RESERVOIR_H */
32 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/fft.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Fast Fourier Transform include file
3 | *
4 | * Copyright (c) 2000 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_FFT_H
23 | #define LAME_FFT_H
24 |
25 | void fft_long(lame_internal_flags const *const gfc, FLOAT x_real[BLKSIZE],
26 | int chn, const sample_t *const data[2]);
27 |
28 | void fft_short(lame_internal_flags const *const gfc, FLOAT x_real[3][BLKSIZE_s],
29 | int chn, const sample_t *const data[2]);
30 |
31 | void init_fft(lame_internal_flags * const gfc);
32 |
33 | #endif
34 |
35 | /* End of fft.h */
36 |
--------------------------------------------------------------------------------
/lame/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion ANDROID_BUILD_SDK_VERSION as int
5 | buildToolsVersion ANDROID_BUILD_TOOLS_VERSION
6 |
7 | defaultConfig {
8 | minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION
9 | targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION
10 | versionCode rootProject.ext.versionCode
11 | versionName VERSION_NAME
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | externalNativeBuild {
15 | cmake {
16 | cppFlags "-std=c++11 -frtti -fexceptions"
17 | }
18 | }
19 |
20 | ndk {
21 | abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a',
22 | 'arm64-v8a'
23 | }
24 | }
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 | externalNativeBuild {
32 | cmake {
33 | path "CMakeLists.txt"
34 | }
35 | }
36 | }
37 |
38 | dependencies {
39 | compile fileTree(dir: 'libs', include: ['*.jar'])
40 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
41 | exclude group: 'com.android.support', module: 'support-annotations'
42 | })
43 | compile 'com.android.support:support-annotations:27.0.2'
44 | testCompile 'junit:junit:4.12'
45 | }
46 |
47 |
48 | apply from: '../script/gradle-jcenter-push.gradle'
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/quantize.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 quantization
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_QUANTIZE_H
23 | #define LAME_QUANTIZE_H
24 |
25 | void CBR_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
26 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
27 |
28 | void VBR_old_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
29 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
30 |
31 | void VBR_new_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
32 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
33 |
34 | void ABR_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
35 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
36 |
37 |
38 | #endif /* LAME_QUANTIZE_H */
39 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/bitstream.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 bitstream Output interface for LAME
3 | *
4 | * Copyright (c) 1999 Takehiro TOMINAGA
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_BITSTREAM_H
23 | #define LAME_BITSTREAM_H
24 |
25 | int getframebits(const lame_internal_flags * gfc);
26 |
27 | int format_bitstream(lame_internal_flags * gfc);
28 |
29 | void flush_bitstream(lame_internal_flags * gfc);
30 | void add_dummy_byte(lame_internal_flags * gfc, unsigned char val, unsigned int n);
31 |
32 | int copy_buffer(lame_internal_flags * gfc, unsigned char *buffer, int buffer_size,
33 | int update_crc);
34 | void init_bit_stream_w(lame_internal_flags * gfc);
35 | void CRC_writeheader(lame_internal_flags const *gfc, char *buffer);
36 | int compute_flushbits(const lame_internal_flags * gfp, int *nbytes);
37 |
38 | int get_max_frame_buffer_size_by_constraint(SessionConfig_t const * cfg, int constraint);
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
19 |
20 |
21 | VERSION_NAME=1.2.0
22 | POM_GROUP_ID=net.qiujuer.lame
23 | POM_URL=https://github.com/qiujuer/LameAndroid
24 | POM_SCM_URL=https://github.com/qiujuer/LameAndroid
25 | POM_SCM_CONNECTION=scm:git@github.com:qiujuer/LameAndroid.git
26 | POM_SCM_DEV_CONNECTION=scm:git@github.com:qiujuer/LameAndroid.git
27 | POM_LICENCE_COMMENTS=A business-friendly OSS license
28 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
29 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
30 | POM_LICENCE_DIST=repo
31 | POM_DEVELOPER_ID=qiujuer
32 | POM_DEVELOPER_NAME=Qiu Ju
33 | POM_DEVELOPER_EMAIL=qiujuer@live.cn
34 | POM_DEVELOPER_URL=http://www.qiujuer.net
35 | POM_ISSUE_MANAGEMENT_SYSTEM=Github
36 | POM_ISSUE_MANAGEMENT_URL=https://github.com/qiujuer/LameAndroid/issues
37 | POM_INCEPTION_YEAR=2017
38 | POM_BINTRAY_PRPO=maven
39 | POM_PACKAGING=aar
40 | POM_NAME=Lame
41 | POM_GIT_URL=https://github.com/qiujuer/LameAndroid.git
42 | POM_LICENCE_ALL=["Apache-2.0"]
43 |
44 | ANDROID_BUILD_MIN_SDK_VERSION=14
45 | ANDROID_BUILD_TARGET_SDK_VERSION=27
46 | ANDROID_BUILD_TOOLS_VERSION=27.0.3
47 | ANDROID_BUILD_SDK_VERSION=27
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/id3tag.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAME_ID3_H
3 | #define LAME_ID3_H
4 |
5 |
6 | #define CHANGED_FLAG (1U << 0)
7 | #define ADD_V2_FLAG (1U << 1)
8 | #define V1_ONLY_FLAG (1U << 2)
9 | #define V2_ONLY_FLAG (1U << 3)
10 | #define SPACE_V1_FLAG (1U << 4)
11 | #define PAD_V2_FLAG (1U << 5)
12 |
13 | enum {
14 | MIMETYPE_NONE = 0,
15 | MIMETYPE_JPEG,
16 | MIMETYPE_PNG,
17 | MIMETYPE_GIF,
18 | };
19 |
20 | typedef struct FrameDataNode {
21 | struct FrameDataNode *nxt;
22 | uint32_t fid; /* Frame Identifier */
23 | char lng[4]; /* 3-character language descriptor */
24 | struct {
25 | union {
26 | char *l; /* ptr to Latin-1 chars */
27 | unsigned short *u; /* ptr to UCS-2 text */
28 | unsigned char *b; /* ptr to raw bytes */
29 | } ptr;
30 | size_t dim;
31 | int enc; /* 0:Latin-1, 1:UCS-2, 2:RAW */
32 | } dsc , txt;
33 | } FrameDataNode;
34 |
35 |
36 | typedef struct id3tag_spec {
37 | /* private data members */
38 | unsigned int flags;
39 | int year;
40 | char *title;
41 | char *artist;
42 | char *album;
43 | char *comment;
44 | int track_id3v1;
45 | int genre_id3v1;
46 | unsigned char *albumart;
47 | unsigned int albumart_size;
48 | unsigned int padding_size;
49 | int albumart_mimetype;
50 | FrameDataNode *v2_head, *v2_tail;
51 | } id3tag_spec;
52 |
53 |
54 | /* write tag into stream at current position */
55 | extern int id3tag_write_v2(lame_global_flags * gfp);
56 | extern int id3tag_write_v1(lame_global_flags * gfp);
57 | /*
58 | * NOTE: A version 2 tag will NOT be added unless one of the text fields won't
59 | * fit in a version 1 tag (e.g. the title string is longer than 30 characters),
60 | * or the "id3tag_add_v2" or "id3tag_v2_only" functions are used.
61 | */
62 |
63 | #endif
64 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/net_qiujuer_lame_Lame.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class net_qiujuer_lame_Lame */
4 |
5 | #ifndef _Included_net_qiujuer_lame_Lame
6 | #define _Included_net_qiujuer_lame_Lame
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: net_qiujuer_lame_Lame
12 | * Method: nInit
13 | * Signature: (IIIIII)J
14 | */
15 | JNIEXPORT jlong JNICALL Java_net_qiujuer_lame_Lame_nInit
16 | (JNIEnv *, jclass, jint, jint, jint, jint, jint, jint);
17 |
18 | /*
19 | * Class: net_qiujuer_lame_Lame
20 | * Method: nGetVersion
21 | * Signature: (J)I
22 | */
23 | JNIEXPORT jint JNICALL Java_net_qiujuer_lame_Lame_nGetVersion
24 | (JNIEnv *, jclass, jlong);
25 |
26 | /*
27 | * Class: net_qiujuer_lame_Lame
28 | * Method: mGetMp3bufferSize
29 | * Signature: (J)I
30 | */
31 | JNIEXPORT jint JNICALL Java_net_qiujuer_lame_Lame_mGetMp3bufferSize
32 | (JNIEnv *, jclass, jlong);
33 |
34 | /*
35 | * Class: net_qiujuer_lame_Lame
36 | * Method: mGetMp3bufferSizeWithSamples
37 | * Signature: (JI)I
38 | */
39 | JNIEXPORT jint JNICALL Java_net_qiujuer_lame_Lame_mGetMp3bufferSizeWithSamples
40 | (JNIEnv *, jclass, jlong, jint);
41 |
42 | /*
43 | * Class: net_qiujuer_lame_Lame
44 | * Method: nEncodeShortInterleaved
45 | * Signature: (J[SI[B)I
46 | */
47 | JNIEXPORT jint JNICALL Java_net_qiujuer_lame_Lame_nEncodeShortInterleaved
48 | (JNIEnv *, jclass, jlong, jshortArray, jint, jbyteArray);
49 |
50 | /*
51 | * Class: net_qiujuer_lame_Lame
52 | * Method: nEncodeShort
53 | * Signature: (J[S[SI[B)I
54 | */
55 | JNIEXPORT jint JNICALL Java_net_qiujuer_lame_Lame_nEncodeShort
56 | (JNIEnv *, jclass, jlong, jshortArray, jshortArray, jint, jbyteArray);
57 |
58 | /*
59 | * Class: net_qiujuer_lame_Lame
60 | * Method: nFlush
61 | * Signature: (J[B)I
62 | */
63 | JNIEXPORT jint JNICALL Java_net_qiujuer_lame_Lame_nFlush
64 | (JNIEnv *, jclass, jlong, jbyteArray);
65 |
66 | /*
67 | * Class: net_qiujuer_lame_Lame
68 | * Method: nClose
69 | * Signature: (J)V
70 | */
71 | JNIEXPORT void JNICALL Java_net_qiujuer_lame_Lame_nClose
72 | (JNIEnv *, jclass, jlong);
73 |
74 | #ifdef __cplusplus
75 | }
76 | #endif
77 | #endif
78 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/psymodel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * psymodel.h
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_PSYMODEL_H
23 | #define LAME_PSYMODEL_H
24 |
25 |
26 | int L3psycho_anal_ns(lame_internal_flags * gfc,
27 | const sample_t *const buffer[2], int gr,
28 | III_psy_ratio ratio[2][2],
29 | III_psy_ratio MS_ratio[2][2],
30 | FLOAT pe[2], FLOAT pe_MS[2], FLOAT ener[2], int blocktype_d[2]);
31 |
32 | int L3psycho_anal_vbr(lame_internal_flags * gfc,
33 | const sample_t *const buffer[2], int gr,
34 | III_psy_ratio ratio[2][2],
35 | III_psy_ratio MS_ratio[2][2],
36 | FLOAT pe[2], FLOAT pe_MS[2], FLOAT ener[2], int blocktype_d[2]);
37 |
38 |
39 | int psymodel_init(lame_global_flags const* gfp);
40 |
41 |
42 | #define rpelev 2
43 | #define rpelev2 16
44 | #define rpelev_s 2
45 | #define rpelev2_s 16
46 |
47 | /* size of each partition band, in barks: */
48 | #define DELBARK .34
49 |
50 |
51 | /* tuned for output level (sensitive to energy scale) */
52 | #define VO_SCALE (1./( 14752*14752 )/(BLKSIZE/2))
53 |
54 | #define temporalmask_sustain_sec 0.01
55 |
56 | #define NS_PREECHO_ATT0 0.8
57 | #define NS_PREECHO_ATT1 0.6
58 | #define NS_PREECHO_ATT2 0.3
59 |
60 | #define NS_MSFIX 3.5
61 | #define NSATTACKTHRE 4.4
62 | #define NSATTACKTHRE_S 25
63 |
64 | #endif /* LAME_PSYMODEL_H */
65 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Version numbering for LAME.
3 | *
4 | * Copyright (c) 1999 A.L. Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VERSION_H
23 | #define LAME_VERSION_H
24 |
25 |
26 | /*
27 | * To make a string from a token, use the # operator:
28 | */
29 | #ifndef STR
30 | # define __STR(x) #x
31 | # define STR(x) __STR(x)
32 | #endif
33 |
34 | # define LAME_URL "http://lame.sf.net"
35 |
36 |
37 | # define LAME_MAJOR_VERSION 3 /* Major version number */
38 | # define LAME_MINOR_VERSION 99 /* Minor version number */
39 | # define LAME_TYPE_VERSION 2 /* 0:alpha 1:beta 2:release */
40 | # define LAME_PATCH_VERSION 5 /* Patch level */
41 | # define LAME_ALPHA_VERSION (LAME_TYPE_VERSION==0)
42 | # define LAME_BETA_VERSION (LAME_TYPE_VERSION==1)
43 | # define LAME_RELEASE_VERSION (LAME_TYPE_VERSION==2)
44 |
45 | # define PSY_MAJOR_VERSION 1 /* Major version number */
46 | # define PSY_MINOR_VERSION 0 /* Minor version number */
47 | # define PSY_ALPHA_VERSION 0 /* Set number if this is an alpha version, otherwise zero */
48 | # define PSY_BETA_VERSION 0 /* Set number if this is a beta version, otherwise zero */
49 |
50 | #if LAME_ALPHA_VERSION
51 | #define LAME_PATCH_LEVEL_STRING " alpha " STR(LAME_PATCH_VERSION)
52 | #endif
53 | #if LAME_BETA_VERSION
54 | #define LAME_PATCH_LEVEL_STRING " beta " STR(LAME_PATCH_VERSION)
55 | #endif
56 | #if LAME_RELEASE_VERSION
57 | #if LAME_PATCH_VERSION
58 | #define LAME_PATCH_LEVEL_STRING " release " STR(LAME_PATCH_VERSION)
59 | #else
60 | #define LAME_PATCH_LEVEL_STRING ""
61 | #endif
62 | #endif
63 |
64 | # define LAME_VERSION_STRING STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) LAME_PATCH_LEVEL_STRING
65 |
66 | #endif /* LAME_VERSION_H */
67 |
68 | /* End of version.h */
69 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/l3side.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Layer 3 side include file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_L3SIDE_H
23 | #define LAME_L3SIDE_H
24 |
25 | /* max scalefactor band, max(SBMAX_l, SBMAX_s*3, (SBMAX_s-3)*3+8) */
26 | #define SFBMAX (SBMAX_s*3)
27 |
28 | /* Layer III side information. */
29 | typedef struct {
30 | int l[1 + SBMAX_l];
31 | int s[1 + SBMAX_s];
32 | int psfb21[1 + PSFB21];
33 | int psfb12[1 + PSFB12];
34 | } scalefac_struct;
35 |
36 |
37 | typedef struct {
38 | FLOAT l[SBMAX_l];
39 | FLOAT s[SBMAX_s][3];
40 | } III_psy_xmin;
41 |
42 | typedef struct {
43 | III_psy_xmin thm;
44 | III_psy_xmin en;
45 | } III_psy_ratio;
46 |
47 | typedef struct {
48 | FLOAT xr[576];
49 | int l3_enc[576];
50 | int scalefac[SFBMAX];
51 | FLOAT xrpow_max;
52 |
53 | int part2_3_length;
54 | int big_values;
55 | int count1;
56 | int global_gain;
57 | int scalefac_compress;
58 | int block_type;
59 | int mixed_block_flag;
60 | int table_select[3];
61 | int subblock_gain[3 + 1];
62 | int region0_count;
63 | int region1_count;
64 | int preflag;
65 | int scalefac_scale;
66 | int count1table_select;
67 |
68 | int part2_length;
69 | int sfb_lmax;
70 | int sfb_smin;
71 | int psy_lmax;
72 | int sfbmax;
73 | int psymax;
74 | int sfbdivide;
75 | int width[SFBMAX];
76 | int window[SFBMAX];
77 | int count1bits;
78 | /* added for LSF */
79 | const int *sfb_partition_table;
80 | int slen[4];
81 |
82 | int max_nonzero_coeff;
83 | char energy_above_cutoff[SFBMAX];
84 | } gr_info;
85 |
86 | typedef struct {
87 | gr_info tt[2][2];
88 | int main_data_begin;
89 | int private_bits;
90 | int resvDrain_pre;
91 | int resvDrain_post;
92 | int scfsi[2][4];
93 | } III_side_info_t;
94 |
95 | #endif
96 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/tables.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MPEG layer 3 tables include file
3 | *
4 | * Copyright (c) 1999 Albert L Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_TABLES_H
23 | #define LAME_TABLES_H
24 |
25 | #if 0
26 | typedef struct {
27 | unsigned char no;
28 | unsigned char width;
29 | unsigned char minval_2;
30 | float quiet_thr;
31 | float norm;
32 | float bark;
33 | } type1_t;
34 |
35 | typedef struct {
36 | unsigned char no;
37 | unsigned char width;
38 | float quiet_thr;
39 | float norm;
40 | float SNR;
41 | float bark;
42 | } type2_t;
43 |
44 | typedef struct {
45 | unsigned int no:5;
46 | unsigned int cbw:3;
47 | unsigned int bu:6;
48 | unsigned int bo:6;
49 | unsigned int w1_576:10;
50 | unsigned int w2_576:10;
51 | } type34_t;
52 |
53 | typedef struct {
54 | size_t len1;
55 | const type1_t *const tab1;
56 | size_t len2;
57 | const type2_t *const tab2;
58 | size_t len3;
59 | const type34_t *const tab3;
60 | size_t len4;
61 | const type34_t *const tab4;
62 | } type5_t;
63 |
64 | extern const type5_t table5[6];
65 |
66 | #endif
67 |
68 | #define HTN 34
69 |
70 | struct huffcodetab {
71 | const unsigned int xlen; /* max. x-index+ */
72 | const unsigned int linmax; /* max number to be stored in linbits */
73 | const uint16_t *table; /* pointer to array[xlen][ylen] */
74 | const uint8_t *hlen; /* pointer to array[xlen][ylen] */
75 | };
76 |
77 | extern const struct huffcodetab ht[HTN];
78 | /* global memory block */
79 | /* array of all huffcodtable headers */
80 | /* 0..31 Huffman code table 0..31 */
81 | /* 32,33 count1-tables */
82 |
83 | extern const uint8_t t32l[];
84 | extern const uint8_t t33l[];
85 |
86 | extern const uint32_t largetbl[16 * 16];
87 | extern const uint32_t table23[3 * 3];
88 | extern const uint32_t table56[4 * 4];
89 |
90 | extern const int scfsi_band[5];
91 |
92 | extern const int bitrate_table [3][16];
93 | extern const int samplerate_table [3][ 4];
94 |
95 | #endif /* LAME_TABLES_H */
96 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/set_get.h:
--------------------------------------------------------------------------------
1 | /*
2 | * set_get.h -- Internal set/get definitions
3 | *
4 | * Copyright (C) 2003 Gabriel Bouvigne / Lame project
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19 | */
20 |
21 | #ifndef __SET_GET_H__
22 | #define __SET_GET_H__
23 |
24 | #include "lame.h"
25 |
26 | #if defined(__cplusplus)
27 | extern "C" {
28 | #endif
29 |
30 | /* select psychoacoustic model */
31 |
32 | /* manage short blocks */
33 | int CDECL lame_set_short_threshold(lame_global_flags *, float, float);
34 | int CDECL lame_set_short_threshold_lrm(lame_global_flags *, float);
35 | float CDECL lame_get_short_threshold_lrm(const lame_global_flags *);
36 | int CDECL lame_set_short_threshold_s(lame_global_flags *, float);
37 | float CDECL lame_get_short_threshold_s(const lame_global_flags *);
38 |
39 |
40 | int CDECL lame_set_maskingadjust(lame_global_flags *, float);
41 | float CDECL lame_get_maskingadjust(const lame_global_flags *);
42 |
43 | int CDECL lame_set_maskingadjust_short(lame_global_flags *, float);
44 | float CDECL lame_get_maskingadjust_short(const lame_global_flags *);
45 |
46 | /* select ATH formula 4 shape */
47 | int CDECL lame_set_ATHcurve(lame_global_flags *, float);
48 | float CDECL lame_get_ATHcurve(const lame_global_flags *);
49 |
50 | int CDECL lame_set_preset_notune(lame_global_flags *, int);
51 |
52 | /* substep shaping method */
53 | int CDECL lame_set_substep(lame_global_flags *, int);
54 | int CDECL lame_get_substep(const lame_global_flags *);
55 |
56 | /* scalefactors scale */
57 | int CDECL lame_set_sfscale(lame_global_flags *, int);
58 | int CDECL lame_get_sfscale(const lame_global_flags *);
59 |
60 | /* subblock gain */
61 | int CDECL lame_set_subblock_gain(lame_global_flags *, int);
62 | int CDECL lame_get_subblock_gain(const lame_global_flags *);
63 |
64 |
65 |
66 | /*presets*/
67 | int apply_preset(lame_global_flags *, int preset, int enforce);
68 |
69 | void CDECL lame_set_tune(lame_t, float); /* FOR INTERNAL USE ONLY */
70 | void CDECL lame_set_msfix(lame_t gfp, double msfix);
71 |
72 |
73 | #if defined(__cplusplus)
74 | }
75 | #endif
76 | #endif
77 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/VbrTag.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Xing VBR tagging for LAME.
3 | *
4 | * Copyright (c) 1999 A.L. Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VRBTAG_H
23 | #define LAME_VRBTAG_H
24 |
25 |
26 | /* -----------------------------------------------------------
27 | * A Vbr header may be present in the ancillary
28 | * data field of the first frame of an mp3 bitstream
29 | * The Vbr header (optionally) contains
30 | * frames total number of audio frames in the bitstream
31 | * bytes total number of bytes in the bitstream
32 | * toc table of contents
33 |
34 | * toc (table of contents) gives seek points
35 | * for random access
36 | * the ith entry determines the seek point for
37 | * i-percent duration
38 | * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes
39 | * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes
40 | */
41 |
42 |
43 | #define FRAMES_FLAG 0x0001
44 | #define BYTES_FLAG 0x0002
45 | #define TOC_FLAG 0x0004
46 | #define VBR_SCALE_FLAG 0x0008
47 |
48 | #define NUMTOCENTRIES 100
49 |
50 | #ifndef lame_internal_flags_defined
51 | #define lame_internal_flags_defined
52 | struct lame_internal_flags;
53 | typedef struct lame_internal_flags lame_internal_flags;
54 | #endif
55 |
56 |
57 | /*structure to receive extracted header */
58 | /* toc may be NULL*/
59 | typedef struct {
60 | int h_id; /* from MPEG header, 0=MPEG2, 1=MPEG1 */
61 | int samprate; /* determined from MPEG header */
62 | int flags; /* from Vbr header data */
63 | int frames; /* total bit stream frames from Vbr header data */
64 | int bytes; /* total bit stream bytes from Vbr header data */
65 | int vbr_scale; /* encoded vbr scale from Vbr header data */
66 | unsigned char toc[NUMTOCENTRIES]; /* may be NULL if toc not desired */
67 | int headersize; /* size of VBR header, in bytes */
68 | int enc_delay; /* encoder delay */
69 | int enc_padding; /* encoder paddign added at end of stream */
70 | } VBRTAGDATA;
71 |
72 | int GetVbrTag(VBRTAGDATA * pTagData, const unsigned char *buf);
73 |
74 | int InitVbrTag(lame_global_flags * gfp);
75 | int PutVbrTag(lame_global_flags const *gfp, FILE * fid);
76 | void AddVbrFrame(lame_internal_flags * gfc);
77 | void UpdateMusicCRC(uint16_t * crc, const unsigned char *buffer, int size);
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/lame/src/main/java/net/qiujuer/lame/LameOutputStream.java:
--------------------------------------------------------------------------------
1 | package net.qiujuer.lame;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.util.Log;
5 |
6 | import java.io.Closeable;
7 | import java.io.Flushable;
8 | import java.io.IOException;
9 | import java.io.OutputStream;
10 |
11 | /**
12 | * @author qiujuer Email:qiujuer@live.cn
13 | * @version 1.0.0
14 | */
15 | public class LameOutputStream implements Closeable, Flushable {
16 | private static final String TAG = LameOutputStream.class.getSimpleName();
17 | private Lame lame;
18 | private OutputStream outputStream;
19 | private byte[] outBuf;
20 | private EncoderDelegate encoderDelegate;
21 |
22 | public LameOutputStream(Lame lame, OutputStream outputStream, int shortBufferSize) {
23 | this.lame = lame;
24 | this.outputStream = outputStream;
25 |
26 | if (lame.getInChannels() == 1) {
27 | this.encoderDelegate = new EncoderDelegate() {
28 | @Override
29 | public int encode(short[] b, int len, byte[] buffer) {
30 | return LameOutputStream.this.lame.encode(b, b, len, buffer);
31 | }
32 | };
33 | } else {
34 | this.encoderDelegate = new EncoderDelegate() {
35 | @Override
36 | public int encode(short[] b, int len, byte[] buffer) {
37 | return LameOutputStream.this.lame.encodeInterleaved(b, len >> 1, buffer);
38 | }
39 | };
40 | }
41 | initOutMp3buffer(shortBufferSize);
42 | }
43 |
44 | private void initOutMp3buffer(int writeBufferMaxLen) {
45 | int mp3bufferSize;
46 | if (lame.getInChannels() == 1) {
47 | mp3bufferSize = lame.getMp3bufferSize(writeBufferMaxLen);
48 | } else {
49 | mp3bufferSize = lame.getMp3bufferSize(writeBufferMaxLen / 2);
50 | }
51 | Log.d(TAG, String.format("Lame initOutMp3buffer(%s-%s-%s-%s).", writeBufferMaxLen, mp3bufferSize,
52 | lame.getMp3bufferSize(), (1.25 * writeBufferMaxLen + 7200)));
53 | this.outBuf = new byte[mp3bufferSize];
54 | }
55 |
56 | public void write(@NonNull short[] b, int len) throws IOException {
57 | int count = encoderDelegate.encode(b, len, outBuf);
58 | if (count > 0) {
59 | Log.d(TAG, "Lame encode:" + count);
60 | outputStream.write(outBuf, 0, count);
61 | } else if (count < 0) {
62 | Log.e(TAG, "Lame encode error:" + count);
63 | }
64 | }
65 |
66 | @Override
67 | public void flush() throws IOException {
68 | int count;
69 | do {
70 | count = lame.flush(outBuf);
71 | if (count > 0) {
72 | Log.d(TAG, "Lame encode flush:" + count);
73 | outputStream.write(outBuf, 0, count);
74 | }
75 | } while (count > 0);
76 | outputStream.flush();
77 | }
78 |
79 | @Override
80 | public void close() throws IOException {
81 | try {
82 | flush();
83 | } catch (IOException e) {
84 | e.printStackTrace();
85 | }
86 | lame.close();
87 | outputStream.close();
88 | }
89 |
90 | private interface EncoderDelegate {
91 | int encode(short[] b, int len, byte[] buffer);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/lame/src/main/cpp/libmp3lame/lame-analysis.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GTK plotting routines source file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_GTKANAL_H
23 | #define LAME_GTKANAL_H
24 |
25 |
26 | #define READ_AHEAD 40 /* number of frames to read ahead */
27 | #define MAXMPGLAG READ_AHEAD /* if the mpg123 lag becomes bigger than this
28 | we have to stop */
29 | #define NUMBACK 6 /* number of frames we can back up */
30 | #define NUMPINFO (NUMBACK+READ_AHEAD+1)
31 |
32 |
33 |
34 | struct plotting_data {
35 | int frameNum; /* current frame number */
36 | int frameNum123;
37 | int num_samples; /* number of pcm samples read for this frame */
38 | double frametime; /* starting time of frame, in seconds */
39 | double pcmdata[2][1600];
40 | double pcmdata2[2][1152 + 1152 - DECDELAY];
41 | double xr[2][2][576];
42 | double mpg123xr[2][2][576];
43 | double ms_ratio[2];
44 | double ms_ener_ratio[2];
45 |
46 | /* L,R, M and S values */
47 | double energy_save[4][BLKSIZE]; /* psymodel is one ahead */
48 | double energy[2][4][BLKSIZE];
49 | double pe[2][4];
50 | double thr[2][4][SBMAX_l];
51 | double en[2][4][SBMAX_l];
52 | double thr_s[2][4][3 * SBMAX_s];
53 | double en_s[2][4][3 * SBMAX_s];
54 | double ers_save[4]; /* psymodel is one ahead */
55 | double ers[2][4];
56 |
57 | double sfb[2][2][SBMAX_l];
58 | double sfb_s[2][2][3 * SBMAX_s];
59 | double LAMEsfb[2][2][SBMAX_l];
60 | double LAMEsfb_s[2][2][3 * SBMAX_s];
61 |
62 | int LAMEqss[2][2];
63 | int qss[2][2];
64 | int big_values[2][2];
65 | int sub_gain[2][2][3];
66 |
67 | double xfsf[2][2][SBMAX_l];
68 | double xfsf_s[2][2][3 * SBMAX_s];
69 |
70 | int over[2][2];
71 | double tot_noise[2][2];
72 | double max_noise[2][2];
73 | double over_noise[2][2];
74 | int over_SSD[2][2];
75 | int blocktype[2][2];
76 | int scalefac_scale[2][2];
77 | int preflag[2][2];
78 | int mpg123blocktype[2][2];
79 | int mixed[2][2];
80 | int mainbits[2][2];
81 | int sfbits[2][2];
82 | int LAMEmainbits[2][2];
83 | int LAMEsfbits[2][2];
84 | int framesize, stereo, js, ms_stereo, i_stereo, emph, bitrate, sampfreq, maindata;
85 | int crc, padding;
86 | int scfsi[2], mean_bits, resvsize;
87 | int totbits;
88 | };
89 | #ifndef plotting_data_defined
90 | #define plotting_data_defined
91 | typedef struct plotting_data plotting_data;
92 | #endif
93 | #if 0
94 | extern plotting_data *pinfo;
95 | #endif
96 | #endif
97 |
--------------------------------------------------------------------------------
/app/src/main/java/net/qiujuer/lame/sample/helper/AudioPlayHelper.java:
--------------------------------------------------------------------------------
1 | package net.qiujuer.lame.sample.helper;
2 |
3 | import android.media.AudioManager;
4 | import android.media.MediaPlayer;
5 |
6 | import java.io.IOException;
7 |
8 | /**
9 | * @author qiujuer Email:qiujuer@live.cn
10 | * @version 1.0.0
11 | */
12 | public class AudioPlayHelper implements MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener {
13 | private MediaPlayer mediaPlayer;
14 | private RecordPlayListener listener;
15 | private Holder holder;
16 | private String currentPath;
17 |
18 | public AudioPlayHelper(RecordPlayListener listener) {
19 | this.listener = listener;
20 | this.mediaPlayer = createNewMediaPlayer();
21 | }
22 |
23 | private MediaPlayer createNewMediaPlayer() {
24 | MediaPlayer mediaPlayer = new MediaPlayer();
25 | mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
26 | mediaPlayer.setLooping(false);
27 | mediaPlayer.setOnErrorListener(this);
28 | mediaPlayer.setOnCompletionListener(this);
29 | return mediaPlayer;
30 | }
31 |
32 | public void trigger(Holder holder, String filePath) {
33 | if (mediaPlayer == null)
34 | return;
35 |
36 | // 如果是当前的
37 | if (mediaPlayer.isPlaying() && filePath.equalsIgnoreCase(currentPath)) {
38 | stop();
39 | return;
40 | }
41 |
42 | stop();
43 | play(holder, filePath);
44 | }
45 |
46 | private void play(Holder holder, String filePath) {
47 | if (mediaPlayer == null)
48 | return;
49 |
50 | this.holder = holder;
51 | this.currentPath = filePath;
52 | try {
53 | this.mediaPlayer.setDataSource(filePath);
54 | this.mediaPlayer.prepare();
55 | } catch (IOException e) {
56 | e.printStackTrace();
57 | this.listener.onPlayError(holder);
58 | stop();
59 | return;
60 | }
61 | this.mediaPlayer.start();
62 | this.listener.onPlayStart(holder);
63 | }
64 |
65 | public void stop() {
66 | if (mediaPlayer == null)
67 | return;
68 |
69 | mediaPlayer.stop();
70 | mediaPlayer.reset();
71 | currentPath = null;
72 |
73 | Holder holder = this.holder;
74 | this.holder = null;
75 | if (holder != null) {
76 | listener.onPlayStop(holder);
77 | }
78 | }
79 |
80 | public void destroy() {
81 | MediaPlayer mediaPlayer = this.mediaPlayer;
82 | if (mediaPlayer != null) {
83 | this.mediaPlayer = null;
84 | stop();
85 | mediaPlayer.release();
86 | }
87 | }
88 |
89 | @Override
90 | public void onCompletion(MediaPlayer mp) {
91 | stop();
92 | }
93 |
94 | @Override
95 | public boolean onError(MediaPlayer mp, int what, int extra) {
96 | Holder holder = this.holder;
97 | if (holder != null) {
98 | this.listener.onPlayError(holder);
99 | }
100 | stop();
101 | return true;
102 | }
103 |
104 | public interface RecordPlayListener {
105 | void onPlayStart(Holder holder);
106 |
107 | void onPlayStop(Holder holder);
108 |
109 | void onPlayError(Holder holder);
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/net/qiujuer/lame/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package net.qiujuer.lame.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.TextView;
9 |
10 | import net.qiujuer.lame.sample.helper.AudioPlayHelper;
11 | import net.qiujuer.lame.sample.helper.AudioRecordHelper;
12 |
13 | import java.io.File;
14 |
15 | public class MainActivity extends AppCompatActivity implements View.OnTouchListener {
16 | private AudioRecordHelper mAudioRecordHelper;
17 | private AudioPlayHelper mAudioPlayHelper;
18 | private TextView mStatusText;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_main);
24 |
25 | mStatusText = (TextView) findViewById(R.id.txt_status);
26 |
27 | Button record = (Button) findViewById(R.id.btn_record);
28 | record.setOnTouchListener(this);
29 | record.setClickable(true);
30 |
31 | File tmp = new File(getCacheDir(), "tmp.mp3");
32 |
33 | mAudioPlayHelper = new AudioPlayHelper<>(new AudioPlayHelper.RecordPlayListener