-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Change static sound playbackRate
and pitch
settings API
#16396
Conversation
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.
There was a problem hiding this 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. |
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/16396/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/16396/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/16396/merge#BCU1XR#0 |
WebGL2 visualization test reporter: |
Visualization tests for WebGPU |
The static sound
playbackRate
andpitch
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
andpitch
options to be set in theplay
function is confusing because the parent sound's properties will override the new instance's option set by theplay
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
andpitch
properties apply to all playing instances, and by removing theplaybackRate
andpitch
options from theplay
function.