flixel icon indicating copy to clipboard operation
flixel copied to clipboard

FlxSound not being able to set the pan after playing it

Open Cherif107 opened this issue 1 year ago • 3 comments

  • 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

Cherif107 avatar Jul 02 '23 00:07 Cherif107

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 avatar Jul 02 '23 14:07 Starmapo

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 image

Cherif107 avatar Jul 02 '23 16:07 Cherif107

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

Geokureli avatar Jul 21 '23 21:07 Geokureli