junyuecao / AndroidSoundTouch

A SoundTouch java wrapper library for Android
GNU Lesser General Public License v3.0
30 stars 5 forks source link
android java soundtouch

AndroidSoundTouch

Build Status

A handy SoundTouch java wrapper library for Android

This repo is a java wrapper of SoundTouch for Android.

Demo

Demo apk download link

Note: You should grant audio record permission manually before using.

Usage

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 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(); }