├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── manna
│ │ └── capture
│ │ ├── MainActivity.java
│ │ ├── adapter
│ │ ├── AdapterDiffCallback.java
│ │ ├── BaseAdapter.java
│ │ └── ItemViewType.java
│ │ ├── capture
│ │ ├── AudioCaptureActivity.java
│ │ ├── AudioFileActivity.java
│ │ ├── AudioFileEntity.java
│ │ ├── AudioFileItemType.java
│ │ └── AudioPlayActivity.java
│ │ ├── utils
│ │ ├── AudioFileUtils.java
│ │ └── PermissionUtils.java
│ │ └── widget
│ │ └── CustomViewPager.java
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── ic_launcher_background.xml
│ └── shape_bg_start_audio.xml
│ ├── layout
│ ├── activity_audio_capture.xml
│ ├── activity_audio_file.xml
│ ├── activity_audio_play.xml
│ ├── activity_main.xml
│ └── item_audio_file.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_audio.png
│ ├── ic_detail_record.png
│ ├── ic_launcher.png
│ ├── ic_launcher_round.png
│ ├── ic_pause_record.png
│ ├── ic_play.png
│ ├── ic_play_audio.png
│ ├── ic_play_round.png
│ ├── ic_play_single.png
│ ├── ic_round.jpg
│ ├── ic_start_audio_record.png
│ ├── ic_start_record.png
│ └── ic_stop_record.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_round.png
│ ├── ic_play_disc.png
│ └── ic_play_needle.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library_audio
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ ├── CMakeLists.txt
│ ├── lame-lib.cpp
│ ├── lame-lib.h
│ └── libmp3lame
│ │ ├── Makefile.am
│ │ ├── Makefile.in
│ │ ├── VbrTag.c
│ │ ├── VbrTag.h
│ │ ├── bitstream.c
│ │ ├── bitstream.h
│ │ ├── depcomp
│ │ ├── encoder.c
│ │ ├── encoder.h
│ │ ├── fft.c
│ │ ├── fft.h
│ │ ├── gain_analysis.c
│ │ ├── gain_analysis.h
│ │ ├── i386
│ │ ├── Makefile.am
│ │ ├── Makefile.in
│ │ ├── choose_table.nas
│ │ ├── cpu_feat.nas
│ │ ├── fft.nas
│ │ ├── fft3dn.nas
│ │ ├── fftfpu.nas
│ │ ├── fftsse.nas
│ │ ├── ffttbl.nas
│ │ ├── nasm.h
│ │ └── scalar.nas
│ │ ├── id3tag.c
│ │ ├── id3tag.h
│ │ ├── l3side.h
│ │ ├── lame-analysis.h
│ │ ├── lame.c
│ │ ├── lame.h
│ │ ├── lame.rc
│ │ ├── lame_global_flags.h
│ │ ├── lame_util.c
│ │ ├── lameerror.h
│ │ ├── logoe.ico
│ │ ├── 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
│ │ ├── Makefile.am
│ │ ├── Makefile.in
│ │ ├── lame_intrin.h
│ │ └── xmm_quantize_sub.c
│ │ ├── version.c
│ │ └── version.h
│ ├── java
│ └── com
│ │ └── manna
│ │ └── audio
│ │ ├── AudioCapture.java
│ │ ├── AudioPlayInterface.java
│ │ ├── AudioPlayService.java
│ │ ├── AudioPlayer.java
│ │ ├── LameEncode.java
│ │ ├── utils
│ │ ├── ByteUtils.java
│ │ ├── Complex.java
│ │ ├── FFT.java
│ │ ├── FftFactory.java
│ │ ├── FileUtils.java
│ │ └── TimeUtils.java
│ │ └── widget
│ │ └── WaveView.java
│ ├── jniLibs
│ ├── arm64-v8a
│ │ └── liblame-lib.so
│ └── armeabi-v7a
│ │ └── liblame-lib.so
│ └── res
│ └── values
│ └── strings.xml
├── screenshot
├── ic_audio_file.png
├── ic_capture.png
├── ic_play_start.png
├── ic_playing.png
├── ic_start.png
└── xiaomiquan.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | xmlns:android
11 |
12 | ^$
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | xmlns:.*
22 |
23 | ^$
24 |
25 |
26 | BY_NAME
27 |
28 |
29 |
30 |
31 |
32 |
33 | .*:id
34 |
35 | http://schemas.android.com/apk/res/android
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | .*:name
45 |
46 | http://schemas.android.com/apk/res/android
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | name
56 |
57 | ^$
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | style
67 |
68 | ^$
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | .*
78 |
79 | ^$
80 |
81 |
82 | BY_NAME
83 |
84 |
85 |
86 |
87 |
88 |
89 | .*
90 |
91 | http://schemas.android.com/apk/res/android
92 |
93 |
94 | ANDROID_ATTRIBUTE_ORDER
95 |
96 |
97 |
98 |
99 |
100 |
101 | .*
102 |
103 | .*
104 |
105 |
106 | BY_NAME
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AudioCapturePlay
2 | 基于AudioRecord录制原始pcm音频,使用开源库lame实时转换pcm音频为MP3格式音频,采用Service、MediaPlayer播放MP3,提供录制音频计时器显示,音频音量分贝值显示,音频频谱显示,录制、播放状态控制等
3 | ## 功能简介
4 | 目前包含基本的音频录制、播放操作,功能如下:
5 | 1. 基于AudioRecord录制原始PCM格式音频数据
6 | 2. 基于lame库实时转换PCM音频为MP3格式音频
7 | 3. 基于原始lame项目中C文件编译生成对应so文件、提供调用lame编码封装类
8 | 4. 基于FFT格式化PCM数据并实时显示音频频谱
9 | 5. 提供录制音频计时器显示、音量分贝值显示、录制开始、暂停、继续等状态控制与文件写入
10 | 6. 提供AudioPlayManager对象控制MediaPlayer播放、暂停、继续状态、Timer定时更新SeekBar进度条
11 | 7. 提供ObjectAnimator方式实现唱针、唱片旋转、复原动画操作
12 |
13 | 其它音频格式:
14 | 1. wav、m4a、aac可在录制PCM格式实时回调中添加相应头文件、转换操作
15 | ## lame编解码
16 | 1. lame_encode_buffer_interleaved 该方法为传入双声道音频buffer,如果AudioCapture中使用AudioFormat.CHANNEL_IN_STEREO
17 | 2. lame_encode_buffer 该方法为传入单声道音频buffer,如果AudioCapture中使用AudioFormat.CHANNEL_IN_MONO
18 | ## Chronometer、RoundedBitmapDrawable控件类
19 | 1. Chronometer为原生计时器,提供计时、倒计时等功能,初始格式为00:00,通过setFormat格式化为00:00:00,暂停、继续计时需减掉已计时时间戳
20 | 2. RoundedBitmapDrawable可作为圆角Bitmap使用,通过setCornerRadius、setCircular可实现圆角设置、圆型
21 | ## 公共库
22 | 1. 包含录音控制类、lame编解码cpp文件、编译so文件、Service播放控制类,使用方式参见app中AudioCaptureActivity.class
23 | ## 截图展示
24 | 录制开始、暂停、完成 :
25 |
26 | 
27 |
28 | 音频文件 :
29 |
30 | 
31 |
32 | 播放准备 :
33 |
34 | 
35 |
36 | 播放中 :
37 |
38 | 
39 |
40 | ## 感谢开源
41 | 1. 音频频谱柱状图 https://github.com/zhaolewei/MusicVisualizer
42 | 2. lame编解码库 https://sourceforge.net/projects/lame/files/lame
43 |
44 | ## 我的个人新球
45 |
46 | 免费加入星球一起讨论项目、研究新技术,共同成长!
47 |
48 | 
49 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.manna.capture"
7 | minSdkVersion 18
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 |
20 | compileOptions {
21 | sourceCompatibility = '1.8'
22 | targetCompatibility = '1.8'
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | implementation 'com.android.support:appcompat-v7:28.0.0'
29 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
30 |
31 | implementation project(path: ':library_audio')
32 | implementation 'com.android.support:recyclerview-v7:28.0.0'
33 | }
34 |
--------------------------------------------------------------------------------
/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/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
30 |
33 |
34 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture;
2 |
3 | import android.content.Intent;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | import com.manna.capture.R;
11 | import com.manna.capture.capture.AudioCaptureActivity;
12 | import com.manna.capture.utils.PermissionUtils;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 |
16 | private final String TAG = MainActivity.class.getSimpleName();
17 | private TextView tvAudioRecord, tvVideoRecord;
18 | //录视频项目地址
19 | private static final String MSG = "开源项目地址为 : https://github.com/MannaYang/AudioVideoCodec";
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 |
26 | initView();
27 | }
28 |
29 | public void initView() {
30 | tvAudioRecord = findViewById(R.id.tv_audio_record);
31 | tvVideoRecord = findViewById(R.id.tv_video_record);
32 |
33 | tvAudioRecord.setOnClickListener(v -> {
34 |
35 | if (PermissionUtils.hasAudioPermission(this)) {
36 | openAudioCapture();
37 | } else {
38 | //获取缓存目录
39 | PermissionUtils.requestAudioPermission(this, false);
40 | }
41 | });
42 |
43 | tvVideoRecord.setOnClickListener(v -> {
44 | //录视频参看我另外的开源项目,地址为:https://github.com/MannaYang/AudioVideoCodec
45 | Toast.makeText(this, MSG, Toast.LENGTH_LONG).show();
46 | });
47 | }
48 |
49 | @Override
50 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
51 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
52 | if (!PermissionUtils.hasAudioPermission(this)) {
53 | Toast.makeText(this,
54 | "应用缺少录音权限", Toast.LENGTH_LONG).show();
55 | PermissionUtils.launchPermissionSettings(this);
56 | } else {
57 | openAudioCapture();
58 | }
59 | }
60 |
61 | private void openAudioCapture() {
62 | startActivity(new Intent(this, AudioCaptureActivity.class));
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/adapter/AdapterDiffCallback.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture.adapter;
2 |
3 | import android.support.v7.util.DiffUtil;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * adapter数据差异对比
9 | */
10 | public class AdapterDiffCallback extends DiffUtil.Callback {
11 |
12 | private List oldList, newList;
13 |
14 | AdapterDiffCallback(List oldList, List newList) {
15 | this.oldList = oldList;
16 | this.newList = newList;
17 | }
18 |
19 | @Override
20 | public int getOldListSize() {
21 | return oldList.size();
22 | }
23 |
24 | @Override
25 | public int getNewListSize() {
26 | return newList.size();
27 | }
28 |
29 | @Override
30 | public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
31 | return oldList.get(oldItemPosition).getClass().equals(newList.get(newItemPosition).getClass());
32 | }
33 |
34 | @Override
35 | public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
36 | ItemViewType oldBean = oldList.get(oldItemPosition);
37 | ItemViewType newBean = newList.get(newItemPosition);
38 | return oldBean.equals(newBean);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/adapter/BaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.util.DiffUtil;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * 基础RecyclerView adapter
15 | */
16 | public class BaseAdapter extends RecyclerView.Adapter {
17 |
18 | private Context context;
19 | private List itemViewTypeList;
20 |
21 | public BaseAdapter(Context context, List viewTypeList) {
22 | this.context = context;
23 | itemViewTypeList = new ArrayList<>();
24 | if (viewTypeList.size() > 0) {
25 | itemViewTypeList.addAll(viewTypeList);
26 | }
27 | }
28 |
29 | @Override
30 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
31 | View itemView = LayoutInflater.from(context).inflate(viewType, parent, false);
32 | ItemViewType itemViewType = getItemViewTypeByViewType(viewType);
33 | return itemViewType != null ? itemViewType.getViewHolder(itemView) : null;
34 | }
35 |
36 | @Override
37 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
38 | ItemViewType itemViewType = getItemViewTypeByPosition(position);
39 | int index = getItemViewTypeIndexByPosition(position);
40 | if (itemViewType != null) {
41 | itemViewType.bindViewHolder(holder, index);
42 | }
43 | }
44 |
45 | @Override
46 | public int getItemCount() {
47 | int count = 0;
48 | for (ItemViewType viewType : itemViewTypeList) {
49 | count = count + viewType.getItemCount();
50 | }
51 | return count;
52 | }
53 |
54 | @Override
55 | public int getItemViewType(int position) {
56 | ItemViewType itemViewType = getItemViewTypeByPosition(position);
57 | return itemViewType != null ? itemViewType.getLayoutId() : 0;
58 | }
59 |
60 | private ItemViewType getItemViewTypeByPosition(int position) {
61 | int count = 0;
62 | for (ItemViewType itemViewType : itemViewTypeList) {
63 | count = count + itemViewType.getItemCount();
64 | if (position < count) {
65 | return itemViewType;
66 | }
67 | }
68 | return null;
69 | }
70 |
71 | private ItemViewType getItemViewTypeByViewType(int viewType) {
72 | for (ItemViewType itemViewType : itemViewTypeList) {
73 | if (itemViewType.getLayoutId() == viewType) {
74 | return itemViewType;
75 | }
76 | }
77 | return null;
78 | }
79 |
80 | /**
81 | * 返回itemViewTypeList所在index
82 | *
83 | * @param position:当前position
84 | * @return :int
85 | */
86 | private int getItemViewTypeIndexByPosition(int position) {
87 | int count = 0;
88 | for (ItemViewType itemType : itemViewTypeList) {
89 | count = count + itemType.getItemCount();
90 | if (position < count) {
91 | int preItemCount = (count - itemType.getItemCount());
92 | return position - preItemCount;
93 | }
94 | }
95 | return -1;
96 | }
97 |
98 | public void setRefreshData(List data) {
99 | if (itemViewTypeList.size() == 0) {
100 | itemViewTypeList.addAll(data);
101 | notifyItemInserted(0);
102 | } else {
103 | DiffUtil.DiffResult result =
104 | DiffUtil.calculateDiff(new AdapterDiffCallback(itemViewTypeList, data), false);
105 | result.dispatchUpdatesTo(this);
106 | itemViewTypeList.clear();
107 | itemViewTypeList.addAll(data);
108 | }
109 | }
110 |
111 | public void setLoadMoreData(List data) {
112 | itemViewTypeList.addAll(data);
113 | notifyItemInserted(itemViewTypeList.size() - 1);
114 | }
115 |
116 | public void setEmptyData() {
117 | this.itemViewTypeList.clear();
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/adapter/ItemViewType.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.View;
5 |
6 | /**
7 | * 每种类型的约束
8 | */
9 | public interface ItemViewType {
10 |
11 | /**
12 | * item个数
13 | *
14 | * @return :count
15 | */
16 | int getItemCount();
17 |
18 | /**
19 | * 布局id
20 | *
21 | * @return :resId
22 | */
23 | int getLayoutId();
24 |
25 | /**
26 | * 继承RecyclerView.ViewHolder
27 | *
28 | * @param viewHolder :每种类型的具体实现
29 | * @return :RecyclerView.ViewHolder
30 | */
31 | RecyclerView.ViewHolder getViewHolder(View viewHolder);
32 |
33 | /**
34 | * 返回创建完成的view holder
35 | *
36 | * @param viewHolder :每种类型
37 | * @param index :每种类型在类型数组中的下标,方便点击事件处理等
38 | */
39 | void bindViewHolder(RecyclerView.ViewHolder viewHolder, int index);
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/capture/AudioFileActivity.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture.capture;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 |
10 | import com.manna.capture.R;
11 | import com.manna.capture.adapter.BaseAdapter;
12 | import com.manna.capture.adapter.ItemViewType;
13 | import com.manna.capture.utils.AudioFileUtils;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | /**
19 | * 录音文件列表、解码播放
20 | */
21 | public class AudioFileActivity extends AppCompatActivity {
22 |
23 | private String dirFilePath;
24 | private RecyclerView rvAudioFile;
25 | private BaseAdapter baseAdapter;
26 | private AudioFileItemType itemType;
27 | private List typeList;
28 | private List list;
29 |
30 | @Override
31 | protected void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_audio_file);
34 |
35 | initView();
36 | initData();
37 | }
38 |
39 | private void initView() {
40 | rvAudioFile = findViewById(R.id.rv_audio_file);
41 | dirFilePath = getIntent().getStringExtra("dirFilePath");
42 | }
43 |
44 | //初始化音频列表
45 | private void initData() {
46 | list = AudioFileUtils.getAllFiles(this,dirFilePath, "mp3");
47 | itemType = new AudioFileItemType(list, (AudioFileItemType.AudioPlayListener) this::playMusic);
48 |
49 | typeList = new ArrayList<>();
50 | typeList.add(itemType);
51 | baseAdapter = new BaseAdapter(this, typeList);
52 |
53 | rvAudioFile.setLayoutManager(new LinearLayoutManager(this));
54 | rvAudioFile.setAdapter(baseAdapter);
55 | }
56 |
57 | /**
58 | * 播放音乐
59 | * @param filePath 文件路径
60 | * @param fileName 文件名称
61 | */
62 | private void playMusic(String filePath, String fileName) {
63 | startActivity(new Intent(this, AudioPlayActivity.class)
64 | .putExtra("filePath", filePath).putExtra("fileName", fileName));
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/capture/AudioFileEntity.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture.capture;
2 |
3 | /**
4 | * 录音文件信息
5 | */
6 | public class AudioFileEntity {
7 | //文件名称
8 | private String fileName;
9 | //创建时间
10 | private String createTime;
11 | //录音时长
12 | private String audioTime;
13 | //文件路径
14 | private String filePath;
15 |
16 | public String getFileName() {
17 | return fileName;
18 | }
19 |
20 | public void setFileName(String fileName) {
21 | this.fileName = fileName;
22 | }
23 |
24 | public String getCreateTime() {
25 | return createTime;
26 | }
27 |
28 | public void setCreateTime(String createTime) {
29 | this.createTime = createTime;
30 | }
31 |
32 | public String getAudioTime() {
33 | return audioTime;
34 | }
35 |
36 | public void setAudioTime(String audioTime) {
37 | this.audioTime = audioTime;
38 | }
39 |
40 | public String getFilePath() {
41 | return filePath;
42 | }
43 |
44 | public void setFilePath(String filePath) {
45 | this.filePath = filePath;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/capture/AudioFileItemType.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture.capture;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 | import android.widget.ImageView;
7 | import android.widget.TextView;
8 |
9 | import com.manna.capture.R;
10 | import com.manna.capture.adapter.ItemViewType;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * RecyclerView - holder
16 | */
17 | public class AudioFileItemType implements ItemViewType {
18 |
19 | private List list;
20 | private AudioPlayListener listener;
21 |
22 | public AudioFileItemType(List list, AudioPlayListener listener) {
23 | this.list = list;
24 | this.listener = listener;
25 | }
26 |
27 | @Override
28 | public int getItemCount() {
29 | return list.size();
30 | }
31 |
32 | @Override
33 | public int getLayoutId() {
34 | return R.layout.item_audio_file;
35 | }
36 |
37 | @Override
38 | public RecyclerView.ViewHolder getViewHolder(View viewHolder) {
39 | return new ItemViewHolder(viewHolder);
40 | }
41 |
42 | @Override
43 | public void bindViewHolder(RecyclerView.ViewHolder viewHolder, int index) {
44 | ItemViewHolder holder = (ItemViewHolder) viewHolder;
45 | AudioFileEntity entity = list.get(index);
46 | holder.fileName.setText(entity.getFileName());
47 | holder.createTime.setText(entity.getCreateTime());
48 | holder.audioTime.setText(entity.getAudioTime());
49 | holder.ivPlay.setOnClickListener(v -> listener.audioPlay(entity.getFilePath(),entity.getFileName()));
50 | }
51 |
52 | public class ItemViewHolder extends RecyclerView.ViewHolder {
53 |
54 | private TextView fileName, createTime, audioTime;
55 | private ImageView ivPlay;
56 |
57 | public ItemViewHolder(@NonNull View itemView) {
58 | super(itemView);
59 | fileName = itemView.findViewById(R.id.tv_file_name);
60 | createTime = itemView.findViewById(R.id.tv_create_time);
61 | audioTime = itemView.findViewById(R.id.tv_audio_time);
62 | ivPlay = itemView.findViewById(R.id.iv_play);
63 | }
64 | }
65 |
66 | //播放录音
67 | public interface AudioPlayListener {
68 | void audioPlay(String filePath, String fileName);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/utils/AudioFileUtils.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture.utils;
2 |
3 | import android.content.Context;
4 | import android.text.format.Formatter;
5 |
6 | import com.manna.capture.capture.AudioFileEntity;
7 |
8 | import java.io.File;
9 | import java.text.SimpleDateFormat;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | import java.util.Locale;
13 |
14 | public class AudioFileUtils {
15 | /**
16 | * 获取指定目录内所有文件路径
17 | *
18 | * @param dirPath 文件目录
19 | * @param fileType 文件后缀类型
20 | */
21 | public static List getAllFiles(Context context, String dirPath, String fileType) {
22 | File f = new File(dirPath);
23 | if (!f.exists()) {//判断路径是否存在
24 | return null;
25 | }
26 | List list = new ArrayList<>();
27 | File[] files = f.listFiles();
28 |
29 | if (files == null) {//判断权限
30 | return null;
31 | }
32 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd", Locale.CHINA);
33 | for (File file : files) {//遍历目录
34 | if (file.isFile() && file.getName().endsWith(fileType)) {
35 | AudioFileEntity entity = new AudioFileEntity();
36 | int end = file.getName().lastIndexOf('.');
37 | //获取文件名
38 | String fileName = file.getName().substring(0, end);
39 | //获取文件路径
40 | String filePath = file.getAbsolutePath();
41 | //创建时间
42 | String createTime = dateFormat.format(file.lastModified());
43 | //文件大小
44 | String fileSize = formatSize(context, file.length());
45 |
46 | entity.setFileName(fileName);
47 | entity.setFilePath(filePath);
48 | entity.setCreateTime(createTime);
49 | entity.setAudioTime(fileSize);
50 | list.add(entity);
51 | } else if (file.isDirectory()) {//查询子目录
52 | getAllFiles(context, file.getAbsolutePath(), fileType);
53 | } else {
54 | }
55 | }
56 | return list;
57 | }
58 |
59 | /**
60 | * 格式化数据
61 | *
62 | * @param context :context
63 | * @param fileSize :byte
64 | * @return String
65 | */
66 | public static String formatSize(Context context, long fileSize) {
67 | return Formatter.formatFileSize(context, fileSize);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/utils/PermissionUtils.java:
--------------------------------------------------------------------------------
1 |
2 | package com.manna.capture.utils;
3 |
4 | import android.Manifest;
5 | import android.app.Activity;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager;
8 | import android.net.Uri;
9 | import android.provider.Settings;
10 | import android.support.v4.app.ActivityCompat;
11 | import android.support.v4.content.ContextCompat;
12 | import android.widget.Toast;
13 |
14 | /**
15 | * 权限申请
16 | */
17 | public class PermissionUtils {
18 | private static final int REQUEST_CODE = 1000;
19 |
20 | public static boolean hasAudioPermission(Activity activity) {
21 | return ContextCompat.checkSelfPermission(activity,
22 | Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
23 | }
24 |
25 | public static boolean hasWriteStoragePermission(Activity activity) {
26 | return ContextCompat.checkSelfPermission(activity,
27 | Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
28 | }
29 |
30 | public static void requestAudioPermission(Activity activity, boolean requestWritePermission) {
31 |
32 | boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(activity,
33 | Manifest.permission.RECORD_AUDIO) || (requestWritePermission &&
34 | ActivityCompat.shouldShowRequestPermissionRationale(activity,
35 | Manifest.permission.WRITE_EXTERNAL_STORAGE));
36 | if (showRationale) {
37 | Toast.makeText(activity, "应用缺少录音权限", Toast.LENGTH_LONG).show();
38 | } else {
39 |
40 | String permissions[] = requestWritePermission ? new String[]{Manifest.permission.RECORD_AUDIO,
41 | Manifest.permission.WRITE_EXTERNAL_STORAGE} : new String[]{Manifest.permission.RECORD_AUDIO};
42 | ActivityCompat.requestPermissions(activity, permissions, REQUEST_CODE);
43 | }
44 | }
45 |
46 | public static void requestWriteStoragePermission(Activity activity) {
47 | boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(activity,
48 | Manifest.permission.WRITE_EXTERNAL_STORAGE);
49 | if (showRationale) {
50 | Toast.makeText(activity, "应用缺少读写文件权限", Toast.LENGTH_LONG).show();
51 | } else {
52 | String permissions[] = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
53 | ActivityCompat.requestPermissions(activity, permissions, REQUEST_CODE);
54 | }
55 | }
56 |
57 | /**
58 | * 设置权限
59 | */
60 | public static void launchPermissionSettings(Activity activity) {
61 | Intent intent = new Intent();
62 | intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
63 | intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
64 | activity.startActivity(intent);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/manna/capture/widget/CustomViewPager.java:
--------------------------------------------------------------------------------
1 | package com.manna.capture.widget;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | /**
9 | * 去除ViewPager切换动画
10 | * */
11 | public class CustomViewPager extends ViewPager {
12 |
13 | private boolean isCanScroll = true;
14 |
15 | public CustomViewPager(Context context) {
16 | super(context);
17 | }
18 |
19 | public CustomViewPager(Context context, AttributeSet attrs) {
20 | super(context, attrs);
21 | }
22 |
23 | @Override
24 | public void setCurrentItem(int item) { // false 去掉切换动画
25 | super.setCurrentItem(item, false);
26 | }
27 |
28 | @Override
29 | public void setCurrentItem(int item, boolean smoothScroll) {
30 | super.setCurrentItem(item, smoothScroll);
31 | }
32 |
33 | public void setCanScroll(boolean isCanScroll) {
34 | this.isCanScroll = isCanScroll;
35 | }
36 |
37 | @Override
38 | public boolean onInterceptTouchEvent(MotionEvent ev) {
39 | return isCanScroll && super.onInterceptTouchEvent(ev);
40 | }
41 |
42 | @Override
43 | public boolean onTouchEvent(MotionEvent ev) {
44 | return isCanScroll && super.onTouchEvent(ev);
45 | }
46 | }
--------------------------------------------------------------------------------
/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/drawable/shape_bg_start_audio.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_audio_capture.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
30 |
31 |
39 |
40 |
51 |
52 |
63 |
64 |
75 |
76 |
87 |
88 |
100 |
101 |
113 |
114 |
126 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_audio_file.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
28 |
29 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_audio_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
31 |
32 |
42 |
43 |
55 |
56 |
69 |
70 |
80 |
81 |
93 |
94 |
104 |
105 |
116 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
31 |
32 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_audio_file.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
18 |
19 |
30 |
31 |
43 |
44 |
54 |
55 |
66 |
67 |
72 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_audio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_audio.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_detail_record.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_detail_record.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_pause_record.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_pause_record.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_play.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_play_audio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_play_audio.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_play_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_play_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_play_single.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_play_single.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_round.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_round.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_start_audio_record.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_start_audio_record.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_start_record.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_start_record.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_stop_record.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xhdpi/ic_stop_record.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_play_disc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xxhdpi/ic_play_disc.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_play_needle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xxhdpi/ic_play_needle.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #2c2c2c
4 | #2c2c2c
5 | #2c2c2c
6 | #f2f2f2
7 | #FFFFFF
8 | #FF3A2B20
9 | #FF877B71
10 | #EDEDED
11 | #877B71
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AudioCapturePlay
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.0'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 |
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Aug 21 14:19:24 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/library_audio/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library_audio/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 |
7 | defaultConfig {
8 | minSdkVersion 18
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | externalNativeBuild {
15 | cmake {
16 | cppFlags "-frtti -fexceptions"
17 | cFlags "-DSTDC_HEADERS"
18 | abiFilters /*"armeabi",*/ "armeabi-v7a","arm64-v8a"
19 | }
20 | }
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 |
30 | externalNativeBuild {
31 | cmake {
32 | path "src/main/cpp/CMakeLists.txt"
33 | version "3.10.2"
34 | }
35 | }
36 |
37 | sourceSets {
38 | main {
39 | jniLibs.srcDirs = ['libs']
40 | }
41 | }
42 |
43 | packagingOptions {
44 | pickFirst 'lib/armeabi-v7a/liblame-lib.so'
45 | pickFirst 'lib/arm64-v8a/liblame-lib.so'
46 | pickFirst 'lib/x86/liblame-lib.so'
47 | pickFirst 'lib/x86_64/liblame-lib.so'
48 | }
49 | }
50 |
51 | dependencies {
52 | implementation fileTree(dir: 'libs', include: ['*.jar'])
53 |
54 | implementation 'com.android.support:appcompat-v7:28.0.0'
55 | testImplementation 'junit:junit:4.12'
56 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
57 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
58 | }
59 |
--------------------------------------------------------------------------------
/library_audio/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 |
--------------------------------------------------------------------------------
/library_audio/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/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.2)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | #指定生成路径
14 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI})
15 |
16 | # 编译出一个动态库 native-lib,源文件只有 src/main/cpp/native-lib.cpp
17 | add_library( # Sets the name of the library.
18 | lame-lib
19 | #so文件名称
20 | # Sets the library as a shared library.
21 | SHARED
22 |
23 | # Provides a relative path to your source file(s).
24 | lame-lib.cpp
25 | libmp3lame/bitstream.c
26 | libmp3lame/encoder.c
27 | libmp3lame/fft.c
28 | libmp3lame/gain_analysis.c
29 | libmp3lame/id3tag.c
30 | libmp3lame/lame.c
31 | libmp3lame/mpglib_interface.c
32 | libmp3lame/newmdct.c
33 | libmp3lame/presets.c
34 | libmp3lame/psymodel.c
35 | libmp3lame/quantize.c
36 | libmp3lame/quantize_pvt.c
37 | libmp3lame/reservoir.c
38 | libmp3lame/set_get.c
39 | libmp3lame/tables.c
40 | libmp3lame/takehiro.c
41 | libmp3lame/util.c
42 | libmp3lame/vbrquantize.c
43 | libmp3lame/VbrTag.c
44 | libmp3lame/version.c)
45 |
46 | # Searches for a specified prebuilt library and stores the path as a
47 | # variable. Because CMake includes system libraries in the search path by
48 | # default, you only need to specify the name of the public NDK library
49 | # you want to add. CMake verifies that the library exists before
50 | # completing its build.
51 |
52 | # 找到预编译库 log_lib 并link到我们的动态库 native-lib中
53 | find_library( # Sets the name of the path variable.
54 | log-lib
55 | android
56 | # Specifies the name of the NDK library that
57 | # you want CMake to locate.
58 | log)
59 |
60 | # Specifies libraries CMake should link to your target library. You
61 | # can link multiple libraries, such as libraries you define in this
62 | # build script, prebuilt third-party libraries, or system libraries.
63 |
64 | target_link_libraries(
65 | lame-lib
66 | )
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/lame-lib.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "libmp3lame/lame.h"
9 |
10 | //lame 对象
11 | static lame_global_flags *gfp = NULL;
12 |
13 | //jstring转string -- defined in lame_util.c 69 lines
14 | char *Jstring2CStr(JNIEnv *env, jstring jstr) {
15 | char *rtn = NULL;
16 | jclass clsstring = env->FindClass("java/lang/String"); //String
17 | jstring strencode = env->NewStringUTF("GB2312"); // 得到一个java字符串 "GB2312"
18 | jmethodID mid = env->GetMethodID(clsstring, "getBytes",
19 | "(Ljava/lang/String;)[B"); //[ String.getBytes("gb2312");
20 | jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid,
21 | strencode); // String .getByte("GB2312");
22 | jsize alen = env->GetArrayLength(barr); // byte数组的长度
23 | jbyte *ba = env->GetByteArrayElements(barr, JNI_FALSE);
24 | if (alen > 0) {
25 | rtn = (char *) malloc(alen + 1); //"\0"
26 | memcpy(rtn, ba, alen);
27 | rtn[alen] = 0;
28 | }
29 | env->ReleaseByteArrayElements(barr, ba, 0); //
30 | return rtn;
31 | }
32 |
33 | //初始化lame参数
34 | extern "C" JNIEXPORT void JNICALL
35 | Java_com_manna_audio_LameEncode_init(JNIEnv *env, jclass jclass1, jint sampleRate,
36 | jint channelCount,
37 | jint audioFormatBit, jint quality) {
38 | //初始化lame -- 采用默认输入音频参数配置,转换为MP3后,bitrate比特率为128kbps
39 | gfp = lame_init();
40 | //采样率
41 | // lame_set_in_samplerate(gfp, sampleRate);
42 | //声道数
43 | // lame_set_num_channels(gfp, channelCount);
44 | //输入采样率
45 | // lame_set_out_samplerate(gfp, sampleRate);
46 | //位宽
47 | // lame_set_brate(gfp, audioFormatBit);
48 | //音频质量
49 | // lame_set_quality(gfp, quality);
50 | //初始化参数配置
51 | lame_init_params(gfp);
52 | }
53 |
54 | //开启MP3编码
55 | extern "C" JNIEXPORT jint JNICALL
56 | Java_com_manna_audio_LameEncode_encoder(JNIEnv *env, jclass jclass1, jshortArray pcm_buffer,
57 | jbyteArray mp3_buffer, jint sample_num) {
58 | //lame转换需要short指针参数
59 | jshort *pcm_buf = env->GetShortArrayElements(pcm_buffer, JNI_FALSE);
60 | //获取MP3数组长度
61 | const jsize mp3_buff_len = env->GetArrayLength(mp3_buffer);
62 | //获取buffer指针
63 | jbyte *mp3_buf = env->GetByteArrayElements(mp3_buffer, JNI_FALSE);
64 | //编译后得bytes
65 | int encode_result;
66 | //根据输入音频声道数判断
67 | if (lame_get_num_channels(gfp) == 2) {
68 | encode_result = lame_encode_buffer_interleaved(gfp, pcm_buf, sample_num / 2, mp3_buf,
69 | mp3_buff_len);
70 | } else {
71 | encode_result = lame_encode_buffer(gfp, pcm_buf, pcm_buf, sample_num, mp3_buf,
72 | mp3_buff_len);
73 | }
74 | //释放资源
75 | env->ReleaseShortArrayElements(pcm_buffer, pcm_buf, 0);
76 | env->ReleaseByteArrayElements(mp3_buffer, mp3_buf, 0);
77 | return encode_result;
78 | }
79 |
80 | //关闭MP3编码buffer
81 | extern "C" JNIEXPORT jint JNICALL
82 | Java_com_manna_audio_LameEncode_flush(JNIEnv *env, jclass jclass1, jbyteArray mp3_buffer) {
83 | //获取MP3数组长度
84 | const jsize mp3_buff_len = env->GetArrayLength(mp3_buffer);
85 | //获取buffer指针
86 | jbyte *mp3_buf = env->GetByteArrayElements(mp3_buffer, JNI_FALSE);
87 | //刷新编码器缓冲,获取残留在编码器缓冲里的数据
88 | int flush_result = lame_encode_flush(gfp, mp3_buf, mp3_buff_len);
89 | env->ReleaseByteArrayElements(mp3_buffer, mp3_buf, 0);
90 | return flush_result;
91 | }
92 |
93 | //释放编码器
94 | JNIEXPORT void JNICALL
95 | Java_com_manna_audio_LameEncode_close(JNIEnv *env, jclass type) {
96 | lame_close(gfp);
97 | }
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/lame-lib.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by 15971 on 2019/7/18.
3 | //
4 |
5 |
6 | #ifndef AUDIO_LAME_LIB_H
7 | #define AUDIO_LAME_LIB_H
8 |
9 | #include "../../../../../../AndroidSDK/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/jni.h"
10 |
11 | #endif //AUDIO_LAME_LIB_H
12 | extern "C" void wavConvertToMP3(JNIEnv *env, jobject clazz, jstring wavFilePath,
13 | jstring mp3FilePath, jint sampleRate,
14 | jint channels, jint outBitrate);
15 |
16 | extern "C" void
17 | pcmToMP3(JNIEnv *env, jobject clazz, jstring mp3FilePath, jint sampleRate, jint channelCount,
18 | jshortArray pcmArray,jint readByte);
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/Makefile.am:
--------------------------------------------------------------------------------
1 | ## $Id: Makefile.am,v 1.41 2016/01/29 21:06:26 aleidinger Exp $
2 |
3 | include $(top_srcdir)/Makefile.am.global
4 |
5 | SUBDIRS = i386 vector
6 |
7 | lib_LTLIBRARIES = libmp3lame.la
8 |
9 | if HAVE_NASM
10 | cpu_ldadd = $(top_builddir)/libmp3lame/@CPUTYPE@/liblameasmroutines.la
11 | endif
12 | if WITH_VECTOR
13 | vector_ldadd = $(top_builddir)/libmp3lame/vector/liblamevectorroutines.la
14 | endif
15 |
16 | if LIB_WITH_DECODER
17 | decoder_ldadd = $(top_builddir)/mpglib/libmpgdecoder.la
18 | else
19 | decoder_ldadd =
20 | endif
21 |
22 | libmp3lame_la_LIBADD = $(cpu_ldadd) $(vector_ldadd) $(decoder_ldadd) \
23 | $(CONFIG_MATH_LIB)
24 | libmp3lame_la_LDFLAGS = -version-info @LIB_MAJOR_VERSION@:@LIB_MINOR_VERSION@ \
25 | -export-symbols $(top_srcdir)/include/libmp3lame.sym \
26 | -no-undefined
27 |
28 | INCLUDES = @INCLUDES@ -I$(top_srcdir)/mpglib -I$(top_builddir)
29 |
30 | DEFS = @DEFS@ @CONFIG_DEFS@
31 |
32 | EXTRA_DIST = \
33 | lame.rc \
34 | vbrquantize.h \
35 | logoe.ico
36 |
37 | libmp3lame_la_SOURCES = \
38 | VbrTag.c \
39 | bitstream.c \
40 | encoder.c \
41 | fft.c \
42 | gain_analysis.c \
43 | id3tag.c \
44 | lame.c \
45 | newmdct.c \
46 | presets.c \
47 | psymodel.c \
48 | quantize.c \
49 | quantize_pvt.c \
50 | reservoir.c \
51 | set_get.c \
52 | tables.c \
53 | takehiro.c \
54 | util.c \
55 | vbrquantize.c \
56 | version.c \
57 | mpglib_interface.c
58 |
59 | noinst_HEADERS= \
60 | VbrTag.h \
61 | bitstream.h \
62 | encoder.h \
63 | fft.h \
64 | gain_analysis.h \
65 | id3tag.h \
66 | l3side.h \
67 | lame-analysis.h \
68 | lame_global_flags.h \
69 | lameerror.h \
70 | machine.h \
71 | newmdct.h \
72 | psymodel.h \
73 | quantize.h \
74 | quantize_pvt.h \
75 | reservoir.h \
76 | set_get.h \
77 | tables.h \
78 | util.h \
79 | vbrquantize.h \
80 | version.h
81 |
82 | CLEANFILES = lclint.txt
83 |
84 | LCLINTFLAGS= \
85 | +posixlib \
86 | +showsummary \
87 | +showalluses \
88 | +whichlib \
89 | +forcehints \
90 | -fixedformalarray \
91 | +matchanyintegral \
92 | -Dlint
93 |
94 | lclint.txt: ${libmp3lame_la_SOURCES} ${noinst_HEADERS}
95 | @lclint ${LCLINTFLAGS} ${INCLUDES} ${DEFS} ${libmp3lame_la_SOURCES} 2>&1 >lclint.txt || true
96 |
97 | lclint: lclint.txt
98 | more lclint.txt
99 |
100 | #$(OBJECTS): libtool
101 | #libtool: $(LIBTOOL_DEPS)
102 | # $(SHELL) $(top_builddir)/config.status --recheck
103 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/VbrTag.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Xing VBR tagging for LAME.
3 | *
4 | * Copyright (c) 1999 A.L. Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VRBTAG_H
23 | #define LAME_VRBTAG_H
24 |
25 |
26 | /* -----------------------------------------------------------
27 | * A Vbr header may be present in the ancillary
28 | * data field of the first frame of an mp3 bitstream
29 | * The Vbr header (optionally) contains
30 | * frames total number of audio frames in the bitstream
31 | * bytes total number of bytes in the bitstream
32 | * toc table of contents
33 |
34 | * toc (table of contents) gives seek points
35 | * for random access
36 | * the ith entry determines the seek point for
37 | * i-percent duration
38 | * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes
39 | * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes
40 | */
41 |
42 |
43 | #define FRAMES_FLAG 0x0001
44 | #define BYTES_FLAG 0x0002
45 | #define TOC_FLAG 0x0004
46 | #define VBR_SCALE_FLAG 0x0008
47 |
48 | #define NUMTOCENTRIES 100
49 |
50 | #ifndef lame_internal_flags_defined
51 | #define lame_internal_flags_defined
52 | struct lame_internal_flags;
53 | typedef struct lame_internal_flags lame_internal_flags;
54 | #endif
55 |
56 |
57 | /*structure to receive extracted header */
58 | /* toc may be NULL*/
59 | typedef struct {
60 | int h_id; /* from MPEG header, 0=MPEG2, 1=MPEG1 */
61 | int samprate; /* determined from MPEG header */
62 | int flags; /* from Vbr header data */
63 | int frames; /* total bit stream frames from Vbr header data */
64 | int bytes; /* total bit stream bytes from Vbr header data */
65 | int vbr_scale; /* encoded vbr scale from Vbr header data */
66 | unsigned char toc[NUMTOCENTRIES]; /* may be NULL if toc not desired */
67 | int headersize; /* size of VBR header, in bytes */
68 | int enc_delay; /* encoder delay */
69 | int enc_padding; /* encoder paddign added at end of stream */
70 | } VBRTAGDATA;
71 |
72 | int GetVbrTag(VBRTAGDATA * pTagData, const unsigned char *buf);
73 |
74 | int InitVbrTag(lame_global_flags * gfp);
75 | int PutVbrTag(lame_global_flags const *gfp, FILE * fid);
76 | void AddVbrFrame(lame_internal_flags * gfc);
77 | void UpdateMusicCRC(uint16_t * crc, const unsigned char *buffer, int size);
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/bitstream.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 bitstream Output interface for LAME
3 | *
4 | * Copyright (c) 1999 Takehiro TOMINAGA
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_BITSTREAM_H
23 | #define LAME_BITSTREAM_H
24 |
25 | int getframebits(const lame_internal_flags * gfc);
26 |
27 | int format_bitstream(lame_internal_flags * gfc);
28 |
29 | void flush_bitstream(lame_internal_flags * gfc);
30 | void add_dummy_byte(lame_internal_flags * gfc, unsigned char val, unsigned int n);
31 |
32 | int copy_buffer(lame_internal_flags * gfc, unsigned char *buffer, int buffer_size,
33 | int update_crc);
34 | void init_bit_stream_w(lame_internal_flags * gfc);
35 | void CRC_writeheader(lame_internal_flags const *gfc, char *buffer);
36 | int compute_flushbits(const lame_internal_flags * gfp, int *nbytes);
37 |
38 | int get_max_frame_buffer_size_by_constraint(SessionConfig_t const * cfg, int constraint);
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/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
141 | , MPG_MD_LR_I = 1
142 | , MPG_MD_MS_LR = 2
143 | , MPG_MD_MS_I = 3
144 | };
145 |
146 | #ifndef lame_internal_flags_defined
147 | #define lame_internal_flags_defined
148 | struct lame_internal_flags;
149 | typedef struct lame_internal_flags lame_internal_flags;
150 | #endif
151 |
152 | int lame_encode_mp3_frame(lame_internal_flags * gfc,
153 | sample_t const *inbuf_l,
154 | sample_t const *inbuf_r, unsigned char *mp3buf, int mp3buf_size);
155 |
156 | #endif /* LAME_ENCODER_H */
157 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/fft.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Fast Fourier Transform include file
3 | *
4 | * Copyright (c) 2000 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_FFT_H
23 | #define LAME_FFT_H
24 |
25 | void fft_long(lame_internal_flags const *const gfc, FLOAT x_real[BLKSIZE],
26 | int chn, const sample_t *const data[2]);
27 |
28 | void fft_short(lame_internal_flags const *const gfc, FLOAT x_real[3][BLKSIZE_s],
29 | int chn, const sample_t *const data[2]);
30 |
31 | void init_fft(lame_internal_flags * const gfc);
32 |
33 | #endif
34 |
35 | /* End of fft.h */
36 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/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 { GAIN_NOT_ENOUGH_SAMPLES = -24601, GAIN_ANALYSIS_ERROR = 0, GAIN_ANALYSIS_OK =
62 | 1, INIT_GAIN_ANALYSIS_ERROR = 0, INIT_GAIN_ANALYSIS_OK = 1
63 | };
64 |
65 | enum { MAX_ORDER = (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER)
66 | , MAX_SAMPLES_PER_WINDOW = ((MAX_SAMP_FREQ * RMS_WINDOW_TIME_NUMERATOR) / RMS_WINDOW_TIME_DENOMINATOR + 1) /* max. Samples per Time slice */
67 | };
68 |
69 | struct replaygain_data {
70 | Float_t linprebuf[MAX_ORDER * 2];
71 | Float_t *linpre; /* left input samples, with pre-buffer */
72 | Float_t lstepbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
73 | Float_t *lstep; /* left "first step" (i.e. post first filter) samples */
74 | Float_t loutbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
75 | Float_t *lout; /* left "out" (i.e. post second filter) samples */
76 | Float_t rinprebuf[MAX_ORDER * 2];
77 | Float_t *rinpre; /* right input samples ... */
78 | Float_t rstepbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
79 | Float_t *rstep;
80 | Float_t routbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
81 | Float_t *rout;
82 | long sampleWindow; /* number of samples required to reach number of milliseconds required for RMS window */
83 | long totsamp;
84 | double lsum;
85 | double rsum;
86 | int freqindex;
87 | int first;
88 | uint32_t A[STEPS_per_dB * MAX_dB];
89 | uint32_t B[STEPS_per_dB * MAX_dB];
90 |
91 | };
92 | #ifndef replaygain_data_defined
93 | #define replaygain_data_defined
94 | typedef struct replaygain_data replaygain_t;
95 | #endif
96 |
97 |
98 |
99 |
100 | int InitGainAnalysis(replaygain_t * rgData, long samplefreq);
101 | int AnalyzeSamples(replaygain_t * rgData, const Float_t * left_samples,
102 | const Float_t * right_samples, size_t num_samples, int num_channels);
103 | Float_t GetTitleGain(replaygain_t * rgData);
104 |
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 | #endif /* GAIN_ANALYSIS_H */
110 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/i386/Makefile.am:
--------------------------------------------------------------------------------
1 | ## $Id: Makefile.am,v 1.28 2013/06/12 09:16:29 rbrito Exp $
2 |
3 | AUTOMAKE_OPTIONS = foreign
4 |
5 | DEFS = @DEFS@ @CONFIG_DEFS@
6 |
7 | ECHO ?= echo
8 |
9 | nasm_sources = \
10 | choose_table.nas \
11 | cpu_feat.nas \
12 | fft3dn.nas \
13 | fftsse.nas
14 |
15 | if HAVE_NASM
16 | noinst_LTLIBRARIES = liblameasmroutines.la
17 | liblameasmroutines_la_SOURCES = $(nasm_sources)
18 | liblameasmroutines_la_DEPENDENCIES = $(nasm_sources:.nas.lo)
19 | am_liblameasmroutines_la_OBJECTS = \
20 | choose_table$U.lo \
21 | cpu_feat$U.lo \
22 | fft3dn$U.lo \
23 | fftsse$U.lo
24 | endif
25 |
26 | noinst_HEADERS = nasm.h
27 |
28 | INCLUDES = @INCLUDES@ -I$(top_srcdir)/libmp3lame/@CPUTYPE@
29 |
30 | SUFFIXES = .nas .lo
31 |
32 | EXTRA_liblameasmroutines_la_SOURCES = $(nasm_sources)
33 |
34 | CLEANFILES = \
35 | choose_table.o.lst \
36 | choose_table.lo.lst \
37 | cpu_feat.o.lst \
38 | cpu_feat.lo.lst \
39 | fft3dn.o.lst \
40 | fft3dn.lo.lst \
41 | fftsse.o.lst \
42 | fftsse.lo.lst
43 |
44 | EXTRA_DIST = \
45 | fft.nas \
46 | fftfpu.nas \
47 | ffttbl.nas \
48 | scalar.nas
49 |
50 | NASM = @NASM@
51 | NASMFLAGS=@NASM_FORMAT@ -i $(top_srcdir)/libmp3lame/@CPUTYPE@/
52 |
53 | .nas.o: $< nasm.h
54 | $(NASM) $(NASMFLAGS) $< -o $@ -l $@.lst
55 |
56 | .nas.lo: $< nasm.h
57 | $(ECHO) '# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)' >$@
58 | $(ECHO) "pic_object='$*.o'" >>$@
59 | $(ECHO) "non_pic_object='$*.o'" >>$@
60 | $(NASM) $(NASMFLAGS) $< -o $*.o -l $@.lst
61 |
62 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
63 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
64 | LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
65 | $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
66 | CCLD = $(CC)
67 | LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
68 | $(AM_LDFLAGS) $(LDFLAGS) -o $@
69 |
70 |
71 | #$(OBJECTS): libtool
72 | #libtool: $(LIBTOOL_DEPS)
73 | # $(SHELL) $(top_builddir)/config.status --recheck
74 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/i386/cpu_feat.nas:
--------------------------------------------------------------------------------
1 | ;
2 | ;
3 | ; assembler routines to detect CPU-features
4 | ;
5 | ; MMX / 3DNow! / SSE / SSE2
6 | ;
7 | ; for the LAME project
8 | ; Frank Klemm, Robert Hegemann 2000-10-12
9 | ;
10 |
11 | %include "nasm.h"
12 |
13 | globaldef has_MMX_nasm
14 | globaldef has_3DNow_nasm
15 | globaldef has_SSE_nasm
16 | globaldef has_SSE2_nasm
17 |
18 | segment_code
19 |
20 | testCPUID:
21 | pushfd
22 | pop eax
23 | mov ecx,eax
24 | xor eax,0x200000
25 | push eax
26 | popfd
27 | pushfd
28 | pop eax
29 | cmp eax,ecx
30 | ret
31 |
32 | ;---------------------------------------
33 | ; int has_MMX_nasm (void)
34 | ;---------------------------------------
35 |
36 | has_MMX_nasm:
37 | pushad
38 | call testCPUID
39 | jz return0 ; no CPUID command, so no MMX
40 |
41 | mov eax,0x1
42 | CPUID
43 | test edx,0x800000
44 | jz return0 ; no MMX support
45 | jmp return1 ; MMX support
46 |
47 | ;---------------------------------------
48 | ; int has_SSE_nasm (void)
49 | ;---------------------------------------
50 |
51 | has_SSE_nasm:
52 | pushad
53 | call testCPUID
54 | jz return0 ; no CPUID command, so no SSE
55 |
56 | mov eax,0x1
57 | CPUID
58 | test edx,0x02000000
59 | jz return0 ; no SSE support
60 | jmp return1 ; SSE support
61 |
62 | ;---------------------------------------
63 | ; int has_SSE2_nasm (void)
64 | ;---------------------------------------
65 |
66 | has_SSE2_nasm:
67 | pushad
68 | call testCPUID
69 | jz return0 ; no CPUID command, so no SSE2
70 |
71 | mov eax,0x1
72 | CPUID
73 | test edx,0x04000000
74 | jz return0 ; no SSE2 support
75 | jmp return1 ; SSE2 support
76 |
77 | ;---------------------------------------
78 | ; int has_3DNow_nasm (void)
79 | ;---------------------------------------
80 |
81 | has_3DNow_nasm:
82 | pushad
83 | call testCPUID
84 | jz return0 ; no CPUID command, so no 3DNow!
85 |
86 | mov eax,0x80000000
87 | CPUID
88 | cmp eax,0x80000000
89 | jbe return0 ; no extended MSR(1), so no 3DNow!
90 |
91 | mov eax,0x80000001
92 | CPUID
93 | test edx,0x80000000
94 | jz return0 ; no 3DNow! support
95 | ; 3DNow! support
96 | return1:
97 | popad
98 | xor eax,eax
99 | inc eax
100 | ret
101 |
102 | return0:
103 | popad
104 | xor eax,eax
105 | ret
106 |
107 | end
108 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/i386/fft.nas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/library_audio/src/main/cpp/libmp3lame/i386/fft.nas
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/i386/fftsse.nas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/library_audio/src/main/cpp/libmp3lame/i386/fftsse.nas
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/i386/ffttbl.nas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/library_audio/src/main/cpp/libmp3lame/i386/ffttbl.nas
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/i386/nasm.h:
--------------------------------------------------------------------------------
1 |
2 | ; Copyright (C) 1999 URURI
3 |
4 | ; nasm�ѥޥ���
5 | ; 1999/08/21 ���
6 | ; 1999/10/10 ���Ĥ��ɲ�
7 | ; 1999/10/27 aout�б�
8 | ; 1999/11/07 pushf, popf ��NASM�ΥХ��б�
9 | ; 1999/12/02 for BCC ( Thanks to Miquel )
10 |
11 | ; for Windows Visual C++ -> define WIN32
12 | ; Borland or cygwin -> WIN32 and COFF
13 | ; for FreeBSD 2.x -> AOUT
14 | ; for TownsOS -> __tos__
15 | ; otherwise -> none
16 |
17 | ;̾����դ���
18 |
19 | BITS 32
20 |
21 | section .note.GNU-stack noalloc noexec nowrite progbits
22 |
23 | %ifdef YASM
24 | %define segment_code segment .text align=16 use32
25 | %define segment_data segment .data align=16 use32
26 | %define segment_bss segment .bss align=16 use32
27 | %elifdef WIN32
28 | %define segment_code segment .text align=16 class=CODE use32
29 | %define segment_data segment .data align=16 class=DATA use32
30 | %ifdef __BORLANDC__
31 | %define segment_bss segment .data align=16 class=DATA use32
32 | %else
33 | %define segment_bss segment .bss align=16 class=DATA use32
34 | %endif
35 | %elifdef AOUT
36 | %define _NAMING
37 | %define segment_code segment .text
38 | %define segment_data segment .data
39 | %define segment_bss segment .bss
40 | %else
41 | %ifidn __OUTPUT_FORMAT__,elf
42 | section .note.GNU-stack progbits noalloc noexec nowrite align=1
43 | %endif
44 | %define segment_code segment .text align=16 class=CODE use32
45 | %define segment_data segment .data align=16 class=DATA use32
46 | %define segment_bss segment .bss align=16 class=DATA use32
47 | %endif
48 |
49 | %ifdef WIN32
50 | %define _NAMING
51 | %endif
52 |
53 | %ifdef __tos__
54 | group CGROUP text
55 | group DGROUP data
56 | %endif
57 |
58 | ;ñ�����ư��������
59 |
60 | %idefine float dword
61 | %idefine fsize 4
62 | %idefine fsizen(a) (fsize*(a))
63 |
64 | ;��ɷ��
65 |
66 | %idefine wsize 2
67 | %idefine wsizen(a) (wsize*(a))
68 | %idefine dwsize 4
69 | %idefine dwsizen(a) (dwsize*(a))
70 |
71 | ;REG
72 |
73 | %define r0 eax
74 | %define r1 ebx
75 | %define r2 ecx
76 | %define r3 edx
77 | %define r4 esi
78 | %define r5 edi
79 | %define r6 ebp
80 | %define r7 esp
81 |
82 | ;MMX,3DNow!,SSE
83 |
84 | %define pmov movq
85 | %define pmovd movd
86 |
87 | %define pupldq punpckldq
88 | %define puphdq punpckhdq
89 | %define puplwd punpcklwd
90 | %define puphwd punpckhwd
91 |
92 | %define xm0 xmm0
93 | %define xm1 xmm1
94 | %define xm2 xmm2
95 | %define xm3 xmm3
96 | %define xm4 xmm4
97 | %define xm5 xmm5
98 | %define xm6 xmm6
99 | %define xm7 xmm7
100 |
101 | ;�����åե��Ѥ�4�ʥޥ���
102 |
103 | %define R4(a,b,c,d) (a*64+b*16+c*4+d)
104 |
105 | ;C�饤���ʴʰץޥ���
106 |
107 | %imacro globaldef 1
108 | %ifdef _NAMING
109 | %define %1 _%1
110 | %endif
111 | global %1
112 | %endmacro
113 |
114 | %imacro externdef 1
115 | %ifdef _NAMING
116 | %define %1 _%1
117 | %endif
118 | extern %1
119 | %endmacro
120 |
121 | %imacro proc 1
122 | %push proc
123 | %ifdef _NAMING
124 | global _%1
125 | %else
126 | global %1
127 | %endif
128 |
129 | align 32
130 | %1:
131 | _%1:
132 |
133 | %assign %$STACK 0
134 | %assign %$STACKN 0
135 | %assign %$ARG 4
136 | %endmacro
137 |
138 | %imacro endproc 0
139 | %ifnctx proc
140 | %error expected 'proc' before 'endproc'.
141 | %else
142 | %if %$STACK > 0
143 | add esp, %$STACK
144 | %endif
145 |
146 | %if %$STACK <> (-%$STACKN)
147 | %error STACKLEVEL mismatch check 'local', 'alloc', 'pushd', 'popd'
148 | %endif
149 |
150 | ret
151 | %pop
152 | %endif
153 | %endmacro
154 |
155 | %idefine sp(a) esp+%$STACK+a
156 |
157 | %imacro arg 1
158 | %00 equ %$ARG
159 | %assign %$ARG %$ARG+%1
160 | %endmacro
161 |
162 | %imacro local 1
163 | %assign %$STACKN %$STACKN-%1
164 | %00 equ %$STACKN
165 | %endmacro
166 |
167 | %imacro alloc 0
168 | sub esp, (-%$STACKN)-%$STACK
169 | %assign %$STACK (-%$STACKN)
170 | %endmacro
171 |
172 | %imacro pushd 1-*
173 | %rep %0
174 | push %1
175 | %assign %$STACK %$STACK+4
176 | %rotate 1
177 | %endrep
178 | %endmacro
179 |
180 | %imacro popd 1-*
181 | %rep %0
182 | %rotate -1
183 | pop %1
184 | %assign %$STACK %$STACK-4
185 | %endrep
186 | %endmacro
187 |
188 | ; bug of NASM-0.98
189 | %define pushf db 0x66, 0x9C
190 | %define popf db 0x66, 0x9D
191 |
192 | %define ge16(n) ((((n) / 16)*0xFFFFFFFF) & 0xFFFFFFFF)
193 | %define ge15(n) ((((n) / 15)*0xFFFFFFFF) & 0xFFFFFFFF)
194 | %define ge14(n) ((((n) / 14)*0xFFFFFFFF) & 0xFFFFFFFF)
195 | %define ge13(n) ((((n) / 13)*0xFFFFFFFF) & 0xFFFFFFFF)
196 | %define ge12(n) ((((n) / 12)*0xFFFFFFFF) & 0xFFFFFFFF)
197 | %define ge11(n) ((((n) / 11)*0xFFFFFFFF) & 0xFFFFFFFF)
198 | %define ge10(n) ((((n) / 10)*0xFFFFFFFF) & 0xFFFFFFFF)
199 | %define ge9(n) ((((n) / 9)*0xFFFFFFFF) & 0xFFFFFFFF)
200 | %define ge8(n) (ge9(n) | ((((n) / 8)*0xFFFFFFFF) & 0xFFFFFFFF))
201 | %define ge7(n) (ge9(n) | ((((n) / 7)*0xFFFFFFFF) & 0xFFFFFFFF))
202 | %define ge6(n) (ge9(n) | ((((n) / 6)*0xFFFFFFFF) & 0xFFFFFFFF))
203 | %define ge5(n) (ge9(n) | ((((n) / 5)*0xFFFFFFFF) & 0xFFFFFFFF))
204 | %define ge4(n) (ge5(n) | ((((n) / 4)*0xFFFFFFFF) & 0xFFFFFFFF))
205 | %define ge3(n) (ge5(n) | ((((n) / 3)*0xFFFFFFFF) & 0xFFFFFFFF))
206 | %define ge2(n) (ge3(n) | ((((n) / 2)*0xFFFFFFFF) & 0xFFFFFFFF))
207 | %define ge1(n) (ge2(n) | ((((n) / 1)*0xFFFFFFFF) & 0xFFFFFFFF))
208 |
209 | ; macro to align for begining of loop
210 | ; %1 does not align if it LE bytes to next alignment
211 | ; 4..16
212 | ; default is 12
213 |
214 | %imacro loopalignK6 0-1 12
215 | %%here:
216 | times (($$-%%here) & 15 & ge1(($$-%%here) & 15) & ~ge4(($$-%%here) & 15)) nop
217 | times (1 & ge4(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) jmp short %%skip
218 | times (((($$-%%here) & 15)-2) & ge4(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) nop
219 | %%skip:
220 | %endmacro
221 |
222 | %imacro loopalignK7 0-1 12
223 | %%here:
224 | times (1 & ge1(($$-%%here) & 15) & ~ge2(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) nop
225 | times (1 & ge2(($$-%%here) & 15) & ~ge3(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 08Bh,0C0h
226 | times (1 & ge3(($$-%%here) & 15) & ~ge4(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 08Dh,004h,020h
227 | times (1 & ge4(($$-%%here) & 15) & ~ge5(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 08Dh,044h,020h,000h
228 | times (1 & ge5(($$-%%here) & 15) & ~ge6(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 08Dh,044h,020h,000h,090h
229 | times (1 & ge6(($$-%%here) & 15) & ~ge7(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 08Dh,080h,0,0,0,0
230 | times (1 & ge7(($$-%%here) & 15) & ~ge8(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 08Dh,004h,005h,0,0,0,0
231 | times (1 & ge8(($$-%%here) & 15) & ~ge9(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 08Dh,004h,005h,0,0,0,0,90h
232 | times (1 & ge9(($$-%%here) & 15) & ~ge10(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 0EBh,007h,90h,90h,90h,90h,90h,90h,90h
233 | times (1 & ge10(($$-%%here) & 15) & ~ge11(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 0EBh,008h,90h,90h,90h,90h,90h,90h,90h,90h
234 | times (1 & ge11(($$-%%here) & 15) & ~ge12(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 0EBh,009h,90h,90h,90h,90h,90h,90h,90h,90h,90h
235 | times (1 & ge12(($$-%%here) & 15) & ~ge13(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 0EBh,00Ah,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h
236 | times (1 & ge13(($$-%%here) & 15) & ~ge14(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 0EBh,00Bh,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h
237 | times (1 & ge14(($$-%%here) & 15) & ~ge15(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 0EBh,00Ch,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h
238 | times (1 & ge15(($$-%%here) & 15) & ~ge16(($$-%%here) & 15) & ~ge%1(($$-%%here) & 15)) DB 0EBh,00Dh,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h,90h
239 | %%skip:
240 | %endmacro
241 |
242 | %imacro loopalign 0-1 12
243 | loopalignK7 %1
244 | %endmacro
245 | %define PACK(x,y,z,w) (x*64+y*16+z*4+w)
246 |
247 | %ifidn __OUTPUT_FORMAT__,elf
248 |
249 | %idefine PIC_BASE(A) _GLOBAL_OFFSET_TABLE_ + $$ - $ wrt ..gotpc
250 | %idefine PIC_EBP_REL(A) ebp + A wrt ..gotoff
251 | %macro PIC_OFFSETTABLE 0
252 | extern _GLOBAL_OFFSET_TABLE_
253 | get_pc.bp:
254 | mov ebp, [esp]
255 | retn
256 | %endmacro
257 |
258 | %else
259 |
260 | %define PIC_BASE(A) (0)
261 | %define PIC_EBP_REL(A) (A)
262 | %macro PIC_OFFSETTABLE 0
263 | get_pc.bp:
264 | mov ebp, [esp]
265 | retn
266 | %endmacro
267 |
268 | %endif
269 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/id3tag.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAME_ID3_H
3 | #define LAME_ID3_H
4 |
5 |
6 | #define CHANGED_FLAG (1U << 0)
7 | #define ADD_V2_FLAG (1U << 1)
8 | #define V1_ONLY_FLAG (1U << 2)
9 | #define V2_ONLY_FLAG (1U << 3)
10 | #define SPACE_V1_FLAG (1U << 4)
11 | #define PAD_V2_FLAG (1U << 5)
12 |
13 | enum {
14 | MIMETYPE_NONE = 0,
15 | MIMETYPE_JPEG,
16 | MIMETYPE_PNG,
17 | MIMETYPE_GIF
18 | };
19 |
20 | typedef struct FrameDataNode {
21 | struct FrameDataNode *nxt;
22 | uint32_t fid; /* Frame Identifier */
23 | char lng[4]; /* 3-character language descriptor */
24 | struct {
25 | union {
26 | char *l; /* ptr to Latin-1 chars */
27 | unsigned short *u; /* ptr to UCS-2 text */
28 | unsigned char *b; /* ptr to raw bytes */
29 | } ptr;
30 | size_t dim;
31 | int enc; /* 0:Latin-1, 1:UCS-2, 2:RAW */
32 | } dsc , txt;
33 | } FrameDataNode;
34 |
35 |
36 | typedef struct id3tag_spec {
37 | /* private data members */
38 | unsigned int flags;
39 | int year;
40 | char *title;
41 | char *artist;
42 | char *album;
43 | char *comment;
44 | int track_id3v1;
45 | int genre_id3v1;
46 | unsigned char *albumart;
47 | unsigned int albumart_size;
48 | unsigned int padding_size;
49 | int albumart_mimetype;
50 | char language[4]; /* the language of the frame's content, according to ISO-639-2 */
51 | FrameDataNode *v2_head, *v2_tail;
52 | } id3tag_spec;
53 |
54 |
55 | /* write tag into stream at current position */
56 | extern int id3tag_write_v2(lame_global_flags * gfp);
57 | extern int id3tag_write_v1(lame_global_flags * gfp);
58 | /*
59 | * NOTE: A version 2 tag will NOT be added unless one of the text fields won't
60 | * fit in a version 1 tag (e.g. the title string is longer than 30 characters),
61 | * or the "id3tag_add_v2" or "id3tag_v2_only" functions are used.
62 | */
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/l3side.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Layer 3 side include file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_L3SIDE_H
23 | #define LAME_L3SIDE_H
24 |
25 | /* max scalefactor band, max(SBMAX_l, SBMAX_s*3, (SBMAX_s-3)*3+8) */
26 | #define SFBMAX (SBMAX_s*3)
27 |
28 | /* Layer III side information. */
29 | typedef struct {
30 | int l[1 + SBMAX_l];
31 | int s[1 + SBMAX_s];
32 | int psfb21[1 + PSFB21];
33 | int psfb12[1 + PSFB12];
34 | } scalefac_struct;
35 |
36 |
37 | typedef struct {
38 | FLOAT l[SBMAX_l];
39 | FLOAT s[SBMAX_s][3];
40 | } III_psy_xmin;
41 |
42 | typedef struct {
43 | III_psy_xmin thm;
44 | III_psy_xmin en;
45 | } III_psy_ratio;
46 |
47 | typedef struct {
48 | FLOAT xr[576];
49 | int l3_enc[576];
50 | int scalefac[SFBMAX];
51 | FLOAT xrpow_max;
52 |
53 | int part2_3_length;
54 | int big_values;
55 | int count1;
56 | int global_gain;
57 | int scalefac_compress;
58 | int block_type;
59 | int mixed_block_flag;
60 | int table_select[3];
61 | int subblock_gain[3 + 1];
62 | int region0_count;
63 | int region1_count;
64 | int preflag;
65 | int scalefac_scale;
66 | int count1table_select;
67 |
68 | int part2_length;
69 | int sfb_lmax;
70 | int sfb_smin;
71 | int psy_lmax;
72 | int sfbmax;
73 | int psymax;
74 | int sfbdivide;
75 | int width[SFBMAX];
76 | int window[SFBMAX];
77 | int count1bits;
78 | /* added for LSF */
79 | const int *sfb_partition_table;
80 | int slen[4];
81 |
82 | int max_nonzero_coeff;
83 | char energy_above_cutoff[SFBMAX];
84 | } gr_info;
85 |
86 | typedef struct {
87 | gr_info tt[2][2];
88 | int main_data_begin;
89 | int private_bits;
90 | int resvDrain_pre;
91 | int resvDrain_post;
92 | int scfsi[2][4];
93 | } III_side_info_t;
94 |
95 | #endif
96 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/lame-analysis.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GTK plotting routines source file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_GTKANAL_H
23 | #define LAME_GTKANAL_H
24 |
25 |
26 | #define READ_AHEAD 40 /* number of frames to read ahead */
27 | #define MAXMPGLAG READ_AHEAD /* if the mpg123 lag becomes bigger than this
28 | we have to stop */
29 | #define NUMBACK 6 /* number of frames we can back up */
30 | #define NUMPINFO (NUMBACK+READ_AHEAD+1)
31 |
32 |
33 |
34 | struct plotting_data {
35 | int frameNum; /* current frame number */
36 | int frameNum123;
37 | int num_samples; /* number of pcm samples read for this frame */
38 | double frametime; /* starting time of frame, in seconds */
39 | double pcmdata[2][1600];
40 | double pcmdata2[2][1152 + 1152 - DECDELAY];
41 | double xr[2][2][576];
42 | double mpg123xr[2][2][576];
43 | double ms_ratio[2];
44 | double ms_ener_ratio[2];
45 |
46 | /* L,R, M and S values */
47 | double energy_save[4][BLKSIZE]; /* psymodel is one ahead */
48 | double energy[2][4][BLKSIZE];
49 | double pe[2][4];
50 | double thr[2][4][SBMAX_l];
51 | double en[2][4][SBMAX_l];
52 | double thr_s[2][4][3 * SBMAX_s];
53 | double en_s[2][4][3 * SBMAX_s];
54 | double ers_save[4]; /* psymodel is one ahead */
55 | double ers[2][4];
56 |
57 | double sfb[2][2][SBMAX_l];
58 | double sfb_s[2][2][3 * SBMAX_s];
59 | double LAMEsfb[2][2][SBMAX_l];
60 | double LAMEsfb_s[2][2][3 * SBMAX_s];
61 |
62 | int LAMEqss[2][2];
63 | int qss[2][2];
64 | int big_values[2][2];
65 | int sub_gain[2][2][3];
66 |
67 | double xfsf[2][2][SBMAX_l];
68 | double xfsf_s[2][2][3 * SBMAX_s];
69 |
70 | int over[2][2];
71 | double tot_noise[2][2];
72 | double max_noise[2][2];
73 | double over_noise[2][2];
74 | int over_SSD[2][2];
75 | int blocktype[2][2];
76 | int scalefac_scale[2][2];
77 | int preflag[2][2];
78 | int mpg123blocktype[2][2];
79 | int mixed[2][2];
80 | int mainbits[2][2];
81 | int sfbits[2][2];
82 | int LAMEmainbits[2][2];
83 | int LAMEsfbits[2][2];
84 | int framesize, stereo, js, ms_stereo, i_stereo, emph, bitrate, sampfreq, maindata;
85 | int crc, padding;
86 | int scfsi[2], mean_bits, resvsize;
87 | int totbits;
88 | };
89 | #ifndef plotting_data_defined
90 | #define plotting_data_defined
91 | typedef struct plotting_data plotting_data;
92 | #endif
93 | #if 0
94 | extern plotting_data *pinfo;
95 | #endif
96 | #endif
97 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/lame.rc:
--------------------------------------------------------------------------------
1 | #include
2 | #include "version.h"
3 |
4 | #ifdef _DLL
5 | IDI_ICON1 ICON DISCARDABLE "logoe.ico"
6 | #else
7 | IDI_ICON1 ICON DISCARDABLE "logoe.ico"
8 | #endif
9 |
10 | VS_VERSION_INFO VERSIONINFO
11 | FILEVERSION LAME_MAJOR_VERSION,LAME_MINOR_VERSION,LAME_TYPE_VERSION,LAME_PATCH_VERSION
12 | PRODUCTVERSION LAME_MAJOR_VERSION,LAME_MINOR_VERSION,LAME_TYPE_VERSION,LAME_PATCH_VERSION
13 | FILEFLAGSMASK 0x3fL
14 | #ifdef _DEBUG
15 | FILEFLAGS VS_FF_DEBUG
16 | #else
17 | FILEFLAGS 0x0L
18 | #endif
19 | FILEOS VOS__WINDOWS32
20 | #ifdef _DLL
21 | FILETYPE VFT_DLL
22 | #else
23 | FILETYPE VFT_APP
24 | #endif
25 | FILESUBTYPE 0x0L
26 | BEGIN
27 | BLOCK "StringFileInfo"
28 | BEGIN
29 | BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
30 | BEGIN
31 | VALUE "CompanyName", LAME_URL "\0"
32 | VALUE "FileDescription", "MP3 Encoder.\0"
33 | VALUE "FileVersion", LAME_VERSION_STRING "\0"
34 | VALUE "LegalCopyright", "Copyright (C) 1999-2011 The L.A.M.E. Team\0"
35 | #ifdef _DLL
36 | VALUE "OriginalFilename", STR(_DLL) "\0"
37 | #else
38 | VALUE "OriginalFilename", STR(_APP) "\0"
39 | #endif
40 | VALUE "ProductName", "L.A.M.E.\0"
41 | VALUE "ProductVersion", LAME_VERSION_STRING "\0"
42 | END
43 | END
44 | BLOCK "VarFileInfo"
45 | BEGIN
46 | VALUE "Translation", 0x409, 1252 // mandatory by convention
47 | END
48 | END
49 | /* End of Version info */
50 |
51 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/lame_util.c:
--------------------------------------------------------------------------------
1 | #include "lame_3.99.5_libmp3lame/lame.h"
2 | #include "com_czt_mp3recorder_util_LameUtil.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | static lame_global_flags *lame = NULL;
9 |
10 |
11 | JNIEXPORT void JNICALL Java_com_czt_mp3recorder_util_LameUtil_init(
12 | JNIEnv *env, jclass cls, jint inSamplerate, jint inChannel, jint outSamplerate, jint outBitrate, jint quality) {
13 | if (lame != NULL) {
14 | lame_close(lame);
15 | lame = NULL;
16 | }
17 | lame = lame_init();
18 | lame_set_in_samplerate(lame, inSamplerate);
19 | lame_set_num_channels(lame, inChannel);//输入流的声道
20 | lame_set_out_samplerate(lame, outSamplerate);
21 | lame_set_brate(lame, outBitrate);
22 | lame_set_quality(lame, quality);
23 | lame_init_params(lame);
24 | }
25 |
26 | JNIEXPORT jint JNICALL Java_com_czt_mp3recorder_util_LameUtil_encode(
27 | JNIEnv *env, jclass cls, jshortArray buffer_l, jshortArray buffer_r,
28 | jint samples, jbyteArray mp3buf) {
29 | jshort* j_buffer_l = (*env)->GetShortArrayElements(env, buffer_l, NULL);
30 |
31 | jshort* j_buffer_r = (*env)->GetShortArrayElements(env, buffer_r, NULL);
32 |
33 | const jsize mp3buf_size = (*env)->GetArrayLength(env, mp3buf);
34 | jbyte* j_mp3buf = (*env)->GetByteArrayElements(env, mp3buf, NULL);
35 |
36 | int result = lame_encode_buffer(lame, j_buffer_l, j_buffer_r,
37 | samples, j_mp3buf, mp3buf_size);
38 |
39 | (*env)->ReleaseShortArrayElements(env, buffer_l, j_buffer_l, 0);
40 | (*env)->ReleaseShortArrayElements(env, buffer_r, j_buffer_r, 0);
41 | (*env)->ReleaseByteArrayElements(env, mp3buf, j_mp3buf, 0);
42 |
43 | return result;
44 | }
45 |
46 | JNIEXPORT jint JNICALL Java_com_czt_mp3recorder_util_LameUtil_flush(
47 | JNIEnv *env, jclass cls, jbyteArray mp3buf) {
48 | const jsize mp3buf_size = (*env)->GetArrayLength(env, mp3buf);
49 | jbyte* j_mp3buf = (*env)->GetByteArrayElements(env, mp3buf, NULL);
50 |
51 | int result = lame_encode_flush(lame, j_mp3buf, mp3buf_size);
52 |
53 | (*env)->ReleaseByteArrayElements(env, mp3buf, j_mp3buf, 0);
54 |
55 | return result;
56 | }
57 |
58 | JNIEXPORT void JNICALL Java_com_czt_mp3recorder_util_LameUtil_close
59 | (JNIEnv *env, jclass cls) {
60 | lame_close(lame);
61 | lame = NULL;
62 | }
63 |
64 |
65 | /**
66 | * 返回值 char* 这个代表char数组的首地址
67 | * Jstring2CStr 把java中的jstring的类型转化成一个c语言中的char 字符串
68 | */
69 | char* Jstring2CStr(JNIEnv* env, jstring jstr) {
70 | char* rtn = NULL;
71 | jclass clsstring = (*env)->FindClass(env, "java/lang/String"); //String
72 | jstring strencode = (*env)->NewStringUTF(env, "GB2312"); // 得到一个java字符串 "GB2312"
73 | jmethodID mid = (*env)->GetMethodID(env, clsstring, "getBytes",
74 | "(Ljava/lang/String;)[B"); //[ String.getBytes("gb2312");
75 | jbyteArray barr = (jbyteArray)(*env)->CallObjectMethod(env, jstr, mid,
76 | strencode); // String .getByte("GB2312");
77 | jsize alen = (*env)->GetArrayLength(env, barr); // byte数组的长度
78 | jbyte* ba = (*env)->GetByteArrayElements(env, barr, JNI_FALSE);
79 | if (alen > 0) {
80 | rtn = (char*) malloc(alen + 1); //"\0"
81 | memcpy(rtn, ba, alen);
82 | rtn[alen] = 0;
83 | }
84 | (*env)->ReleaseByteArrayElements(env, barr, ba, 0); //
85 | return rtn;
86 | }
87 |
88 | int flag = 0;
89 | /**
90 | * wav转换mp3
91 | */
92 | JNIEXPORT void JNICALL Java_com_czt_mp3recorder_util_LameUtil_convert
93 | (JNIEnv * env, jobject obj, jstring jwav, jstring jmp3, jint inSamplerate) {
94 |
95 | //1.初始化lame的编码器
96 | lame_t lameConvert = lame_init();
97 | int channel = 1;//单声道
98 |
99 | //2. 设置lame mp3编码的采样率
100 | lame_set_in_samplerate(lameConvert , inSamplerate);
101 | lame_set_out_samplerate(lameConvert, inSamplerate);
102 | lame_set_num_channels(lameConvert,1);
103 |
104 | // 3. 设置MP3的编码方式
105 | lame_set_VBR(lameConvert, vbr_default);
106 | lame_init_params(lameConvert);
107 |
108 | char* cwav =Jstring2CStr(env,jwav) ;
109 | char* cmp3=Jstring2CStr(env,jmp3);
110 |
111 | const int SIZE = (inSamplerate/20)+7200;
112 |
113 | //4.打开 wav,MP3文件
114 | FILE* fwav = fopen(cwav,"rb");
115 | fseek(fwav, 4*1024, SEEK_CUR);
116 | FILE* fmp3 = fopen(cmp3,"wb+");
117 |
118 |
119 | short int wav_buffer[SIZE*channel];
120 | unsigned char mp3_buffer[SIZE];
121 |
122 |
123 | int read ; int write; //代表读了多少个次 和写了多少次
124 | int total=0; // 当前读的wav文件的byte数目
125 | do{
126 | if(flag==404){
127 | return;
128 | }
129 | read = fread(wav_buffer,sizeof(short int)*channel, SIZE,fwav);
130 | total += read* sizeof(short int)*channel;
131 | if(read!=0){
132 | write = lame_encode_buffer(lameConvert, wav_buffer, NULL, read, mp3_buffer, SIZE);
133 | //write = lame_encode_buffer_interleaved(lame,wav_buffer,read,mp3_buffer,SIZE);
134 | }else{
135 | write = lame_encode_flush(lameConvert,mp3_buffer,SIZE);
136 | }
137 | //把转化后的mp3数据写到文件里
138 | fwrite(mp3_buffer,sizeof(unsigned char),write,fmp3);
139 |
140 | }while(read!=0);
141 | lame_mp3_tags_fid(lameConvert,fmp3);
142 | lame_close(lameConvert);
143 | fclose(fwav);
144 | fclose(fmp3);
145 | }
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/lameerror.h:
--------------------------------------------------------------------------------
1 | /*
2 | * A collection of LAME Error Codes
3 | *
4 | * Please use the constants defined here instead of some arbitrary
5 | * values. Currently the values starting at -10 to avoid intersection
6 | * with the -1, -2, -3 and -4 used in the current code.
7 | *
8 | * May be this should be a part of the include/lame.h.
9 | */
10 |
11 | typedef enum {
12 | LAME_OKAY = 0,
13 | LAME_NOERROR = 0,
14 | LAME_GENERICERROR = -1,
15 | LAME_NOMEM = -10,
16 | LAME_BADBITRATE = -11,
17 | LAME_BADSAMPFREQ = -12,
18 | LAME_INTERNALERROR = -13,
19 |
20 | FRONTEND_READERROR = -80,
21 | FRONTEND_WRITEERROR = -81,
22 | FRONTEND_FILETOOLARGE = -82,
23 |
24 | } lame_errorcodes_t;
25 |
26 | /* end of lameerror.h */
27 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/logoe.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/library_audio/src/main/cpp/libmp3lame/logoe.ico
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/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 | # ifndef HAVE_STRCHR
35 | # define strchr index
36 | # define strrchr rindex
37 | # endif
38 | char *strchr(), *strrchr();
39 | # ifndef HAVE_MEMCPY
40 | # define memcpy(d, s, n) bcopy ((s), (d), (n))
41 | # define memmove(d, s, n) bcopy ((s), (d), (n))
42 | # endif
43 | #endif
44 |
45 | #if defined(__riscos__) && defined(FPA10)
46 | # include "ymath.h"
47 | #else
48 | # include
49 | #endif
50 | #include
51 |
52 | #include
53 |
54 | #ifdef HAVE_ERRNO_H
55 | # include
56 | #endif
57 | #ifdef HAVE_FCNTL_H
58 | # include
59 | #endif
60 |
61 | #if defined(macintosh)
62 | # include
63 | # include
64 | #else
65 | # include
66 | # include
67 | #endif
68 |
69 | #ifdef HAVE_INTTYPES_H
70 | # include
71 | #else
72 | # ifdef HAVE_STDINT_H
73 | # include
74 | # endif
75 | #endif
76 |
77 | #ifdef WITH_DMALLOC
78 | #include
79 | #endif
80 |
81 | /*
82 | * 3 different types of pow() functions:
83 | * - table lookup
84 | * - pow()
85 | * - exp() on some machines this is claimed to be faster than pow()
86 | */
87 |
88 | #define POW20(x) (assert(0 <= (x+Q_MAX2) && x < Q_MAX), pow20[x+Q_MAX2])
89 | /*#define POW20(x) pow(2.0,((double)(x)-210)*.25) */
90 | /*#define POW20(x) exp( ((double)(x)-210)*(.25*LOG2) ) */
91 |
92 | #define IPOW20(x) (assert(0 <= x && x < Q_MAX), ipow20[x])
93 | /*#define IPOW20(x) exp( -((double)(x)-210)*.1875*LOG2 ) */
94 | /*#define IPOW20(x) pow(2.0,-((double)(x)-210)*.1875) */
95 |
96 | /* in case this is used without configure */
97 | #ifndef inline
98 | # define inline
99 | #endif
100 |
101 | #if defined(_MSC_VER)
102 | # undef inline
103 | # define inline _inline
104 | #elif defined(__SASC) || defined(__GNUC__) || defined(__ICC) || defined(__ECC)
105 | /* if __GNUC__ we always want to inline, not only if the user requests it */
106 | # undef inline
107 | # define inline __inline
108 | #endif
109 |
110 | #if defined(_MSC_VER)
111 | # pragma warning( disable : 4244 )
112 | /*# pragma warning( disable : 4305 ) */
113 | #endif
114 |
115 | /*
116 | * FLOAT for variables which require at least 32 bits
117 | * FLOAT8 for variables which require at least 64 bits
118 | *
119 | * On some machines, 64 bit will be faster than 32 bit. Also, some math
120 | * routines require 64 bit float, so setting FLOAT=float will result in a
121 | * lot of conversions.
122 | */
123 |
124 | #if ( defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) )
125 | # define WIN32_LEAN_AND_MEAN
126 | # include
127 | # include
128 | # define FLOAT_MAX FLT_MAX
129 | #else
130 | # ifndef FLOAT
131 | typedef float FLOAT;
132 | # ifdef FLT_MAX
133 | # define FLOAT_MAX FLT_MAX
134 | # else
135 | # define FLOAT_MAX 1e37 /* approx */
136 | # endif
137 | # endif
138 | #endif
139 |
140 | #ifndef FLOAT8
141 | typedef double FLOAT8;
142 | # ifdef DBL_MAX
143 | # define FLOAT8_MAX DBL_MAX
144 | # else
145 | # define FLOAT8_MAX 1e99 /* approx */
146 | # endif
147 | #else
148 | # ifdef FLT_MAX
149 | # define FLOAT8_MAX FLT_MAX
150 | # else
151 | # define FLOAT8_MAX 1e37 /* approx */
152 | # endif
153 | #endif
154 |
155 | /* sample_t must be floating point, at least 32 bits */
156 | typedef FLOAT sample_t;
157 |
158 | #define dimension_of(array) (sizeof(array)/sizeof(array[0]))
159 | #define beyond(array) (array+dimension_of(array))
160 | #define compiletime_assert(expression) enum{static_assert_##FILE##_##LINE = 1/((expression)?1:0)}
161 | #define lame_calloc(TYPE, COUNT) ((TYPE*)calloc(COUNT, sizeof(TYPE)))
162 | #define multiple_of(CHUNK, COUNT) (\
163 | ( (COUNT) < 1 || (CHUNK) < 1 || (COUNT) % (CHUNK) == 0 ) \
164 | ? (COUNT) \
165 | : ((COUNT) + (CHUNK) - (COUNT) % (CHUNK)) \
166 | )
167 |
168 | #if 1
169 | #define EQ(a,b) (\
170 | (fabs(a) > fabs(b)) \
171 | ? (fabs((a)-(b)) <= (fabs(a) * 1e-6f)) \
172 | : (fabs((a)-(b)) <= (fabs(b) * 1e-6f)))
173 | #else
174 | #define EQ(a,b) (fabs((a)-(b))<1E-37)
175 | #endif
176 |
177 | #define NEQ(a,b) (!EQ(a,b))
178 |
179 | #ifdef _MSC_VER
180 | # if _MSC_VER < 1400
181 | # define fabsf fabs
182 | # define powf pow
183 | # define log10f log10
184 | # endif
185 | #endif
186 |
187 | #endif
188 |
189 | /* end of machine.h */
190 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/newmdct.h:
--------------------------------------------------------------------------------
1 | /*
2 | * New Modified DCT include file
3 | *
4 | * Copyright (c) 1999 Takehiro TOMINAGA
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_NEWMDCT_H
23 | #define LAME_NEWMDCT_H
24 |
25 | void mdct_sub48(lame_internal_flags * gfc, const sample_t * w0, const sample_t * w1);
26 |
27 | #endif /* LAME_NEWMDCT_H */
28 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/psymodel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * psymodel.h
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_PSYMODEL_H
23 | #define LAME_PSYMODEL_H
24 |
25 |
26 | int L3psycho_anal_ns(lame_internal_flags * gfc,
27 | const sample_t *const buffer[2], int gr,
28 | III_psy_ratio ratio[2][2],
29 | III_psy_ratio MS_ratio[2][2],
30 | FLOAT pe[2], FLOAT pe_MS[2], FLOAT ener[2], int blocktype_d[2]);
31 |
32 | int L3psycho_anal_vbr(lame_internal_flags * gfc,
33 | const sample_t *const buffer[2], int gr,
34 | III_psy_ratio ratio[2][2],
35 | III_psy_ratio MS_ratio[2][2],
36 | FLOAT pe[2], FLOAT pe_MS[2], FLOAT ener[2], int blocktype_d[2]);
37 |
38 |
39 | int psymodel_init(lame_global_flags const* gfp);
40 |
41 |
42 | #define rpelev 2
43 | #define rpelev2 16
44 | #define rpelev_s 2
45 | #define rpelev2_s 16
46 |
47 | /* size of each partition band, in barks: */
48 | #define DELBARK .34
49 |
50 |
51 | /* tuned for output level (sensitive to energy scale) */
52 | #define VO_SCALE (1./( 14752*14752 )/(BLKSIZE/2))
53 |
54 | #define temporalmask_sustain_sec 0.01
55 |
56 | #define NS_PREECHO_ATT0 0.8
57 | #define NS_PREECHO_ATT1 0.6
58 | #define NS_PREECHO_ATT2 0.3
59 |
60 | #define NS_MSFIX 3.5
61 | #define NSATTACKTHRE 4.4
62 | #define NSATTACKTHRE_S 25
63 |
64 | #endif /* LAME_PSYMODEL_H */
65 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/quantize.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 quantization
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_QUANTIZE_H
23 | #define LAME_QUANTIZE_H
24 |
25 | void CBR_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
26 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
27 |
28 | void VBR_old_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
29 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
30 |
31 | void VBR_new_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
32 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
33 |
34 | void ABR_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
35 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
36 |
37 |
38 | #endif /* LAME_QUANTIZE_H */
39 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/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 |
104 |
105 | /* takehiro.c */
106 |
107 | int count_bits(lame_internal_flags const *const gfc, const FLOAT * const xr,
108 | gr_info * const cod_info, calc_noise_data * prev_noise);
109 | int noquant_count_bits(lame_internal_flags const *const gfc,
110 | gr_info * const cod_info, calc_noise_data * prev_noise);
111 |
112 |
113 | void best_huffman_divide(const lame_internal_flags * const gfc, gr_info * const cod_info);
114 |
115 | void best_scalefac_store(const lame_internal_flags * gfc, const int gr, const int ch,
116 | III_side_info_t * const l3_side);
117 |
118 | int scale_bitcount(const lame_internal_flags * gfc, gr_info * cod_info);
119 |
120 | void huffman_init(lame_internal_flags * const gfc);
121 |
122 | void init_xrpow_core_init(lame_internal_flags * const gfc);
123 |
124 | FLOAT athAdjust(FLOAT a, FLOAT x, FLOAT athFloor, float ATHfixpoint);
125 |
126 | #define LARGE_BITS 100000
127 |
128 | #endif /* LAME_QUANTIZE_PVT_H */
129 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/reservoir.h:
--------------------------------------------------------------------------------
1 | /*
2 | * bit reservoir include file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_RESERVOIR_H
23 | #define LAME_RESERVOIR_H
24 |
25 | int ResvFrameBegin(lame_internal_flags * gfc, int *mean_bits);
26 | void ResvMaxBits(lame_internal_flags * gfc, int mean_bits, int *targ_bits, int *max_bits,
27 | int cbr);
28 | void ResvAdjust(lame_internal_flags * gfc, gr_info const *gi);
29 | void ResvFrameEnd(lame_internal_flags * gfc, int mean_bits);
30 |
31 | #endif /* LAME_RESERVOIR_H */
32 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/set_get.h:
--------------------------------------------------------------------------------
1 | /*
2 | * set_get.h -- Internal set/get definitions
3 | *
4 | * Copyright (C) 2003 Gabriel Bouvigne / Lame project
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19 | */
20 |
21 | #ifndef __SET_GET_H__
22 | #define __SET_GET_H__
23 |
24 | #include "lame.h"
25 | #if defined(__cplusplus)
26 | extern "C" {
27 | #endif
28 |
29 | /* select psychoacoustic model */
30 |
31 | /* manage short blocks */
32 | int CDECL lame_set_short_threshold(lame_global_flags *, float, float);
33 | int CDECL lame_set_short_threshold_lrm(lame_global_flags *, float);
34 | float CDECL lame_get_short_threshold_lrm(const lame_global_flags *);
35 | int CDECL lame_set_short_threshold_s(lame_global_flags *, float);
36 | float CDECL lame_get_short_threshold_s(const lame_global_flags *);
37 |
38 |
39 | int CDECL lame_set_maskingadjust(lame_global_flags *, float);
40 | float CDECL lame_get_maskingadjust(const lame_global_flags *);
41 |
42 | int CDECL lame_set_maskingadjust_short(lame_global_flags *, float);
43 | float CDECL lame_get_maskingadjust_short(const lame_global_flags *);
44 |
45 | /* select ATH formula 4 shape */
46 | int CDECL lame_set_ATHcurve(lame_global_flags *, float);
47 | float CDECL lame_get_ATHcurve(const lame_global_flags *);
48 |
49 | int CDECL lame_set_preset_notune(lame_global_flags *, int);
50 |
51 | /* substep shaping method */
52 | int CDECL lame_set_substep(lame_global_flags *, int);
53 | int CDECL lame_get_substep(const lame_global_flags *);
54 |
55 | /* scalefactors scale */
56 | int CDECL lame_set_sfscale(lame_global_flags *, int);
57 | int CDECL lame_get_sfscale(const lame_global_flags *);
58 |
59 | /* subblock gain */
60 | int CDECL lame_set_subblock_gain(lame_global_flags *, int);
61 | int CDECL lame_get_subblock_gain(const lame_global_flags *);
62 |
63 |
64 |
65 | /*presets*/
66 | int apply_preset(lame_global_flags *, int preset, int enforce);
67 |
68 | void CDECL lame_set_tune(lame_t, float); /* FOR INTERNAL USE ONLY */
69 | void CDECL lame_set_msfix(lame_t gfp, double msfix);
70 |
71 |
72 | #if defined(__cplusplus)
73 | }
74 | #endif
75 | #endif
76 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/tables.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MPEG layer 3 tables include file
3 | *
4 | * Copyright (c) 1999 Albert L Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_TABLES_H
23 | #define LAME_TABLES_H
24 |
25 | #if 0
26 | typedef struct {
27 | unsigned char no;
28 | unsigned char width;
29 | unsigned char minval_2;
30 | float quiet_thr;
31 | float norm;
32 | float bark;
33 | } type1_t;
34 |
35 | typedef struct {
36 | unsigned char no;
37 | unsigned char width;
38 | float quiet_thr;
39 | float norm;
40 | float SNR;
41 | float bark;
42 | } type2_t;
43 |
44 | typedef struct {
45 | unsigned int no:5;
46 | unsigned int cbw:3;
47 | unsigned int bu:6;
48 | unsigned int bo:6;
49 | unsigned int w1_576:10;
50 | unsigned int w2_576:10;
51 | } type34_t;
52 |
53 | typedef struct {
54 | size_t len1;
55 | const type1_t *const tab1;
56 | size_t len2;
57 | const type2_t *const tab2;
58 | size_t len3;
59 | const type34_t *const tab3;
60 | size_t len4;
61 | const type34_t *const tab4;
62 | } type5_t;
63 |
64 | extern const type5_t table5[6];
65 |
66 | #endif
67 |
68 | #define HTN 34
69 |
70 | struct huffcodetab {
71 | const unsigned int xlen; /* max. x-index+ */
72 | const unsigned int linmax; /* max number to be stored in linbits */
73 | const uint16_t *table; /* pointer to array[xlen][ylen] */
74 | const uint8_t *hlen; /* pointer to array[xlen][ylen] */
75 | };
76 |
77 | extern const struct huffcodetab ht[HTN];
78 | /* global memory block */
79 | /* array of all huffcodtable headers */
80 | /* 0..31 Huffman code table 0..31 */
81 | /* 32,33 count1-tables */
82 |
83 | extern const uint8_t t32l[];
84 | extern const uint8_t t33l[];
85 |
86 | extern const uint32_t largetbl[16 * 16];
87 | extern const uint32_t table23[3 * 3];
88 | extern const uint32_t table56[4 * 4];
89 |
90 | extern const int scfsi_band[5];
91 |
92 | extern const int bitrate_table [3][16];
93 | extern const int samplerate_table [3][ 4];
94 |
95 | #endif /* LAME_TABLES_H */
96 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/vbrquantize.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 VBR quantization
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VBRQUANTIZE_H
23 | #define LAME_VBRQUANTIZE_H
24 |
25 | int VBR_encode_frame(lame_internal_flags * gfc, const FLOAT xr34orig[2][2][576],
26 | const FLOAT l3_xmin[2][2][SFBMAX], const int maxbits[2][2]);
27 |
28 | #endif /* LAME_VBRQUANTIZE_H */
29 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/vector/Makefile.am:
--------------------------------------------------------------------------------
1 | ## $Id: Makefile.am,v 1.1 2007/01/09 10:15:53 aleidinger Exp $
2 |
3 | include $(top_srcdir)/Makefile.am.global
4 |
5 | if WITH_XMM
6 | noinst_LTLIBRARIES = liblamevectorroutines.la
7 | endif
8 |
9 | ##liblamecpuroutines_la_LIBADD =
10 | ##liblamecpuroutines_la_LDFLAGS =
11 |
12 | INCLUDES = @INCLUDES@ \
13 | -I$(top_srcdir)/libmp3lame \
14 | -I$(top_srcdir)/mpglib \
15 | -I$(top_builddir)
16 |
17 | DEFS = @DEFS@ @CONFIG_DEFS@
18 |
19 | xmm_sources = xmm_quantize_sub.c
20 |
21 | if WITH_XMM
22 | liblamevectorroutines_la_SOURCES = $(xmm_sources)
23 | endif
24 |
25 | noinst_HEADERS = lame_intrin.h
26 |
27 | EXTRA_liblamevectorroutines_la_SOURCES = $(xmm_sources)
28 |
29 | CLEANFILES = lclint.txt
30 |
31 | LCLINTFLAGS= \
32 | +posixlib \
33 | +showsummary \
34 | +showalluses \
35 | +whichlib \
36 | +forcehints \
37 | -fixedformalarray \
38 | +matchanyintegral \
39 | -Dlint
40 |
41 | lclint.txt: ${liblamecpuroutines_la_SOURCES} ${noinst_HEADERS}
42 | @lclint ${LCLINTFLAGS} ${INCLUDES} ${DEFS} ${liblamecpuroutines_la_SOURCES} 2>&1 >lclint.txt || true
43 |
44 | lclint: lclint.txt
45 | more lclint.txt
46 |
47 | #$(OBJECTS): libtool
48 | #libtool: $(LIBTOOL_DEPS)
49 | # $(SHELL) $(top_builddir)/config.status --recheck
50 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/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 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/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)
55 | { /* primary to write screen reports */
56 | /* Here we can also add informations about compile time configurations */
57 |
58 | #if LAME_ALPHA_VERSION
59 | static /*@observer@ */ const char *const str =
60 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
61 | "(alpha " STR(LAME_PATCH_VERSION) ", " __DATE__ " " __TIME__ ")";
62 | #elif LAME_BETA_VERSION
63 | static /*@observer@ */ const char *const str =
64 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
65 | "(beta " STR(LAME_PATCH_VERSION) ", " __DATE__ ")";
66 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
67 | static /*@observer@ */ const char *const str =
68 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
69 | #else
70 | static /*@observer@ */ const char *const str =
71 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
72 | #endif
73 |
74 | return str;
75 | }
76 |
77 |
78 | /*! Get the short LAME version string. */
79 | /*!
80 | It's mainly for inclusion into the MP3 stream.
81 |
82 | \param void
83 | \return a pointer to the short version of the LAME version string.
84 | */
85 | const char *
86 | get_lame_short_version(void)
87 | {
88 | /* adding date and time to version string makes it harder for output
89 | validation */
90 |
91 | #if LAME_ALPHA_VERSION
92 | static /*@observer@ */ const char *const str =
93 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (alpha " STR(LAME_PATCH_VERSION) ")";
94 | #elif LAME_BETA_VERSION
95 | static /*@observer@ */ const char *const str =
96 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (beta " STR(LAME_PATCH_VERSION) ")";
97 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
98 | static /*@observer@ */ const char *const str =
99 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
100 | #else
101 | static /*@observer@ */ const char *const str =
102 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
103 | #endif
104 |
105 | return str;
106 | }
107 |
108 | /*! Get the _very_ short LAME version string. */
109 | /*!
110 | It's used in the LAME VBR tag only.
111 |
112 | \param void
113 | \return a pointer to the short version of the LAME version string.
114 | */
115 | const char *
116 | get_lame_very_short_version(void)
117 | {
118 | /* adding date and time to version string makes it harder for output
119 | validation */
120 | #if LAME_ALPHA_VERSION
121 | #define P "a"
122 | #elif LAME_BETA_VERSION
123 | #define P "b"
124 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
125 | #define P "r"
126 | #else
127 | #define P " "
128 | #endif
129 | static /*@observer@ */ const char *const str =
130 | #if (LAME_PATCH_VERSION > 0)
131 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P STR(LAME_PATCH_VERSION)
132 | #else
133 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
134 | #endif
135 | ;
136 | return str;
137 | }
138 |
139 | /*! Get the _very_ short LAME version string. */
140 | /*!
141 | It's used in the LAME VBR tag only, limited to 9 characters max.
142 | Due to some 3rd party HW/SW decoders, it has to start with LAME.
143 |
144 | \param void
145 | \return a pointer to the short version of the LAME version string.
146 | */
147 | const char*
148 | get_lame_tag_encoder_short_version(void)
149 | {
150 | static /*@observer@ */ const char *const str =
151 | /* FIXME: new scheme / new version counting / drop versioning here ? */
152 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
153 | ;
154 | return str;
155 | }
156 |
157 | /*! Get the version string for GPSYCHO. */
158 | /*!
159 | \param void
160 | \return a pointer to a string which describes the version of GPSYCHO.
161 | */
162 | const char *
163 | get_psy_version(void)
164 | {
165 | #if PSY_ALPHA_VERSION > 0
166 | static /*@observer@ */ const char *const str =
167 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
168 | " (alpha " STR(PSY_ALPHA_VERSION) ", " __DATE__ " " __TIME__ ")";
169 | #elif PSY_BETA_VERSION > 0
170 | static /*@observer@ */ const char *const str =
171 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
172 | " (beta " STR(PSY_BETA_VERSION) ", " __DATE__ ")";
173 | #else
174 | static /*@observer@ */ const char *const str =
175 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION);
176 | #endif
177 |
178 | return str;
179 | }
180 |
181 |
182 | /*! Get the URL for the LAME website. */
183 | /*!
184 | \param void
185 | \return a pointer to a string which is a URL for the LAME website.
186 | */
187 | const char *
188 | get_lame_url(void)
189 | {
190 | static /*@observer@ */ const char *const str = LAME_URL;
191 |
192 | return str;
193 | }
194 |
195 |
196 | /*! Get the numerical representation of the version. */
197 | /*!
198 | Writes the numerical representation of the version of LAME and
199 | GPSYCHO into lvp.
200 |
201 | \param lvp
202 | */
203 | void
204 | get_lame_version_numerical(lame_version_t * lvp)
205 | {
206 | static /*@observer@ */ const char *const features = ""; /* obsolete */
207 |
208 | /* generic version */
209 | lvp->major = LAME_MAJOR_VERSION;
210 | lvp->minor = LAME_MINOR_VERSION;
211 | #if LAME_ALPHA_VERSION
212 | lvp->alpha = LAME_PATCH_VERSION;
213 | lvp->beta = 0;
214 | #elif LAME_BETA_VERSION
215 | lvp->alpha = 0;
216 | lvp->beta = LAME_PATCH_VERSION;
217 | #else
218 | lvp->alpha = 0;
219 | lvp->beta = 0;
220 | #endif
221 |
222 | /* psy version */
223 | lvp->psy_major = PSY_MAJOR_VERSION;
224 | lvp->psy_minor = PSY_MINOR_VERSION;
225 | lvp->psy_alpha = PSY_ALPHA_VERSION;
226 | lvp->psy_beta = PSY_BETA_VERSION;
227 |
228 | /* compile time features */
229 | /*@-mustfree@ */
230 | lvp->features = features;
231 | /*@=mustfree@ */
232 | }
233 |
234 |
235 | const char *
236 | get_lame_os_bitness(void)
237 | {
238 | static /*@observer@ */ const char *const strXX = "";
239 | static /*@observer@ */ const char *const str32 = "32bits";
240 | static /*@observer@ */ const char *const str64 = "64bits";
241 |
242 | switch (sizeof(void *)) {
243 | case 4:
244 | return str32;
245 |
246 | case 8:
247 | return str64;
248 |
249 | default:
250 | return strXX;
251 | }
252 | }
253 |
254 | /* end of version.c */
255 |
--------------------------------------------------------------------------------
/library_audio/src/main/cpp/libmp3lame/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Version numbering for LAME.
3 | *
4 | * Copyright (c) 1999 A.L. Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VERSION_H
23 | #define LAME_VERSION_H
24 |
25 |
26 | /*
27 | * To make a string from a token, use the # operator:
28 | */
29 | #ifndef STR
30 | # define __STR(x) #x
31 | # define STR(x) __STR(x)
32 | #endif
33 |
34 | # define LAME_URL "http://lame.sf.net"
35 |
36 |
37 | # define LAME_MAJOR_VERSION 3 /* Major version number */
38 | # define LAME_MINOR_VERSION 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 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/AudioCapture.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio;
2 |
3 | import android.media.AudioFormat;
4 | import android.media.AudioRecord;
5 | import android.media.MediaRecorder;
6 | import android.os.SystemClock;
7 | import android.util.Log;
8 |
9 | import java.nio.ByteBuffer;
10 | import java.nio.ByteOrder;
11 |
12 | /**
13 | * 音频采集,边采集边转码MP3
14 | */
15 | public class AudioCapture {
16 |
17 | private static final String TAG = "AudioCapture.class";
18 |
19 | //默认参数
20 | private static final int AUDIO_SOURCE = MediaRecorder.AudioSource.MIC;
21 | private static final int SAMPLE_RATE = 44100;
22 | private static final int CHANNEL_CONFIGS = AudioFormat.CHANNEL_IN_STEREO;
23 | private static final int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
24 | public static int bufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIGS, AUDIO_FORMAT);
25 |
26 | private boolean isStartRecord = false;
27 | private boolean isStopRecord = false;
28 | private boolean isDebug = true;
29 |
30 | private AudioRecord audioRecord;
31 |
32 | /**
33 | * 采集回调监听
34 | */
35 | private AudioCaptureListener captureListener;
36 |
37 | /**
38 | * 采集子线程
39 | */
40 | private Thread threadCapture;
41 |
42 | public void start() {
43 | start(AUDIO_SOURCE, SAMPLE_RATE, CHANNEL_CONFIGS, AUDIO_FORMAT);
44 | }
45 |
46 | public void start(int audioSource, int sampleRate, int channels, int audioFormat) {
47 | if (isStartRecord) {
48 | if (isDebug)
49 | Log.d(TAG, "音频录制已经开启");
50 | return;
51 | }
52 |
53 | //各厂商实现存在差异
54 | bufferSize = AudioRecord.getMinBufferSize(sampleRate, channels, audioFormat);
55 |
56 | if (bufferSize == AudioRecord.ERROR_BAD_VALUE) {
57 | if (isDebug)
58 | Log.d(TAG, "无效参数");
59 | return;
60 | }
61 |
62 | if (isDebug)
63 | Log.d(TAG, "bufferSize = ".concat(String.valueOf(bufferSize)).concat(" byte"));
64 |
65 | isStartRecord = true;
66 | isStopRecord = false;
67 |
68 | audioRecord = new AudioRecord(AudioCapture.AUDIO_SOURCE, sampleRate, channels, audioFormat, bufferSize);
69 | audioRecord.startRecording();
70 |
71 | threadCapture = new Thread(new CaptureRunnable());
72 | threadCapture.start();
73 |
74 | if (isDebug) {
75 | Log.d(TAG, "音频录制开启...");
76 | }
77 | }
78 |
79 | public void stop() {
80 | if (!isStartRecord) {
81 | return;
82 | }
83 | isStopRecord = true;
84 | threadCapture.interrupt();
85 |
86 | audioRecord.stop();
87 | audioRecord.release();
88 |
89 | isStartRecord = false;
90 | }
91 |
92 | /**
93 | * 子线程读取采集到的数据
94 | */
95 | private class CaptureRunnable implements Runnable {
96 |
97 | @Override
98 | public void run() {
99 | while (!isStopRecord) {
100 | short[] pcmBuffer = new short[bufferSize];
101 | // byte[] pcmBuffer = new byte[bufferSize];
102 | int readRecord = audioRecord.read(pcmBuffer, 0, bufferSize);
103 | if (readRecord > 0) {
104 | if (captureListener != null)
105 | captureListener.onCaptureListener(pcmBuffer, readRecord);
106 | if (isDebug) {
107 | Log.d(TAG, "音频采集数据源 -- ".concat(String.valueOf(readRecord)).concat(" -- bytes"));
108 | }
109 | } else {
110 | if (isDebug)
111 | Log.d(TAG, "录音采集异常");
112 | }
113 | //延迟写入 SystemClock -- Android专用
114 | SystemClock.sleep(10);
115 | }
116 | }
117 | }
118 |
119 | public interface AudioCaptureListener {
120 |
121 | /**
122 | * 音频采集回调数据源
123 | *
124 | * @param audioSource :音频采集回调数据源
125 | * @param audioReadSize :每次读取数据的大小
126 | */
127 | void onCaptureListener(byte[] audioSource, int audioReadSize);
128 |
129 | void onCaptureListener(short[] audioSource, int audioReadSize);
130 | }
131 |
132 | public AudioCaptureListener getCaptureListener() {
133 | return captureListener;
134 | }
135 |
136 | public void setCaptureListener(AudioCaptureListener captureListener) {
137 | this.captureListener = captureListener;
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/AudioPlayInterface.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio;
2 |
3 | /**
4 | * 音乐播放控制接口,与AudioPlayer中方法一致
5 | */
6 | public interface AudioPlayInterface {
7 |
8 | void start();
9 |
10 | void pause();
11 |
12 | void stop();
13 |
14 | boolean isPlaying();
15 |
16 | boolean isComplete();
17 |
18 | void seekTo(int progress);
19 |
20 | int getDuration();
21 |
22 | int getCurrentPosition();
23 | }
24 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/AudioPlayService.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.media.AudioManager;
6 | import android.media.MediaPlayer;
7 | import android.os.Binder;
8 | import android.os.IBinder;
9 | import android.util.Log;
10 |
11 | import java.util.Timer;
12 | import java.util.TimerTask;
13 |
14 | /**
15 | * 播放service
16 | */
17 | public class AudioPlayService extends Service {
18 | private final String TAG = AudioPlayService.class.getSimpleName();
19 | private AudioPlayer audioPlayer;
20 | //系统音频管理工具
21 | private AudioManager audioManager;
22 | //定时发送进度更新
23 | private Timer timer;
24 | //标记是否播放完成
25 | private boolean isComplete;
26 | //标记是否获得音频焦点
27 | private boolean isFocusGranted;
28 | private MediaPlayListener listener;
29 |
30 | public void setListener(MediaPlayListener listener) {
31 | this.listener = listener;
32 | }
33 |
34 | @Override
35 | public void onCreate() {
36 | super.onCreate();
37 | audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
38 | isFocusGranted = requestAudioFocus();
39 | Log.d(TAG, "onCreate: 获取音频焦点" + isFocusGranted);
40 | }
41 |
42 | @Override
43 | public IBinder onBind(Intent intent) {
44 | return new AudioPlayManager();
45 | }
46 |
47 | @Override
48 | public void onDestroy() {
49 | super.onDestroy();
50 | if (audioPlayer != null)
51 | audioPlayer.stop();
52 | if (timer != null)
53 | timer.cancel();
54 | if (audioManager != null)
55 | audioManager.abandonAudioFocus(audioFocusListener);//放弃音频焦点
56 | listener = null;
57 | isFocusGranted = false;
58 | }
59 |
60 | /**
61 | * 申请获取音频焦点
62 | */
63 | private boolean requestAudioFocus() {
64 | int requestResult = audioManager.requestAudioFocus(audioFocusListener, AudioManager.STREAM_MUSIC,
65 | AudioManager.AUDIOFOCUS_GAIN);
66 | //返回是否授权
67 | return requestResult == AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
68 | }
69 |
70 | //单独定义listener
71 | AudioManager.OnAudioFocusChangeListener audioFocusListener = new AudioManager.OnAudioFocusChangeListener() {
72 | public void onAudioFocusChange(int focusChange) {
73 | if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT) {
74 | //暂时失去音频焦点,暂停MediaPlayer
75 | audioPlayer.pause();
76 | } else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) {
77 | //获得音频焦点
78 | audioPlayer.start();
79 | } else if (focusChange == AudioManager.AUDIOFOCUS_LOSS) {
80 | //失去音频焦点,释放MediaPlayer
81 | audioManager.abandonAudioFocus(audioFocusListener);
82 | audioPlayer.stop();
83 | }
84 | }
85 | };
86 |
87 | /**
88 | * 提供上层调用方法 -- AudioPlayManager
89 | */
90 | public class AudioPlayManager extends Binder implements AudioPlayInterface, AudioPlayer.AudioPlayerListener {
91 |
92 | public void initPlayer(String dataSource, int sourceType, MediaPlayListener mediaPlayListener) {
93 | audioPlayer = new AudioPlayer(dataSource, sourceType);
94 | audioPlayer.setListener(this);
95 | setListener(mediaPlayListener);
96 | }
97 |
98 | @Override
99 | public void start() {
100 | //播放完成继续播放 -- 清空完成标记(MediaPlayer并未reset)
101 | audioPlayer.setComplete(false);
102 | audioPlayer.start();
103 | sendPlayProgress();
104 | }
105 |
106 | @Override
107 | public void pause() {
108 | audioPlayer.pause();
109 | if (listener != null)
110 | listener.onPause(audioPlayer.getCurrentPosition());
111 | }
112 |
113 | @Override
114 | public void stop() {
115 | audioPlayer.stop();
116 | }
117 |
118 | @Override
119 | public boolean isPlaying() {
120 | return audioPlayer.isPlaying();
121 | }
122 |
123 | @Override
124 | public boolean isComplete() {
125 | return audioPlayer.isComplete();
126 | }
127 |
128 | @Override
129 | public void seekTo(int progress) {
130 | audioPlayer.seekTo(progress);
131 | }
132 |
133 | @Override
134 | public int getDuration() {
135 | return audioPlayer.getDuration();
136 | }
137 |
138 | @Override
139 | public int getCurrentPosition() {
140 | return audioPlayer.getCurrentPosition();
141 | }
142 |
143 | @Override
144 | public void onPrepared(MediaPlayer mp) {
145 | //prepared
146 | if (listener != null)
147 | listener.onPrepared(mp);
148 | }
149 |
150 | @Override
151 | public void onComplete(MediaPlayer mp) {
152 | //complete
153 | if (listener != null)
154 | listener.onComplete(mp);
155 | }
156 |
157 | @Override
158 | public void onError(MediaPlayer mp, int what, int extra) {
159 | //error
160 | if (listener != null)
161 | listener.onError(mp, what, extra);
162 | }
163 | }
164 |
165 | /**
166 | * 开始播放后子线程定时发送进度信息
167 | */
168 | private void sendPlayProgress() {
169 | if (timer == null) {
170 | timer = new Timer();
171 | }
172 | timer.schedule(new TimerTask() {
173 | @Override
174 | public void run() {
175 | boolean isPaused = !audioPlayer.isPlaying() && audioPlayer.getCurrentPosition() > 1;
176 | if (isPaused) {
177 | //播放器处于暂停状态,停止发送进度
178 | return;
179 | }
180 | if (audioPlayer.isPlaying()) {
181 | //正在播放中,回调播放进度
182 | int currentPosition = audioPlayer.getCurrentPosition();
183 | if (listener != null)
184 | listener.onPlaying(currentPosition);
185 | } else if (audioPlayer.isComplete()) {
186 | //播放完成 -- 返回音频最大值
187 | int currentPosition = audioPlayer.getDuration();
188 | if (listener != null)
189 | listener.onPlaying(currentPosition);
190 | timer.cancel();
191 | } else {
192 | int currentPosition = 0;
193 | if (listener != null)
194 | listener.onPlaying(currentPosition);
195 | timer.cancel();
196 | }
197 | }
198 | }, 200, 200);
199 | }
200 |
201 | /**
202 | * 播放进度监听
203 | */
204 | public interface MediaPlayListener {
205 | //播放中
206 | void onPlaying(int duration);
207 |
208 | //暂停中
209 | void onPause(int duration);
210 |
211 | //准备完成
212 | void onPrepared(MediaPlayer mp);
213 |
214 | //播放完成
215 | void onComplete(MediaPlayer mp);
216 |
217 | //初始化、播放出错
218 | void onError(MediaPlayer mp, int what, int extra);
219 | }
220 | }
221 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/AudioPlayer.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio;
2 |
3 | import android.content.Context;
4 | import android.media.AudioManager;
5 | import android.media.MediaPlayer;
6 | import android.net.Uri;
7 | import android.util.Log;
8 |
9 | /**
10 | * 封装MediaPlayer播放音频
11 | */
12 | public class AudioPlayer {
13 |
14 | private final String TAG = AudioPlayer.class.getSimpleName();
15 |
16 | private MediaPlayer mediaPlayer;
17 | //播放源
18 | private String dataSource;
19 |
20 | private AudioPlayerListener listener;
21 |
22 | //是否完全播放完成
23 | private boolean isComplete;
24 |
25 |
26 | public AudioPlayerListener getListener() {
27 | return listener;
28 | }
29 |
30 | public void setListener(AudioPlayerListener listener) {
31 | this.listener = listener;
32 | }
33 |
34 | public AudioPlayer(String dataSource, int sourceType) {
35 | initPlayer(dataSource, sourceType);
36 | }
37 |
38 | /**
39 | * 初始化player
40 | *
41 | * @param dataSource :播放源
42 | * @param sourceType :播放源类型,0 表示本地资源,1 表示网络资源
43 | */
44 | private void initPlayer(String dataSource, int sourceType) {
45 | resetPlayer();
46 |
47 | mediaPlayer = new MediaPlayer();
48 |
49 | // 准备好的监听
50 | mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
51 | @Override
52 | public void onPrepared(MediaPlayer mp) {
53 | if (listener != null) {
54 | listener.onPrepared(mp);
55 | }
56 | }
57 | });
58 |
59 | mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
60 | @Override
61 | public void onCompletion(MediaPlayer mp) {
62 | isComplete = true;
63 | if (listener != null)
64 | listener.onComplete(mp);
65 | }
66 | });
67 |
68 | mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
69 | @Override
70 | public boolean onError(MediaPlayer mp, int what, int extra) {
71 | if (listener != null) {
72 | listener.onError(mp, what, extra);
73 | }
74 | return true;
75 | }
76 | });
77 |
78 | try {
79 | mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
80 | mediaPlayer.setScreenOnWhilePlaying(true);
81 | if (sourceType == 0) {
82 | mediaPlayer.setDataSource(dataSource);
83 | mediaPlayer.prepare();
84 | }/* else {
85 | mediaPlayer.setDataSource(context, Uri.parse("路径地址"));
86 | mediaPlayer.prepareAsync();
87 | }*/
88 | Log.d(TAG, "initPlayer: 初始化MediaPlayer");
89 | } catch (Exception e) {
90 | e.printStackTrace();
91 | Log.d(TAG, "initPlayer: 初始化失败");
92 | if (listener != null)
93 | listener.onError(mediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
94 | }
95 | }
96 |
97 | public void start() {
98 | if (mediaPlayer.isPlaying()) {
99 | return;
100 | }
101 | mediaPlayer.start();
102 | }
103 |
104 | public void pause() {
105 | if (mediaPlayer.isPlaying()) {
106 | mediaPlayer.pause();
107 | }
108 | }
109 |
110 | public void stop() {
111 | if (mediaPlayer != null) {
112 | mediaPlayer.stop();
113 | mediaPlayer.release();
114 | isComplete = false;
115 | }
116 | }
117 |
118 | /**
119 | * 重置player
120 | */
121 | private void resetPlayer() {
122 | if (mediaPlayer != null) {
123 | mediaPlayer.reset();
124 | mediaPlayer.release();
125 | isComplete = false;
126 | }
127 | }
128 |
129 | //状态
130 | public boolean isPlaying() {
131 | if (mediaPlayer == null) {
132 | return false;
133 | }
134 | return mediaPlayer.isPlaying();
135 | }
136 |
137 | //跳转播放
138 | public void seekTo(int progress) {
139 | if (mediaPlayer != null) {
140 | mediaPlayer.seekTo(progress);
141 | }
142 | }
143 |
144 | //获取时长
145 | public int getDuration() {
146 | if (mediaPlayer != null) {
147 | return mediaPlayer.getDuration();
148 | }
149 | return 0;
150 | }
151 |
152 | //获取当前播放位置
153 | public int getCurrentPosition() {
154 | if (mediaPlayer != null) {
155 | return mediaPlayer.getCurrentPosition();
156 | }
157 | return 0;
158 | }
159 |
160 | //获取播放完成状态
161 | public boolean isComplete() {
162 | return isComplete;
163 | }
164 |
165 | public void setComplete(boolean isComplete) {
166 | this.isComplete = isComplete;
167 | }
168 |
169 | /**
170 | * 状态监听
171 | */
172 | public interface AudioPlayerListener {
173 | void onPrepared(MediaPlayer mp);
174 |
175 | void onComplete(MediaPlayer mp);
176 |
177 | void onError(MediaPlayer mp, int what, int extra);
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/LameEncode.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio;
2 |
3 | /**
4 | * 调用lame-lib.so中的native方法
5 | */
6 | public class LameEncode {
7 | //加载lame-lib.so
8 | static {
9 | System.loadLibrary("lame-lib");
10 | }
11 |
12 | /**
13 | * 初始化lame,cpp中初始化采用lame默认参数配置
14 | *
15 | * @param sampleRate :采样率 -- 录音默认44100
16 | * @param channelCount :通道数 -- 录音默认双通道2
17 | * @param audioFormatBit :位宽 -- 录音默认ENCODING_PCM_16BIT 16bit
18 | * @param quality :MP3音频质量 0~9 其中0是最好,非常慢,9是最差 2=high(高) 5 = medium(中) 7=low(低)
19 | */
20 | public static native void init(int sampleRate, int channelCount, int audioFormatBit, int quality);
21 |
22 | /**
23 | * 启用lame编码
24 | *
25 | * @param pcmBuffer :音频数据源
26 | * @param mp3_buffer :写入MP3数据buffer
27 | * @param sample_num :采样个数
28 | */
29 | public static native int encoder(short[] pcmBuffer, byte[] mp3_buffer, int sample_num);
30 |
31 | /**
32 | * 刷新缓冲器
33 | *
34 | * @param mp3_buffer :MP3编码buffer
35 | * @return int 返回剩余编码器字节数据,需要写入文件
36 | */
37 | public static native int flush(byte[] mp3_buffer);
38 |
39 | /**
40 | * 释放编码器
41 | */
42 | public static native void close();
43 | }
44 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/utils/ByteUtils.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio.utils;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.RandomAccessFile;
7 | import java.nio.ByteBuffer;
8 | import java.util.Arrays;
9 |
10 | /**
11 | * 字节转换工具
12 | */
13 | public class ByteUtils {
14 | private static final String TAG = ByteUtils.class.getSimpleName();
15 |
16 | /**
17 | * short[] 转 byte[]
18 | */
19 | public static byte[] toBytes(short[] src) {
20 | int count = src.length;
21 | byte[] dest = new byte[count << 1];
22 | for (int i = 0; i < count; i++) {
23 | dest[i * 2] = (byte) (src[i]);
24 | dest[i * 2 + 1] = (byte) (src[i] >> 8);
25 | }
26 |
27 | return dest;
28 | }
29 |
30 | /**
31 | * 浮点转换为字节
32 | */
33 | public static byte[] toBytes(float f) {
34 | // 把float转换为byte[]
35 | int fbit = Float.floatToIntBits(f);
36 |
37 | byte[] b = new byte[4];
38 | for (int i = 0; i < 4; i++) {
39 | b[i] = (byte) (fbit >> (24 - i * 8));
40 | }
41 |
42 | int len = b.length;
43 | byte[] dest = new byte[len];
44 | System.arraycopy(b, 0, dest, 0, len);
45 | byte temp;
46 | for (int i = 0; i < len / 2; ++i) {
47 | temp = dest[i];
48 | dest[i] = dest[len - i - 1];
49 | dest[len - i - 1] = temp;
50 | }
51 | return dest;
52 |
53 | }
54 |
55 | public static byte[] byteMerger(byte[] bt1, byte[] bt2) {
56 | byte[] bt3 = new byte[bt1.length + bt2.length];
57 | System.arraycopy(bt1, 0, bt3, 0, bt1.length);
58 | System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
59 | return bt3;
60 | }
61 |
62 | /**
63 | * short[] 转 byte[]
64 | */
65 | public static byte[] toBytes(short src) {
66 | byte[] dest = new byte[2];
67 | dest[0] = (byte) (src);
68 | dest[1] = (byte) (src >> 8);
69 |
70 | return dest;
71 | }
72 |
73 | /**
74 | * int 转 byte[]
75 | */
76 | public static byte[] toBytes(int i) {
77 | byte[] b = new byte[4];
78 | b[0] = (byte) (i & 0xff);
79 | b[1] = (byte) ((i >> 8) & 0xff);
80 | b[2] = (byte) ((i >> 16) & 0xff);
81 | b[3] = (byte) ((i >> 24) & 0xff);
82 | return b;
83 | }
84 |
85 |
86 | /**
87 | * String 转 byte[]
88 | */
89 | public static byte[] toBytes(String str) {
90 | return str.getBytes();
91 | }
92 |
93 | /**
94 | * long类型转成byte数组
95 | */
96 | public static byte[] toBytes(long number) {
97 | ByteBuffer buffer = ByteBuffer.allocate(8);
98 | buffer.putLong(0, number);
99 | return buffer.array();
100 | }
101 |
102 | public static int toInt(byte[] src, int offset) {
103 | return ((src[offset] & 0xFF)
104 | | ((src[offset + 1] & 0xFF) << 8)
105 | | ((src[offset + 2] & 0xFF) << 16)
106 | | ((src[offset + 3] & 0xFF) << 24));
107 | }
108 |
109 | public static int toInt(byte[] src) {
110 | return toInt(src, 0);
111 | }
112 |
113 | /**
114 | * 字节数组到long的转换.
115 | */
116 | public static long toLong(byte[] b) {
117 | ByteBuffer buffer = ByteBuffer.allocate(8);
118 | buffer.put(b, 0, b.length);
119 | return buffer.getLong();
120 | }
121 |
122 | /**
123 | * byte[] 转 short[]
124 | * short: 2字节
125 | */
126 | public static short[] toShorts(byte[] src) {
127 | int count = src.length >> 1;
128 | short[] dest = new short[count];
129 | for (int i = 0; i < count; i++) {
130 | dest[i] = (short) ((src[i * 2] & 0xff) | ((src[2 * i + 1] & 0xff) << 8));
131 | }
132 | return dest;
133 | }
134 |
135 | public static byte[] merger(byte[] bt1, byte[] bt2) {
136 | byte[] bt3 = new byte[bt1.length + bt2.length];
137 | System.arraycopy(bt1, 0, bt3, 0, bt1.length);
138 | System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
139 | return bt3;
140 | }
141 |
142 | public static String toString(byte[] b) {
143 | return Arrays.toString(b);
144 | }
145 |
146 | /**
147 | * 将byte[] 追加到文件末尾
148 | */
149 | public static void byte2File(byte[] buf, File file) {
150 | try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) {
151 | long fileLength = file.length();
152 | randomAccessFile.seek(fileLength);
153 | randomAccessFile.write(buf);
154 | } catch (Exception e) {
155 | }
156 | }
157 |
158 | /**
159 | * 将byte[] 追加到文件末尾
160 | */
161 | public static byte[] byte2FileForResult(byte[] buf, File file) {
162 | try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) {
163 | long fileLength = file.length();
164 | randomAccessFile.seek(fileLength);
165 | randomAccessFile.write(buf);
166 | } catch (Exception e) {
167 | }
168 | return file2Bytes(file);
169 |
170 | }
171 |
172 |
173 | public static byte[] file2Bytes(File file) {
174 |
175 | byte[] buffer = null;
176 | try (FileInputStream fis = new FileInputStream(file);
177 | ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
178 |
179 | byte[] b = new byte[1024];
180 | int n;
181 | while ((n = fis.read(b)) != -1) {
182 | bos.write(b, 0, n);
183 | }
184 | buffer = bos.toByteArray();
185 | } catch (Exception e) {
186 | }
187 | return buffer;
188 | }
189 |
190 | public static double[] toHardDouble(short[] shorts) {
191 | int length = 512;
192 | double[] ds = new double[length];
193 | for (int i = 0; i < length; i++) {
194 | ds[i] = shorts[i];
195 | }
196 | return ds;
197 | }
198 |
199 | public static byte[] toHardBytes(double[] doubles) {
200 | byte[] bytes = new byte[doubles.length];
201 | for (int i = 0; i < doubles.length; i++) {
202 | double item = doubles[i];
203 | bytes[i] = (byte) (item > 127 ? 127 : item);
204 | }
205 | return bytes;
206 | }
207 |
208 | public static short[] toHardShort(double[] doubles) {
209 | short[] bytes = new short[doubles.length];
210 | for (int i = 0; i < doubles.length; i++) {
211 | double item = doubles[i];
212 | bytes[i] = (short) (item > 32767 ? 32767 : item);
213 | }
214 | return bytes;
215 | }
216 |
217 | public static byte[] toSoftBytes(double[] doubles) {
218 | double max = getMax(doubles);
219 |
220 | double sc = 1f;
221 | if (max > 127) {
222 | sc = (max / 128f);
223 | }
224 |
225 | byte[] bytes = new byte[doubles.length];
226 | for (int i = 0; i < doubles.length; i++) {
227 | double item = doubles[i] / sc;
228 | bytes[i] = (byte) (item > 127 ? 127 : item);
229 | }
230 | return bytes;
231 | }
232 |
233 | public static short[] toSoftShorts(double[] doubles) {
234 | double max = getMax(doubles);
235 |
236 | double sc = 1f;
237 | if (max > 127) {
238 | sc = (max / 128f);
239 | }
240 |
241 | short[] bytes = new short[doubles.length];
242 | for (int i = 0; i < doubles.length; i++) {
243 | double item = doubles[i] / sc;
244 | bytes[i] = (short) (item > 32767 ? 32767 : item);
245 | }
246 | return bytes;
247 | }
248 |
249 | public static double getMax(double[] data) {
250 | double max = 0;
251 | for (int i = 0; i < data.length; i++) {
252 | if (data[i] > max) {
253 | max = data[i];
254 | }
255 | }
256 | return max;
257 | }
258 | }
259 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/utils/Complex.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio.utils;
2 |
3 | import java.util.Objects;
4 |
5 | /**
6 | * 复数
7 | *
8 | * @author test
9 | */
10 | public class Complex {
11 |
12 | /**
13 | * 实数部分
14 | */
15 | private final double real;
16 |
17 | /**
18 | * 虚数部分 imaginary
19 | */
20 | private final double im;
21 |
22 | public Complex(double real, double imag) {
23 | this.real = real;
24 | im = imag;
25 | }
26 |
27 | @Override
28 | public String toString() {
29 | return String.format("hypot: %s, complex: %s+%si", hypot(), real, im);
30 | }
31 |
32 | public double hypot() {
33 | return Math.hypot(real, im);
34 | }
35 |
36 | public double phase() {
37 | return Math.atan2(im, real);
38 | }
39 |
40 | /**
41 | * 复数求和
42 | */
43 | public Complex plus(Complex b) {
44 | double real = this.real + b.real;
45 | double imag = this.im + b.im;
46 | return new Complex(real, imag);
47 | }
48 |
49 | // return a new Complex object whose value is (this - b)
50 | public Complex minus(Complex b) {
51 | double real = this.real - b.real;
52 | double imag = this.im - b.im;
53 | return new Complex(real, imag);
54 | }
55 |
56 | // return a new Complex object whose value is (this * b)
57 | public Complex times(Complex b) {
58 | Complex a = this;
59 | double real = a.real * b.real - a.im * b.im;
60 | double imag = a.real * b.im + a.im * b.real;
61 | return new Complex(real, imag);
62 | }
63 |
64 | // return a new object whose value is (this * alpha)
65 | public Complex scale(double alpha) {
66 | return new Complex(alpha * real, alpha * im);
67 | }
68 |
69 | // return a new Complex object whose value is the conjugate of this
70 | public Complex conjugate() {
71 | return new Complex(real, -im);
72 | }
73 |
74 | // return a new Complex object whose value is the reciprocal of this
75 | public Complex reciprocal() {
76 | double scale = real * real + im * im;
77 | return new Complex(real / scale, -im / scale);
78 | }
79 |
80 | // return the real or imaginary part
81 | public double re() {
82 | return real;
83 | }
84 |
85 | public double im() {
86 | return im;
87 | }
88 |
89 | // return a / b
90 | public Complex divides(Complex b) {
91 | Complex a = this;
92 | return a.times(b.reciprocal());
93 | }
94 |
95 | // return a new Complex object whose value is the complex exponential of this
96 | public Complex exp() {
97 | return new Complex(Math.exp(real) * Math.cos(im), Math.exp(real) * Math.sin(im));
98 | }
99 |
100 | // return a new Complex object whose value is the complex sine of this
101 | public Complex sin() {
102 | return new Complex(Math.sin(real) * Math.cosh(im), Math.cos(real) * Math.sinh(im));
103 | }
104 |
105 | // return a new Complex object whose value is the complex cosine of this
106 | public Complex cos() {
107 | return new Complex(Math.cos(real) * Math.cosh(im), -Math.sin(real) * Math.sinh(im));
108 | }
109 |
110 | // return a new Complex object whose value is the complex tangent of this
111 | public Complex tan() {
112 | return sin().divides(cos());
113 | }
114 |
115 |
116 | // a static version of plus
117 | public static Complex plus(Complex a, Complex b) {
118 | double real = a.real + b.real;
119 | double imag = a.im + b.im;
120 | Complex sum = new Complex(real, imag);
121 | return sum;
122 | }
123 |
124 | // See Section 3.3.
125 | @Override
126 | public boolean equals(Object x) {
127 | if (x == null) return false;
128 | if (this.getClass() != x.getClass()) return false;
129 | Complex that = (Complex) x;
130 | return (this.real == that.real) && (this.im == that.im);
131 | }
132 |
133 | // See Section 3.3.
134 | @Override
135 | public int hashCode() {
136 | return Objects.hash(real, im);
137 | }
138 |
139 | }
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/utils/FFT.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio.utils;
2 |
3 |
4 | public class FFT {
5 |
6 | // compute the FFT of x[], assuming its length is a power of 2
7 | public static Complex[] fft(Complex[] x) {
8 | int n = x.length;
9 |
10 | // base case
11 | if (n == 1) return new Complex[]{x[0]};
12 |
13 | // radix 2 Cooley-Tukey FFT
14 | if (n % 2 != 0) {
15 | throw new IllegalArgumentException("n is not a power of 2");
16 | }
17 |
18 | // fft of even terms
19 | Complex[] even = new Complex[n / 2];
20 | for (int k = 0; k < n / 2; k++) {
21 | even[k] = x[2 * k];
22 | }
23 | Complex[] q = fft(even);
24 |
25 | // fft of odd terms
26 | for (int k = 0; k < n / 2; k++) {
27 | even[k] = x[2 * k + 1];
28 | }
29 | Complex[] r = fft(even);
30 |
31 | // combine
32 | Complex[] y = new Complex[n];
33 | for (int k = 0; k < n / 2; k++) {
34 | double kth = -2 * k * Math.PI / n;
35 | Complex wk = new Complex(Math.cos(kth), Math.sin(kth));
36 | y[k] = q[k].plus(wk.times(r[k]));
37 | y[k + n / 2] = q[k].minus(wk.times(r[k]));
38 | }
39 | return y;
40 | }
41 |
42 | public static double[] fft(double[] x, int sc) {
43 | int len = x.length;
44 | if (len == 1) {
45 | return x;
46 | }
47 | Complex[] cs = new Complex[len];
48 | double[] ds = new double[len / 2];
49 | for (int i = 0; i < len; i++) {
50 | cs[i] = new Complex(x[i], 0);
51 | }
52 | Complex[] ffts = fft(cs);
53 |
54 | for (int i = 0; i < ds.length; i++) {
55 | ds[i] = Math.sqrt(Math.pow(ffts[i].re(), 2) + Math.pow(ffts[i].im(), 2)) / x.length;
56 | }
57 | return ds;
58 | }
59 |
60 | // compute the inverse FFT of x[], assuming its length is a power of 2
61 | public static Complex[] ifft(Complex[] x) {
62 | int n = x.length;
63 | Complex[] y = new Complex[n];
64 |
65 | // take conjugate
66 | for (int i = 0; i < n; i++) {
67 | y[i] = x[i].conjugate();
68 | }
69 |
70 | // compute forward FFT
71 | y = fft(y);
72 |
73 | // take conjugate again
74 | for (int i = 0; i < n; i++) {
75 | y[i] = y[i].conjugate();
76 | }
77 |
78 | // divide by n
79 | for (int i = 0; i < n; i++) {
80 | y[i] = y[i].scale(1.0 / n);
81 | }
82 |
83 | return y;
84 |
85 | }
86 |
87 | // compute the circular convolution of x and y
88 | public static Complex[] cconvolve(Complex[] x, Complex[] y) {
89 |
90 | // should probably pad x and y with 0s so that they have same length
91 | // and are powers of 2
92 | if (x.length != y.length) {
93 | throw new IllegalArgumentException("Dimensions don't agree");
94 | }
95 |
96 | int n = x.length;
97 |
98 | // compute FFT of each sequence
99 | Complex[] a = fft(x);
100 | Complex[] b = fft(y);
101 |
102 | // point-wise multiply
103 | Complex[] c = new Complex[n];
104 | for (int i = 0; i < n; i++) {
105 | c[i] = a[i].times(b[i]);
106 | }
107 |
108 | // compute inverse FFT
109 | return ifft(c);
110 | }
111 |
112 |
113 | // compute the linear convolution of x and y
114 | public static Complex[] convolve(Complex[] x, Complex[] y) {
115 | Complex ZERO = new Complex(0, 0);
116 |
117 | Complex[] a = new Complex[2 * x.length];
118 | for (int i = 0; i < x.length; i++) a[i] = x[i];
119 | for (int i = x.length; i < 2 * x.length; i++) a[i] = ZERO;
120 |
121 | Complex[] b = new Complex[2 * y.length];
122 | for (int i = 0; i < y.length; i++) b[i] = y[i];
123 | for (int i = y.length; i < 2 * y.length; i++) b[i] = ZERO;
124 |
125 | return cconvolve(a, b);
126 | }
127 |
128 | // display an array of Complex numbers to standard output
129 | public static void show(Complex[] x, String title) {
130 | System.out.println(title);
131 | System.out.println("-------------------");
132 | for (int i = 0; i < SIZE; i++) {
133 | System.out.println(x[i]);
134 | }
135 | System.out.println();
136 | }
137 |
138 | private static final int SIZE = 16384 / 4;
139 |
140 | public static double fun(int x) {
141 | return Math.sin(15f * x);//f= 3.142
142 | }
143 |
144 | public static double getY(double[] d) {
145 | double y = 0;
146 | int x = 0;
147 | for (int i = 0; i < d.length; i++) {
148 | if (d[i] > y) {
149 | y = d[i];
150 | x = i;
151 | }
152 | }
153 | x++;
154 | log(String.format("x: %s , y: %s", x, y));
155 | log(String.format("频率: %sHz", (float) x / SIZE));
156 | log(String.format("频率2: %sHz", (float) (SIZE - x) / SIZE));
157 | log(String.format("振幅: %s", y));
158 | return y;
159 | }
160 |
161 | public static void log(String s) {
162 | System.out.println(s);
163 | }
164 |
165 | }
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/utils/FftFactory.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio.utils;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * FFT 数据处理工厂
7 | */
8 | public class FftFactory {
9 | private static final String TAG = FftFactory.class.getSimpleName();
10 | private Level level = Level.Original;
11 |
12 | public FftFactory(Level level) {
13 | // this.level = level;
14 | }
15 |
16 | public byte[] makeFftData(short[] pcmData) {
17 | // Logger.d(TAG, "pcmData length: %s", pcmData.length);
18 | if (pcmData.length < 1024) {
19 | Log.d(TAG, "makeFftData");
20 | return null;
21 | }
22 |
23 | double[] doubles = ByteUtils.toHardDouble(pcmData);
24 | double[] fft = FFT.fft(doubles, 0);
25 |
26 | switch (level) {
27 | case Original:
28 | return ByteUtils.toSoftBytes(fft);
29 | case Maximal:
30 | // return doFftMaximal(fft);
31 | default:
32 | return ByteUtils.toHardBytes(fft);
33 | }
34 | }
35 |
36 |
37 | private byte[] doFftMaximal(double[] fft) {
38 | byte[] bytes = ByteUtils.toSoftBytes(fft);
39 | byte[] result = new byte[bytes.length];
40 |
41 | for (int i = 0; i < bytes.length; i++) {
42 |
43 | if (isSimpleData(bytes, i)) {
44 | result[i] = bytes[i];
45 | } else {
46 | result[Math.max(i - 1, 0)] = (byte) (bytes[i] / 2);
47 | result[Math.min(i + 1, result.length - 1)] = (byte) (bytes[i] / 2);
48 | }
49 | }
50 |
51 | return result;
52 | }
53 |
54 | private boolean isSimpleData(byte[] data, int i) {
55 |
56 | int start = Math.max(0, i - 5);
57 | int end = Math.min(data.length, i + 5);
58 |
59 | byte max = 0, min = 127;
60 | for (int j = start; j < end; j++) {
61 | if (data[j] > max) {
62 | max = data[j];
63 | }
64 | if (data[j] < min) {
65 | min = data[j];
66 | }
67 | }
68 |
69 | return data[i] == min || data[i] == max;
70 | }
71 |
72 |
73 | /**
74 | * FFT 处理等级
75 | */
76 | public enum Level {
77 |
78 | /**
79 | * 原始数据,不做任何优化
80 | */
81 | Original,
82 |
83 | /**
84 | * 对音乐进行优化
85 | */
86 | Music,
87 |
88 | /**
89 | * 对人声进行优化
90 | */
91 | People,
92 |
93 | /**
94 | * 极限优化
95 | */
96 | Maximal
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/utils/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio.utils;
2 |
3 | import android.content.Context;
4 | import android.os.Environment;
5 | import android.text.format.Formatter;
6 |
7 | public class FileUtils {
8 | /**
9 | * 读取缓存目录
10 | *
11 | * @param context :context
12 | * @return String
13 | */
14 | public static String getDiskCachePath(Context context) {
15 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
16 | || !Environment.isExternalStorageRemovable()) {
17 | if (context.getExternalCacheDir() == null) {
18 | return "";
19 | }
20 | return context.getExternalCacheDir().getPath();
21 | } else {
22 | return context.getCacheDir().getPath();
23 | }
24 | }
25 |
26 | /**
27 | * 计算文件大小
28 | *
29 | * @param length
30 | * @return
31 | */
32 | public static String ShowLongFileSize(Long length) {
33 | if (length >= 1048576) {
34 | return (length / 1048576) + "MB";
35 | } else if (length >= 1024) {
36 | return (length / 1024) + "KB";
37 | } else if (length < 1024) {
38 | return length + "B";
39 | } else {
40 | return "0KB";
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/library_audio/src/main/java/com/manna/audio/utils/TimeUtils.java:
--------------------------------------------------------------------------------
1 | package com.manna.audio.utils;
2 |
3 | /**
4 | * 时间转化
5 | */
6 | public class TimeUtils {
7 |
8 | private TimeUtils() {
9 | }
10 |
11 | /**
12 | * 将秒数转为00:00:00
13 | *
14 | * @param time :second
15 | * @return String
16 | */
17 | public static String secondToTime(int time) {
18 | String timeStr = null;
19 | int hour = 0;
20 | int minute = 0;
21 | int second = 0;
22 | if (time <= 0)
23 | return "00:00:00";
24 | else {
25 | minute = time / 60;
26 | if (minute < 60) {
27 | //没超过一小时
28 | second = time % 60;
29 | timeStr = "00" + ":" + unitFormat(minute) + ":" + unitFormat(second);
30 | } else {
31 | hour = minute / 60;
32 | if (hour > 99)
33 | return "99:59:59";
34 | minute = minute % 60;
35 | second = time - hour * 3600 - minute * 60;
36 | timeStr = unitFormat(hour) + ":" + unitFormat(minute) + ":" + unitFormat(second);
37 | }
38 | }
39 | return timeStr;
40 | }
41 |
42 | private static String unitFormat(int i) {
43 | String retStr = null;
44 | if (i >= 0 && i < 10)
45 | retStr = "0" + Integer.toString(i);
46 | else
47 | retStr = "" + i;
48 | return retStr;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/library_audio/src/main/jniLibs/arm64-v8a/liblame-lib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/library_audio/src/main/jniLibs/arm64-v8a/liblame-lib.so
--------------------------------------------------------------------------------
/library_audio/src/main/jniLibs/armeabi-v7a/liblame-lib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/library_audio/src/main/jniLibs/armeabi-v7a/liblame-lib.so
--------------------------------------------------------------------------------
/library_audio/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library_audio
3 |
4 |
--------------------------------------------------------------------------------
/screenshot/ic_audio_file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/screenshot/ic_audio_file.png
--------------------------------------------------------------------------------
/screenshot/ic_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/screenshot/ic_capture.png
--------------------------------------------------------------------------------
/screenshot/ic_play_start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/screenshot/ic_play_start.png
--------------------------------------------------------------------------------
/screenshot/ic_playing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/screenshot/ic_playing.png
--------------------------------------------------------------------------------
/screenshot/ic_start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/screenshot/ic_start.png
--------------------------------------------------------------------------------
/screenshot/xiaomiquan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MannaYang/AudioCapturePlay/b001c0f2690aa6fa346a4ec722df7f575674a823/screenshot/xiaomiquan.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app','library_audio'
2 | rootProject.name='AudioCapturePlay'
3 |
--------------------------------------------------------------------------------