By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,100 Members | 1,465 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

How to play a wave file on the phone (C#) - PART II

P: 5
Part II: Wave file - How to read to a buffer

Wave (or Wav) is the standard format for storing audio data on the PC. As software developers, we are interested in the internal structure of the file so that we can open and read data correctly before transmitting it over the phone line.

Fortunately, there are plenty of good articles on the internet addressing the wave file format. Here is one of them:

We show a small excerpt from that article (thanks to sonicspot) to show the typical layout of a wave file:

From now on we will use HomeZIX software as a demostration platform to show our C# code.

There are 2 files (download from the forum here)

"houston 8kHz Mono 8.wav" is the WAV file with the famous phrase: “Houston we’ve got a problem.”

The second attachment is the C# script to (be imported to HomeZIX) which reads the WAV file. Please download and save the wave file to your C:\ drive, and then load the script into HomeZIX (by dropping an Advanced C# block into your workspace, going to the C# source code window, right clicking on the editor, and selecting File->Open.) The implementation is pretty straightforward. If you don’t care about the details, just focus on the Initialize() function where we open and read wave data into the buffer.

As we pointed out in the Part I, we just want to work with a PCM uncompressed Wave file, Mono, 8 bits per sample and 8kHz sample rate. That’s why our C# script checks to see if we are reading an appropriate file. You may change the file type-checking functionality to accommodate different formats that your voice modem supports.

Put HomeZIX in RUN mode (by selecting Manage->Run.) and click on the Advanced Script block. You should then see debug output, similar to what we are seeing here:

Now, the voice data has been loaded into the buffer. We will send it over the phone line so that whoever answers the phone will hear: “Houston, We’ve got a problem.” See you in PART III

Back to PART I
Sep 7 '07 #1
Share this Article
Share on Google+
1 Comment

P: 1
All links in the article are dead.
Mar 4 '12 #2