This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function noteFrequency(offset) { | |
// A4 has a defined, integer frequency. Let's use this as the base for calculations | |
const A4Frequency = 440; | |
// Allows: | |
// - multiple flats and sharps in any order | |
// - usage of '♭' or lowercase 'B' as flat | |
const noteRegExp = /^([a-gA-G])([♭b♯#]*)(-?\d+)?$/; | |
const semitoneMultiplier = 2 ** (1/12); | |
const scaleNoteCount = 12; | |
// Pre calculate offsets of each note from A |
NewerOlder