Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxSound not being able to set the pan after playing it #2852

Open
Cherif107 opened this issue Jul 2, 2023 · 3 comments
Open

FlxSound not being able to set the pan after playing it #2852

Cherif107 opened this issue Jul 2, 2023 · 3 comments

Comments

@Cherif107
Copy link

  • 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

@Starmapo
Copy link
Contributor

Starmapo commented Jul 2, 2023

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.

@Cherif107
Copy link
Author

Cherif107 commented Jul 2, 2023

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

@Geokureli
Copy link
Member

i created #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants