flixel
flixel copied to clipboard
FlxSound not being able to set the pan after playing it
- Haxe version: 4.3.1
- Flixel version: 5.3.1
- OpenFL version: 9.2.1
- Lime version: 8.0.1
- Affected targets: cpp
Code snippet reproducing the issue:
package;
import flixel.FlxState;
import flixel.FlxG
class PlayState extends FlxState
{
override public function create():Void
{
var sound = new FlxSound().loadEmbedded('sounds/[367] Ballerina_4');
// sound.pan = 1 if i put it in here it works
sound.play();
sound.pan = 1; // does not work
}
}
Observed behavior: the sound is not panning at all, stays at the center which is the pan of 0
Expected behavior: the sound should be coming from the right instead of the center
im assuming the issue is when openfl Sound clones the sound transform after playing it, specifically here https://github.com/openfl/openfl/blob/master/src/openfl/media/Sound.hx#L634
so the sound panning only works if you set it before actually playing the sound
Is your sound stereo (has 2 channels)? I've come across this problem before, and changing the sound to mono (only 1 channel) fixed it.
Is your sound stereo (has 2 channels)? I've come across this problem before, and changing the sound to mono (only 1 channel) fixed it.
@Starmapo my sound works perfectly when it comes to panning, i pointed out that it only works if you set it before playing the sound
i created https://github.com/HaxeFlixel/flixel/pull/2863 to try and fix this, but it only fixes it on html5, for mac builds panning seems to not work at all for me. I'm asking for guidance from openfl people