-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
126 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict' | ||
|
||
import * as a from './audio.js' | ||
|
||
test('filler test', () => { | ||
expect(true).toBe(true) | ||
}) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,116 @@ | ||
'use strict' | ||
import { chordDistance } from './chordexplorer.js'; | ||
import { chordDistance, ChordExplorer, DefaultChordExplorer, defaultDistance } from './chordexplorer.js'; | ||
|
||
// TODO figure out why proptests were so slow and maybe bring them back. | ||
|
||
test('distance between a chord and itself should be zero', () => { | ||
let chord = ["C4", "E4", "G4"] | ||
expect(chordDistance(chord, chord)).toBe(0) | ||
}) | ||
|
||
test('distance between a chord and itself with different order should be zero', () => { | ||
test('chordDistance between a chord and itself with different order should be zero', () => { | ||
let chord = ["C4", "E4", "G4"] | ||
let transposition = ["E4", "G4", "C4"] | ||
expect(chordDistance(chord, transposition)).toBe(0) | ||
expect(chordDistance(transposition, chord)).toBe(0) | ||
}) | ||
|
||
test('distance between chords should be one if they have one note different', () => { | ||
test('chordDistance between chords should be one if they have one note different', () => { | ||
let chord = ["C4", "E4"] | ||
let other = ["C4", "E4", "A4"] | ||
expect(chordDistance(chord, other)).toBe(1) | ||
expect(chordDistance(other, chord)).toBe(1) | ||
}) | ||
|
||
test('ChordExplorer generates chords correctly', () => { | ||
let chord = ["C4", "E4", "G4"] | ||
let e = new ChordExplorer( | ||
[[0, 1, 2]], | ||
["C"], | ||
["M"], | ||
[4], | ||
0, | ||
) | ||
expect(e.allChords).toEqual([chord]) | ||
}) | ||
|
||
test('ChordExplorer generates possible chords correctly', () => { | ||
let chord = ["C4", "E4", "G4"] | ||
let invertedChords = [ | ||
["C4", "E4", "G4"], | ||
["E4", "G4", "C5"], | ||
["G4", "C5", "E5"] | ||
] | ||
let inversions = [ | ||
[0, 1, 2], | ||
[1, 2, 3], | ||
[2, 3, 4] | ||
] | ||
let e = new ChordExplorer( | ||
inversions, | ||
["C"], | ||
["M"], | ||
[4], | ||
2, | ||
) | ||
let possibles = e.possibleNextChords(chord) | ||
expect(possibles).toEqual([invertedChords[1]]) | ||
}) | ||
|
||
test('ChordExplorer never generates the same chord', () => { | ||
let chord = ["C4", "E4", "G4"] | ||
let e = new ChordExplorer( | ||
[[0, 1, 2]], | ||
["C"], | ||
["M"], | ||
[4], | ||
1, | ||
) | ||
let next = e.nextChord(chord) | ||
expect(next).toBeUndefined() | ||
}) | ||
|
||
test('ChordExplorer generates inversions of C major', () => { | ||
let chord = ["C4", "E4", "G4"] | ||
let invertedChords = [ | ||
["C4", "E4", "G4"], | ||
["E4", "G4", "C5"], | ||
["G4", "C5", "E5"] | ||
] | ||
let inversions = [ | ||
[0, 1, 2], | ||
[1, 2, 3], | ||
[2, 3, 4] | ||
] | ||
let e = new ChordExplorer( | ||
inversions, | ||
["C"], | ||
["M"], | ||
[4], | ||
2, | ||
) | ||
for (let i = 0; i < 100; i++) { | ||
let next = e.nextChord(chord) | ||
expect(next).toBeDefined() | ||
let found = false | ||
for (let j = 0; j < invertedChords.length; j++) { | ||
if (chordDistance(next, invertedChords[j]) === 0) { | ||
found = true | ||
break | ||
} | ||
} | ||
expect(found).toBe(true) | ||
} | ||
}) | ||
|
||
test('DefaultChordExplorer always generates chords defaultDistance away', () => { | ||
let e = new DefaultChordExplorer() | ||
let chord = e.allChords[0] | ||
for (let i = 0; i < 1000; i++) { | ||
let next = e.nextChord(chord) | ||
expect(next).toBeDefined() | ||
expect(next).not.toEqual(chord) | ||
expect(chordDistance(chord, next)).toBe(defaultDistance) | ||
chord = next | ||
} | ||
}) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
* | ||
{ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
html, | ||
body | ||
{ | ||
body { | ||
overflow: hidden; | ||
} | ||
|
||
.webgl | ||
{ | ||
.webgl { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
outline: none; | ||
} | ||
} |