-
Notifications
You must be signed in to change notification settings - Fork 4
/
hello.html
56 lines (45 loc) · 1.25 KB
/
hello.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
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello web audio</title>
</head>
<body>
</body>
<script src="mouse.js"></script>
<script>
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var delay= audioCtx.createDelay(5);
delay.delayTime.value = 0.09;
var delayFeedback = audioCtx.createGain();
delayFeedback.gain.value=0.79;
var volume = audioCtx.createGain();
var sinea = audioCtx.createOscillator();
sinea.frequency.value = 440;
sinea.type = "sine";
sinea.start();
sinea.connect(volume);
var sineb = audioCtx.createOscillator();
sineb.frequency.value = 523.25;
sineb.type = "sine";
sineb.start();
sineb.connect(volume);
var sinec = audioCtx.createOscillator();
sinec.frequency.value = 698.46;
sinec.type = "sine";
sinec.start();
sinec.connect(volume);
volume.connect(delay);
volume.connect(audioCtx.destination);
delayFeedback.connect(volume);
delay.connect(delayFeedback);
delayFeedback.connect(delay);
volume.gain.value=0.2;
mouse.onMouseMove=function(event){
sinea.frequency.value = event.pageX/1000.00*440;
sineb.frequency.value = event.pageX/1000.00*523.25;
sinec.frequency.value = event.pageX/1000.00*698.46;
delayFeedback.gain.value=Math.max(0.7,event.pageY/700.00);
};
</script>
</html>