-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenjie.html
37 lines (37 loc) · 889 Bytes
/
benjie.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<pre id='log'>
</pre>
<script src="/socket.io/socket.io.js"></script>
<script src="/js/nxt.js"></script>
<script>
var logEl = document.getElementById('log');
function log(msg) {
if (logEl) {
logEl.textContent = msg + "\n" + logEl.textContent;
}
}
var socket = io.connect('http://'+window.location.host);
log("Connecting");
function play(e) {
e.preventDefault();
tone(e.pageX);
window.onmousemove = play;
}
function stop() {
window.onmousemove = null;
}
window.onmousedown = play;
window.onmouseup = stop;
function tone(hz) {
if (!hz) {
hz = 440+parseInt(Math.random()*800);
}
log("Playing tone: "+hz);
nxt.play_tone(hz, 50);
}
socket.on('welcome', function (data) {
log('Connected');
//setInterval(tone, 2000);
console.log(data);
socket.emit('my other event', { my: 'data' });
});
</script>