I should do a program that allow to convert a WAV file in a Mpeg 2 Layer 3 (MP3) file trough Java. I've read on various websites that Java doesn't allow the manipulation of MP3 file natively. Therefore I had to download some external libraries. People say that to allow the manipulation of MP3 files in Java, the library to use is MP3SPI that to work need others libraries: JLayer and Tritonus. Little problem: this library doesn't allow to convert WAV in MP3 but only to play MP3 files. Therefore it doesn't allow the MP3 Encoding.
To allow the MP3 encoding in Java, Tritonus has an ulterior library that, trough the encoder Lame, allow the MP3 encoding. When people download this library (download here), the zip file contains alsa a readme file and an example program called Mp3Encoder.java
After the compilation, this program allow to convert a WAV file in a MP3 file trough the command "java Mp3Encoder <file>.wav". And until here it work perfectly. The problem is that the MP3 converted is a Mpeg 1 Layer 3 while I should have a Mpeg 2 Layer 3!
And it isn't so easy as it seems. It doesn't suffice replace the row
private static final AudioFormat.Encoding MPEG1L3 = Encodings.getEncoding("MPEG1L3");
because the program outputs the error "Unsupported conversion". According to the documentation of Lame it shoulds be possible convert in a Mpeg 2 Layer 3!
private static final AudioFormat.Encoding MPEG1L3 = Encodings.getEncoding("MPEG2L3");
Where is the problem?
Thanks in advance, Dario Simonetti