A
A
Andrey Apanasik2013-11-08 14:32:53
Android
Andrey Apanasik, 2013-11-08 14:32:53

Decoding mp3 to PCM on Android?

Good afternoon. We ran into a problem while developing the game.
Initially, the game was developed for iOS, so the game engine is in C ++, for OpenAL sounds. Under iOS there were no problems with music decoding. Under Android, everything is more complicated ... I’ll
note right away:
1) No, you can’t convert mp3 to wav, since it will take up a lot of space.
2) No, you won't be able to play sounds through Java by calling methods from C++, as there will be delays, etc. As you know, MediaCodec
appeared in version 16 of the API . You can use it for new devices, but we need support for older ones (3.0+). Tried using JLayer . But decoding our sound files takes 30-50 seconds, which is absolutely unacceptable.
There is also Libmad and mpg123. They might be faster.
Also, as far as I know, OpenSL supports mp3 decoding since 4.0.
So, two questions:
1) If someone worked with these libraries, can you tell me which one is better to choose / which one is faster?
2) All C++ libs work with the FILE handler, and, as you know, all resources from assets are packed into .apk, so they can only be read using AAssetManager. What can be done about these? In the case of .ogg, Vorbis allows you to define the methods for reading the file itself, so there were no problems with AAssetManager. I did not see anything similar in Libmad and mpg123.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Sysolyatin, 2013-11-09
@PSyton

maybe this is your case: stackoverflow.com/questions/10770979/is-it-possible-to-get-a-byte-buffer-directly-from-an-audio-asset-in-opensl-es-f/18863797# 18863797
My own OpenSL plays mp3 perfectly, but there are problems with delays, which are not critical in my case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question