audio processing

This is a discussion on audio processing within the C++ Programming forums, part of the General Programming Boards category; hey all, maybe someone has some experience with this. ive been looking on google for a class/function which will read ...

  1. #1
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455

    audio processing

    hey all,
    maybe someone has some experience with this. ive been looking on google for a class/function which will read in a wav file and return the peaks for the file, either in vector or matrix form, the peaks for both channels. is it hard to write something like this (i imagine that it is), any ideas where i could get something that would do this?

    thanks

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    The hardest part of what you want to do is loading the wav file. Once you get that down, the rest is easy.

    The max and min values for any sound sample are the same as the min and max values in C data types.

    For instance:

    • 8 bit unsigned sound - 0 to 255
    • 8 bit signed sound -128 to +127
    • 16 bit unsigned sound 0 to 65535
    • 16 bit signed sound -32768 to 32767



    AFAIK 32 bit sound samples do not exist or are very rare.

    Remember that because of the D/A converter and the A/D converter all sound on the computer is a jumble of numbers within a certain range. Played at the right frequency, these sound values will reproduce the original recorded sound. Each number represents one slice of time and what the sound was at that time.

    Code:
    for (int i=0;i<bufferlength;i++)
    {
       unsigned char sndvalue=buffer[i];
       switch (sndvalue)
       {
          case 255: peaknum++;peaks[peaknum]=sndvalue;break;
          case 0:lownum++;lows[lownum]=sndvalue;break;
       }
    }
    If you want more information about sound consult www.creative.com or let me know. I coded a complete sound engine in DOS that can play an unlimited amount of sounds (theoretically) from a small buffer of 128 bytes. Also, there is no clicking in my sound engine which is my number one complaint of sound engines.

    Unfortunately, I'm not sure where my code is (imagine that), but if you would like, perhaps you could help me re-code it and convert it to use DirectSound. It really is quite an interesting subject.

  3. #3
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    alright, thanks. i figured it out. i didn't want to play the file, but rather analyze it. i got the set samples from teh sound file so then i can analyze the peaks and things from there.

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Recommended book:

    If you want "get into" audio processing I recommend "Digital Audio Processing" by Doug Coulter. He includes the source code for a complete wave-file editor... WOW! (His code is written for MSVC++.)

    The text covers the concepts and some of the math behind DSP. He doesn't discuss the details of his code. I guess you have to study the actual source code (which I haven't done yet).

  5. #5
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    oh ok, thanks. well i was having one problem with reading in sample values, and we compared it to the output of what it was from MATLAB (this language is like, crazy haha), it ended up being a problem with the numbers being signed/unsigned.

    the concepts behind the project have already been figured out, its mostly just porting code over from MATLAB to C++. im not using MSVC++ (because i cant find someone in the office with a copy), so im using dev-c++/gcc, and it seems to be working good

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Libraries for Audio Signal Processing?
    By GOBLIN-85 in forum C++ Programming
    Replies: 4
    Last Post: 06-15-2009, 02:12 AM
  2. Audio Processing
    By GOBLIN-85 in forum C++ Programming
    Replies: 4
    Last Post: 06-08-2009, 01:40 PM
  3. Audio Processing Question
    By bobthebullet990 in forum Linux Programming
    Replies: 7
    Last Post: 09-08-2006, 01:36 PM
  4. audio programming (from scratch)
    By simpleid in forum C Programming
    Replies: 6
    Last Post: 07-26-2006, 10:32 AM
  5. file writing crashes
    By test in forum C Programming
    Replies: 25
    Last Post: 08-13-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21