toMidi now understands numbers

This commit is contained in:
Felix Roos
2022-06-30 16:49:01 +02:00
parent d0acb32497
commit 31d0225341
+3
View File
@@ -19,6 +19,9 @@ export const tokenizeNote = (note) => {
// turns the given note into its midi number representation
export const toMidi = (note) => {
if (typeof note === 'number') {
return note;
}
const [pc, acc, oct] = tokenizeNote(note);
if (!pc) {
throw new Error('not a note: "' + note + '"');