├── .gitignore ├── Lame ├── .gitignore ├── LameMP3 │ └── CMake │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── cpp │ │ └── lamemp3 │ │ │ ├── CMakeLists.txt │ │ │ ├── VbrTag.c │ │ │ ├── VbrTag.h │ │ │ ├── bitstream.c │ │ │ ├── bitstream.h │ │ │ ├── encoder.c │ │ │ ├── encoder.h │ │ │ ├── fft.c │ │ │ ├── fft.h │ │ │ ├── gain_analysis.c │ │ │ ├── gain_analysis.h │ │ │ ├── id3tag.c │ │ │ ├── id3tag.h │ │ │ ├── l3side.h │ │ │ ├── lame-analysis.h │ │ │ ├── lame.c │ │ │ ├── lame.h │ │ │ ├── lame_global_flags.h │ │ │ ├── lameerror.h │ │ │ ├── machine.h │ │ │ ├── mpglib_interface.c │ │ │ ├── newmdct.c │ │ │ ├── newmdct.h │ │ │ ├── presets.c │ │ │ ├── psymodel.c │ │ │ ├── psymodel.h │ │ │ ├── quantize.c │ │ │ ├── quantize.h │ │ │ ├── quantize_pvt.c │ │ │ ├── quantize_pvt.h │ │ │ ├── reservoir.c │ │ │ ├── reservoir.h │ │ │ ├── set_get.c │ │ │ ├── set_get.h │ │ │ ├── tables.c │ │ │ ├── tables.h │ │ │ ├── takehiro.c │ │ │ ├── util.c │ │ │ ├── util.h │ │ │ ├── vbrquantize.c │ │ │ ├── vbrquantize.h │ │ │ ├── vector │ │ │ ├── lame_intrin.h │ │ │ └── xmm_quantize_sub.c │ │ │ ├── version.c │ │ │ └── version.h │ │ └── jniLibs │ │ ├── arm64-v8a │ │ ├── liblame.so │ │ └── libmp3lame.so │ │ ├── armeabi-v7a │ │ ├── liblame.so │ │ └── libmp3lame.so │ │ └── x86_64 │ │ ├── liblame.so │ │ └── libmp3lame.so ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── README.md ├── app ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── chezi │ │ └── mp3recorddemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── chezi │ │ │ └── mp3recorder │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.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 │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── chezi │ └── mp3recorddemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── recorder-audio ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── libs │ ├── arm64-v8a │ │ └── libmp3lame.so │ ├── armeabi-v7a │ │ └── libmp3lame.so │ ├── include │ │ └── libmp3lame │ │ │ ├── VbrTag.h │ │ │ ├── bitstream.h │ │ │ ├── encoder.h │ │ │ ├── fft.h │ │ │ ├── gain_analysis.h │ │ │ ├── i386 │ │ │ └── nasm.h │ │ │ ├── id3tag.h │ │ │ ├── l3side.h │ │ │ ├── lame-analysis.h │ │ │ ├── lame.h │ │ │ ├── lame_global_flags.h │ │ │ ├── lameerror.h │ │ │ ├── machine.h │ │ │ ├── newmdct.h │ │ │ ├── psymodel.h │ │ │ ├── quantize.h │ │ │ ├── quantize_pvt.h │ │ │ ├── reservoir.h │ │ │ ├── set_get.h │ │ │ ├── tables.h │ │ │ ├── util.h │ │ │ ├── vbrquantize.h │ │ │ ├── vector │ │ │ └── lame_intrin.h │ │ │ └── version.h │ ├── x86 │ │ └── libmp3lame.so │ └── x86_64 │ │ └── libmp3lame.so ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── chezi │ │ └── recorder │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── cpp │ │ └── lame_util.c │ ├── java │ │ └── com │ │ │ └── chezi │ │ │ └── recorder │ │ │ ├── IAudioRecorder.java │ │ │ ├── Mp3Recorder.java │ │ │ ├── PCMFormat.java │ │ │ ├── RecorderProgressView.java │ │ │ ├── RecorderView.java │ │ │ ├── SpectrumView.java │ │ │ ├── listener │ │ │ └── AudioRecordListener.java │ │ │ └── utils │ │ │ ├── DateUtils.java │ │ │ └── LameUtil.java │ └── res │ │ ├── drawable │ │ └── ve_mic_white.xml │ │ ├── mipmap-xhdpi │ │ └── ic_mic_white.png │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── chezi │ └── recorder │ └── ExampleUnitTest.java ├── recorder.gif ├── recorder_2.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### NetBeans template 3 | nbproject/private/ 4 | build/ 5 | nbbuild/ 6 | dist/ 7 | nbdist/ 8 | nbactions.xml 9 | nb-configuration.xml 10 | 11 | # Mac OS X Garbage 12 | .DS_Store 13 | Thumbs.db 14 | 15 | .idea/ 16 | 17 | ### Android Studio 18 | /jniLibs 19 | mobile/mobile.iml 20 | mobile/mobile.iml 21 | tv/tv.iml 22 | app/app.iml 23 | app/*.iml 24 | *.iml 25 | mobile/*.iml 26 | tv/*.iml 27 | .idea/workspace.xml 28 | .idea/libraries 29 | .idea/ 30 | .idea 31 | /build 32 | /captures 33 | ### Android template 34 | # Built application files 35 | *.apk 36 | *.ap_ 37 | /build 38 | /captures 39 | .externalNativeBuild 40 | # Files for the Dalvik VM 41 | *.dex 42 | 43 | # Java class files 44 | *.class 45 | 46 | # Generated files 47 | bin/ 48 | gen/ 49 | 50 | # Gradle files 51 | .gradle/ 52 | 53 | # Local configuration file (sdk path, etc) 54 | local.properties 55 | 56 | # Proguard folder generated by Eclipse 57 | proguard/ 58 | 59 | # Log Files 60 | *.log 61 | 62 | 63 | ### Java template 64 | *.class 65 | 66 | # Mobile Tools for Java (J2ME) 67 | .mtj.tmp/ 68 | 69 | # Package Files # 70 | *.jar 71 | *.war 72 | *.ear 73 | 74 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 75 | hs_err_pid* 76 | 77 | 78 | ### Eclipse template 79 | *.pydevproject 80 | .metadata 81 | .gradle 82 | bin/ 83 | tmp/ 84 | *.tmp 85 | *.bak 86 | *.swp 87 | *~.nib 88 | .settings/ 89 | .loadpath 90 | /build 91 | /captures 92 | # External tool builders 93 | .externalToolBuilders/ 94 | 95 | # Locally stored "Eclipse launch configurations" 96 | *.launch 97 | 98 | # CDT-specific 99 | .cproject 100 | 101 | # PDT-specific 102 | .buildpath 103 | 104 | # sbteclipse plugin 105 | .target 106 | 107 | # TeXlipse plugin 108 | .texlipse 109 | 110 | # Android Studio 111 | *.iml 112 | 113 | # Keep external libs 114 | !app/libs/*.jar 115 | 116 | # script output 117 | check-dpi.txt* 118 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about using CMake with Android Studio, read the 2 | # documentation: https://d.android.com/studio/projects/add-native-code.html 3 | 4 | # Sets the minimum version of CMake required to build the native library. 5 | 6 | cmake_minimum_required(VERSION 3.4.1) 7 | 8 | #define cpp source path 9 | set(SRC_DIR src/main/cpp/lamemp3) 10 | 11 | #set *.h source path 12 | include_directories(src/main/cpp/lamemp3) 13 | 14 | #set cpp source path 15 | aux_source_directory(src/main/cpp/lamemp3 SRC_LIST) 16 | 17 | #set *.so files output path,please add this before add_library 18 | #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}) 19 | set(jnilibs "${CMAKE_SOURCE_DIR}/src/main/jniLibs") 20 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${jnilibs}/${ANDROID_ABI}) 21 | 22 | ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/src/main/cpp/lamemp3) -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jay-Goo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/README.md: -------------------------------------------------------------------------------- 1 | # Mp3Converter 2 | Use latest [Lame-3.100](http://lame.sourceforge.net/) to transform PCM, WAV, AIFF and other uncompressed formats into MP3 format files. 3 | http://gujinjie.top/article/%E6%89%8B%E6%8A%8A%E6%89%8B%E6%95%99%E4%BD%A0Android%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8NDK%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AAMP3%E8%BD%AC%E7%A0%81%E5%BA%93/ 4 | http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2018/0419/9615.html 5 | https://github.com/GavinCT/AndroidMP3Recorder 6 | https://github.com/Jay-Goo/Mp3Converter 7 | # Usage 8 | ## Dependencies 9 | 10 | ``` 11 | //Project build.gradle 12 | allprojects { 13 | repositories { 14 | ... 15 | maven { url 'https://jitpack.io' } 16 | } 17 | } 18 | //Module build.gradle 19 | dependencies { 20 | implementation 'com.github.Jay-Goo:Mp3Converter:v0.0.3' 21 | } 22 | ``` 23 | ## Methods 24 | 25 | ``` 26 | /** 27 | * init lame 28 | * @param inSampleRate 29 | * input sample rate in Hz 30 | * @param channel 31 | * number of channels 32 | * @param mode 33 | * 0 = CBR, 1 = VBR, 2 = ABR. default = 0 34 | * @param outSampleRate 35 | * output sample rate in Hz 36 | * @param outBitRate 37 | * rate compression ratio in KHz 38 | * @param quality 39 | * quality=0..9. 0=best (very slow). 9=worst.
40 | * recommended:
41 | * 2 near-best quality, not too slow
42 | * 5 good quality, fast
43 | * 7 ok quality, really fast 44 | */ 45 | Mp3Converter.init(44100, 1, 0, 44100, 96, 7); 46 | 47 | /** 48 | * file convert to mp3 49 |     * it may cost a lot of time and better put it in a thread 50 |     * @param input 51 | * file path to be converted 52 | * @param mp3 53 | * mp3 output file path 54 | */ 55 | Mp3Converter.convertMp3(inputPath, mp3Path); 56 | 57 | 58 | /** 59 | * get converted bytes in inputBuffer 60 | * @return 61 | * converted bytes in inputBuffer 62 | * to ignore the deviation of the file size,when return to -1 represents convert complete 63 | */ 64 | Mp3Converter.getConvertBytes() 65 | ``` 66 | ## Build 67 | You can use Android Studio `Make Module 'library'`to create your *.so files, they will be created in your `library/src/jniLibs`Folder. 68 | 69 | # ABI 70 | This library support `armeabi-v7a`, `arm64-v8a`, `mips`, `mips64`, `x86`, `x86_64` 71 | 72 | # Blog 73 | You can learn how to build this library through [this article](https://gujinjie.top/2018/04/19/%E6%89%8B%E6%8A%8A%E6%89%8B%E6%95%99%E4%BD%A0Android%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8NDK%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AAMP3%E8%BD%AC%E7%A0%81%E5%BA%93/). 74 | 75 | # Future 76 | Support amr format 77 | 78 | # License 79 | MIT License 80 | Copyright (c) 2018 Jay-Goo 81 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "29.0.0" 6 | defaultConfig { 7 | minSdkVersion 18 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | externalNativeBuild { 13 | cmake { 14 | cppFlags "-std=c++11" 15 | abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a" 16 | } 17 | } 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | 27 | externalNativeBuild { 28 | cmake { 29 | path "CMakeLists.txt" 30 | } 31 | } 32 | 33 | packagingOptions { 34 | pickFirst 'lib/armeabi-v7a/libmp3lame.so' 35 | pickFirst 'lib/arm64-v8a/libmp3lame.so' 36 | pickFirst 'lib/armeabi/libmp3lame.so' 37 | pickFirst 'lib/x86/libmp3lame.so' 38 | pickFirst 'lib/mips/libmp3lame.so' 39 | pickFirst 'lib/mips64/libmp3lame.so' 40 | pickFirst 'lib/x86_64/libmp3lame.so' 41 | } 42 | } 43 | 44 | dependencies { 45 | implementation fileTree(dir: 'libs', include: ['*.jar']) 46 | } 47 | 48 | // Ref :https://stackoverflow.com/questions/39613452/copy-shared-objects-to-jnilibs-when-using-cmake-for-android 49 | task copySoTojniLibs(type: Copy, dependsOn: 'bundleDebug') { 50 | from ('.externalNativeBuild/cmake/debug/libs') { 51 | include '**/*.so' 52 | } 53 | into 'src/main/jniLibs' 54 | } 55 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #add cpp files into library 2 | # SUBDIRECTORY method 3 | add_library( 4 | # Sets the name of the library. 5 | mp3lame 6 | # Sets the library as a shared library. 7 | SHARED 8 | # Provides a relative path to your source file(s). 9 | lame.c 10 | bitstream.c 11 | encoder.c 12 | fft.c 13 | gain_analysis.c 14 | id3tag.c 15 | mpglib_interface.c 16 | newmdct.c 17 | presets.c 18 | psymodel.c 19 | quantize.c 20 | quantize_pvt.c 21 | reservoir.c 22 | set_get.c 23 | tables.c 24 | takehiro.c 25 | vbrquantize.c 26 | util.c 27 | VbrTag.c 28 | version.c 29 | ) 30 | 31 | find_library( # Sets the name of the path variable. 32 | log-lib 33 | # Specifies the name of the NDK library that 34 | # you want CMake to locate. 35 | log) 36 | 37 | # Specifies libraries CMake should link to your target library. You 38 | # can link multiple libraries, such as libraries you define in this 39 | # build script, prebuilt third-party libraries, or system libraries. 40 | 41 | target_link_libraries( # Specifies the target library. 42 | mp3lame 43 | # Links the target library to the log library 44 | # included in the NDK. 45 | ${log-lib}) -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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 | 76 | int PutVbrTag(lame_global_flags const *gfp, FILE *fid); 77 | 78 | void AddVbrFrame(lame_internal_flags *gfc); 79 | 80 | void UpdateMusicCRC(uint16_t *crc, const unsigned char *buffer, int size); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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 | 31 | void add_dummy_byte(lame_internal_flags *gfc, unsigned char val, unsigned int n); 32 | 33 | int copy_buffer(lame_internal_flags *gfc, unsigned char *buffer, int buffer_size, 34 | int update_crc); 35 | 36 | void init_bit_stream_w(lame_internal_flags *gfc); 37 | 38 | void CRC_writeheader(lame_internal_flags const *gfc, char *buffer); 39 | 40 | int compute_flushbits(const lame_internal_flags *gfp, int *nbytes); 41 | 42 | int get_max_frame_buffer_size_by_constraint(SessionConfig_t const *cfg, int constraint); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * encoder.h 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 | 23 | #ifndef LAME_ENCODER_H 24 | #define LAME_ENCODER_H 25 | 26 | /*********************************************************************** 27 | * 28 | * encoder and decoder delays 29 | * 30 | ***********************************************************************/ 31 | 32 | /* 33 | * layer III enc->dec delay: 1056 (1057?) (observed) 34 | * layer II enc->dec delay: 480 (481?) (observed) 35 | * 36 | * polyphase 256-16 (dec or enc) = 240 37 | * mdct 256+32 (9*32) (dec or enc) = 288 38 | * total: 512+16 39 | * 40 | * My guess is that delay of polyphase filterbank is actualy 240.5 41 | * (there are technical reasons for this, see postings in mp3encoder). 42 | * So total Encode+Decode delay = ENCDELAY + 528 + 1 43 | */ 44 | 45 | /* 46 | * ENCDELAY The encoder delay. 47 | * 48 | * Minimum allowed is MDCTDELAY (see below) 49 | * 50 | * The first 96 samples will be attenuated, so using a value less than 96 51 | * will result in corrupt data for the first 96-ENCDELAY samples. 52 | * 53 | * suggested: 576 54 | * set to 1160 to sync with FhG. 55 | */ 56 | 57 | #define ENCDELAY 576 58 | 59 | 60 | 61 | /* 62 | * make sure there is at least one complete frame after the 63 | * last frame containing real data 64 | * 65 | * Using a value of 288 would be sufficient for a 66 | * a very sophisticated decoder that can decode granule-by-granule instead 67 | * of frame by frame. But lets not assume this, and assume the decoder 68 | * will not decode frame N unless it also has data for frame N+1 69 | * 70 | */ 71 | /*#define POSTDELAY 288*/ 72 | #define POSTDELAY 1152 73 | 74 | 75 | 76 | /* 77 | * delay of the MDCT used in mdct.c 78 | * original ISO routines had a delay of 528! 79 | * Takehiro's routines: 80 | */ 81 | 82 | #define MDCTDELAY 48 83 | #define FFTOFFSET (224+MDCTDELAY) 84 | 85 | /* 86 | * Most decoders, including the one we use, have a delay of 528 samples. 87 | */ 88 | 89 | #define DECDELAY 528 90 | 91 | 92 | /* number of subbands */ 93 | #define SBLIMIT 32 94 | 95 | /* parition bands bands */ 96 | #define CBANDS 64 97 | 98 | /* number of critical bands/scale factor bands where masking is computed*/ 99 | #define SBPSY_l 21 100 | #define SBPSY_s 12 101 | 102 | /* total number of scalefactor bands encoded */ 103 | #define SBMAX_l 22 104 | #define SBMAX_s 13 105 | #define PSFB21 6 106 | #define PSFB12 6 107 | 108 | 109 | 110 | /* FFT sizes */ 111 | #define BLKSIZE 1024 112 | #define HBLKSIZE (BLKSIZE/2 + 1) 113 | #define BLKSIZE_s 256 114 | #define HBLKSIZE_s (BLKSIZE_s/2 + 1) 115 | 116 | 117 | /* #define switch_pe 1800 */ 118 | #define NORM_TYPE 0 119 | #define START_TYPE 1 120 | #define SHORT_TYPE 2 121 | #define STOP_TYPE 3 122 | 123 | /* 124 | * Mode Extention: 125 | * When we are in stereo mode, there are 4 possible methods to store these 126 | * two channels. The stereo modes -m? are using a subset of them. 127 | * 128 | * -ms: MPG_MD_LR_LR 129 | * -mj: MPG_MD_LR_LR and MPG_MD_MS_LR 130 | * -mf: MPG_MD_MS_LR 131 | * -mi: all 132 | */ 133 | #if 0 134 | #define MPG_MD_LR_LR 0 135 | #define MPG_MD_LR_I 1 136 | #define MPG_MD_MS_LR 2 137 | #define MPG_MD_MS_I 3 138 | #endif 139 | enum MPEGChannelMode { 140 | MPG_MD_LR_LR = 0, MPG_MD_LR_I = 1, MPG_MD_MS_LR = 2, MPG_MD_MS_I = 3 141 | }; 142 | 143 | #ifndef lame_internal_flags_defined 144 | #define lame_internal_flags_defined 145 | struct lame_internal_flags; 146 | typedef struct lame_internal_flags lame_internal_flags; 147 | #endif 148 | 149 | int lame_encode_mp3_frame(lame_internal_flags *gfc, 150 | sample_t const *inbuf_l, 151 | sample_t const *inbuf_r, unsigned char *mp3buf, int mp3buf_size); 152 | 153 | #endif /* LAME_ENCODER_H */ 154 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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/LameMP3/CMake/src/main/cpp/lamemp3/gain_analysis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ReplayGainAnalysis - analyzes input samples and give the recommended dB change 3 | * Copyright (C) 2001 David Robinson and Glen Sawyer 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * concept and filter values by David Robinson (David@Robinson.org) 20 | * -- blame him if you think the idea is flawed 21 | * coding by Glen Sawyer (mp3gain@hotmail.com) 735 W 255 N, Orem, UT 84057-4505 USA 22 | * -- blame him if you think this runs too slowly, or the coding is otherwise flawed 23 | * 24 | * For an explanation of the concepts and the basic algorithms involved, go to: 25 | * http://www.replaygain.org/ 26 | */ 27 | 28 | #ifndef GAIN_ANALYSIS_H 29 | #define GAIN_ANALYSIS_H 30 | 31 | #ifdef HAVE_INTTYPES_H 32 | # include 33 | #else 34 | # ifdef HAVE_STDINT_H 35 | # include 36 | # endif 37 | #endif 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | 44 | typedef sample_t Float_t; /* Type used for filtering */ 45 | 46 | 47 | #define PINK_REF 64.82 /* 298640883795 */ /* calibration value for 89dB */ 48 | 49 | 50 | #define YULE_ORDER 10 51 | #define BUTTER_ORDER 2 52 | #define YULE_FILTER filterYule 53 | #define BUTTER_FILTER filterButter 54 | #define RMS_PERCENTILE 0.95 /* percentile which is louder than the proposed level */ 55 | #define MAX_SAMP_FREQ 48000L /* maximum allowed sample frequency [Hz] */ 56 | #define RMS_WINDOW_TIME_NUMERATOR 1L 57 | #define RMS_WINDOW_TIME_DENOMINATOR 20L /* numerator / denominator = time slice size [s] */ 58 | #define STEPS_per_dB 100 /* Table entries per dB */ 59 | #define MAX_dB 120 /* Table entries for 0...MAX_dB (normal max. values are 70...80 dB) */ 60 | 61 | enum { 62 | GAIN_NOT_ENOUGH_SAMPLES = -24601, GAIN_ANALYSIS_ERROR = 0, GAIN_ANALYSIS_OK = 63 | 1, INIT_GAIN_ANALYSIS_ERROR = 0, INIT_GAIN_ANALYSIS_OK = 1 64 | }; 65 | 66 | enum { 67 | MAX_ORDER = (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER), 68 | MAX_SAMPLES_PER_WINDOW = ( 69 | (MAX_SAMP_FREQ * RMS_WINDOW_TIME_NUMERATOR) / RMS_WINDOW_TIME_DENOMINATOR + 70 | 1) /* max. Samples per Time slice */ 71 | }; 72 | 73 | struct replaygain_data { 74 | Float_t linprebuf[MAX_ORDER * 2]; 75 | Float_t *linpre; /* left input samples, with pre-buffer */ 76 | Float_t lstepbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER]; 77 | Float_t *lstep; /* left "first step" (i.e. post first filter) samples */ 78 | Float_t loutbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER]; 79 | Float_t *lout; /* left "out" (i.e. post second filter) samples */ 80 | Float_t rinprebuf[MAX_ORDER * 2]; 81 | Float_t *rinpre; /* right input samples ... */ 82 | Float_t rstepbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER]; 83 | Float_t *rstep; 84 | Float_t routbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER]; 85 | Float_t *rout; 86 | long sampleWindow; /* number of samples required to reach number of milliseconds required for RMS window */ 87 | long totsamp; 88 | double lsum; 89 | double rsum; 90 | int freqindex; 91 | int first; 92 | uint32_t A[STEPS_per_dB * MAX_dB]; 93 | uint32_t B[STEPS_per_dB * MAX_dB]; 94 | 95 | }; 96 | #ifndef replaygain_data_defined 97 | #define replaygain_data_defined 98 | typedef struct replaygain_data replaygain_t; 99 | #endif 100 | 101 | 102 | int InitGainAnalysis(replaygain_t *rgData, long samplefreq); 103 | 104 | int AnalyzeSamples(replaygain_t *rgData, const Float_t *left_samples, 105 | const Float_t *right_samples, size_t num_samples, int num_channels); 106 | 107 | Float_t GetTitleGain(replaygain_t *rgData); 108 | 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | #endif /* GAIN_ANALYSIS_H */ 114 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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 | #include "lame.h" 14 | 15 | enum { 16 | MIMETYPE_NONE = 0, 17 | MIMETYPE_JPEG, 18 | MIMETYPE_PNG, 19 | MIMETYPE_GIF 20 | }; 21 | 22 | typedef struct FrameDataNode { 23 | struct FrameDataNode *nxt; 24 | uint32_t fid; /* Frame Identifier */ 25 | char lng[4]; /* 3-character language descriptor */ 26 | struct { 27 | union { 28 | char *l; /* ptr to Latin-1 chars */ 29 | unsigned short *u; /* ptr to UCS-2 text */ 30 | unsigned char *b; /* ptr to raw bytes */ 31 | } ptr; 32 | size_t dim; 33 | int enc; /* 0:Latin-1, 1:UCS-2, 2:RAW */ 34 | } dsc, txt; 35 | } FrameDataNode; 36 | 37 | 38 | typedef struct id3tag_spec { 39 | /* private data members */ 40 | unsigned int flags; 41 | int year; 42 | char *title; 43 | char *artist; 44 | char *album; 45 | char *comment; 46 | int track_id3v1; 47 | int genre_id3v1; 48 | unsigned char *albumart; 49 | unsigned int albumart_size; 50 | unsigned int padding_size; 51 | int albumart_mimetype; 52 | char language[4]; /* the language of the frame's content, according to ISO-639-2 */ 53 | FrameDataNode *v2_head, *v2_tail; 54 | } id3tag_spec; 55 | 56 | 57 | /* write tag into stream at current position */ 58 | extern int id3tag_write_v2(lame_global_flags *gfp); 59 | 60 | extern int id3tag_write_v1(lame_global_flags *gfp); 61 | /* 62 | * NOTE: A version 2 tag will NOT be added unless one of the text fields won't 63 | * fit in a version 1 tag (e.g. the title string is longer than 30 characters), 64 | * or the "id3tag_add_v2" or "id3tag_v2_only" functions are used. 65 | */ 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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/LameMP3/CMake/src/main/cpp/lamemp3/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 | struct plotting_data { 34 | int frameNum; /* current frame number */ 35 | int frameNum123; 36 | int num_samples; /* number of pcm samples read for this frame */ 37 | double frametime; /* starting time of frame, in seconds */ 38 | double pcmdata[2][1600]; 39 | double pcmdata2[2][1152 + 1152 - DECDELAY]; 40 | double xr[2][2][576]; 41 | double mpg123xr[2][2][576]; 42 | double ms_ratio[2]; 43 | double ms_ener_ratio[2]; 44 | 45 | /* L,R, M and S values */ 46 | double energy_save[4][BLKSIZE]; /* psymodel is one ahead */ 47 | double energy[2][4][BLKSIZE]; 48 | double pe[2][4]; 49 | double thr[2][4][SBMAX_l]; 50 | double en[2][4][SBMAX_l]; 51 | double thr_s[2][4][3 * SBMAX_s]; 52 | double en_s[2][4][3 * SBMAX_s]; 53 | double ers_save[4]; /* psymodel is one ahead */ 54 | double ers[2][4]; 55 | 56 | double sfb[2][2][SBMAX_l]; 57 | double sfb_s[2][2][3 * SBMAX_s]; 58 | double LAMEsfb[2][2][SBMAX_l]; 59 | double LAMEsfb_s[2][2][3 * SBMAX_s]; 60 | 61 | int LAMEqss[2][2]; 62 | int qss[2][2]; 63 | int big_values[2][2]; 64 | int sub_gain[2][2][3]; 65 | 66 | double xfsf[2][2][SBMAX_l]; 67 | double xfsf_s[2][2][3 * SBMAX_s]; 68 | 69 | int over[2][2]; 70 | double tot_noise[2][2]; 71 | double max_noise[2][2]; 72 | double over_noise[2][2]; 73 | int over_SSD[2][2]; 74 | int blocktype[2][2]; 75 | int scalefac_scale[2][2]; 76 | int preflag[2][2]; 77 | int mpg123blocktype[2][2]; 78 | int mixed[2][2]; 79 | int mainbits[2][2]; 80 | int sfbits[2][2]; 81 | int LAMEmainbits[2][2]; 82 | int LAMEsfbits[2][2]; 83 | int framesize, stereo, js, ms_stereo, i_stereo, emph, bitrate, sampfreq, maindata; 84 | int crc, padding; 85 | int scfsi[2], mean_bits, resvsize; 86 | int totbits; 87 | }; 88 | #ifndef plotting_data_defined 89 | #define plotting_data_defined 90 | typedef struct plotting_data plotting_data; 91 | #endif 92 | #if 0 93 | extern plotting_data *pinfo; 94 | #endif 95 | #endif 96 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/lame_global_flags.h: -------------------------------------------------------------------------------- 1 | #ifndef LAME_GLOBAL_FLAGS_H 2 | #define LAME_GLOBAL_FLAGS_H 3 | 4 | #ifndef lame_internal_flags_defined 5 | #define lame_internal_flags_defined 6 | struct lame_internal_flags; 7 | typedef struct lame_internal_flags lame_internal_flags; 8 | #endif 9 | 10 | 11 | typedef enum short_block_e { 12 | short_block_not_set = -1, /* allow LAME to decide */ 13 | short_block_allowed = 0, /* LAME may use them, even different block types for L/R */ 14 | short_block_coupled, /* LAME may use them, but always same block types in L/R */ 15 | short_block_dispensed, /* LAME will not use short blocks, long blocks only */ 16 | short_block_forced /* LAME will not use long blocks, short blocks only */ 17 | } short_block_t; 18 | 19 | /*********************************************************************** 20 | * 21 | * Control Parameters set by User. These parameters are here for 22 | * backwards compatibility with the old, non-shared lib API. 23 | * Please use the lame_set_variablename() functions below 24 | * 25 | * 26 | ***********************************************************************/ 27 | struct lame_global_struct { 28 | unsigned int class_id; 29 | 30 | /* input description */ 31 | unsigned long num_samples; /* number of samples. default=2^32-1 */ 32 | int num_channels; /* input number of channels. default=2 */ 33 | int samplerate_in; /* input_samp_rate in Hz. default=44.1 kHz */ 34 | int samplerate_out; /* output_samp_rate. 35 | default: LAME picks best value 36 | at least not used for MP3 decoding: 37 | Remember 44.1 kHz MP3s and AC97 */ 38 | float scale; /* scale input by this amount before encoding 39 | at least not used for MP3 decoding */ 40 | float scale_left; /* scale input of channel 0 (left) by this 41 | amount before encoding */ 42 | float scale_right; /* scale input of channel 1 (right) by this 43 | amount before encoding */ 44 | 45 | /* general control params */ 46 | int analysis; /* collect data for a MP3 frame analyzer? */ 47 | int write_lame_tag; /* add Xing VBR tag? */ 48 | int decode_only; /* use lame/mpglib to convert mp3 to wav */ 49 | int quality; /* quality setting 0=best, 9=worst default=5 */ 50 | MPEG_mode mode; /* see enum in lame.h 51 | default = LAME picks best value */ 52 | int force_ms; /* force M/S mode. requires mode=1 */ 53 | int free_format; /* use free format? default=0 */ 54 | int findReplayGain; /* find the RG value? default=0 */ 55 | int decode_on_the_fly; /* decode on the fly? default=0 */ 56 | int write_id3tag_automatic; /* 1 (default) writes ID3 tags, 0 not */ 57 | 58 | int nogap_total; 59 | int nogap_current; 60 | 61 | int substep_shaping; 62 | int noise_shaping; 63 | int subblock_gain; /* 0 = no, 1 = yes */ 64 | int use_best_huffman; /* 0 = no. 1=outside loop 2=inside loop(slow) */ 65 | 66 | /* 67 | * set either brate>0 or compression_ratio>0, LAME will compute 68 | * the value of the variable not set. 69 | * Default is compression_ratio = 11.025 70 | */ 71 | int brate; /* bitrate */ 72 | float compression_ratio; /* sizeof(wav file)/sizeof(mp3 file) */ 73 | 74 | 75 | /* frame params */ 76 | int copyright; /* mark as copyright. default=0 */ 77 | int original; /* mark as original. default=1 */ 78 | int extension; /* the MP3 'private extension' bit. 79 | Meaningless */ 80 | int emphasis; /* Input PCM is emphased PCM (for 81 | instance from one of the rarely 82 | emphased CDs), it is STRONGLY not 83 | recommended to use this, because 84 | psycho does not take it into account, 85 | and last but not least many decoders 86 | don't care about these bits */ 87 | int error_protection; /* use 2 bytes per frame for a CRC 88 | checksum. default=0 */ 89 | int strict_ISO; /* enforce ISO spec as much as possible */ 90 | 91 | int disable_reservoir; /* use bit reservoir? */ 92 | 93 | /* quantization/noise shaping */ 94 | int quant_comp; 95 | int quant_comp_short; 96 | int experimentalY; 97 | int experimentalZ; 98 | int exp_nspsytune; 99 | 100 | int preset; 101 | 102 | /* VBR control */ 103 | vbr_mode VBR; 104 | float VBR_q_frac; /* Range [0,...,1[ */ 105 | int VBR_q; /* Range [0,...,9] */ 106 | int VBR_mean_bitrate_kbps; 107 | int VBR_min_bitrate_kbps; 108 | int VBR_max_bitrate_kbps; 109 | int VBR_hard_min; /* strictly enforce VBR_min_bitrate 110 | normaly, it will be violated for analog 111 | silence */ 112 | 113 | 114 | /* resampling and filtering */ 115 | int lowpassfreq; /* freq in Hz. 0=lame choses. 116 | -1=no filter */ 117 | int highpassfreq; /* freq in Hz. 0=lame choses. 118 | -1=no filter */ 119 | int lowpasswidth; /* freq width of filter, in Hz 120 | (default=15%) */ 121 | int highpasswidth; /* freq width of filter, in Hz 122 | (default=15%) */ 123 | 124 | 125 | 126 | /* 127 | * psycho acoustics and other arguments which you should not change 128 | * unless you know what you are doing 129 | */ 130 | float maskingadjust; 131 | float maskingadjust_short; 132 | int ATHonly; /* only use ATH */ 133 | int ATHshort; /* only use ATH for short blocks */ 134 | int noATH; /* disable ATH */ 135 | int ATHtype; /* select ATH formula */ 136 | float ATHcurve; /* change ATH formula 4 shape */ 137 | float ATH_lower_db; /* lower ATH by this many db */ 138 | int athaa_type; /* select ATH auto-adjust scheme */ 139 | float athaa_sensitivity; /* dB, tune active region of auto-level */ 140 | short_block_t short_blocks; 141 | int useTemporal; /* use temporal masking effect */ 142 | float interChRatio; 143 | float msfix; /* Naoki's adjustment of Mid/Side maskings */ 144 | 145 | int tune; /* 0 off, 1 on */ 146 | float tune_value_a; /* used to pass values for debugging and stuff */ 147 | 148 | float attackthre; /* attack threshold for L/R/M channel */ 149 | float attackthre_s; /* attack threshold for S channel */ 150 | 151 | 152 | struct { 153 | void (*msgf)(const char *format, va_list ap); 154 | 155 | void (*debugf)(const char *format, va_list ap); 156 | 157 | void (*errorf)(const char *format, va_list ap); 158 | } report; 159 | 160 | /************************************************************************/ 161 | /* internal variables, do not set... */ 162 | /* provided because they may be of use to calling application */ 163 | /************************************************************************/ 164 | 165 | int lame_allocated_gfp; /* is this struct owned by calling 166 | program or lame? */ 167 | 168 | 169 | 170 | /**************************************************************************/ 171 | /* more internal variables are stored in this structure: */ 172 | /**************************************************************************/ 173 | lame_internal_flags *internal_flags; 174 | 175 | 176 | struct { 177 | int mmx; 178 | int amd3dnow; 179 | int sse; 180 | 181 | } asm_optimizations; 182 | }; 183 | 184 | int is_lame_global_flags_valid(const lame_global_flags *gfp); 185 | 186 | #endif /* LAME_GLOBAL_FLAGS_H */ 187 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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/LameMP3/CMake/src/main/cpp/lamemp3/machine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Machine dependent defines/includes 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_MACHINE_H 23 | #define LAME_MACHINE_H 24 | 25 | #include "version.h" 26 | 27 | #include 28 | #include 29 | 30 | #ifdef STDC_HEADERS 31 | # include 32 | # include 33 | #else 34 | 35 | //# ifndef HAVE_STRCHR 36 | //# define strchr index 37 | //# define strrchr rindex 38 | //# endif 39 | //char *strchr(), *strrchr(); 40 | //# ifndef HAVE_MEMCPY 41 | //# define memcpy(d, s, n) bcopy ((s), (d), (n)) 42 | //# define memmove(d, s, n) bcopy ((s), (d), (n)) 43 | //# endif 44 | #endif 45 | 46 | #if defined(__riscos__) && defined(FPA10) 47 | # include "ymath.h" 48 | #else 49 | 50 | # include 51 | 52 | #endif 53 | 54 | #include 55 | 56 | #include 57 | 58 | #ifdef HAVE_ERRNO_H 59 | # include 60 | #endif 61 | #ifdef HAVE_FCNTL_H 62 | # include 63 | #endif 64 | 65 | #if defined(macintosh) 66 | # include 67 | # include 68 | #else 69 | 70 | # include 71 | # include 72 | 73 | #endif 74 | 75 | #ifdef HAVE_INTTYPES_H 76 | # include 77 | #else 78 | # ifdef HAVE_STDINT_H 79 | # include 80 | # endif 81 | #endif 82 | 83 | #ifdef WITH_DMALLOC 84 | #include 85 | #endif 86 | 87 | /* 88 | * 3 different types of pow() functions: 89 | * - table lookup 90 | * - pow() 91 | * - exp() on some machines this is claimed to be faster than pow() 92 | */ 93 | 94 | #define POW20(x) (assert(0 <= (x+Q_MAX2) && x < Q_MAX), pow20[x+Q_MAX2]) 95 | /*#define POW20(x) pow(2.0,((double)(x)-210)*.25) */ 96 | /*#define POW20(x) exp( ((double)(x)-210)*(.25*LOG2) ) */ 97 | 98 | #define IPOW20(x) (assert(0 <= x && x < Q_MAX), ipow20[x]) 99 | /*#define IPOW20(x) exp( -((double)(x)-210)*.1875*LOG2 ) */ 100 | /*#define IPOW20(x) pow(2.0,-((double)(x)-210)*.1875) */ 101 | 102 | /* in case this is used without configure */ 103 | #ifndef inline 104 | # define inline 105 | #endif 106 | 107 | #if defined(_MSC_VER) 108 | # undef inline 109 | # define inline _inline 110 | #elif defined(__SASC) || defined(__GNUC__) || defined(__ICC) || defined(__ECC) 111 | /* if __GNUC__ we always want to inline, not only if the user requests it */ 112 | # undef inline 113 | # define inline __inline 114 | #endif 115 | 116 | #if defined(_MSC_VER) 117 | # pragma warning( disable : 4244 ) 118 | /*# pragma warning( disable : 4305 ) */ 119 | #endif 120 | 121 | /* 122 | * FLOAT for variables which require at least 32 bits 123 | * FLOAT8 for variables which require at least 64 bits 124 | * 125 | * On some machines, 64 bit will be faster than 32 bit. Also, some math 126 | * routines require 64 bit float, so setting FLOAT=float will result in a 127 | * lot of conversions. 128 | */ 129 | 130 | #if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)) 131 | # define WIN32_LEAN_AND_MEAN 132 | # include 133 | # include 134 | # define FLOAT_MAX FLT_MAX 135 | #else 136 | # ifndef FLOAT 137 | typedef float FLOAT; 138 | # ifdef FLT_MAX 139 | # define FLOAT_MAX FLT_MAX 140 | # else 141 | # define FLOAT_MAX 1e37 /* approx */ 142 | # endif 143 | # endif 144 | #endif 145 | 146 | #ifndef FLOAT8 147 | typedef double FLOAT8; 148 | # ifdef DBL_MAX 149 | # define FLOAT8_MAX DBL_MAX 150 | # else 151 | # define FLOAT8_MAX 1e99 /* approx */ 152 | # endif 153 | #else 154 | # ifdef FLT_MAX 155 | # define FLOAT8_MAX FLT_MAX 156 | # else 157 | # define FLOAT8_MAX 1e37 /* approx */ 158 | # endif 159 | #endif 160 | 161 | /* sample_t must be floating point, at least 32 bits */ 162 | typedef FLOAT sample_t; 163 | 164 | #define dimension_of(array) (sizeof(array)/sizeof(array[0])) 165 | #define beyond(array) (array+dimension_of(array)) 166 | #define compiletime_assert(expression) enum{static_assert_##FILE##_##LINE = 1/((expression)?1:0)} 167 | #define lame_calloc(TYPE, COUNT) ((TYPE*)calloc(COUNT, sizeof(TYPE))) 168 | #define multiple_of(CHUNK, COUNT) (\ 169 | ( (COUNT) < 1 || (CHUNK) < 1 || (COUNT) % (CHUNK) == 0 ) \ 170 | ? (COUNT) \ 171 | : ((COUNT) + (CHUNK) - (COUNT) % (CHUNK)) \ 172 | ) 173 | 174 | #if 1 175 | #define EQ(a, b) (\ 176 | (abs(a) > abs(b)) \ 177 | ? (abs((a)-(b)) <= (abs(a) * 1e-6f)) \ 178 | : (abs((a)-(b)) <= (abs(b) * 1e-6f))) 179 | #else 180 | #define EQ(a,b) (abs((a)-(b))<1E-37) 181 | #endif 182 | 183 | #define NEQ(a, b) (!EQ(a,b)) 184 | 185 | #ifdef _MSC_VER 186 | # if _MSC_VER < 1400 187 | # define fabsf fabs 188 | # define powf pow 189 | # define log10f log10 190 | # endif 191 | #endif 192 | 193 | #endif 194 | 195 | /* end of machine.h */ 196 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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/LameMP3/CMake/src/main/cpp/lamemp3/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/LameMP3/CMake/src/main/cpp/lamemp3/quantize_pvt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * quantize_pvt 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_QUANTIZE_PVT_H 23 | #define LAME_QUANTIZE_PVT_H 24 | 25 | #define IXMAX_VAL 8206 /* ix always <= 8191+15. see count_bits() */ 26 | 27 | /* buggy Winamp decoder cannot handle values > 8191 */ 28 | /* #define IXMAX_VAL 8191 */ 29 | 30 | #define PRECALC_SIZE (IXMAX_VAL+2) 31 | 32 | 33 | extern const int nr_of_sfb_block[6][3][4]; 34 | extern const int pretab[SBMAX_l]; 35 | extern const int slen1_tab[16]; 36 | extern const int slen2_tab[16]; 37 | 38 | extern const scalefac_struct sfBandIndex[9]; 39 | 40 | extern FLOAT pow43[PRECALC_SIZE]; 41 | #ifdef TAKEHIRO_IEEE754_HACK 42 | extern FLOAT adj43asm[PRECALC_SIZE]; 43 | #else 44 | extern FLOAT adj43[PRECALC_SIZE]; 45 | #endif 46 | 47 | #define Q_MAX (256+1) 48 | #define Q_MAX2 116 /* minimum possible number of 49 | -cod_info->global_gain 50 | + ((scalefac[] + (cod_info->preflag ? pretab[sfb] : 0)) 51 | << (cod_info->scalefac_scale + 1)) 52 | + cod_info->subblock_gain[cod_info->window[sfb]] * 8; 53 | 54 | for long block, 0+((15+3)<<2) = 18*4 = 72 55 | for short block, 0+(15<<2)+7*8 = 15*4+56 = 116 56 | */ 57 | 58 | extern FLOAT pow20[Q_MAX + Q_MAX2 + 1]; 59 | extern FLOAT ipow20[Q_MAX]; 60 | 61 | typedef struct calc_noise_result_t { 62 | FLOAT over_noise; /* sum of quantization noise > masking */ 63 | FLOAT tot_noise; /* sum of all quantization noise */ 64 | FLOAT max_noise; /* max quantization noise */ 65 | int over_count; /* number of quantization noise > masking */ 66 | int over_SSD; /* SSD-like cost of distorted bands */ 67 | int bits; 68 | } calc_noise_result; 69 | 70 | 71 | /** 72 | * allows re-use of previously 73 | * computed noise values 74 | */ 75 | typedef struct calc_noise_data_t { 76 | int global_gain; 77 | int sfb_count1; 78 | int step[39]; 79 | FLOAT noise[39]; 80 | FLOAT noise_log[39]; 81 | } calc_noise_data; 82 | 83 | 84 | int on_pe(lame_internal_flags *gfc, const FLOAT pe[2][2], 85 | int targ_bits[2], int mean_bits, int gr, int cbr); 86 | 87 | void reduce_side(int targ_bits[2], FLOAT ms_ener_ratio, int mean_bits, int max_bits); 88 | 89 | 90 | void iteration_init(lame_internal_flags *gfc); 91 | 92 | 93 | int calc_xmin(lame_internal_flags const *gfc, 94 | III_psy_ratio const *const ratio, gr_info *const cod_info, FLOAT *l3_xmin); 95 | 96 | int calc_noise(const gr_info *const cod_info, 97 | const FLOAT *l3_xmin, 98 | FLOAT *distort, calc_noise_result *const res, calc_noise_data *prev_noise); 99 | 100 | void set_frame_pinfo(lame_internal_flags *gfc, const III_psy_ratio ratio[2][2]); 101 | 102 | 103 | /* takehiro.c */ 104 | 105 | int count_bits(lame_internal_flags const *const gfc, const FLOAT *const xr, 106 | gr_info *const cod_info, calc_noise_data *prev_noise); 107 | 108 | int noquant_count_bits(lame_internal_flags const *const gfc, 109 | gr_info *const cod_info, calc_noise_data *prev_noise); 110 | 111 | 112 | void best_huffman_divide(const lame_internal_flags *const gfc, gr_info *const cod_info); 113 | 114 | void best_scalefac_store(const lame_internal_flags *gfc, const int gr, const int ch, 115 | III_side_info_t *const l3_side); 116 | 117 | int scale_bitcount(const lame_internal_flags *gfc, gr_info *cod_info); 118 | 119 | void huffman_init(lame_internal_flags *const gfc); 120 | 121 | void init_xrpow_core_init(lame_internal_flags *const gfc); 122 | 123 | FLOAT athAdjust(FLOAT a, FLOAT x, FLOAT athFloor, float ATHfixpoint); 124 | 125 | #define LARGE_BITS 100000 126 | 127 | #endif /* LAME_QUANTIZE_PVT_H */ 128 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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 | 27 | void ResvMaxBits(lame_internal_flags *gfc, int mean_bits, int *targ_bits, int *max_bits, 28 | int cbr); 29 | 30 | void ResvAdjust(lame_internal_flags *gfc, gr_info const *gi); 31 | 32 | void ResvFrameEnd(lame_internal_flags *gfc, int mean_bits); 33 | 34 | #endif /* LAME_RESERVOIR_H */ 35 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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 | 35 | int CDECL lame_set_short_threshold_lrm(lame_global_flags *, float); 36 | 37 | float CDECL lame_get_short_threshold_lrm(const lame_global_flags *); 38 | 39 | int CDECL lame_set_short_threshold_s(lame_global_flags *, float); 40 | 41 | float CDECL lame_get_short_threshold_s(const lame_global_flags *); 42 | 43 | 44 | int CDECL lame_set_maskingadjust(lame_global_flags *, float); 45 | 46 | float CDECL lame_get_maskingadjust(const lame_global_flags *); 47 | 48 | int CDECL lame_set_maskingadjust_short(lame_global_flags *, float); 49 | 50 | float CDECL lame_get_maskingadjust_short(const lame_global_flags *); 51 | 52 | /* select ATH formula 4 shape */ 53 | int CDECL lame_set_ATHcurve(lame_global_flags *, float); 54 | 55 | float CDECL lame_get_ATHcurve(const lame_global_flags *); 56 | 57 | int CDECL lame_set_preset_notune(lame_global_flags *, int); 58 | 59 | /* substep shaping method */ 60 | int CDECL lame_set_substep(lame_global_flags *, int); 61 | 62 | int CDECL lame_get_substep(const lame_global_flags *); 63 | 64 | /* scalefactors scale */ 65 | int CDECL lame_set_sfscale(lame_global_flags *, int); 66 | 67 | int CDECL lame_get_sfscale(const lame_global_flags *); 68 | 69 | /* subblock gain */ 70 | int CDECL lame_set_subblock_gain(lame_global_flags *, int); 71 | 72 | int CDECL lame_get_subblock_gain(const lame_global_flags *); 73 | 74 | 75 | /*presets*/ 76 | int apply_preset(lame_global_flags *, int preset, int enforce); 77 | 78 | void CDECL lame_set_tune(lame_t, float); /* FOR INTERNAL USE ONLY */ 79 | void CDECL lame_set_msfix(lame_t gfp, double msfix); 80 | 81 | 82 | #if defined(__cplusplus) 83 | } 84 | #endif 85 | #endif 86 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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/LameMP3/CMake/src/main/cpp/lamemp3/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 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/vector/lame_intrin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lame_intrin.h include file 3 | * 4 | * Copyright (c) 2006 Gabriel Bouvigne 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 | 23 | #ifndef LAME_INTRIN_H 24 | #define LAME_INTRIN_H 25 | 26 | 27 | void 28 | init_xrpow_core_sse(gr_info *const cod_info, FLOAT xrpow[576], int upper, FLOAT *sum); 29 | 30 | void 31 | fht_SSE2(FLOAT *, int); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/version.c: -------------------------------------------------------------------------------- 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 | /*! 23 | \file version.c 24 | \brief Version numbering for LAME. 25 | 26 | Contains functions which describe the version of LAME. 27 | 28 | \author A.L. Faber 29 | \version \$Id: version.c,v 1.34 2011/11/18 09:51:02 robert Exp $ 30 | \ingroup libmp3lame 31 | */ 32 | 33 | 34 | #ifdef HAVE_CONFIG_H 35 | # include 36 | #endif 37 | 38 | 39 | #include "lame.h" 40 | #include "machine.h" 41 | 42 | #include "version.h" /* macros of version numbers */ 43 | 44 | 45 | 46 | 47 | 48 | /*! Get the LAME version string. */ 49 | /*! 50 | \param void 51 | \return a pointer to a string which describes the version of LAME. 52 | */ 53 | const char * 54 | get_lame_version(void) { /* primary to write screen reports */ 55 | /* Here we can also add informations about compile time configurations */ 56 | 57 | #if LAME_ALPHA_VERSION 58 | static /*@observer@ */ const char *const str = 59 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " " 60 | "(alpha " STR(LAME_PATCH_VERSION) ", " __DATE__ " " __TIME__ ")"; 61 | #elif LAME_BETA_VERSION 62 | static /*@observer@ */ const char *const str = 63 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " " 64 | "(beta " STR(LAME_PATCH_VERSION) ", " __DATE__ ")"; 65 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0) 66 | static /*@observer@ */ const char *const str = 67 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION); 68 | #else 69 | static /*@observer@ */ const char *const str = 70 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION); 71 | #endif 72 | 73 | return str; 74 | } 75 | 76 | 77 | /*! Get the short LAME version string. */ 78 | /*! 79 | It's mainly for inclusion into the MP3 stream. 80 | 81 | \param void 82 | \return a pointer to the short version of the LAME version string. 83 | */ 84 | const char * 85 | get_lame_short_version(void) { 86 | /* adding date and time to version string makes it harder for output 87 | validation */ 88 | 89 | #if LAME_ALPHA_VERSION 90 | static /*@observer@ */ const char *const str = 91 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (alpha " STR(LAME_PATCH_VERSION) ")"; 92 | #elif LAME_BETA_VERSION 93 | static /*@observer@ */ const char *const str = 94 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (beta " STR(LAME_PATCH_VERSION) ")"; 95 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0) 96 | static /*@observer@ */ const char *const str = 97 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION); 98 | #else 99 | static /*@observer@ */ const char *const str = 100 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION); 101 | #endif 102 | 103 | return str; 104 | } 105 | 106 | /*! Get the _very_ short LAME version string. */ 107 | /*! 108 | It's used in the LAME VBR tag only. 109 | 110 | \param void 111 | \return a pointer to the short version of the LAME version string. 112 | */ 113 | const char * 114 | get_lame_very_short_version(void) { 115 | /* adding date and time to version string makes it harder for output 116 | validation */ 117 | #if LAME_ALPHA_VERSION 118 | #define P "a" 119 | #elif LAME_BETA_VERSION 120 | #define P "b" 121 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0) 122 | #define P "r" 123 | #else 124 | #define P " " 125 | #endif 126 | static /*@observer@ */ const char *const str = 127 | #if (LAME_PATCH_VERSION > 0) 128 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P STR(LAME_PATCH_VERSION) 129 | #else 130 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P 131 | #endif 132 | ; 133 | return str; 134 | } 135 | 136 | /*! Get the _very_ short LAME version string. */ 137 | /*! 138 | It's used in the LAME VBR tag only, limited to 9 characters max. 139 | Due to some 3rd party HW/SW decoders, it has to start with LAME. 140 | 141 | \param void 142 | \return a pointer to the short version of the LAME version string. 143 | */ 144 | const char * 145 | get_lame_tag_encoder_short_version(void) { 146 | static /*@observer@ */ const char *const str = 147 | /* FIXME: new scheme / new version counting / drop versioning here ? */ 148 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P; 149 | return str; 150 | } 151 | 152 | /*! Get the version string for GPSYCHO. */ 153 | /*! 154 | \param void 155 | \return a pointer to a string which describes the version of GPSYCHO. 156 | */ 157 | const char * 158 | get_psy_version(void) { 159 | #if PSY_ALPHA_VERSION > 0 160 | static /*@observer@ */ const char *const str = 161 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION) 162 | " (alpha " STR(PSY_ALPHA_VERSION) ", " __DATE__ " " __TIME__ ")"; 163 | #elif PSY_BETA_VERSION > 0 164 | static /*@observer@ */ const char *const str = 165 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION) 166 | " (beta " STR(PSY_BETA_VERSION) ", " __DATE__ ")"; 167 | #else 168 | static /*@observer@ */ const char *const str = 169 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION); 170 | #endif 171 | 172 | return str; 173 | } 174 | 175 | 176 | /*! Get the URL for the LAME website. */ 177 | /*! 178 | \param void 179 | \return a pointer to a string which is a URL for the LAME website. 180 | */ 181 | const char * 182 | get_lame_url(void) { 183 | static /*@observer@ */ const char *const str = LAME_URL; 184 | 185 | return str; 186 | } 187 | 188 | 189 | /*! Get the numerical representation of the version. */ 190 | /*! 191 | Writes the numerical representation of the version of LAME and 192 | GPSYCHO into lvp. 193 | 194 | \param lvp 195 | */ 196 | void 197 | get_lame_version_numerical(lame_version_t *lvp) { 198 | static /*@observer@ */ const char *const features = ""; /* obsolete */ 199 | 200 | /* generic version */ 201 | lvp->major = LAME_MAJOR_VERSION; 202 | lvp->minor = LAME_MINOR_VERSION; 203 | #if LAME_ALPHA_VERSION 204 | lvp->alpha = LAME_PATCH_VERSION; 205 | lvp->beta = 0; 206 | #elif LAME_BETA_VERSION 207 | lvp->alpha = 0; 208 | lvp->beta = LAME_PATCH_VERSION; 209 | #else 210 | lvp->alpha = 0; 211 | lvp->beta = 0; 212 | #endif 213 | 214 | /* psy version */ 215 | lvp->psy_major = PSY_MAJOR_VERSION; 216 | lvp->psy_minor = PSY_MINOR_VERSION; 217 | lvp->psy_alpha = PSY_ALPHA_VERSION; 218 | lvp->psy_beta = PSY_BETA_VERSION; 219 | 220 | /* compile time features */ 221 | /*@-mustfree@ */ 222 | lvp->features = features; 223 | /*@=mustfree@ */ 224 | } 225 | 226 | 227 | const char * 228 | get_lame_os_bitness(void) { 229 | static /*@observer@ */ const char *const strXX = ""; 230 | static /*@observer@ */ const char *const str32 = "32bits"; 231 | static /*@observer@ */ const char *const str64 = "64bits"; 232 | 233 | switch (sizeof(void *)) { 234 | case 4: 235 | return str32; 236 | 237 | case 8: 238 | return str64; 239 | 240 | default: 241 | return strXX; 242 | } 243 | } 244 | 245 | /* end of version.c */ 246 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/cpp/lamemp3/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 100 /* Minor version number */ 39 | # define LAME_TYPE_VERSION 2 /* 0:alpha 1:beta 2:release */ 40 | # define LAME_PATCH_VERSION 0 /* 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 | -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/jniLibs/arm64-v8a/liblame.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/CZRecorder/a72219594fb49b7b2ad9e407dcc23b5b2973936e/Lame/LameMP3/CMake/src/main/jniLibs/arm64-v8a/liblame.so -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/jniLibs/arm64-v8a/libmp3lame.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/CZRecorder/a72219594fb49b7b2ad9e407dcc23b5b2973936e/Lame/LameMP3/CMake/src/main/jniLibs/arm64-v8a/libmp3lame.so -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/jniLibs/armeabi-v7a/liblame.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/CZRecorder/a72219594fb49b7b2ad9e407dcc23b5b2973936e/Lame/LameMP3/CMake/src/main/jniLibs/armeabi-v7a/liblame.so -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/jniLibs/armeabi-v7a/libmp3lame.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/CZRecorder/a72219594fb49b7b2ad9e407dcc23b5b2973936e/Lame/LameMP3/CMake/src/main/jniLibs/armeabi-v7a/libmp3lame.so -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/jniLibs/x86_64/liblame.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/CZRecorder/a72219594fb49b7b2ad9e407dcc23b5b2973936e/Lame/LameMP3/CMake/src/main/jniLibs/x86_64/liblame.so -------------------------------------------------------------------------------- /Lame/LameMP3/CMake/src/main/jniLibs/x86_64/libmp3lame.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/CZRecorder/a72219594fb49b7b2ad9e407dcc23b5b2973936e/Lame/LameMP3/CMake/src/main/jniLibs/x86_64/libmp3lame.so -------------------------------------------------------------------------------- /Lame/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | javasource = JavaVersion.VERSION_1_8 6 | javatarget = JavaVersion.VERSION_1_8 7 | 8 | compileVersion = 28 9 | targetVersion = 28 10 | minVersion = 14 11 | buildVersion = '29.0.0' 12 | supportLibVersion = '28.0.0' 13 | lifecycleLibVersion = '1.1.1' 14 | runnerVersion = '0.5' 15 | rulesVersion = '0.5' 16 | UiAutomatorLibVersion = '2.1.2' 17 | FirebaseLibVersion = '11.8.0' 18 | versionName = '0.0.0' 19 | protobufVersion = '3.6.1' 20 | grpcVersion = '1.14.0' // CURRENT_GRPC_VERSION 21 | nettyTcNativeVersion = '2.0.7.Final' 22 | okHttp3Version = '3.11.0' 23 | retrofit2Version = '2.4.0' 24 | gsonVersion = '2.8.5' 25 | } 26 | repositories { 27 | maven { url "https://maven.google.com" } 28 | google() 29 | jcenter() 30 | maven { // The google mirror is less flaky than mavenCentral() 31 | url "https://maven-central.storage-download.googleapis.com/repos/central/data/" 32 | } 33 | maven { url 'https://jitpack.io' } 34 | maven { url "https://plugins.gradle.org/m2/" } 35 | } 36 | dependencies { 37 | classpath 'com.android.tools.build:gradle:3.4.1' 38 | 39 | 40 | // NOTE: Do not place your application dependencies here; they belong 41 | // in the individual module build.gradle files 42 | } 43 | } 44 | 45 | allprojects { 46 | repositories { 47 | maven { url "https://maven.google.com" } 48 | google() 49 | jcenter() 50 | maven { // The google mirror is less flaky than mavenCentral() 51 | url "https://maven-central.storage-download.googleapis.com/repos/central/data/" 52 | } 53 | mavenLocal() 54 | maven { url "https://jitpack.io" } 55 | maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' } 56 | } 57 | } 58 | 59 | def buildTime() { 60 | return new Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC")) 61 | } 62 | 63 | ext { 64 | javasource = JavaVersion.VERSION_1_8 65 | javatarget = JavaVersion.VERSION_1_8 66 | 67 | compileVersion = 28 68 | targetVersion = 28 69 | minVersion = 14 70 | buildVersion = '29.0.0' 71 | supportLibVersion = '28.0.0' 72 | lifecycleLibVersion = '1.1.1' 73 | runnerVersion = '0.5' 74 | rulesVersion = '0.5' 75 | UiAutomatorLibVersion = '2.1.2' 76 | FirebaseLibVersion = '11.8.0' 77 | versionName = '0.0.0' 78 | protobufVersion = '3.6.1' 79 | grpcVersion = '1.14.0' // CURRENT_GRPC_VERSION 80 | nettyTcNativeVersion = '2.0.7.Final' 81 | okHttp3Version = '3.11.0' 82 | retrofit2Version = '2.4.0' 83 | gsonVersion = '2.8.5' 84 | appbuildTime = buildTime() 85 | } 86 | 87 | task clean(type: Delete) { 88 | delete rootProject.buildDir 89 | } 90 | -------------------------------------------------------------------------------- /Lame/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | 15 | 16 | -------------------------------------------------------------------------------- /Lame/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /Lame/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /Lame/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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /Lame/settings.gradle: -------------------------------------------------------------------------------- 1 | //Library 2 | include ':LameMP3' 3 | project(":LameMP3").projectDir = file("./LameMP3/CMake") 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## CZRecorder 2 | [![](https://jitpack.io/v/chezi008/CZRecorder.svg)](https://jitpack.io/#chezi008/CZRecorder) 3 | ### 一、功能说明 4 | 1、通过libmp3lame库将PCM转成MP3的音频格式。 5 | 2、添加一个自定义的录音控件。 6 | #### 1.1对外开放方法说明: 7 | ``` 8 | /** 9 | * 设置保存文件的路径 10 | * 11 | * @param filePath 录制文件的地址 12 | */ 13 | void setAudioPath(String filePath); 14 | 15 | /** 16 | * 设置回调 17 | * 18 | * @param audioListener 回调接口 19 | */ 20 | void setAudioListener(AudioRecordListener audioListener); 21 | 22 | /** 23 | * 开始录制音频 24 | */ 25 | void startRecord(); 26 | 27 | /** 28 | * 暂停录制 29 | */ 30 | void onPause(); 31 | 32 | /** 33 | * 继续录制 34 | */ 35 | void onResume(); 36 | 37 | /** 38 | * 停止录制 39 | */ 40 | void stopRecord(); 41 | ``` 42 | #### 1.2 mp3录制方法说明: 43 | ``` 44 | /** 45 | * Initialize LAME. 46 | * 47 | * @param inSamplerate 48 | * input sample rate in Hz. 49 | * @param inChannel 50 | * number of channels in input stream. 51 | * @param outSamplerate 52 | * output sample rate in Hz. 53 | * @param outBitrate 54 | * brate compression ratio in KHz. 55 | * @param quality 56 | *

quality=0..9. 0=best (very slow). 9=worst.

57 | *

recommended:

58 | *

2 near-best quality, not too slow

59 | *

5 good quality, fast

60 | * 7 ok quality, really fast 61 | */ 62 | public native static void init(int inSamplerate, int inChannel, 63 | int outSamplerate, int outBitrate, int quality); 64 | 65 | /** 66 | * Encode buffer to mp3. 67 | * 68 | * @param bufferLeft 69 | * PCM data for left channel. 70 | * @param bufferRight 71 | * PCM data for right channel. 72 | * @param samples 73 | * number of samples per channel. 74 | * @param mp3buf 75 | * result encoded MP3 stream. You must specified 76 | * "7200 + (1.25 * buffer_l.length)" length array. 77 | * @return

number of bytes output in mp3buf. Can be 0.

78 | *

-1: mp3buf was too small

79 | *

-2: malloc() problem

80 | *

-3: lame_init_params() not called

81 | * -4: psycho acoustic problems 82 | */ 83 | public native static int encode(short[] bufferLeft, short[] bufferRight, 84 | int samples, byte[] mp3buf); 85 | 86 | /** 87 | * Flush LAME buffer. 88 | * 89 | * REQUIRED: 90 | * lame_encode_flush will flush the intenal PCM buffers, padding with 91 | * 0's to make sure the final frame is complete, and then flush 92 | * the internal MP3 buffers, and thus may return a 93 | * final few mp3 frames. 'mp3buf' should be at least 7200 bytes long 94 | * to hold all possible emitted data. 95 | * 96 | * will also write id3v1 tags (if any) into the bitstream 97 | * 98 | * return code = number of bytes output to mp3buf. Can be 0 99 | * @param mp3buf 100 | * result encoded MP3 stream. You must specified at least 7200 101 | * bytes. 102 | * @return number of bytes output to mp3buf. Can be 0. 103 | */ 104 | public native static int flush(byte[] mp3buf); 105 | 106 | /** 107 | * Close LAME. 108 | */ 109 | public native static void close(); 110 | ``` 111 | #### 1.3 自定义录音控件 112 | 喜欢的可以用用,不喜欢也没办法,反正我是打包在里面了。 113 | 114 | ### 二、所做修改 115 | 原作者博客中,原理和过程已经写的很清楚了。这里就不再进行赘述了。只是作者之前使用.mk文件进行编译的。但是最新的as软件需要使用cmake进行编译。所以我在这里进行整理了一下。在最新的编译软件下面也可以使用。 116 | 117 | ### 三、修改记录 118 | 1. 使用cmake编译mp3lame库。 119 | 2. include文件中,只保留头文件。 120 | 3. 删除DataEncodeThread类,转换mp3放在录制线程中。 121 | 4. 添加录音暂停,继续功能。 122 | 5. 重新封装mp3record。 123 | 124 | ### 四、新增功能: 125 | 126 | #### 4.1 暂停,继续功能 127 | 在开发的过程中,我想有些同学肯定用得到录制暂停的功能,所以我在原来的基础上面增加了暂停的功能。实现的原理是,当用户点击暂停时,就不再往MP3文件中写流,也不在MP3文件写入MP3结尾信息。当用户点击继续是,在原来文件流的基础上继续增加数据,只有当用户停止录制的时候才写入MP3尾部信息。 128 | #### 4.2 自定义了麦克风录制控件 129 | 效果图如下: 130 | 1、长按进行MP3文件录制。 131 | 2、松开按钮结束录制。 132 | ![录音动画.gif](https://upload-images.jianshu.io/upload_images/419652-e3a7765371c40a84.gif?imageMogr2/auto-orient/strip) 133 | 134 | 135 | #### 4.3 自定义了频谱控件 136 | 效果如上图 137 | ![频谱.gif](https://upload-images.jianshu.io/upload_images/419652-592aceef58530cdf.gif?imageMogr2/auto-orient/strip) 138 | 139 | ### 五、如何使用 140 | You need to make sure you have the JCenter and Google repositories included in the build.gradle file in the root of your project: 141 | ``` 142 | repositories { 143 | jcenter() 144 | maven { url 'https://jitpack.io' } 145 | } 146 | 147 | ``` 148 | Next add a dependency in the build.gradle file of your app module. The following will add a dependency to the full library: 149 | ``` 150 | dependencies { 151 | implementation 'com.github.chezi008:CZRecorder:1.0.9' 152 | } 153 | 154 | ``` 155 | 156 | ### github: https://github.com/chezi008/CZRecorder 157 | ### [参考] 158 | 1. 编译libmp3lame库: http://www.cnblogs.com/ct2011/p/4080193.html 159 | 2. 自定义圆形录制控件的动画参考:不记得了 160 | 3. 频谱波动控件参考:https://www.jianshu.com/p/76aceacbc243 161 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 30 5 | buildToolsVersion "30.0.0" 6 | defaultConfig { 7 | applicationId "com.chezi008.mp3recorddemo" 8 | minSdkVersion 24 9 | targetSdkVersion 30 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | } 22 | 23 | dependencies { 24 | testImplementation 'junit:junit:4.13.2' 25 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 26 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 27 | 28 | implementation fileTree(include: ['*.jar'], dir: 'libs') 29 | implementation 'com.google.android.material:material:1.4.0' 30 | implementation project(path: ':recorder-audio') 31 | // implementation 'com.github.chezi008:AndroidMp3Recorder:v1.0.4' 32 | // implementation project(path: ':lamemp3') 33 | 34 | // 权限请求框架:https://github.com/getActivity/XXPermissions 35 | implementation 'com.github.getActivity:XXPermissions:18.5' 36 | } 37 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/chezi/mp3recorddemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.chezi.mp3recorddemo; 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 | * Instrumented 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("com.chezi008.mp3recorddemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/chezi/mp3recorder/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.chezi.mp3recorder; 2 | 3 | import android.os.Environment; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.Toast; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.appcompat.app.AppCompatActivity; 12 | 13 | import com.chezi.recorder.IAudioRecorder; 14 | import com.chezi.recorder.Mp3Recorder; 15 | import com.chezi.recorder.SpectrumView; 16 | import com.chezi.recorder.listener.AudioRecordListener; 17 | import com.chezi.recorder.RecorderView; 18 | import com.chezi.mp3recorddemo.R; 19 | import com.hjq.permissions.OnPermissionCallback; 20 | import com.hjq.permissions.Permission; 21 | import com.hjq.permissions.XXPermissions; 22 | 23 | import java.io.File; 24 | import java.io.IOException; 25 | import java.util.List; 26 | 27 | public class MainActivity extends AppCompatActivity { 28 | private String TAG = getClass().getSimpleName(); 29 | 30 | // Used to load the 'native-lib' library on application startup. 31 | 32 | private IAudioRecorder mRecorder; 33 | private String filePath; 34 | private SpectrumView spectrum_view; 35 | 36 | private RecorderView mic_view; 37 | 38 | @Override 39 | public void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.activity_main); 42 | filePath = getFilesDir().getAbsolutePath()+ "/test.mp3"; 43 | // createFile(); 44 | requestPermission(); 45 | mRecorder = new Mp3Recorder(); 46 | mRecorder.setAudioListener(new AudioRecordListener() { 47 | @Override 48 | public void onGetVolume(int volume) { 49 | Log.d(TAG, "onGetVolume: -->" + volume); 50 | } 51 | }); 52 | Button startButton = (Button) findViewById(R.id.StartButton); 53 | startButton.setOnClickListener(new View.OnClickListener() { 54 | @Override 55 | public void onClick(View v) { 56 | mRecorder.start(filePath); 57 | spectrum_view.start(); 58 | } 59 | }); 60 | Button stopButton = (Button) findViewById(R.id.StopButton); 61 | stopButton.setOnClickListener(new View.OnClickListener() { 62 | @Override 63 | public void onClick(View v) { 64 | mRecorder.stop(); 65 | spectrum_view.stop(); 66 | } 67 | }); 68 | Button btnPause = findViewById(R.id.btn_pause); 69 | btnPause.setOnClickListener(new View.OnClickListener() { 70 | @Override 71 | public void onClick(View v) { 72 | mRecorder.onPause(); 73 | } 74 | }); 75 | Button btnResume = findViewById(R.id.btn_resume); 76 | btnResume.setOnClickListener(new View.OnClickListener() { 77 | @Override 78 | public void onClick(View v) { 79 | mRecorder.onResume(); 80 | } 81 | }); 82 | 83 | spectrum_view = findViewById(R.id.spectrum_view); 84 | 85 | mic_view = findViewById(R.id.mic_view); 86 | mic_view.setRecorderViewListener(new RecorderView.RecorderViewListener() { 87 | @Override 88 | public void onStart() { 89 | mRecorder.start(filePath); 90 | } 91 | 92 | @Override 93 | public void onStop() { 94 | mRecorder.stop(); 95 | String strFinish = String.format("录制完成,保存在:%s",filePath); 96 | Toast.makeText(MainActivity.this, strFinish, Toast.LENGTH_SHORT).show(); 97 | } 98 | }); 99 | } 100 | 101 | private void requestPermission() { 102 | XXPermissions.with(this) 103 | // 申请单个权限 104 | .permission(Permission.RECORD_AUDIO) 105 | // 申请多个权限 106 | // 设置权限请求拦截器(局部设置) 107 | //.interceptor(new PermissionInterceptor()) 108 | // 设置不触发错误检测机制(局部设置) 109 | //.unchecked() 110 | .request(new OnPermissionCallback() { 111 | 112 | @Override 113 | public void onGranted(@NonNull List permissions, boolean allGranted) { 114 | if (!allGranted) { 115 | return; 116 | } 117 | } 118 | 119 | @Override 120 | public void onDenied(@NonNull List permissions, boolean doNotAskAgain) { 121 | if (doNotAskAgain) { 122 | // 如果是被永久拒绝就跳转到应用权限系统设置页面 123 | XXPermissions.startPermissionActivity(MainActivity.this, permissions); 124 | } else { 125 | } 126 | } 127 | }); 128 | } 129 | 130 | private void createFile() { 131 | File file = new File(filePath); 132 | if (!file.exists()){ 133 | try { 134 | file.createNewFile(); 135 | } catch (IOException e) { 136 | e.printStackTrace(); 137 | } 138 | } 139 | } 140 | 141 | @Override 142 | protected void onDestroy() { 143 | super.onDestroy(); 144 | mRecorder.stop(); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 |