-1

I am currently working on a small project where I want to split an mp3 into frames, send them to a client (browser) through a websocket and then play them back using WebAudio (webkitAudioContext). My server is running nodejs and to transfer the data as binary, I use binaryJS. The browser I am testing with is Chrome 25.0.1354.0 dev, running on Ubuntu 12.04.

I have gotten as far as successfully splitting the mp3 into frames, or, at least, based on my tests, it seems to work. If I write the frames back into a file, mplayer has no problem playing back the file and also parses the header correctly. Each frame is stored in a nodejs Buffer of the correct size and the last byte of the buffer is always the first byte before the next sync word.

As an initial test, I am only sending the first MP3 frame. The client receives the frame successfully (stored in an ArrayBuffer), and the buffer contains the correct data. However, when I call decode, I get the following message:

Uncaught Error: SyntaxError: DOM Exception 12 

My function, where I call decodeAudio, looks like this:

streamDone = ->
    bArray = new Uint8Array(arr[0].byteLength)
    console.log "Stream is done, bytes", bArray.length
    context.decodeAudioData bArray, playAudio, err

The initial frame that I am trying to deocde, can be found here.

I have been banging my head in the wall for a couple of days now trying to solve this. Has anyone managed to solve this and sucessfully decoded mp3 frames, and see what I do wrong? I have found two related question on StackOverflow, but the answers did not help me solve my problem. However, according to the accepted answer here, my frame should qualify as a valid mp3 chunk and, thus, be decoded.

Thanks in advance for any help!

Community
  • 1
  • 1
Kristian Evensen
  • 1,315
  • 13
  • 14
  • I did some more testing with a smaller file, without an ID3 tag. When writing the frames to disk, the new file has the same md5 hash as the original. When I send all the frames to the server, they fit within one binaryJS chunk, and the content of the ArrayBuffer matches the file. I still get the DOM Exception. – Kristian Evensen Dec 13 '12 at 13:54

1 Answers1

0

Turns out that a break and some fresh eyes can work wonders, a general code cleanup solved the issue. If anyone is interested in the code, I published it here.

Kristian Evensen
  • 1,315
  • 13
  • 14
  • Can you be more specific? Did you track the exception back to a certain issue in your code? – Vince Mar 30 '13 at 17:43
  • No, not really. However, my theory is that there was something I did with the client in connection with storing the binary data. – Kristian Evensen Mar 31 '13 at 20:22