Fixed issue with 'b' flats being output as note 'B' (#2055)

* Fixed issue with 'b' flats being output as note 'B'

* 'b' will only be interpreted as a flat when following another note, otherwise it will be interpreted as the 'B' note
This commit is contained in:
kimprice 2019-05-16 12:50:08 -07:00 committed by GitHub
parent e41bb87600
commit 84fcc38e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -397,22 +397,23 @@ namespace music {
let isrest: boolean = false; let isrest: boolean = false;
let beatPos: number; let beatPos: number;
let parsingOctave: boolean = true; let parsingOctave: boolean = true;
let prevNote: boolean = false;
for (let pos = 0; pos < currNote.length; pos++) { for (let pos = 0; pos < currNote.length; pos++) {
let noteChar = currNote.charAt(pos); let noteChar = currNote.charAt(pos);
switch (noteChar) { switch (noteChar) {
case 'c': case 'C': note = 1; break; case 'c': case 'C': note = 1; prevNote = true; break;
case 'd': case 'D': note = 3; break; case 'd': case 'D': note = 3; prevNote = true; break;
case 'e': case 'E': note = 5; break; case 'e': case 'E': note = 5; prevNote = true; break;
case 'f': case 'F': note = 6; break; case 'f': case 'F': note = 6; prevNote = true; break;
case 'g': case 'G': note = 8; break; case 'g': case 'G': note = 8; prevNote = true; break;
case 'a': case 'A': note = 10; break; case 'a': case 'A': note = 10; prevNote = true; break;
case 'b': case 'B': note = 12; break; case 'B': note = 12; prevNote = true; break;
case 'r': case 'R': isrest = true; break; case 'r': case 'R': isrest = true; prevNote = false; break;
case '#': note++; break; case '#': note++; prevNote = false; break;
case 'b': note--; break; case 'b': if (prevNote) note--; else { note = 12; prevNote = true; } break;
case ':': parsingOctave = false; beatPos = pos; break; case ':': parsingOctave = false; beatPos = pos; prevNote = false; break;
default: if (parsingOctave) currentOctave = parseInt(noteChar); default: prevNote = false; if (parsingOctave) currentOctave = parseInt(noteChar);
} }
} }
if (!parsingOctave) { if (!parsingOctave) {