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?
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.
- 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.
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.
for (int i=0;i<bufferlength;i++)
unsigned char sndvalue=buffer[i];
case 255: peaknum++;peaks[peaknum]=sndvalue;break;
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.
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.
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).
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