3d audio sound bug?


Trying to use the 3d audio manager i have experienced a problem. The left right channel volumes are only based on the position of the camera, not relative to the viewangle of it. (move to some position, and turn around)

I have an example to show the problem including the code. I could not include the textures as i do not own the rights to distribute them. (come to the kunsthaus zürich switzerland at the 27.1 to view them :slight_smile: Just move to the white area, where you will see some bowl in the center, this is the sounds position.



indeed. in case the camera spawns with the x-axis pointing to the bowl the position is only incluenced by the y-axis (if z is up). the volume is correct… but neither y nor any camera rotation are taken into account when it comes to the direction the sound is heared from.

Is this a bug in my code or is this a error in panda3d code? :slight_smile:

dont really know. your code looks ok. i also tried to simply it as much as possible to avoid any sort of mistakes. well the manual sais nothing about setting the listeners rotation either… might be a bug… maybe we just missed something. perhaps asking josh can help.

@drwr: any ideas? cause i’ll have this problem too… quite soon
btw welcome back david =) glad to see you healthy again. we all missed you here :slight_smile:

Thanks! It’s great to be back!

Actually, I know little about the 3-D audio system. In general, we use a different audio implementation at the VR Studio, and we don’t use the 3-D part of the audio system at all. I’ll have to defer to Josh on this one.


This is a bug and you can fix this by changing the update method in Audio3DManager.py in direct.showbase like shown here below. The method was not taking the transformed forward and up vectors in to account when calling audio3dSetListenerAttributes. Previously these values where hardcoded (now vectors y and z). A more general way would be to define forward and up vectors as members with default values that could be overridden in special cases if y and z are not forward and up respectively.

def update(self, task=None):
        Updates position of sounds in the 3D audio system. Will be called automatically
        in a task.
        # Update the positions of all sounds based on the objects
        # to which they are attached
        for known_object in self.sound_dict.keys():
            tracked_sound = 0
            while tracked_sound < len(self.sound_dict[known_object]):
                sound = self.sound_dict[known_object][tracked_sound]
                pos = known_object.getPos(self.root)
                vel = self.getSoundVelocity(sound)
                sound.set3dAttributes(pos[0], pos[1], pos[2], vel[0], vel[1], vel[2])
                tracked_sound += 1

        # Update the position of the listener based on the object
        # to which it is attached
        if self.listener_target:
            pos = self.listener_target.getPos(self.root)
            y = self.listener_target.getRelativeVector(self.root, VBase3(0,1,0))
            z = self.listener_target.getRelativeVector(self.root, VBase3(0,0,1))
            vel = self.getListenerVelocity()
            self.audio_manager.audio3dSetListenerAttributes(pos[0], pos[1], pos[2], vel[0], vel[1], vel[2], y[0], y[1], y[2], z[0], z[1], z[2])
            self.audio_manager.audio3dSetListenerAttributes(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1)
        return Task.cont


Will this be fixed in the next release? Its just that i dont want to forget about this problem an wonder another time why it doesnt work :slight_smile:


I think there is still a mistake in the “corrected” code.
In my program, where the camera is always looking at my object (an airplane), the engine sound turns around the camera.
Now I changed the code like this:

y = self.root.getRelativeVector(self.listener_target, VBase3(0,1,0))
z = self.root.getRelativeVector(self.listener_target, VBase3(0,0,1))

instead of

y = self.listener_target.getRelativeVector(self.root, VBase3(0,1,0))
z = self.listener_target.getRelativeVector(self.root, VBase3(0,0,1))

And it works fine.
Just to let you know …

I’m going to have to write a new audiomanager this summer. I’ll bear this problem in mind when designing the new one.

I tested my OpenAL implementation with a 4 speaker setup and could clearly hear the direction of the audio source wrt. the camera. I am not sure how this could relate to a bug in the python part of panda3d.