-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.js
48 lines (35 loc) · 1.04 KB
/
nodes.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*var ctx = new(window.AudioContext || window.webkitAudioContext)();
const osc = ctx.createOscillator();
osc.connect(ctx.destination);*/
const btn = document.querySelector("button");
btn.addEventListener("click", () => {
const ctx = new(window.AudioContext || window.webkitAudioContext)();
const osc = ctx.createOscillator();
osc.connect(ctx.destination);
osc.start(0);
osc.stop(2);
osc.onended = () => {
console.log(ctx.state)
}
})
/*function Oscillator(frequency, detune){
this.osc = ctx.createOscillator();
this.osc.type = 'sawtooth';
this.osc.frequency.value = frequency;
this.osc.detune.value = detune;
this.osc.connect(ctx.destination);
this.osc.start(0);
this.osc.stop(3);
}
const osc1 = new Oscillator(440, 0);
const osc2 = new Oscillator(440, 10);
const osc3 = new Oscillator(440, 15);
const osc4 = new Oscillator(440, 20);
//var osc = ctx.createOscillator();*/
//var gain = ctx.createGain();
//console.log(gain)
//osc.connect(ctx.destination);
//osc.start();
//setTimeout(() => {
// osc.stop();
//},2000)