OK, I went down the rabbit hole of OpenAL for a bit and have returned with a few tips. I probably won’t be using OpenAL in my current projects but here are a few suggestions for your journey.
- Check out ThinMatrix a Java developer with inspiring blogs - one about OpenAL
[media]https://www.youtube.com/watch?v=BR8KjNkYURk&t=15s[/media]
-
If you want to use 2D sound, referencing a listener and an object, your source sound MUST BE MONO. Boy did I waste a lot of time trying to figure that one out.
-
Offset the z value for the listener or the source for better sound quality. If they have matching z values - the sound transfer left/right will be too abrupt.
-
Here is some code that gets the basics of positional sound working
[lua]
local soundTable = {
wood = audio.loadSound( “sound/wood10.mp3” )
}
al.DistanceModel(al.LINEAR_DISTANCE_CLAMPED)
local function sound2D( o, t )
local mychannel, mysource = audio.play(soundTable[“wood”])
al.Listener(al.POSITION, o.x/100, o.y/100, 1)
al.Source(mysource, al.POSITION, t.x/100, t.y/100, 0.0)
---- distance model info -----
al.Source(mysource, al.ROLLOFF_FACTOR, 1)
al.Source(mysource, al.REFERENCE_DISTANCE, 2)
al.Source(mysource, al.MAX_DISTANCE, 15)
end
[/lua]
I look forward to playing around with OpenAL in the future, but for now, it’s time to move on.