-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuzz.html
128 lines (91 loc) · 3.41 KB
/
buzz.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<title>Buzz pollenator tool</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-34084184-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-34084184-1');
</script>
<script>
var context = null; var usingWebAudio = true;
if (typeof AudioContext !== 'undefined') { context = new AudioContext(); }
else if (typeof webkitAudioContext !== 'undefined') { context = new webkitAudioContext(); }
else { usingWebAudio = false; }
function experiment() {
startSound()
setTimeout(stopSound, document.getElementById("durationText").value)
}
function startSound(newFreq) {
osc = context.createOscillator();
gain = context.createGain();
osc.connect(gain);
gain.connect(context.destination)
osc.frequency.value = document.getElementById("freqText").value;
gain.gain.value = document.getElementById("amplitudeText").value / 10.0;
osc.start(0);
}
function stopSound() {
osc.stop(0);
}
window.onload = function() {
if (!usingWebAudio) {
document.getElementById("audioControls").innerHTML = "<p>Web audio required.</p>"
}
}
</script>
</head>
<body style="font-size:14px">
<br>
<div class="container" id="audioControls">
<h3 class="text-center">Buzz pollenator tool</h3>
<br>
<div class="input-group input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-lg">Frequency:</span>
</div>
<input type="number" pattern="[0-9]*" class="form-control" id="freqText" value="440">
<div class="input-group-append">
<span class="input-group-text">Hz</span>
</div>
</div>
<br>
<div class="input-group input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-lg">Amplitude:</span>
</div>
<input type="number" pattern="[0-9]*" class="form-control" id="amplitudeText" value="5">
<div class="input-group-append">
<span class="input-group-text">(0-10)</span>
</div>
</div>
<br>
<div class="input-group input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-lg">Duration:</span>
</div>
<input type="number" pattern="[0-9]*" class="form-control" id="durationText" value="1000">
<div class="input-group-append">
<span class="input-group-text">ms</span>
</div>
</div>
<br>
<div class="input-group input-group-lg">
<button type="button" class="btn btn-primary btn-lg btn-block" id="start" value="Run" onclick="experiment()">Run</button>
</div>
<br>
<p>A project of the <a href="http://groverlab.org">Grover Lab</a> and <a href="http://woodardlab.com">Woodard Lab</a>, University of California, Riverside</p>
</div>
</body>
</html>