[Gambas-user] OpenAL (gb.openal) example code

Benoît Minisini gambas at ...1...
Fri Sep 11 04:33:52 CEST 2015


Le 11/09/2015 04:12, Kevin Fishburne a écrit :
> On 09/07/2015 01:42 AM, Kevin Fishburne wrote:
>>
>> I now have OpenAL working well but I need to know how to change the
>> orientation of the coordinate system to reflect that used by my game.
>> Normally in a 3D game the X axis is left/right, the Y axis is
>> up/down/elevation, and the Z axis goes into the screen (in/out). In
>> Sylph the Y axis goes into the screen and the Z axis is
>> up/down/elevation. As you move into the screen the Y coordinates
>> decrease. An easy way to think about it is a piece of graph paper where
>> the upper-left corner is X:0, Y:0 and the bottom-right corner is X:100,
>> Y:100. You start at the bottom, facing the top, and move along the Y
>> axis toward the top.
>>
>> I believe that
>>
>> Al.Listenerfv(Al.ORIENTATION, [0, 0, -1, 0, 1, 0])
>>
>> orients the audio environment using the traditional axes and not mine
>> where the Z and Y axes are switched. I have no idea how to calculate the
>> proper values for this statement to reflect the axes used in Sylph.
>>
>> Here's another explanation of how the two vectors in Al.Listenerfv work:
>>
>> http://stackoverflow.com/questions/7861306/clarification-on-openal-listener-orientation
>>
>> If the answer is obvious to anyone reading this, please clue me in.
>
> I've only tested this on a 2.0 (stereo) audio setup, so there is some
> chance that the front and rear speakers will be reversed, but these are
> the two sets of values for the listener orientation for the two
> coordinate orientations I mentioned.
>
> For a game where the Z axis goes "into" the screen and the Y axis is
> height/elevation (the normal way things are done), this works:
>
> Al.Listenerfv(Al.ORIENTATION, [0, 0, -1, 0, 1, 0])
>
> For a game where the Y axis goes "into" the screen and the Z axis is
> height/elevation (what Sylph uses), this works:
>
> Al.Listenerfv(Al.ORIENTATION, [0, -1, 0, 0, 0, -1])
>
> In a game where the camera's orientation is completely arbitrary (an FPS
> or flight sim, for example) the listener orientation should correspond
> to the "camera" orientation.
>
> Something else to note about OpenAL is that if a sample/sound file is
> multichannel (stereo, for example) 3D positioning and doppler effects
> will be ignored and the sound will play equally on all speakers (like
> you were playing music in a media player). If you want a sound effect to
> use 3D positioning and doppler effects it must be mono (one channel).
> You can use a program like Audacity to check/correct this.
>

You should put that in a wiki article...

-- 
Benoît Minisini




More information about the User mailing list