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.