We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, Anyone know how to store data within an audio file? I need to put together an audio CD that has embedded data in it that I can use to sync the embedded hardware to. Any help or pointers appreciated. Cheers Mark
Anyone know how to store data within an audio file? What file extension? .wav?
Hi Alex, Thanks for the quick response. I can use any format I like, the sound quality is not important as the sound track is going to be used just as a lip sync for the mechs. Provided it can be played on standard equipment (i.e. CD, DVD, mini disk etc) and I can grab the data into my embedded system then I'm open to suggestions. Thanks again Mark
You can record/extract a .wav in a CD and play it in almost every CD/DVD player... To write a .WAV file you need to know the .wav structure. Here's what maybe you'll need:
struct WAVEFMT { char signature[4]; // must contain 'RIFF' long RIFFsize; // size of file (in bytes) minus 8 char type[4]; // must contain 'WAVE' char fmtchunk[4]; // must contain 'fmt ' (including blank) long fmtsize; // size of format chunk, must be 16 int format; // normally 1 (PCM) int channels; // number of channels, 1=mono, 2=stereo long samplerate; // sampling frequency: 11025, 22050 or 44100 long average_bps; // average bytes per second; samplerate * channels int align; // 1=byte aligned, 2=word aligned int bitspersample; // should be 8 or 16 char datchunk[4]; // must contain 'data' long samples; // number of samples };
Hello Alex, Thanks for the information on .WAV files. Can you make the datachunk array any size you like? The application I had in mind requires regular data elements so that the embedded side syncs with the music. Can I do this with the .WAV format? Thanks again Mark.
Can you make the datachunk array any size you like? I think so Mark, I don't know how much is the size limit ( if it really exist ) but, remember that you can have just one track of music inside a CD, it means 74 seconds, something around 650MB of data in just one WAV file, so I'm not sure about a limit. I also think that these regular elements can be put inside the file without problems.
the data on an audio CD isn't a WAV file; when you burn an audio CD (ie, one you can play on an audio CD player) your burner performs the conversion. BTW: that's 74 minutes, not seconds!
that's 74 minutes, not seconds! Thanks Andrew. the data on an audio CD isn't a WAV file Oh that's why I didn't found the WAV structure inside the binary image of my Audio CD... hummmm.. I really wasted a lot of time dumping 473MB of binary numbers in my hex editor...
Provided it can be played on standard equipment (i.e. CD, DVD, mini disk etc) If it's gotta be standard audio equipment, then I think you're gonna have to use in-band audio - any clever tricks with merged data would require a specialised player to handle that data. As you're not worried about audio quality, why not just use one side of the stereo CD audio for your sound, and the other side for sync tones? Note that MD uses lossy compression - I don't think that'd be good for data, and you'd probably also have to check carefully for any effects on signalling tones (the compression relies on psycho-acoustics, and is designed for reproducing music for human listeners - not data or tones for machines!) The same applies to MP3 and Real Audio (TM?)
Hi NG, Some information which is stored in the Subcode of a CD will be forwarded to the SPDIF output ("Digital Out" on some CD players). That true at least according to CD track start information, as you can see on some Dat recorders which can automatically get over the Start IDs while recording from CD. So you can get a signal up to every 4 seconds (minimum distance between start track signals) In addition, a CD contains indices (not many CD players display them). I don't know whether they appear on the SPDIF output. To put SPDIF signals in your embedded hardware, use a special receiver IC (e. g. Crystal's 8212 or 8202, AFAIK after a few years). Much success - Peter