Question

I am using ffmpeg (c++) to decode variety of audio files into 44100 stereo OR mono (according to the source). I have to keep this like this because I play them too. Meanwhile, I also need 11025 mono versions of these. So I am trying to find a very quick/easy way to convert 44100 stereo PCM into 11025 mono without ffmpeg to save cpu.

Is this possible in java (android) or c++ (ndk)?

I am already using java and c++ in the same project.

Was it helpful?

Solution

sample-by-sample averaging is correct for stereo to mono conversion, but for sample rate conversion, why not use a library like libsamplerate? If even that is too heavy, averaging is indeed fast, but it is not the correct method. Whether it is acceptable or not depends on your application. An alternative method is described in my answer to this SO post:

How to convert pcm samples in byte array as floating point numbers in the range -1.0 to 1.0 and back?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top