multiple audio3d listeners

I find out that that have multiple listeners in Panda3d is possible bypassing the default 3D audio manager and creating your own manager using the FMOD library (through python bindings) as suggested earlier. With it you can easily create a Sound object and one or more Listener objects, pass their respective positions and velocities and then get 3d sound reaching all listeners. However… according to FMOD documentation (https://www.fmod.org/docs/content/generated/overview/3dsound.html), effects like doppler and others are disabled to avoid confusion which makes multiple listeners less attractive (at least to me):

I upload some example about how use FMOD in python here:

Of if you don’t care about spectrums, this is simpler:

import sys
import time
import pyfmodex
from pyfmodex.constants import FMOD_SOFTWARE, FMOD_LOOP_NORMAL, FMOD_3D

if __name__ == '__main__':

    def change_listener(listener):
        current_listener.position = listener
        fmod.update()

    ## FMOD initialization
    fmod = pyfmodex.System()
    fmod.init()

    ## Load the sound
    sound1 = fmod.create_sound("sine.wav",
                               mode=FMOD_LOOP_NORMAL | FMOD_3D | FMOD_SOFTWARE)

    ## Play the sound
    channel = sound1.play()
    channel.volume = 0.7
    channel.min_distance = 50
    channel.max_distance = 10000  ## Need this for sound fall off

    ## Create listeners positions
   listener1 = (0, 0, 0)
   listener2 = (0, 10, 0)

    ## Create a FMOD listener in the center of the scene
    current_listener = fmod.listener(id=0)
    change_listener(listener1)

    ## Walk the sound around your head
    min_x = -30
    max_x = 30
    sound_pos = (max_x, 3, 0)
    x = min_x
    inc = 1
    while True:
        if x == min_x:
            inc = 1
        elif x == max_x:
            inc = -1
        x += inc
        channel.position = [x, sound_pos[1], sound_pos[2]]
        fmod.update()
        print("Playing at %r" % str(channel.position))
        time.sleep(0.1)

Put your headphones, run the code above and enjoy… :wink:

PS:

In this case, you still have a single listener, not multiple listeners hearing at same time. The difference is that you can change which user will hear…

Yes, I created the function change_listener to fill this role.