-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo.js
32 lines (24 loc) · 889 Bytes
/
demo.js
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
var ac = new AudioContext();
var osc = ac.createOscillator();
var analyser = ac.createAnalyser();
var dcbias = DCBias(ac);
var mixer = ac.createGain();
var oscilloscope = document.querySelector('openmusic-oscilloscope');
var slider = document.querySelector('input[type=range]');
var currentValue = document.querySelector('span');
osc.connect(mixer);
mixer.connect(analyser);
analyser.connect(ac.destination);
// By connecting it to the 'mixer', whatever value the DCBias node is emitting
// will be added to the overall output value of that node
// The visual representation shows the wave shifting upwards/downwards.
dcbias.connect(mixer);
oscilloscope.attachTo(analyser);
slider.addEventListener('input', updateBias);
function updateBias() {
dcbias.gain.value = parseFloat(slider.value);
currentValue.innerHTML = dcbias.gain.value;
}
updateBias();
dcbias.start();
osc.start();