Draft
Conversation
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fully addresses #4724 — fixing both issues with Custom Pitch Blocks:
Root Cause
Identity Loss (js/blocks.js)
The switch statement that handles block replacement when dragging from the palette had no
casefor"customNote". Without it, custom pitch blocks fell through to the default behavior and were replaced with regular pitch blocks.Missing Preview Sound (js/piemenus.js + js/utils/synthutils.js)
The __selectionChanged handler in piemenuCustomNotes (js/piemenus.js) had two problems:
No audio context initialization —
Tone.start()was never called. Modern browsers require this after user interaction before audio can play.getNote() can't parse custom note names — Custom notes like C(+0¢) were passed through getNote(), which only understands standard note names (C, D, E...), producing invalid output that caused the frequency lookup to fail.
Additionally, getCustomFrequency() in synthutils.js could not handle pitch-index labels (e.g.,
"0","1") — when custom temperament data stores entries as plain ratio numbers instead of[ratio, name, octave]arrays, the function failed to find a match and returned a string instead of a frequency.Changes
js/blocks.js
case "customNote"to the block replacement switch statement so Custom Pitch Blocks retain their identity when dragged from the palette.js/utils/synthutils.js — getCustomFrequency()
"0") in the temperament data and computes the frequency directly from the ratio.js/piemenus.js —
piemenuCustomNotes.__selectionChanged()asyncand addedTone.start()for proper audio context initialization.note + octavepassed to getCustomFrequency().Testing
PR Category