Hi, I am new to openAL. I wanted to generate a wave with user parameters using openAL. i.e. according to the parameters input, a certain wave will be produced. The code I wrote is below. I am unable however, to get a sine wave at the parameters that should be producing a sine wave. So i feel that there is a problem with my code.. Any help would be greatly appreciated. Thank you.

Please use ...[/code] tags when posting code on the forum, to preserve the formatting. As for your problem, your sine-generating code looks wrong. It's a buffer of integers, but you're multiplying by 0.000001, so everything will be rounded to zero. With S32 amplitudes the range is +/- 2 billion and change. Try multiplying the sine by 100 million or 1 billion and you should be able to hear something. [code]...[/code****] tags when posting code on the forum, to preserve the formatting.

As for your problem, your sine-generating code looks wrong. It's a buffer of integers, but you're multiplying by 0.000001, so everything will be rounded to zero. With S32 amplitudes the range is +/- 2 billion and change. Try multiplying the sine by 100 million or 1 billion and you should be able to hear something.

My OpenAL version could be a bit old, but my version only supports up to 16bit streams. Either way, when you call alBufferData(...), make sure you supply the correct audio format, which is 32bit in your case (and assuming that's supported). I'm also only familiar with 32bit floating point buffers for audio data in other APIs. I've never seen integer based ones. If OpenAL allows it though, it should be fine as long as you properly map your floating point sin wav to an integer.

As Reed said, you're buffer assignment is a little off. Your amplitude (0.000001) is way to low. For a 32bit floating point audio stream, you want your sin wave to oscillate between 1.0 and -1.0 for full loudness. For the time being, set your amplitude to 1.0. Secondly, your bit stream is using an int data type, so you want to map your floating point value back into an integer. You need to multiply your sin wave, which should be in the range -1.0 to 1.0, by 2\\^31.