Fog Creek Software
Discussion Board

Can I use a byte array for sound files?

I am using MCI (winmm.dll) to read, record and playback sound. For now, I am doing this with disk files instead of realtime doing it straight from the memory. If I want to stream/relay/transmit this sound (file) on a Windows socket (not using FTP but TCP), can I read the file into a byte array? Because if it is possible then I can send it on the socket but the problems I foresee are:

How will I repack it into the file. Will just reading back the byte array into a file with the same extention work? I mean, say, I have a .wav file and I read that into a byte array. Then I prefix some header of my own containing the file name, the type and size etc. and send this message on a socket, then at the other end, I read this header and the following byte array and read it back into a file with the same name and extention, will it be okay or it'll just be gobbledegook?

How do they stream sound on the Internet otherwise?

Friday, June 04, 2004

Why don't you try your plan and see what happens.

Guy LeDouche
Friday, June 04, 2004

Get a copy of the API-Guide from They have a VB code sample on playing audio from memory. The API calls, IIRC are, waveIn* and  waveOut*

Friday, June 04, 2004

I found this place some time ago.  They had a sample code about playing a sound file from raw data I think.  Maybe check it out.

Friday, June 04, 2004

*  Recent Topics

*  Fog Creek Home