I am using OpenAL and ALUT on a project I am working on. I need to get the waveform from the buffer. I am using alutLoadWAVFile to load the data into the buffer. When I output each item in the buffer, I get something like this:
This is not the waveform, because the waveform looks like this in Audacity:
My code (the relevant parts anyway):
unsigned char* alBuffer;
...
alutLoadWAVFile((ALbyte*)("test2.wav"), &alFormatBuffer,
(void **)&alBuffer, (ALsizei*)&alBufferLen, &alFreqBuffer, &alLoop);
...
for (int i = 0; i < (alBufferLen>5000?5000:alBufferLen); i++) {
log << (int)data[i] << "\n";
}
I'm thinking that what you're expecting is that the buffer data to be exactly what you see in Audacity. This won't really be the case if the wav is anything other than 8Bit Mono (I think anyway, it's been a while).
Also, you seem to be casting data[i] from an unsigned char to an int, which may be another problem.
Also, you might want to attempt manually reading the wav file instead of using ALUT. ALUT is a crutch that makes you weak. :)
Here's a program that reads and plays a wav without ALUT. With it you'll be able to figure out the mono/stereoness and freq of the wav file. Hopefully from there you can start messing with the buffer directly and output exactly what you want.