-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
79 lines (69 loc) · 1.61 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
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
<!doctype html>
<html>
<head>
<title>synth.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<table>
<tr>
<td><input type="number" id="oscFreq" min="0" max="20000" value="440"></td>
<td>osc frequency</td>
</tr>
<tr>
<td><input type="number" id="lfoRate" min="0" max="20" value="5"></td>
<td>LFO Rate</td>
</tr>
<tr>
<td><input type="number" id="lfoDepth" min="0" max="100" value="100"></td>
<td>LFO Depth</td>
</tr>
</table>
<script type="module">
import * as SYNTH from './js/synth.js';
//listen for first click
document.addEventListener("click", setup, { once: true });
function setup(e) {
var osc = new SYNTH.Oscillator({
frequency: 100,
gain: 1,
type:'square'
});
osc.start();
osc.hz(200);
new SYNTH.ADSR({
at:osc,
gain:0.1,
frequency: 600,
duration: 2000
});
new SYNTH.Ramp({
at:osc,
gain:0.1,
frequency: 600,
duration: 2000
});
let eq = new SYNTH.EQ({
type:'lowpass',
frequency: 440,
gain: 0.8,
Q:1
});
var lfo = new SYNTH.LFO({
type:'sine',
frequency: 200,
gain: 0.8,
});
setTimeout(function(){
osc.plug(eq)
lfo.plug(osc)
}, 500);
// event listers
document.getElementById("lfoRate").addEventListener ( 'input', function( e ) { lfo.setFrequency(this.value) });
document.getElementById("lfoDepth").addEventListener( 'input', function( e ) { lfo.depth(this.value) });
document.getElementById("oscFreq").addEventListener ( 'input', function( e ) { osc.setFrequency(this.value) });
}
</script>
</body>
</html>