java - Get decoded byte stream from MP3 file -


i want fft on mp3 file. this, extract decoded byte stream file format (i believe called raw pcm data).for task using jlayer 1.0.1 library. here code should extract pcm data each frame:

        short[] pcmout = {};         bitstream bitstream = new bitstream(new fileinputstream(path_to_mp3_file));         boolean done = false;         while (!done) {             header frameheader = bitstream.readframe();             if (frameheader == null) {                 done = true;             } else {                 decoder decoder = new decoder();                 samplebuffer output = (samplebuffer) decoder.decodeframe(bitstream.readframe(), bitstream); //returns next 2304 samples                 short[] next = output.getbuffer();                 pcmout = concatarrays(pcmout, next);                 //do whatever samples             }             bitstream.closeframe();         }         (int = 0; < pcmout.length; i++) {             if (pcmout[i] != 0) {                 system.out.println(pcmout[i]);             }         } 

the problem variable short[] pcmout filled zeros valid mp3 file. root cause of such problem?

checking seems related decoder; apart waste create new decoder each time seems fundamental problem in implementation seems return first frame while constant decoder seems keep track:

decoder decoder = new decoder(); while (!done) {   header frameheader = bitstream.readframe();   if (frameheader == null) {             done = true;   }   else {      samplebuffer output = (samplebuffer) decoder.decodeframe(frameheader, bitstream);             short[] next = output.getbuffer();             for(int i=0; i<next.length; i++) system.out.print(" "+next[i]);             pcmout = concatarrays(pcmout, next);             //do whatever samples   } 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -