1.soundtouch官网:http://www.surina.net/soundtouch/。这上面有soundtouch的介绍、源码,封装好的dll文件、使用方法、以及一些demo。这上面demo做的不好。
2.一个利用java的jni调用soundtouch非常短小精悍的java swing界面小程序:http://www.aplu.ch/home/apluhomex.jsp?site=44。
3.csdn suhetao做的soundtouch源码分析:http://blog.csdn.net/suhetao/article/details/5843480。
4.关于声音处理的一个理论网页:http://www.surina.net/article/time-and-pitch-scaling.html。
5.其他资料:http://baosu.iteye.com/blog/1840054
http://baosu.iteye.com/blog/1843031
http://blog.csdn.net/leilu2008/article/details/6724354
1. 音频采集
这点主要是通过Android设备的麦克风实时采集音频,由于Android平台的MediaRecorder类录制音频到文件,虽然可以通过空设备回调获得实时的音频流,不过为了降低开发者的难度,Android开发网推荐使用正统的AudioRecord和AudioTrack,首先我们仍然需要加入android.permission.RECORD_AUDIO这个权限。
android.media.AudioRecord类的read方法主要有
3
种重载形式:
int
read(
short
[] audioData,
int
offsetInShorts,
int
sizeInShorts)
//short在java中占用两个字节
int
read(
byte
[] audioData,
int
offsetInBytes,
int
sizeInBytes)
//byte在java中占用一个字节
int
read(ByteBuffer audioBuffer,
int
sizeInBytes)
//基于NIO的ByteBuffer类型
我们可以看到从麦克风中获取的音频无需经过文件系统直接通过AudioRecord类的read方法读入到我们预定的缓冲区中,这里需要注意的是采样率的大小必须有足够的缓冲区空间处理
2. 变声处理
这点需要一些基本的音频处理方式,比如移调、变速,Android开发网推荐大家参考Adobe Audition的早期Cool Editi泄露的代码,当然音频处理算法比较多,大家可以自己实现。
3. 播放原始音频流
同样,处理完后考虑到效率我们仍然直接从内存流中播放,最简单的就是AudioTrack类,通过android.media.AudioTrack类的write方法,让Android声卡播放原始音频流。两种重载方法如下
int
write(
short
[] audioData,
int
offsetInShorts,
int
sizeInShorts)
int
write(
byte
[] audioData,
int
offsetInBytes,
int
sizeInBytes)
4,编译NDK:http://soundtouch.surina.net/README-SoundTouch-Android.html