tags:

views:

120

answers:

3

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?

A: 

Where are you uploading to? Your own site? Sounds like you need some server-side code to take your raw sample uploads and assemble them into a valid WAV file (correct file-length field, one data chunk) on the server.

But if you're really trying to speed up the upload, I'd think you actually want to upload MP3-encoded frames and have the server assemble those into an MP3 file. Which is more complicated, I'm afraid.

Conrad Albrecht
A: 

Hi guys!

Sorry for interrupting the topic, but I'm doing an educational project in which 1) I record voice commands on a separate device and after appropriate processing etc... 2) I send 16-bit samples encapsulated in UDP packets over Ethernet to the PC.

After receiving the packets and "extracting" data (samples) from them, I need to assemble the samples to a WAV file.

Actually, I need exactly what CONRAD ALBRECHT describes in his first paragraph.

Is there such a code? Any suggestions?

Thank you in advance!

refugee
How does this answer jonasb's question?
Christopher Parker
Welcome at Stackoverflow! If you have a question, please press `Ask Question` button at right top. Do not use `Post Your Answer` button at the bottom. A question is namely not an answer :) This is not a forum or so.
BalusC
+1  A: 

You will just have to use a container format that supports appending without editing the header.

I suggest Raw PCM samples. They can be converted to anything else at will.

Audacity will import raw bytes from the File -> Import -> Raw Data menu.

Another option might be a lossless audio codec such as FLAC inside of a streamable container format. (As done by a Czech web radio station)

I notice VLC can compress and stream FLAC-in-OGG from the soundcard. Should be a simple step from there to store or uncompress the stream on the server end.

Joe Koberg