Skip to content

feat: forward cents from custom pitch blocks and make always-visible#7770

Open
021nirav-blip wants to merge 3 commits into
sugarlabs:masterfrom
021nirav-blip:refactor-custom-pitch-blocks
Open

feat: forward cents from custom pitch blocks and make always-visible#7770
021nirav-blip wants to merge 3 commits into
sugarlabs:masterfrom
021nirav-blip:refactor-custom-pitch-blocks

Conversation

@021nirav-blip

@021nirav-blip 021nirav-blip commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

this PR finally makes custom pitch blocks actually respect cents and also makes them findable.

What's new:

Cents now forward. CustomNoteBlock.flow() and CustomPitchBlock.flow() parse "C(+42¢)" : ["C", 42] and send the cents to the synth. Before, you could type cents in the UI but they'd just get ignored - you'd hear C+0¢.

Blocks are always visible. Both custom blocks now show up in the Pitch palette without needing a custom temperament first. They used to be hidden, which made them impossible to discover.

Pie menu preserves cents. If you have C(+50¢) and pick D from the pie menu, you get D(+50¢) - not just D. That was devins feedback, and it's fixed.

CENTSSYMBOL constant. Added "\u00A2" to musicutils.js and exported it. Tests now use SHARP/FLAT/CENTSSYMBOL constants instead of raw unicode - cleaner and more maintainable.

Quick test: drop a CustomNoteBlock, type C(+42¢), play – you should hear 42 cents above C. Pick D from the pie menu – cents stay. Both blocks are visible in the palette immediately.

Tests pass (6541/6541 – the 3 widget failures were already there).
Files touched: PitchBlocks.js, musicutils.js, piemenus.js.
Part of #7171.

PR Category

  • Feature
  • Tests
  • Bug Fix
  • Performance
  • Documentation

@github-actions github-actions Bot added feature Adds new functionality size/M Medium: 50-249 lines changed area/javascript Changes to JS source files area/tests Changes to test files labels Jul 9, 2026
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.00%. Comparing base (a7a655c) to head (c6012a4).
⚠️ Report is 34 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7770   +/-   ##
=======================================
  Coverage   55.99%   56.00%           
=======================================
  Files         172      172           
  Lines       57397    57407   +10     
=======================================
+ Hits        32141    32151   +10     
  Misses      25256    25256           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@021nirav-blip 021nirav-blip marked this pull request as ready for review July 9, 2026 11:49
@021nirav-blip

Copy link
Copy Markdown
Contributor Author

@walterbender , @pikurasa
can you review my changes whenever you have time

Comment thread js/blocks/__tests__/PitchBlocks.test.js Outdated
global.NOTESFLAT = ["C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"];
global.NOTESTEP = { C: 1, D: 3, E: 5, F: 6, G: 8, A: 10, B: 12 };
global.EQUIVALENTNATURALS = {
"E\u266F": "F",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have constants defined for the various accidentals. We should use those as it makes the code easier to read.

Comment thread js/blocks/__tests__/PitchBlocks.test.js Outdated

describe("CustomNoteBlock", () => {
const customNoteCents = [
["C(+42¢)", "C", 42],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should prob. define a constant for the ¢ symbol too. (I don't think there is one.)

@walterbender

Copy link
Copy Markdown
Member

What is the best way to test this inside of MB?
And I am on the fence about the custom pitch block. It behaves strangely when there are no custom pitches defined.

C+0¢

And when you click on it, it opens the solfege menu with no ability to adjust cents. Maybe not relevant to this PR, but perhaps we should (1) open a pie menu with letter names instead and (2) allow some adjustment of cents? Then it really would be a custom note?

Once a temperament is defined, it would by default live in that range of notes -- but still, being able to tweak cents might be a good addition.

- Add _parseCents() static helper to CustomNoteBlock
- CustomNoteBlock.flow() parses (+N¢)/(-N¢) suffix and forwards cents
- CustomPitchBlock.flow() parses and forwards cents instead of hardcoded 0
- Set hidden=false for both blocks (always visible in palette)
- Add tests for _parseCents, cents forwarding, and always-visible

Related to sugarlabs#7171
Walter review feedback:
- Define CENTSSYMBOL constant in musicutils.js and export it
- Use SHARP/FLAT constants instead of unicode literals in tests
- Use CENTSSYMBOL constant instead of literal ¢ in test data

Related to sugarlabs#7171
When changing a note via the pie menu, preserve any existing cents
suffix (e.g., C(+50¢) → D(+50¢) instead of just D).

Related to sugarlabs#7171
@021nirav-blip 021nirav-blip force-pushed the refactor-custom-pitch-blocks branch from c6012a4 to e618c9a Compare July 9, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/javascript Changes to JS source files area/tests Changes to test files feature Adds new functionality size/M Medium: 50-249 lines changed

Projects

Development

Successfully merging this pull request may close these issues.

2 participants