diff options
| author | Brian Cully <bjc@spork.org> | 2025-07-28 14:07:40 -0400 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-07-28 14:08:54 -0400 |
| commit | 7ca6bcfb6cab46103f2f6d8e714c3e06b8157033 (patch) | |
| tree | fbfbc4d2ddb6e9b9532c614e77d446f007eb2fd5 /player-tests.mjs | |
| parent | 20edfe198d508a556f971ec7b9fe8fa957da15c7 (diff) | |
| download | chords-7ca6bcfb6cab46103f2f6d8e714c3e06b8157033.tar.gz chords-7ca6bcfb6cab46103f2f6d8e714c3e06b8157033.zip | |
add player tests
Diffstat (limited to 'player-tests.mjs')
| -rw-r--r-- | player-tests.mjs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/player-tests.mjs b/player-tests.mjs new file mode 100644 index 0000000..e2ba42f --- /dev/null +++ b/player-tests.mjs @@ -0,0 +1,20 @@ +import { Note, toCents } from './scale.mjs'; + +export default function() { + const cNote = Note.fromString('C'); + console.assert(cNote.distanceTo(cNote) === 0); + const dNote = Note.fromString('D'); + console.assert(cNote.distanceTo(dNote) === 2); + const dSharpNote = Note.fromString('D♯'); + console.assert(cNote.distanceTo(dSharpNote) === 3); + + const aNote = Note.fromString('A', 'A to A'); + console.assert(toCents([aNote, 4], [aNote, 3]) === -1200); + const bNote = Note.fromString('B'); + console.assert(toCents([aNote, 4], [bNote, 4]) == 200, 'A4 to B4 is 200 cents'); + // E F F# G G# A + const eNote = Note.fromString('E'); + console.assert(toCents([aNote, 4], [eNote, 4]) === -500, 'E4 is 500 cents lower than A4'); + + console.assert(toCents([aNote, 4], [bNote, 3]) === -1000, 'A4 to B3 is 100 cents above -1200'); +} |
