From cdf19b0ac5f3a48518d89928422fa96ff5cb01f0 Mon Sep 17 00:00:00 2001 From: Nicolas Mafra Date: Wed, 31 Jan 2024 19:58:29 -0300 Subject: [PATCH] feat: only parse accident on second char --- theory/PitchNotation.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/theory/PitchNotation.mjs b/theory/PitchNotation.mjs index c511829..b9c6f74 100644 --- a/theory/PitchNotation.mjs +++ b/theory/PitchNotation.mjs @@ -7,8 +7,11 @@ export default { textToChroma(text) { const letter = text.substring(0, 1); let chroma = notes.indexOf(letter); - if (text.includes('#')) chroma++; - if (text.includes('b')) chroma--; + if (text.length > 1) { + const acc = text.substring(1, 2); + if (acc == '#') chroma++; + if (acc == 'b') chroma--; + } return (chroma + 12) % 12; }, pitchToText(midiNumber) {