Thread: reading a wav header in C

  1. #1
    Registered User
    Join Date
    Aug 2001

    reading a wav header in C

    I've been looking all over the net for this one, and so far have come up with a solution for every language BUT C. What I need is a function that will read the header of a wav file so I can extract the sample speed of the wav file so it doesn't sound like either a chipmunk chorus or the voice of satan is eminating from my speakers.

    This program is for Linux, using OSS drivers, if that helps. Also, please note that while I am looking for a way to do this in C, I'll take a way to do it in C++ too, so if you know of one, please send it on.



  2. #2
    Super Moderator
    Join Date
    Sep 2001
    If you have one for assembly (I'm taking you literally on that EVERY language statement) you could just put it between ASM{...] tags. You could also visit this for the file format. Since this is Linux specific, you might also want to post this in the Linux forum, although you might get some snotty messages about cross posting.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001

    Go to and look for the wav header definition.


    struct WAVheader
    ..put the info in here

    }header; the file in binary, read-only mode

    int handle=read(filename,header,sizeof(WAVheader));

    You can also use other file i/o functions to do this so use the one you are most comfortable with.

    Then extract the information you are looking for from the header structure.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class methods in header or source file?
    By TriKri in forum C++ Programming
    Replies: 13
    Last Post: 09-17-2007, 05:23 AM
  2. header file/class problems
    By Calef13 in forum C++ Programming
    Replies: 6
    Last Post: 07-20-2007, 08:33 AM
  3. Problems in reading binary file
    By serena in forum C Programming
    Replies: 3
    Last Post: 04-14-2005, 03:54 AM
  4. Replies: 6
    Last Post: 04-02-2002, 05:46 AM
  5. header file compile error
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 02-23-2002, 06:28 AM