Search code examples
androidaudiosignal-processingandroid-mediacodecresampling

Native Audio Resampling on Android


I am building a custom audio player with MediaCodec/MediaExtractor/AudioTrack etc. which mixes and plays multiple audio files. Therefore I need a resampling algorithm, if one of the files has a different samplerate.

I can see that there is a native AudioResample class available: https://android.googlesource.com/platform/frameworks/av/+/jb-mr1.1-release/services/audioflinger/AudioResampler.h - But so far I did not find any examples how it can be used.

My question: Is it possible to use the native resampler on Android? (in Java or with JNI) If yes, does anyone know an example out there? Or any docs how one can use this custom AudioResampler class?

Thanks for any hints!


Solution

  • This is not a public API, so you can't officially rely on using it (and even unofficially, using it would be very hard). You need to find a library (ideally in C, for NDK) to bundle within your app.