Google Answers Logo
View Question
 
Q: C networked audio program ( No Answer,   1 Comment )
Question  
Subject: C networked audio program
Category: Computers > Programming
Asked by: gareth1234-ga
List Price: $40.00
Posted: 24 Sep 2005 14:39 PDT
Expires: 24 Oct 2005 14:39 PDT
Question ID: 572113
I'm trying to create a simple C program in Windows which can extract
audio data from a wave file (I'm using FRead) and send it to a another
Windows 98 PC on the same network (for which in using UDP sendto) the
receiving PC should then play the audio back (I'm currently using
wavOutWrite and other similar functions for this). I obviously need to
send the audio in sections but I am having trouble getting any sound
out of the receiving PC. I think I may be sending the audio in the
wrong format, how do you send audio data when sendTo requireS a
pointer to char? I'm using a PC running Windows XP and LCC-WIn32
compiler for programming but this is not part of the network. Could
you provide some skeletal code?
Answer  
There is no answer at this time.

Comments  
Subject: Re: C networked audio program
From: vakulgarg-ga on 26 Sep 2005 08:52 PDT
 
Dear Gareth

I hope that you are already familiar with wave file format.
Wave files have a RIFF header at the top and then a number of
different chunks after that. These chunks are "data" chunks, "fmt"
chunks etc.

"fmt" chunks describe the format of the waveform data in wavefile.
E.g. they describe sampling frequency, number of channels, bitrate
etc.

"data" chunks contain the actual waveform data.

For details, look at 
http://www.sonicspot.com/guide/wavefiles.html

For your program, you need to send format chunks first to the
receiving computer. This helps the receiving computer open the wave
device accordingly as the paramters in it. Then you need to send the
data chunks. Since in most of the wavefiles, there is only one data
chunk, it might be very big in size to fit into one UDP sendto(). So
you can split the waveform data in the single data chunk in the wave
file in question into multiple data chunks and send them one by one
over UDP using sendto.

E.g if the wave file contains 10240 bytes of waveform in each of data
chunk, you can split it into 10 udp sendto of 1024 bytes each.


Thus the buffer for sendto() to send actual waveform data should look like:

struct wave_data
{
  unsigned long int size;
  char wave_form_data[1024];
}

At the receiving end, the data chunks containing waveform should be
converted to WAVEHDR using waveOutPrepareHeader before passing to
waveOutWrite.

Important:
Please make sure that you poll for 'WHDR_DONE' over 'dwFlags' in
WAVEHDR. If your programs terminates before WAVEHDR buffer is played
fully by sound driver, then no sound would be audible.


Before playing the wavefile over network, make sure that you are able
to play the chunks prepared locally. Once it works, network enabling
is quite easy..

I have developed a sample code (LCC-Win32) for playing wavefile
locally which can be enhanced easily. If you need, then you can
indicate.

Please ask if you need more help or anything is unclear.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy