-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
50 lines (43 loc) · 1.34 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
<!doctype html>
<html><head>
<script src="/client.js"></script>
<script src="/client.getsockettime.js"></script>
<style>
.on {
background-color: white;
color: black;
}
body {
background-color: black;
color: white;
font-family: "Arial";
}
</style>
</head><body>
<h1 id="title"></h1>
<script>
var context = new AudioContext();
var interval = 2000
var clockSkew = new ClockSkew({//
log:true,
getTime: function(){
return context.currentTime * 1000;
},
getServerTime: ClockSkew.getSocketTime('ws://localhost:9999/')
});
clockSkew.start();
var chord = [10,12,15,18]; //min 7th;
var note = 440;
var random = Math.floor(Math.random() * 4);
var f = note / chord[0] * chord[random];
document.getElementById('title').innerText = 'Synchronized playing of A-min7th (#'+(random+1)+'/4)';
setInterval(function(){
var osc = context.createOscillator();
osc.connect(context.destination);
osc.frequency.value = f;
var audioTime = clockSkew.getTimeOfNextCycle(interval) / 1000;
osc.start(audioTime);
osc.stop(audioTime + 0.2);
},interval);
</script>
</body></html>