fix(musicutils): correct octave check for "ti" in getNumNote#7447
fix(musicutils): correct octave check for "ti" in getNumNote#7447Harshit-Mishra2212 wants to merge 1 commit into
Conversation
|
🧪 Jest Test Results ✅ All Jest tests passed! This PR is ready to merge. Coverage: Statements: 48.09% | Branches: 39.62% | Functions: 52.88% | Lines: 48.49% |
mahesh-09-12
left a comment
There was a problem hiding this comment.
looks good to me - the fix addresses the octave check correctly, and the added tests cover the affected path well
|
This PR has merge conflicts with Please rebase your branch: # Add upstream remote (one-time setup)
git remote add upstream https://github.com/sugarlabs/musicblocks.git
# Fetch latest master and rebase
git fetch upstream
git rebase upstream/master
# Resolve any conflicts, then:
git push --force-with-lease origin YOUR_BRANCH
|
a6be81a to
eed8b0a
Compare
|
🧪 Jest Test Results ❌ Some Jest tests failed. Please check the logs and fix the issues before merging. Coverage: Statements: 48.23% | Branches: 39.77% | Functions: 52.95% | Lines: 48.63% Note: These failures may be introduced by this PR or may already exist in the master branch. Failed Tests: |
|
Rebased on latest master to resolve merge conflict. The upstream changes added temperament support to getNumNote - the ti octave fix applies cleanly to the new implementation. |
Description
getNumNoteinmusicutils.jsconverts a numeric pitch value into a solfege note name and octave. When the resulting note is"ti", the octave should be decremented by 1 -- this is a standard musical convention since"ti"sits at the boundary between octaves in the solfege system.The existing check was:
Here
noteis a string like"ti"andnumis the modulo result (0–11).note[num]indexes a character from the string at positionnumbut since"ti"is only 2 characters long,note[num]isundefinedfor anynum >= 2. Fornum === 0(the only case where"ti"can appear, sinceNOTESTABLE[0] === "ti"),note[0]gives"t", not"ti". So this condition is always false and the octave decrement never fires.As a result, every call to
getNumNotethat produces a"ti"note returns an octave that is 1 too high.The fix is a one-character change:
note[num]→note.Related Issue
No related issue -- bug identified through code analysis.
PR Category
Changes Made
js/utils/musicutils.js: changenote[num] === "ti"tonote === "ti"ingetNumNotejs/utils/__tests__/musicutils.test.js: add 3 test assertions covering the"ti"octave decrement path, which had zero coverageTesting Performed
npm test -- musicutils- all tests passnpm test- no regressions introducedChecklist
npm run lintandnpx prettier --check .with no errors.