Skip to content

Instantly share code, notes, and snippets.

@johnHackworth
Created October 27, 2012 13:06
Show Gist options
  • Save johnHackworth/3964565 to your computer and use it in GitHub Desktop.
Save johnHackworth/3964565 to your computer and use it in GitHub Desktop.
quick theremin
// 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