forked from Stinkstudios/sono
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecho.js
More file actions
49 lines (37 loc) · 1.14 KB
/
echo.js
File metadata and controls
49 lines (37 loc) · 1.14 KB
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
import AbstractEffect from './abstract-effect';
import sono from '../core/sono';
class Echo extends AbstractEffect {
constructor({delay = 0.5, feedback = 0.5, wet = 1, dry = 1} = {}) {
super(sono.context.createDelay(), sono.context.createGain());
this._delay = this._node;
this._feedback = this._nodeOut;
this._delay.connect(this._feedback);
this._feedback.connect(this._delay);
this.wet = wet;
this.dry = dry;
this.update({delay, feedback});
}
enable(value) {
super.enable(value);
if (this._feedback && value) {
this._feedback.connect(this._delay);
}
}
update(options) {
this.delay = options.delay;
this.feedback = options.feedback;
}
get delay() {
return this._delay.delayTime.value;
}
set delay(value) {
this.setSafeParamValue(this._delay.delayTime, value);
}
get feedback() {
return this._feedback.gain.value;
}
set feedback(value) {
this.setSafeParamValue(this._feedback.gain, value);
}
}
export default sono.register('echo', opts => new Echo(opts));