Created
October 27, 2012 13:06
-
-
Save johnHackworth/3964565 to your computer and use it in GitHub Desktop.
quick theremin
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
// only webkit, please | |
var DoFreq = 261; | |
var SiFreq = 494; | |
var rangeFreq = DoFreq - SiFreq; | |
var context = new webkitAudioContext(); | |
var sineWave = context.createOscillator(); | |
sineWave.connect(context.destination); | |
sineWave.noteOn(1); | |
window.addEventListener('mousemove', function(ev) { | |
var totalSize = window.document.width; | |
sineWave.frequency.value = (ev.clientY * rangeFreq / totalSize) + DoFreq; | |
sineWave.detune.value = ev.clientX; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment