This is a simple Audio Resampler using Oboe Resampler in order to change Channel and SampleRate.
- Add to dependencies
implementation("io.github.nailik:androidresampler:0.3")
- create the Configuration with input and output settings.
val configuration = ResamplerConfiguration(
quality = ResamplerQuality.BEST,
inputChannel = ResamplerChannel.STEREO,
inputSampleRate = 441800,
outputChannel = ResamplerChannel.MONO,
outputSampleRate = 16000
)
- create the resampler, this also creates the OboeAudioProcessor
val resampler = Resampler(configuration)
- to convert audio send in a
ByteArrayand you get back aByteArray - Note: in case of same input and output configuration the input
ByteArrayis just send back directly
val data: ByteArray = resampler.resample(recordedAudio)
- dispose the resampler when finished, note it cannot be used anymore afterwards
isDisposedcan be used to check if resampler was disposed already
resampler.dispose()
val isDisposed = resampler.isDisposed