Skip to content

volume for sound expressions in simulator #10678

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

srietkerk
Copy link
Contributor

fixes microsoft/pxt-microbit#5193

This pull request introduces support for specifying volume in sound expressions. The changes primarily focus on updating the playSoundExpressionAsync and related methods to include a volume parameter, and ensuring compatibility with existing components that utilize these methods.

Enhancements to sound expression functionality:

  • pxtsim/sound/soundexpression.ts: Added a volume property to the PendingSound interface and updated the __playSoundExpression and playSoundExpressionAsync methods to accept a volume parameter. Adjusted the internal logic to pass the volume value through the sound playback pipeline. [1] [2] [3] [4] [5]

Updates to components using sound expressions:

@srietkerk srietkerk requested review from a team and Copilot June 20, 2025 01:15
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 sound expression functionality to support a volume parameter, enhancing the simulator sound playback. The key changes include:

  • Adding a volume property to the PendingSound interface and propagating the volume parameter in sound playback functions.
  • Updating calls to playSoundExpressionAsync in the SoundEffectEditor and SoundGallery components to include a default volume of 127.
  • Modifying the playSoundExpressionAsync API signature and related internal logic to account for volume.

Reviewed Changes

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

File Description
webapp/src/components/soundEffectEditor/SoundGallery.tsx Updated playSoundExpressionAsync call to pass default volume
webapp/src/components/soundEffectEditor/SoundEffectEditor.tsx Updated playSoundExpressionAsync call to pass default volume
pxtsim/sound/soundexpression.ts Extended PendingSound interface and updated internal sound playback logic
Comments suppressed due to low confidence (1)

pxtsim/sound/soundexpression.ts:289

  • To ensure consistent behavior and avoid potential issues when volume is not provided, consider making the volume parameter required or supplying a default value within the function.
    export function playSoundExpressionAsync(notes: string, volume?: number, isCancelled?: () => boolean, onPull?: (freq: number, volume: number) => void) {

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

Successfully merging this pull request may close these issues.

Volume doesn't affect Sound effect blocks in Simulator
1 participant