A handy SoundTouch java wrapper library for Android
This repo is a java wrapper of SoundTouch for Android.
Note: You should grant audio record permission manually before using.
Gradle:
repositories {
jcenter()
}
// For gradle plugin 2.x
dependencies {
compile 'io.github.junyuecao:soundtouch:1.0.1'
}
// For gradle plugin 3.x
dependencies {
implementation 'io.github.junyuecao:soundtouch:1.0.1'
}
The APIs are almost the same with the C/C++ version.
public void onVoiceStart() {
mSoundTouch = new SoundTouch();
mSoundTouch.setChannels(1);
mSoundTouch.setSampleRate(VoiceRecorder.SAMPLE_RATE);
}
public void onVoice(byte[] data, int size) { mSoundTouch.setRate(mRate); mSoundTouch.setPitch(mPitch); mSoundTouch.putSamples(data, size); int bufferSize = 0 do { bufferSize = mSoundTouch.receiveSamples(mTempBuffer, BUFFER_SIZE); if (bufferSize > 0) { mTestWavOutput.write(mTempBuffer, 0, bufferSize); } } while (bufferSize != 0);
}
public void onVoiceEnd() { mSoundTouch.release(); }