-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwedge.html
232 lines (219 loc) · 8.1 KB
/
wedge.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html>
<head>
<title>noises</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
"use strict";
var realCoef;
var imagCoef;
var getInstrument = function (name) {
var name = (name === undefined) ? 'Bass' : name;
$.getJSON("https://raw.githubusercontent.com/mohayonao/wave-tables/master/"+name+".json", function(json) {
realCoef = json["real"];
imagCoef = json["imag"];
});
}
// set up the sounds on page load
getInstrument();
// prepare audio thing
var context = new (window.AudioContext || window.webkitAudioContext)();
var oscillator;
// count seconds
var sec = 0
setInterval( function(){
sec += 1;
// select one column per second
var colname = "#col"+sec
// highlight the column
$( colname ).effect("highlight", {}, 1000);
// select all the checkboxes that are checked in the column, and iterate over them
$( colname+' input:checked').each(function() {
// select the Hz value for each checkbox
var note = $(this).attr('value')
// create an oscillator to play a sine wave at that Hz frequency
oscillator = context.createOscillator();
//oscillator.type = 'sine';
var real = new Float32Array(realCoef);
var imag = new Float32Array(imagCoef);
var wave = context.createPeriodicWave(real, imag);
oscillator = context.createOscillator();
oscillator.setPeriodicWave(wave);
oscillator.frequency.value = note;
var now = context.currentTime;
oscillator.connect(context.destination);
// play the oscillator for a little while, then stop
oscillator.start();
oscillator.stop(now + 0.7);
});
// after three seconds, start back over with the first column again
if (sec == 5) sec = 0;
}, 1000);
// change the sound when user selects from drop-down
var changeInstrument = function (arg) {
getInstrument(arg.value);
}
</script>
<style>
#circle-container {
position: relative;
top: 50px;
}
#circle-container .radial {
display: block;
position: absolute;
top: 50%; left: 50%;
width: 200px; height: 500px;
margin: -2em;
}
#deg000 { } /* 12em = half the width of the wrapper */
#deg072 { transform: rotate(72deg) }
#deg144 { transform: rotate(144deg) }
#deg216 { transform: rotate(216deg) }
#deg288 { transform: rotate(288deg) }
.wedge {
border-top: 140px solid silver;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
height: 0;
width: 100px;
float: all;
}
.holder {
width: 200px;
position: relative;
}
.col {
position: absolute;
width: 200px;
text-align: center;
top: 5px;
}
</style>
</head>
<body>
<div id='circle-container'>
<div class="radial" id="deg000">
<div class="holder">
<div class="wedge"></div>
<div class="col" id="col1">
<input type="checkbox" value="440.000" /><br />
<input type="checkbox" value="391.995" /><br />
<input type="checkbox" value="349.228" /><br />
<input type="checkbox" value="329.628" /><br />
<input type="checkbox" value="293.665" /><br />
<input type="checkbox" value="261.626" /><br />
</div>
</div>
</div>
<div class="radial" id="deg072">
<div class="holder">
<div class="wedge"></div>
<div class="col" id="col2">
<input type="checkbox" value="440.000" /><br />
<input type="checkbox" value="391.995" /><br />
<input type="checkbox" value="349.228" /><br />
<input type="checkbox" value="329.628" /><br />
<input type="checkbox" value="293.665" /><br />
<input type="checkbox" value="261.626" /><br />
</div>
</div>
</div>
<div class="radial" id="deg144">
<div class="holder">
<div class="wedge"></div>
<div class="col" id="col3">
<input type="checkbox" value="440.000" /><br />
<input type="checkbox" value="391.995" /><br />
<input type="checkbox" value="349.228" /><br />
<input type="checkbox" value="329.628" /><br />
<input type="checkbox" value="293.665" /><br />
<input type="checkbox" value="261.626" /><br />
</div>
</div>
</div>
<div class="radial" id="deg216">
<div class="holder">
<div class="wedge"></div>
<div class="col" id="col4">
<input type="checkbox" value="440.000" /><br />
<input type="checkbox" value="391.995" /><br />
<input type="checkbox" value="349.228" /><br />
<input type="checkbox" value="329.628" /><br />
<input type="checkbox" value="293.665" /><br />
<input type="checkbox" value="261.626" /><br />
</div>
</div></div>
<div class="radial" id="deg288">
<div class="holder">
<div class="wedge"></div>
<div class="col" id="col5">
<input type="checkbox" value="440.000" /><br />
<input type="checkbox" value="391.995" /><br />
<input type="checkbox" value="349.228" /><br />
<input type="checkbox" value="329.628" /><br />
<input type="checkbox" value="293.665" /><br />
<input type="checkbox" value="261.626" /><br />
</div>
</div>
</div>
</div>
<p>
<select id="instrument" onchange="changeInstrument(this);">
<option value="Bass">Bass</option>
<option value="BassAmp360">BassAmp360</option>
<option value="BassFuzz">BassFuzz</option>
<option value="BassFuzz2">BassFuzz2</option>
<option value="BassSubDub">BassSubDub</option>
<option value="BassSubDub2">BassSubDub2</option>
<option value="Brass">Brass</option>
<option value="BritBlues">BritBlues</option>
<option value="BritBluesDriven">BritBluesDriven</option>
<option value="Buzzy1">Buzzy1</option>
<option value="Buzzy2">Buzzy2</option>
<option value="Celeste">Celeste</option>
<option value="ChorusStrings">ChorusStrings</option>
<option value="Dissonant1">Dissonant1</option>
<option value="Dissonant2">Dissonant2</option>
<option value="DissonantPiano">DissonantPiano</option>
<option value="DroppedSaw">DroppedSaw</option>
<option value="DroppedSquare">DroppedSquare</option>
<option value="DynaEPBright">DynaEPBright</option>
<option value="DynaEPMed">DynaEPMed</option>
<option value="Ethnic33">Ethnic33</option>
<option value="Full1">Full1</option>
<option value="Full2">Full2</option>
<option value="GuitarFuzz">GuitarFuzz</option>
<option value="Harsh">Harsh</option>
<option value="MklHard">MklHard</option>
<option value="Noise">Noise</option>
<option value="Organ2">Organ2</option>
<option value="Organ3">Organ3</option>
<option value="PhonemeAh">PhonemeAh</option>
<option value="PhonemeBah">PhonemeBah</option>
<option value="PhonemeEe">PhonemeEe</option>
<option value="PhonemeO">PhonemeO</option>
<option value="PhonemeOoh">PhonemeOoh</option>
<option value="PhonemePopAhhhs">PhonemePopAhhhs</option>
<option value="Piano">Piano</option>
<option value="Pulse">Pulse</option>
<option value="PutneyWavering">PutneyWavering</option>
<option value="Saw">Saw</option>
<option value="Square">Square</option>
<option value="TB303Square">TB303Square</option>
<option value="Throaty">Throaty</option>
<option value="Triangle">Triangle</option>
<option value="Trombone">Trombone</option>
<option value="TwelveOpTines">TwelveOpTines</option>
<option value="TwelveStringGuitar1">TwelveStringGuitar1</option>
<option value="WarmSaw">WarmSaw</option>
<option value="WarmSquare">WarmSquare</option>
<option value="WarmTriangle">WarmTriangle</option>
<option value="Wurlitzer">Wurlitzer</option>
<option value="Wurlitzer2">Wurlitzer2</option>
</select>
</p>
</body>
</html>