From 7850fb727e98bbd323d61f57d9cfad294f15a65b Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sun, 11 Jun 2023 13:23:45 +0200 Subject: [PATCH 1/2] fix: allow f for flat notes like tidal --- packages/core/util.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/util.mjs b/packages/core/util.mjs index 5dbf65fc..7fbe7388 100644 --- a/packages/core/util.mjs +++ b/packages/core/util.mjs @@ -6,12 +6,12 @@ This program is free software: you can redistribute it and/or modify it under th // returns true if the given string is a note export const isNoteWithOctave = (name) => /^[a-gA-G][#bs]*[0-9]$/.test(name); -export const isNote = (name) => /^[a-gA-G][#bs]*[0-9]?$/.test(name); +export const isNote = (name) => /^[a-gA-G][#bsf]*[0-9]?$/.test(name); export const tokenizeNote = (note) => { if (typeof note !== 'string') { return []; } - const [pc, acc = '', oct] = note.match(/^([a-gA-G])([#bs]*)([0-9])?$/)?.slice(1) || []; + const [pc, acc = '', oct] = note.match(/^([a-gA-G])([#bsf]*)([0-9])?$/)?.slice(1) || []; if (!pc) { return []; } @@ -25,7 +25,7 @@ export const noteToMidi = (note) => { throw new Error('not a note: "' + note + '"'); } const chroma = { c: 0, d: 2, e: 4, f: 5, g: 7, a: 9, b: 11 }[pc.toLowerCase()]; - const offset = acc?.split('').reduce((o, char) => o + { '#': 1, b: -1, s: 1 }[char], 0) || 0; + const offset = acc?.split('').reduce((o, char) => o + { '#': 1, b: -1, s: 1, f: -1 }[char], 0) || 0; return (Number(oct) + 1) * 12 + chroma + offset; }; export const midiToFreq = (n) => { From 3b4e44a9fd10b439f58d54ed98ed3da780f8fc02 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sun, 11 Jun 2023 13:55:11 +0200 Subject: [PATCH 2/2] fix: main repl option-dot on mac --- website/src/repl/Repl.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/src/repl/Repl.jsx b/website/src/repl/Repl.jsx index ce480701..c30e7663 100644 --- a/website/src/repl/Repl.jsx +++ b/website/src/repl/Repl.jsx @@ -157,7 +157,7 @@ export function Repl({ embedded = false }) { e.preventDefault(); flash(view); await activateCode(); - } else if (e.key === '.' || e.keyCode === 'Period') { + } else if (e.key === '.' || e.code === 'Period') { stop(); e.preventDefault(); }