[Solved] OpenAL issues

Hey all,

I am just wondering if someone could post a minimalistic (but ready-to-run) python file/code that demonstrates 3D positional Audio via OpenAL. -I Can’t seem to get this working.

I have read over both the manual and the forums, as well as external examples I could find on different websites trying every different implementation of the audio setup I could find, and in all of them, the ‘3D’ sound plays, but it is not directional, it simply maintains it’s volume no matter how close the listener object is.

I would really appreciate it if someone could chuck together a simple python file that plays one 3D sound on their computer, and post the code here. This way I can check if it is a problem with my Audio drivers (I do use a wierd legacy sound card) or if it is something I’m doing wrong in code.

Just in case no-one can put together a file like I’ve requested, here’s one version of the audio code I have used (to no avail).

# I have tried attaching it to base.camera, camera, my player object...
audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera)

mySound1 = audio3d.loadSfx("sound/drone.wav")

# I have been attaching it to a point light node point,
# replaced here with object for simplicity
audio3d.attachSoundToObject(mySound1, self.object)

I have, in the past gotten OpenAL demo’s to work under C… So i’m pretty annoyed at not being able to get it working under python, which I enjoy using a LOT more than C.

Thanks :stuck_out_tongue:

Here is my sample for 3D audio:

import direct.directbase.DirectStart
from direct.showbase.Audio3DManager import Audio3DManager

#Load Model
box = loader.loadModel("models/box")
#Load Audio Manager/Sound
audio3d = Audio3DManager(base.sfxManagerList[0], camera)
mySound = audio3d.loadSfx('audio/shortrain.wav')
audio3d.attachSoundToObject(mySound, box)

#Play Sound


For my full audio tutorial, go here:


EDIT: Your dropoff factor is set to almost nothing, so that might be one thing. The example above also has the object off to the side, which is another way to tell if your sound is positioned. The tutorial link just above has all of the media you will need to work with this sample.

@AamesxDavid: Thanyou!!! You’re tutorials are great, and sure enough, they work! The 3D sound is perfectly distinguishable from the ordinary sound tutorial.

I recommend the above links to anyone who stumbles upon this post!

Many thanks again, -I owe you one!

Glad I could help. Audio is my focus 'round here, so feel free to message/e-mail me with any issues. If I don’t already know the answer, I’d be more than happy to find it - it’ll probably end up teaching me something too. :laughing: