Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stream a WAV file?

Tags:

audio

wav

I'm writing an app where I record audio and upload the audio file over the web. In order to speed up the upload I want to start uploading before I've finished recording.

The file I'm creating is a WAV file. My plan was to use multiple data chunks. So instead of the normal encoding (RIFF, fmt , data) I’m using (RIFF, fmt , data, data, ..., data). The first issue is that the RIFF header wants the total length of the whole file, but that is of course not known when streaming the audio (I’m now using an arbitrary number). The other problem is that I'm not sure if it's valid since Audacity doesn't recognise the file, and Windows Media Player opens the file but plays only a very small part. I've been reading WAV specs but haven’t found an answer.

Any suggestions?

like image 211
jonasb Avatar asked Mar 31 '10 10:03

jonasb


1 Answers

I've managed to stream a wav by using only one data chunk and setting ChunkSize to 0xFFFFFFFF and Subchunk2Size to 0xFFFFFFFF as well. The resulting file is not completely up to the specs but when embedded via <audio> tag, Chrome plays it in real-time without a problem. Also the downloaded file is playable.

WAV format

like image 61
danman Avatar answered Sep 28 '22 06:09

danman