469,626 Members | 853 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Share your developer knowledge by writing an article on Bytes.

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

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: http://www.sonicspot.com/guide/wavefiles.html

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
1 14063
bguyb
1
Hi
All links in the article are dead.
Mar 4 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Bill Dandreta | last post: by
4 posts views Thread by Dennis M. Marks | last post: by
1 post views Thread by DaniloAlmeida | last post: by
5 posts views Thread by Slickuser | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.