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

Decompress Audio wave to raw format

Dear all,

I have a audio.wave to convert into raw format to input into Analog Device DAC AD7302.

As I am using DS80C400 as my MCU, I will need to have the audio conversion decoding to be done in C. What are the steps that I need to do?
Is this correct:
Read the audio wave from memory (RAM) and do conversion through reading the following:

fscanf( infile, "%4c", &RIFFsize );
fscanf( infile, "%4c", &type );
fscanf( infile, "%4c", &fmtchunk );
fscanf( infile, "%4c", &fmtsize );
fscanf( infile, "%2c", &format );
fscanf( infile, "%2c", &channels );
fscanf( infile, "%4c", &samplerate );
fscanf( infile, "%4c", &average_bps );
fscanf( infile, "%2c", &align );
fscanf( infile, "%2c", &bitspersample );
fscanf( infile, "%4c", &datchunk );

Then input into DAC D0-D7 and output.

Please advise if the above is correct.

Parents
  • "Any idea how I should do it?"

    You have provided very little information as to exactly how this wave file appears in your SRAM. Let's just assume that it does and that it has the same structure as the original file format. If you had been able to fscanf() a file, then you can sscanf() memory, so instead of infile being a FILE *stream, we will assume it is a buffer in memory (unsigned char *inbuf), in which case you would use in an ideal situation without any conversion errors:

    int len = 0;
    len += sscanf( inbuf+len, "%4c", &RIFFsize );
    len += sscanf( inbuf+len, "%4c", &type );
    len += sscanf( inbuf+len, "%4c", &fmtchunk );
    len += sscanf( inbuf+len, "%4c", &fmtsize );
    len += sscanf( inbuf+len, "%2c", &format );
    len += sscanf( inbuf+len, "%2c", &channels );
    len += sscanf( inbuf+len, "%4c", &samplerate );
    len += sscanf( inbuf+len, "%4c", &average_bps );
    len += sscanf( inbuf+len, "%2c", &align );
    len += sscanf( inbuf+len, "%2c", &bitspersample );
    len += sscanf( inbuf+len, "%4c", &datchunk );
    Not necessarily the most efficient implementation, but you get the point...

Reply
  • "Any idea how I should do it?"

    You have provided very little information as to exactly how this wave file appears in your SRAM. Let's just assume that it does and that it has the same structure as the original file format. If you had been able to fscanf() a file, then you can sscanf() memory, so instead of infile being a FILE *stream, we will assume it is a buffer in memory (unsigned char *inbuf), in which case you would use in an ideal situation without any conversion errors:

    int len = 0;
    len += sscanf( inbuf+len, "%4c", &RIFFsize );
    len += sscanf( inbuf+len, "%4c", &type );
    len += sscanf( inbuf+len, "%4c", &fmtchunk );
    len += sscanf( inbuf+len, "%4c", &fmtsize );
    len += sscanf( inbuf+len, "%2c", &format );
    len += sscanf( inbuf+len, "%2c", &channels );
    len += sscanf( inbuf+len, "%4c", &samplerate );
    len += sscanf( inbuf+len, "%4c", &average_bps );
    len += sscanf( inbuf+len, "%2c", &align );
    len += sscanf( inbuf+len, "%2c", &bitspersample );
    len += sscanf( inbuf+len, "%4c", &datchunk );
    Not necessarily the most efficient implementation, but you get the point...

Children
No data