Skip to content

Commit 603ded1

Browse files
committed
fix(musicutils): restore pitchNumberOffset subtraction directly in _calculate_pitch_number
1 parent 317a633 commit 603ded1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

js/utils/musicutils.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4816,7 +4816,7 @@ function _parse_pitch_string(str) {
48164816
* @param {number} octave - The octave number.
48174817
* @returns {number|string} The calculated pitch number or INVALIDPITCH if calculation fails.
48184818
*/
4819-
function _calculate_pitch_number(noteName, octave) {
4819+
function _calculate_pitch_number(noteName, octave, applyOffset = 0) {
48204820
if (typeof noteName !== "string") {
48214821
return INVALIDPITCH;
48224822
}
@@ -4832,7 +4832,7 @@ function _calculate_pitch_number(noteName, octave) {
48324832
if (baseIndex === -1) baseIndex = NOTESFLAT.indexOf(baseLetter);
48334833
if (baseIndex === -1) return INVALIDPITCH;
48344834
const rawPitch = (parseInt(octave, 10) + 1) * 12 + baseIndex + offset;
4835-
return rawPitch;
4835+
return rawPitch - applyOffset;
48364836
}
48374837

48384838
if (EQUIVALENTSHARPS[name]) {
@@ -4852,7 +4852,7 @@ function _calculate_pitch_number(noteName, octave) {
48524852
return INVALIDPITCH;
48534853
}
48544854

4855-
return (parseInt(octave, 10) + 1) * 12 + pitchIndex;
4855+
return (parseInt(octave, 10) + 1) * 12 + pitchIndex - applyOffset;
48564856
}
48574857

48584858
/**
@@ -6293,9 +6293,7 @@ const getPitchInfo = function (activity, type, currentNote, tur) {
62936293
(octave - 4) * YSTAFFOCTAVEHEIGHT
62946294
);
62956295
case "pitch number":
6296-
return (
6297-
_calculate_pitch_number(pitch, octave) - (tur?.singer?.pitchNumberOffset || 0)
6298-
);
6296+
return _calculate_pitch_number(pitch, octave, tur?.singer?.pitchNumberOffset || 0);
62996297
case "pitch in hertz":
63006298
// This function ignores cents.
63016299
return activity.logo.synth._getFrequency(

0 commit comments

Comments
 (0)