Thread: Reading Audio Files

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    1

    Reading Audio Files

    How do I read an audio file (namely a .wav) into an array for DSP?

    Thanks a lot.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    www.wotsit.org

    A WAV is a chunky file.

    I believe this is how they start.

    "R","I","F","F"
    Length
    Header information
    ...
    ...
    "F","M","T"
    Length
    Header information about the WAV
    ...
    ...
    "W","A",V"
    Length
    WAV data - compression depends on whether or not compression is indicated in the headers. I believe the RIFF header states this information.



    Find "R" "I" "F" "F" Then you need to look for "F","M","T" and then "W","A","V" Each tag is followed by a length value which indicates the length of the chunk. There are more chunks in any WAV, but these are all you should need.

    When you reach FMT, load the length of FMT into the WAVEFORMATEX structure. Then allocate a buffer of the correct data type (8,16-bit) and read the WAV data. You may have to decompress it depending on whether the data is compressed or not. Most are not.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading files
    By hiya in forum C++ Programming
    Replies: 7
    Last Post: 05-21-2005, 11:40 AM
  2. Reading data from consecutively named files
    By a1pro in forum C Programming
    Replies: 10
    Last Post: 04-15-2005, 01:48 AM
  3. A little help reading from files...
    By Invincible in forum C++ Programming
    Replies: 4
    Last Post: 04-03-2002, 10:43 AM
  4. problem reading files in C
    By angelfly in forum C Programming
    Replies: 9
    Last Post: 10-10-2001, 11:58 AM
  5. Need Advice in reading files
    By jon in forum C Programming
    Replies: 4
    Last Post: 10-07-2001, 07:27 AM