3D sound via python in the BGE? I can't seem to get 3D sound working with audaspace.
It works fine when using the logic brick, but I'd like to use python directly if possible.

I'd like to have positional sound relative to the player object:

import bge
import aud

sound = aud.Factory.file(bge.logic.expandPath('//laserfire01_mono.wav'))
scene = bge.logic.getCurrentScene()

def main(cont):
    own = cont.owner

    sound_device = aud.device()
    sound_device.distance_model = aud.AUD_DISTANCE_MODEL_LINEAR
    sound_device.listener_location = scene.objects["player"].worldPosition
    sound_device.listener_orientation = (0,0,0,0)

    sound_handle = sound_device.play(sound)
    sound_handle.location = own.worldPosition
    sound_handle.distance_maximum = 12
    sound_handle.distance_reference = 1
    sound_handle.attenuation = 12


There are no error messages, but the sound is still "2D"; there's no falloff or doppler shift.

Here's a simple test .blend and sound file.
It seems handle.relative defaults to True. Setting it to false fixes the lack of attenuation, but to get doppler shifting you must tell audaspace the velocities of the source and listener objects as well:

import bge
import aud

sound = aud.Factory.file(bge.logic.expandPath('//laserfire01_mono.wav'))
scene = bge.logic.getCurrentScene()

def main(cont):
    own = cont.owner

    sound_device = aud.device()
    sound_device.distance_model = aud.AUD_DISTANCE_MODEL_LINEAR
    sound_device.listener_location = scene.objects["player"].worldPosition
    sound_device.listener_velocity = scene.objects["player"].getLinearVelocity()

    sound_handle = sound_device.play(sound)
    sound_handle.relative = False
    sound_handle.location = own.worldPosition
    sound_handle.velocity = own.getLinearVelocity()
    sound_handle.distance_maximum = 100
    sound_handle.distance_reference = 1