This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compressing Data with Audio

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

Parents
  • 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
      };
    

    After this structure almost all is the sound data.

    Open a .wav file in a hex editor and insert your data there.


Reply
  • 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
      };
    

    After this structure almost all is the sound data.

    Open a .wav file in a hex editor and insert your data there.


Children

  • 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...