Source for demo by carlocci. See also description.
function audio(p,a) {
var i,t,w = "5249464668ac000057415645666d742010000000010002002256000044ac0000020008006461746144ac0000";
a=a*0.2;
for (i=0,l=22050;i<l;++i) {
t=Math.round(a*Math.sin(i/22050*2*Math.PI*p)+127);
w+=t.toString(16)+t.toString(16);
d.fillRect(i,400-t,1,1);
}
window.a && a.pause();
a = document.createElement('audio');
a.src = "data:audio/x-wav," + w.replace(/(\w\w)/g, '%$1');
document.body.appendChild(a);
//a.addEventListener('ended', function() {c.onmousemove = foo;}, 1);
a.play();
c.onmousemove = foo;
}
z = document.createElement('input');
document.body.appendChild(z);
c = document.getElementById('c');
d = c.getContext('2d');
c.width=800;
c.height=400;
function foo(e) {
c.onmousemove = null;
var x=e.pageX-c.offsetLeft,y=400-e.pageY-c.offsetTop;
z.value = x+' '+y;
setTimeout(function () {audio(x,y)}, 20);
}
c.onmousemove = foo;