I’m trying to use the gdx-audio extensions, but am having trouble decoding mp3s. It works, but very slowly!! A 10-second file is taking 6.57 seconds to decode 🙁 Here is the method:
public void decode() {
Mpg123Decoder decoder = new Mpg123Decoder(externalFile);
short[] sampleArray = new short[1024];
// read until we reach the end of the file
while (decoder.readSamples(sampleArray, 0, sampleArray.length) > 0) {}
}
Can anyone tell me why this is taking so long?
Because libmpg123 is a software decoder, that does all the work on the CPU. Depending on what CPU you have, you usually only get 2x real-time decoding. We haven’t enabled ARM assembly in our libmpg123 build, that could help speeding it up a little, but usually not by much.