[Openal] OpenAL .. Directional Effects .. Need Help
Chris Robinson
chris.kcat at gmail.com
Thu Jan 20 12:02:24 PST 2011
On Thursday, January 20, 2011 12:59:16 am Cherukuri Jyothi Swaroop wrote:
> Hi
>
> I ported OpenAL to our platform and able to play the wav files.
> I wrote a sample openal application and try to produce some sound effects.
> Play back of audio is working but sound effects are not working.
>
> I am using jungle.wav which is mono channel sound wave file as input
...
> I am expecting the sound to be played in the right headphone/speaker.
>
> But the sound is played in both the headphones.
Hi.
I think the cause is here:
SourcesPos[0] = 200;
SourcesPos[1] = 200;
SourcesPos[2] = 25;
This sets the source to the right side, but also high up and a bit behind the
listener. This causes the sound to pan towards the center since it's not
strictly on the right side. It shouldn't be perfectly centered (it should be a
bit less than half way to the right), but it does make OpenAL produce sound on
the left speaker as well as the right. If you set that to:
SourcesPos[0] = 200;
SourcesPos[1] = 0;
SourcesPos[2] = 0;
Does it play on the right side that way? If so, that's just how the panning
algorithm works. The farther a source is from a strict right position, the
more it pans towards the left so it can make a smooth transition as it circles
around the listener.
Also, on a side note:
alGenBuffers(NUM, Buffers);
Buffer[0]= alutCreateBufferFromFile("/Res/jungle.wav");
This is causing a leak. alGenBuffers creates NUM buffer IDs and writes them to
the Buffers array, but alutCreateBufferFromFile is creating another buffer ID
and overwriting Buffers[0]. The Buffers[0] that alGenBuffers created is lost,
replaced by the one alutCreateBufferFromFile created.
Hope that helps. :)
More information about the Openal
mailing list