SOLVED: FlxSound not panning mono sounds ?



  • Haxe 3.2.1 - HaxeFlixel 4.0.1

    I was wondering if anyone else has experienced issues with FlxSound not using the pan information its given? No matter what value I store in a FlxSound object's pan property (between -1 and 1), it always seems to play the sound directly in the center of the stereo field ...

    I've been building my project using C++ on Mac and Neko on Windows, and in both cases the result is the same ...

    Has anyone had a similar experience or have any ideas ?

    Thanks!



  • I was able to figure this out after a bit of digging, and get 2D panning working.

    OpenFL was not set up to pass pan information to OpenAL (Lime)

    In openfl.media.Sound in the play() method, add this pan property:

    if (sndTransform != null) {
    	
    	source.gain = sndTransform.volume;
    
    	//ADDED
    	source.pan = sndTransform.pan;
    }
    

    Then in lime.audio.AudioSource, add that property to theAudioSource class:

    public var pan:Float;
    

    then add these two lines before AL.sourcePlay(id):

    AL.distanceModel(AL.NONE);
    AL.source3f(id, AL.POSITION, pan, 0, -1 * Math.sqrt(1 - Math.pow(pan, 2)));
    

    Word is it's on the official fix list for OpenFL, so it'll probably get a proper fix soon.


Log in to reply