HaxeFlixel / HaxeFlixel/flixel

FlxSound not being able to set the pan after playing it

Open
#2,852 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

OpenFL / Lime Sound
Dominant language
Haxe
Stars
2.2k
Forks
522
Avg merge
34m
Merged PRs (30d)
1

Description

  • 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied FlxSound reproduction, then inspect the linked OpenFL Sound.hx code around line 634 and how FlxSound applies pan after play(). Verify the cpp target behavior with pan set after playback; done means the sound moves right when pan is set to 1 after playing, with a regression check if the project has a suitable test location.

Written by the indexing model from the issue text.

Assessment

Domain
audio-video-rtc, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.