-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadhd.js
More file actions
26 lines (22 loc) · 740 Bytes
/
adhd.js
File metadata and controls
26 lines (22 loc) · 740 Bytes
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
'use strict';
const ctx = new AudioContext();
function
play()
{
const oscillators = [
new OscillatorNode(ctx, { frequency: 880.000 }),
new OscillatorNode(ctx, { frequency: 587.330 }),
new OscillatorNode(ctx, { frequency: 493.883 }),
new OscillatorNode(ctx, { frequency: 587.330 }),
];
oscillators.forEach((e, i) => {
const gain = new GainNode(ctx, { gain: 0.8 });
e.connect(gain);
gain.connect(ctx.destination);
e.start(ctx.currentTime + i * 0.25);
gain.gain.exponentialRampToValueAtTime(0.250, ctx.currentTime + i * 0.25 + 0.01);
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + i * 0.25 + 0.75);
e.stop(ctx.currentTime + i * 0.25 + 1.25);
});
}
btnPlay.addEventListener('click', _ => play());