Search code examples
javaaudiomp3

Decomposing MP3s in Java


What is the most popular method/API for reading in an MP3 and turning it into its most basic amplitude waveform (a float that could represent a point on a waveform for visualisation) and then how can I use this basic value to play it out on the computer's audio output? (All of this done in Java)


Solution

  • You might want to take a look at LAMEOnJ. It is a Java wrapper for LAME (JavaDoc).

    As for converting byte arrays to float arrays, how about importing java.nio.ByteBuffer and java.nio.ByteOrder, and doing the following

    float floatVal = ByteBuffer.wrap(array).order(ByteOrder.nativeOrder()).getFloat();
    

    That should do the trick to give you a float array. As for playing it, you could just assign each float value a pitch.