Skip to content

Instantly share code, notes, and snippets.

@diegogurgel
Created May 15, 2014 17:03
Show Gist options
  • Save diegogurgel/cb422091de2698dab492 to your computer and use it in GitHub Desktop.
Save diegogurgel/cb422091de2698dab492 to your computer and use it in GitHub Desktop.
window.onload = function()
{
var type = 0;
var contex = new webkitAudioContext();
var oscillator;
playWave();
function playWave(){
oscillator = contex.createOscillator();
oscillator.type = type;
oscillator.connect(contex.destination);
oscillator.noteOn(0);
}
function addOscillator(){
var osc = contex.createOscillator();
osc.type = osc.SQUARE;
osc.connect(contex.destination);
osc.noteOn(0);
return osc;
}
var osc2 = addOscillator();
var $oscilator = document.getElementsByTagName('body')[0];
$oscilator.onmousemove = function(event){
osc2.frequency.value=event.y*5;
oscillator.frequency.value=event.x*5;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment