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

Change static sound playbackRate and pitch settings API #16396

Merged

Conversation

docEdub
Copy link
Contributor

@docEdub docEdub commented Mar 24, 2025

The static sound playbackRate and pitch options are confusing when it comes to sound instances. Changing those options on a sound with multiple instances playing only updates the most recent instance, but it should update all instances.

Similarly, allowing the playbackRate and pitch options to be set in the play function is confusing because the parent sound's properties will override the new instance's option set by the play function, which will cause the playback rate and pitch to change unexpectedly when the sound's properties are changed.

This change fixes these issues by making the static sound's playbackRate and pitch properties apply to all playing instances, and by removing the playbackRate and pitch options from the play function.

The static sound `playbackRate` and `pitch` options are confusing when it comes to sound instances. Changing those options on a sound with multiple instances playing only updates the the most recent instance, but it should update all instances.

Similarly, allowing the `playbackRate` and `pitch` options to be set in the `play` function is confusing because the parent sound's properties will override the new instance's option set by the `play` function, which will cause the playback rate and pitch to change unexpectedly when the sound's properties are changed.

This change fixes these issues by making the static sound's `playbackRate` and `pitch` properties apply to all playing instances, and by removing the `playbackRate` and `pitch` options from the `play` function.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the static sound API to ensure that changes to playbackRate and pitch apply to all currently playing instances and removes the options from the play function to avoid unintended overrides.

  • Updated type interfaces to remove the separate play options for pitch and playbackRate.
  • Modified the tone setters to iterate over all sound instances instead of updating only the most recent instance.
  • Updated the webAudio sound instance to source tone values from the parent rather than the play options.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/dev/core/src/AudioV2/abstractAudio/staticSound.ts Adjusted type definitions and updated setters to update all instances rather than a single instance.
packages/dev/core/src/AudioV2/webAudio/webAudioStaticSound.ts Removed redundant option updates in instance setters and updated usage to source values from the parent sound.

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 24, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 24, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@docEdub docEdub marked this pull request as ready for review March 24, 2025 18:19
@docEdub docEdub enabled auto-merge (squash) March 24, 2025 18:20
@bjsplat
Copy link
Collaborator

bjsplat commented Mar 24, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 24, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 24, 2025

@docEdub docEdub merged commit 9b91708 into BabylonJS:master Mar 24, 2025
16 checks passed
@docEdub docEdub deleted the 250324-fix-pitch-and-playback-rate-options branch April 7, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants