Created
July 27, 2017 13:10
-
-
Save eric-wood/8bb864e4f74e214ef9b323296b6c6f8d to your computer and use it in GitHub Desktop.
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
// here's the MIDI notes for the sequence | |
// const NOTES = [36, 40, 43, 47, 48, 47, 43, 40]; | |
// web audio oscillators want frequency values, tho, so here's the frequencies: | |
const NOTES = [65.4063913251, 82.4068892282, 97.9988589954, 123.4708253140, 130.8127826503, 123.4708253140, 97.9988589954, 82.4068892282]; | |
let current = 0; | |
setInterval(() => { | |
postMessage(NOTES[current]); | |
current = current < NOTES.length - 1 ? current + 1 : 0; | |
}, 200); |
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
// set up a bunch of stuff, pretend oscillator is already defined | |
const arpeggiator = new Worker('arpeggiator.js'); | |
arpeggiator.onmessage = (event) => { | |
oscillator.frequency.value = event.data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment