Skip to content

Commit f8dfcc6

Browse files
committed
readme
1 parent 1bd5d27 commit f8dfcc6

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
1+
[![](https://jitpack.io/v/stefanJi/Android-Audio-Waveform-Generator.svg)](https://jitpack.io/#stefanJi/Android-Audio-Waveform-Generator)
2+
3+
![](https://github.com/stefanJi/Android-Audio-Waveform-Generator/blob/master/images/final.png)
4+
5+
# Usage
6+
7+
## Add the dependency
8+
9+
```
10+
implementation 'com.github.stefanJi:Android-Audio-Waveform-Generator:Tag'
11+
```
12+
13+
## Code
14+
15+
```kotlin
16+
val decoder = AudioWaveformGenerator(file.absolutePath, 100)
17+
decoder.startDecode()
18+
val samples = decoder.getSampleData()
19+
```
20+
21+
See: `demo/src/main/java/x/stefanji/audiovisulizer/MainActivity.kt`
22+
23+
## Support
24+
25+
[MediaCodec supported audio formats](https://developer.android.com/guide/topics/media/media-formats#audio-codecs).
26+
27+
---
28+
129
# 背景
230

331
|期待效果|初步效果|
432
|:---:|:---:|
5-
|![](images/audio_waveform.png)|![](images/final.png)|
33+
|![](https://github.com/stefanJi/Android-Audio-Waveform-Generator/blob/master/images/audio_waveform.png)|![](https://github.com/stefanJi/Android-Audio-Waveform-Generator/blob/master/images/final.png)|
634

735
首先这样的波形图,是根据音频在采样点的采样值来绘制的。像 mp3 m4a 的音乐格式,都会经历音频采样、编码的过程。采样的结果是 PCM,对 PCM 利用不同的编码算法进行编码就产生了不同格式的音乐文件。
836

@@ -215,7 +243,7 @@ override fun onOutputBufferAvailable(
215243

216244
可以在解码完成之后,将解码之后的数据存储为 Wav 格式,然后利用如下脚本绘制波形图,测试解码是否正常。
217245

218-
![](images/python_output.png)
246+
![](https://github.com/stefanJi/Android-Audio-Waveform-Generator/blob/master/images/python_output.png)
219247

220248
```python
221249
import matplotlib.pyplot as pl
@@ -268,7 +296,7 @@ if __name__ == "__main__":
268296

269297
|计算方法|结果|
270298
|:---:|:---:|
271-
|![](images/rms.png)|![](images/rms_value.jpg)|
299+
|![](https://github.com/stefanJi/Android-Audio-Waveform-Generator/blob/master/images/rms.png)|![](https://github.com/stefanJi/Android-Audio-Waveform-Generator/blob/master/images/rms_value.jpg)|
272300

273301
每一个绘制点的数值范围为 [-RMS, RMS]。如下就是我实现的 RMS,我这是一个动态计算 RMS 的方法。
274302

@@ -294,7 +322,7 @@ private fun calRMS(left: Float) {
294322

295323
|最终效果|专业软件|
296324
|:---:|:---:|
297-
|![](images/final.png)|![](images/audio_pro.png)|
325+
|![](https://github.com/stefanJi/Android-Audio-Waveform-Generator/blob/master/images/final.png)|![](https://github.com/stefanJi/Android-Audio-Waveform-Generator/blob/master/images/audio_pro.png)|
298326

299327
可以看到,和专业的音乐编辑软件的显示差不多。
300328

library/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ dependencies {
3737

3838
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3939
implementation 'androidx.core:core-ktx:1.3.2'
40-
implementation 'com.github.stefanji:Android-Audio-Waveform-Generator:1.0.0'
4140
}
4241

4342
afterEvaluate {

0 commit comments

Comments
 (0)