@logue/reverb 0.5.2 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Meta.d.ts +1 -1
- package/dist/Reverb.d.ts +0 -5
- package/dist/Reverb.d.ts.map +1 -1
- package/dist/reverb.es.js +67 -144
- package/dist/reverb.umd.js +11 -9
- package/package.json +41 -37
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Reverb.js
|
|
2
2
|
|
|
3
3
|
[](https://www.jsdelivr.com/package/npm/@logue/reverb)
|
|
4
|
-
[](https://www.npmjs.com/package/@logue/reverb)
|
|
5
5
|
[](https://uiwjs.github.io/npm-unpkg/#/pkg/@logue/reverb/file/README.md)
|
|
6
6
|
[](https://www.npmjs.com/package/@logue/reverb)
|
|
7
7
|
[](https://gitpod.io/#https://github.com/logue/Reverb.js)
|
package/dist/Meta.d.ts
CHANGED
package/dist/Reverb.d.ts
CHANGED
|
@@ -2,11 +2,6 @@ import type OptionInterface from './interfaces/OptionInterface';
|
|
|
2
2
|
import { type NoiseType } from './NoiseType';
|
|
3
3
|
/**
|
|
4
4
|
* JS reverb effect class
|
|
5
|
-
*
|
|
6
|
-
* @license MIT
|
|
7
|
-
* @author Logue {@link logue@hotmail.co.jp}
|
|
8
|
-
* @copyright 2019-2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
9
|
-
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
5
|
*/
|
|
11
6
|
export default class Reverb {
|
|
12
7
|
/** Version strings */
|
package/dist/Reverb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reverb.d.ts","sourceRoot":"","sources":["../src/Reverb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,8BAA8B,CAAC;AAChE,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpD
|
|
1
|
+
{"version":3,"file":"Reverb.d.ts","sourceRoot":"","sources":["../src/Reverb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,8BAA8B,CAAC;AAChE,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,sBAAsB;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iBAAiB;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mBAAmB;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,oCAAoC;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAW;IACvC,sCAAsC;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAW;IACvC,8BAA8B;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,mBAAmB;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IACtC,aAAa;IACb,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,qBAAqB;IACrB,OAAO,CAAC,WAAW,CAAU;IAE7B;;;;;OAKG;gBACS,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,SAAS;IAsBnE;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS;IAsBhD;;;;OAIG;IACI,UAAU,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;IAe3E;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAU7B;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWhC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAQtC;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAK/C;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAWrC;;;;OAIG;IACI,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAW/B;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,SAAS;IAM/B;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAIf,oFAAoF;IACpF,OAAO,CAAC,YAAY;IAoGpB,2BAA2B;IAC3B,OAAO,CAAC,MAAM,CAAC,UAAU;CAI1B"}
|
package/dist/reverb.es.js
CHANGED
|
@@ -1,188 +1,111 @@
|
|
|
1
|
-
const meta = {
|
|
2
|
-
version: "0.5.2",
|
|
3
|
-
date: "2022-03-31T15:54:38.559Z"
|
|
4
|
-
};
|
|
5
|
-
const Noise = {
|
|
6
|
-
WHITE: "white",
|
|
7
|
-
PINK: "pink",
|
|
8
|
-
BROWN: "brown"
|
|
9
|
-
};
|
|
10
1
|
/**
|
|
11
|
-
*
|
|
2
|
+
* @logue/reverb
|
|
12
3
|
*
|
|
4
|
+
* @description JavaScript Reverb effect class
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2019-2022 By Masashi Yoshikawa All rights reserved.
|
|
13
7
|
* @license MIT
|
|
14
|
-
* @
|
|
15
|
-
* @copyright 2019-2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
8
|
+
* @version 0.5.5
|
|
16
9
|
* @see {@link https://github.com/logue/Reverb.js}
|
|
17
10
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.isConnected =
|
|
30
|
-
this.buildImpulse();
|
|
31
|
-
this.mix(this._options.mix);
|
|
11
|
+
|
|
12
|
+
const d = {
|
|
13
|
+
version: "0.5.5",
|
|
14
|
+
date: "2022-07-21T01:15:40.735Z"
|
|
15
|
+
}, l = {
|
|
16
|
+
WHITE: "white",
|
|
17
|
+
PINK: "pink",
|
|
18
|
+
BROWN: "brown"
|
|
19
|
+
};
|
|
20
|
+
class s {
|
|
21
|
+
constructor(e, o) {
|
|
22
|
+
this.version = d.version, this.build = d.date, this.ctx = e, this._options = { ...u, ...o }, this.wetGainNode = this.ctx.createGain(), this.dryGainNode = this.ctx.createGain(), this.filterNode = this.ctx.createBiquadFilter(), this.convolverNode = this.ctx.createConvolver(), this.outputNode = this.ctx.createGain(), this.isConnected = !1, this.buildImpulse(), this.mix(this._options.mix);
|
|
32
23
|
}
|
|
33
|
-
connect(
|
|
34
|
-
|
|
35
|
-
this.isConnected = false;
|
|
36
|
-
return this.outputNode;
|
|
37
|
-
}
|
|
38
|
-
this.convolverNode.connect(this.filterNode);
|
|
39
|
-
this.filterNode.connect(this.wetGainNode);
|
|
40
|
-
sourceNode.connect(this.convolverNode);
|
|
41
|
-
sourceNode.connect(this.dryGainNode).connect(this.outputNode);
|
|
42
|
-
sourceNode.connect(this.wetGainNode).connect(this.outputNode);
|
|
43
|
-
this.isConnected = true;
|
|
44
|
-
return this.outputNode;
|
|
24
|
+
connect(e) {
|
|
25
|
+
return this.isConnected && this._options.once ? (this.isConnected = !1, this.outputNode) : (this.convolverNode.connect(this.filterNode), this.filterNode.connect(this.wetGainNode), e.connect(this.convolverNode), e.connect(this.dryGainNode).connect(this.outputNode), e.connect(this.wetGainNode).connect(this.outputNode), this.isConnected = !0, this.outputNode);
|
|
45
26
|
}
|
|
46
|
-
disconnect(
|
|
47
|
-
|
|
48
|
-
this.convolverNode.disconnect(this.filterNode);
|
|
49
|
-
this.filterNode.disconnect(this.wetGainNode);
|
|
50
|
-
}
|
|
51
|
-
this.isConnected = false;
|
|
52
|
-
return sourceNode;
|
|
27
|
+
disconnect(e) {
|
|
28
|
+
return this.isConnected && (this.convolverNode.disconnect(this.filterNode), this.filterNode.disconnect(this.wetGainNode)), this.isConnected = !1, e;
|
|
53
29
|
}
|
|
54
|
-
mix(
|
|
55
|
-
if (!this.inRange(
|
|
30
|
+
mix(e) {
|
|
31
|
+
if (!this.inRange(e, 0, 1))
|
|
56
32
|
throw new RangeError("Reverb.js: Dry/Wet ratio must be between 0 to 1.");
|
|
57
|
-
|
|
58
|
-
this._options.mix = mix;
|
|
59
|
-
this.dryGainNode.gain.value = 1 - this._options.mix;
|
|
60
|
-
this.wetGainNode.gain.value = this._options.mix;
|
|
61
|
-
console.debug(`Reverb.js: Set dry/wet ratio to ${mix * 100}%`);
|
|
33
|
+
this._options.mix = e, this.dryGainNode.gain.value = 1 - this._options.mix, this.wetGainNode.gain.value = this._options.mix;
|
|
62
34
|
}
|
|
63
|
-
time(
|
|
64
|
-
if (!this.inRange(
|
|
35
|
+
time(e) {
|
|
36
|
+
if (!this.inRange(e, 1, 50))
|
|
65
37
|
throw new RangeError("Reverb.js: Time length of inpulse response must be less than 50sec.");
|
|
66
|
-
|
|
67
|
-
this._options.time = value;
|
|
68
|
-
this.buildImpulse();
|
|
69
|
-
console.info(`Reverb.js: Set inpulse response time length to ${value}sec.`);
|
|
38
|
+
this._options.time = e, this.buildImpulse();
|
|
70
39
|
}
|
|
71
|
-
decay(
|
|
72
|
-
if (!this.inRange(
|
|
40
|
+
decay(e) {
|
|
41
|
+
if (!this.inRange(e, 0, 100))
|
|
73
42
|
throw new RangeError("Reverb.js: Inpulse Response decay level must be less than 100.");
|
|
74
|
-
|
|
75
|
-
this._options.decay = value;
|
|
76
|
-
this.buildImpulse();
|
|
77
|
-
console.debug(`Reverb.js: Set inpulse response decay level to ${value}.`);
|
|
43
|
+
this._options.decay = e, this.buildImpulse();
|
|
78
44
|
}
|
|
79
|
-
delay(
|
|
80
|
-
if (!this.inRange(
|
|
45
|
+
delay(e) {
|
|
46
|
+
if (!this.inRange(e, 0, 100))
|
|
81
47
|
throw new RangeError("Reverb.js: Inpulse Response delay time must be less than 100.");
|
|
82
|
-
|
|
83
|
-
this._options.delay = value;
|
|
84
|
-
this.buildImpulse();
|
|
85
|
-
console.debug(`Reverb.js: Set inpulse response delay time to ${value}sec.`);
|
|
48
|
+
this._options.delay = e, this.buildImpulse();
|
|
86
49
|
}
|
|
87
|
-
reverse(
|
|
88
|
-
this._options.reverse =
|
|
89
|
-
this.buildImpulse();
|
|
90
|
-
console.debug(`Reverb.js: Inpulse response is ${reverse ? "" : "not "}reversed.`);
|
|
50
|
+
reverse(e) {
|
|
51
|
+
this._options.reverse = e, this.buildImpulse();
|
|
91
52
|
}
|
|
92
|
-
filterType(
|
|
93
|
-
this.filterNode.type = this._options.filterType =
|
|
94
|
-
console.debug(`Set filter type to ${type}`);
|
|
53
|
+
filterType(e) {
|
|
54
|
+
this.filterNode.type = this._options.filterType = e;
|
|
95
55
|
}
|
|
96
|
-
filterFreq(
|
|
97
|
-
if (!this.inRange(
|
|
56
|
+
filterFreq(e) {
|
|
57
|
+
if (!this.inRange(e, 20, 5e3))
|
|
98
58
|
throw new RangeError("Reverb.js: Filter frequrncy must be between 20 and 5000.");
|
|
99
|
-
|
|
100
|
-
this._options.filterFreq = freq;
|
|
101
|
-
this.filterNode.frequency.value = this._options.filterFreq;
|
|
102
|
-
console.debug(`Set filter frequency to ${freq}Hz.`);
|
|
59
|
+
this._options.filterFreq = e, this.filterNode.frequency.value = this._options.filterFreq;
|
|
103
60
|
}
|
|
104
|
-
filterQ(
|
|
105
|
-
if (!this.inRange(
|
|
61
|
+
filterQ(e) {
|
|
62
|
+
if (!this.inRange(e, 0, 10))
|
|
106
63
|
throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");
|
|
107
|
-
|
|
108
|
-
this._options.filterQ = q;
|
|
109
|
-
this.filterNode.Q.value = this._options.filterQ;
|
|
110
|
-
console.debug(`Set filter quality to ${q}.`);
|
|
64
|
+
this._options.filterQ = e, this.filterNode.Q.value = this._options.filterQ;
|
|
111
65
|
}
|
|
112
|
-
setNoise(
|
|
113
|
-
this._options.noise =
|
|
114
|
-
this.buildImpulse();
|
|
115
|
-
console.debug(`Set Noise type to ${type}.`);
|
|
66
|
+
setNoise(e) {
|
|
67
|
+
this._options.noise = e, this.buildImpulse();
|
|
116
68
|
}
|
|
117
|
-
inRange(
|
|
118
|
-
return (
|
|
69
|
+
inRange(e, o, r) {
|
|
70
|
+
return (e - o) * (e - r) <= 0;
|
|
119
71
|
}
|
|
120
72
|
buildImpulse() {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const b = [0, 0, 0, 0, 0, 0, 0];
|
|
128
|
-
for (let i = 0; i < duration; i++) {
|
|
129
|
-
let n = 0;
|
|
130
|
-
if (i < delayDuration) {
|
|
131
|
-
impulseL[i] = 0;
|
|
132
|
-
impulseR[i] = 0;
|
|
133
|
-
n = this._options.reverse ? duration - (i - delayDuration) : i - delayDuration;
|
|
134
|
-
} else {
|
|
135
|
-
n = this._options.reverse ? duration - i : i;
|
|
136
|
-
}
|
|
137
|
-
switch (this._options.noise) {
|
|
138
|
-
case Noise.PINK:
|
|
139
|
-
b[0] = 0.99886 * b[0] + Reverb.whiteNoise() * 0.0555179;
|
|
140
|
-
b[1] = 0.99332 * b[1] + Reverb.whiteNoise() * 0.0750759;
|
|
141
|
-
b[2] = 0.969 * b[2] + Reverb.whiteNoise() * 0.153852;
|
|
142
|
-
b[3] = 0.8665 * b[3] + Reverb.whiteNoise() * 0.3104856;
|
|
143
|
-
b[4] = 0.55 * b[4] + Reverb.whiteNoise() * 0.5329522;
|
|
144
|
-
b[5] = -0.7616 * b[5] - Reverb.whiteNoise() * 0.016898;
|
|
145
|
-
impulseL[i] = b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6] + Reverb.whiteNoise() * 0.5362;
|
|
146
|
-
impulseR[i] = b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6] + Reverb.whiteNoise() * 0.5362;
|
|
147
|
-
impulseL[i] *= 0.11;
|
|
148
|
-
impulseR[i] *= 0.11;
|
|
149
|
-
b[6] = Reverb.whiteNoise() * 0.115926;
|
|
73
|
+
const e = this.ctx.sampleRate, o = Math.max(e * this._options.time, 1), r = e * this._options.delay, c = this.ctx.createBuffer(2, o, e), n = new Float32Array(o), h = new Float32Array(o), t = [0, 0, 0, 0, 0, 0, 0];
|
|
74
|
+
for (let i = 0; i < o; i++) {
|
|
75
|
+
let a = 0;
|
|
76
|
+
switch (i < r ? (n[i] = 0, h[i] = 0, a = this._options.reverse ? o - (i - r) : i - r) : a = this._options.reverse ? o - i : i, this._options.noise) {
|
|
77
|
+
case l.PINK:
|
|
78
|
+
t[0] = 0.99886 * t[0] + s.whiteNoise() * 0.0555179, t[1] = 0.99332 * t[1] + s.whiteNoise() * 0.0750759, t[2] = 0.969 * t[2] + s.whiteNoise() * 0.153852, t[3] = 0.8665 * t[3] + s.whiteNoise() * 0.3104856, t[4] = 0.55 * t[4] + s.whiteNoise() * 0.5329522, t[5] = -0.7616 * t[5] - s.whiteNoise() * 0.016898, n[i] = t[0] + t[1] + t[2] + t[3] + t[4] + t[5] + t[6] + s.whiteNoise() * 0.5362, h[i] = t[0] + t[1] + t[2] + t[3] + t[4] + t[5] + t[6] + s.whiteNoise() * 0.5362, n[i] *= 0.11, h[i] *= 0.11, t[6] = s.whiteNoise() * 0.115926;
|
|
150
79
|
break;
|
|
151
|
-
case
|
|
152
|
-
|
|
153
|
-
b[0] = impulseL[i];
|
|
154
|
-
impulseR[i] = (b[1] + 0.02 * Reverb.whiteNoise()) / 1.02;
|
|
155
|
-
b[1] = impulseR[i];
|
|
156
|
-
impulseL[i] *= 3.5;
|
|
157
|
-
impulseR[i] *= 3.5;
|
|
80
|
+
case l.BROWN:
|
|
81
|
+
n[i] = (t[0] + 0.02 * s.whiteNoise()) / 1.02, t[0] = n[i], h[i] = (t[1] + 0.02 * s.whiteNoise()) / 1.02, t[1] = h[i], n[i] *= 3.5, h[i] *= 3.5;
|
|
158
82
|
break;
|
|
159
|
-
case
|
|
83
|
+
case l.WHITE:
|
|
160
84
|
default:
|
|
161
|
-
|
|
162
|
-
impulseR[i] = Reverb.whiteNoise();
|
|
85
|
+
n[i] = s.whiteNoise(), h[i] = s.whiteNoise();
|
|
163
86
|
break;
|
|
164
87
|
}
|
|
165
|
-
|
|
166
|
-
impulseR[i] *= (1 - n / duration) ** this._options.decay;
|
|
88
|
+
n[i] *= (1 - a / o) ** this._options.decay, h[i] *= (1 - a / o) ** this._options.decay;
|
|
167
89
|
}
|
|
168
|
-
|
|
169
|
-
impulse.getChannelData(1).set(impulseR);
|
|
170
|
-
this.convolverNode.buffer = impulse;
|
|
90
|
+
c.getChannelData(0).set(n), c.getChannelData(1).set(h), this.convolverNode.buffer = c;
|
|
171
91
|
}
|
|
172
92
|
static whiteNoise() {
|
|
173
93
|
return Math.random() * 2 - 1;
|
|
174
94
|
}
|
|
175
95
|
}
|
|
176
|
-
const
|
|
177
|
-
noise:
|
|
96
|
+
const u = {
|
|
97
|
+
noise: l.WHITE,
|
|
178
98
|
decay: 2,
|
|
179
99
|
delay: 0,
|
|
180
|
-
reverse:
|
|
100
|
+
reverse: !1,
|
|
181
101
|
time: 2,
|
|
182
102
|
filterType: "lowpass",
|
|
183
103
|
filterFreq: 2200,
|
|
184
104
|
filterQ: 1,
|
|
185
105
|
mix: 0.5,
|
|
186
|
-
once:
|
|
106
|
+
once: !1
|
|
107
|
+
};
|
|
108
|
+
window.Reverb || (window.Reverb = s);
|
|
109
|
+
export {
|
|
110
|
+
s as default
|
|
187
111
|
};
|
|
188
|
-
export { Reverb as default };
|
package/dist/reverb.umd.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Reverb=t()}(this,(function(){"use strict";const e="0.5.2",t="2022-03-31T15:54:38.559Z",i="white",s="pink",o="brown";
|
|
2
1
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
* @logue/reverb
|
|
3
|
+
*
|
|
4
|
+
* @description JavaScript Reverb effect class
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2019-2022 By Masashi Yoshikawa All rights reserved.
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @version 0.5.5
|
|
9
|
+
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
(function(a,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(a=typeof globalThis<"u"?globalThis:a||self,a.Reverb=r())})(this,function(){"use strict";const a={version:"0.5.5",date:"2022-07-21T01:15:40.735Z"},r={WHITE:"white",PINK:"pink",BROWN:"brown"};class s{constructor(e,o){this.version=a.version,this.build=a.date,this.ctx=e,this._options={...u,...o},this.wetGainNode=this.ctx.createGain(),this.dryGainNode=this.ctx.createGain(),this.filterNode=this.ctx.createBiquadFilter(),this.convolverNode=this.ctx.createConvolver(),this.outputNode=this.ctx.createGain(),this.isConnected=!1,this.buildImpulse(),this.mix(this._options.mix)}connect(e){return this.isConnected&&this._options.once?(this.isConnected=!1,this.outputNode):(this.convolverNode.connect(this.filterNode),this.filterNode.connect(this.wetGainNode),e.connect(this.convolverNode),e.connect(this.dryGainNode).connect(this.outputNode),e.connect(this.wetGainNode).connect(this.outputNode),this.isConnected=!0,this.outputNode)}disconnect(e){return this.isConnected&&(this.convolverNode.disconnect(this.filterNode),this.filterNode.disconnect(this.wetGainNode)),this.isConnected=!1,e}mix(e){if(!this.inRange(e,0,1))throw new RangeError("Reverb.js: Dry/Wet ratio must be between 0 to 1.");this._options.mix=e,this.dryGainNode.gain.value=1-this._options.mix,this.wetGainNode.gain.value=this._options.mix}time(e){if(!this.inRange(e,1,50))throw new RangeError("Reverb.js: Time length of inpulse response must be less than 50sec.");this._options.time=e,this.buildImpulse()}decay(e){if(!this.inRange(e,0,100))throw new RangeError("Reverb.js: Inpulse Response decay level must be less than 100.");this._options.decay=e,this.buildImpulse()}delay(e){if(!this.inRange(e,0,100))throw new RangeError("Reverb.js: Inpulse Response delay time must be less than 100.");this._options.delay=e,this.buildImpulse()}reverse(e){this._options.reverse=e,this.buildImpulse()}filterType(e){this.filterNode.type=this._options.filterType=e}filterFreq(e){if(!this.inRange(e,20,5e3))throw new RangeError("Reverb.js: Filter frequrncy must be between 20 and 5000.");this._options.filterFreq=e,this.filterNode.frequency.value=this._options.filterFreq}filterQ(e){if(!this.inRange(e,0,10))throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");this._options.filterQ=e,this.filterNode.Q.value=this._options.filterQ}setNoise(e){this._options.noise=e,this.buildImpulse()}inRange(e,o,l){return(e-o)*(e-l)<=0}buildImpulse(){const e=this.ctx.sampleRate,o=Math.max(e*this._options.time,1),l=e*this._options.delay,d=this.ctx.createBuffer(2,o,e),n=new Float32Array(o),h=new Float32Array(o),t=[0,0,0,0,0,0,0];for(let i=0;i<o;i++){let c=0;switch(i<l?(n[i]=0,h[i]=0,c=this._options.reverse?o-(i-l):i-l):c=this._options.reverse?o-i:i,this._options.noise){case r.PINK:t[0]=.99886*t[0]+s.whiteNoise()*.0555179,t[1]=.99332*t[1]+s.whiteNoise()*.0750759,t[2]=.969*t[2]+s.whiteNoise()*.153852,t[3]=.8665*t[3]+s.whiteNoise()*.3104856,t[4]=.55*t[4]+s.whiteNoise()*.5329522,t[5]=-.7616*t[5]-s.whiteNoise()*.016898,n[i]=t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+s.whiteNoise()*.5362,h[i]=t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+s.whiteNoise()*.5362,n[i]*=.11,h[i]*=.11,t[6]=s.whiteNoise()*.115926;break;case r.BROWN:n[i]=(t[0]+.02*s.whiteNoise())/1.02,t[0]=n[i],h[i]=(t[1]+.02*s.whiteNoise())/1.02,t[1]=h[i],n[i]*=3.5,h[i]*=3.5;break;case r.WHITE:default:n[i]=s.whiteNoise(),h[i]=s.whiteNoise();break}n[i]*=(1-c/o)**this._options.decay,h[i]*=(1-c/o)**this._options.decay}d.getChannelData(0).set(n),d.getChannelData(1).set(h),this.convolverNode.buffer=d}static whiteNoise(){return Math.random()*2-1}}const u={noise:r.WHITE,decay:2,delay:0,reverse:!1,time:2,filterType:"lowpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};return window.Reverb||(window.Reverb=s),s});
|
package/package.json
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@logue/reverb",
|
|
4
|
-
"version": "0.5.
|
|
5
|
-
"description": "Reverb effect
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"main": "./dist/reverb.umd.js",
|
|
10
|
-
"module": "./dist/reverb.es.js",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/reverb.es.js",
|
|
14
|
-
"require": "./dist/reverb.umd.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"types": "./dist/Reverb.d.ts",
|
|
18
|
-
"directories": {
|
|
19
|
-
"doc": "docs"
|
|
20
|
-
},
|
|
4
|
+
"version": "0.5.5",
|
|
5
|
+
"description": "JavaScript Reverb effect class",
|
|
21
6
|
"keywords": [
|
|
22
7
|
"webaudio",
|
|
23
8
|
"convolver",
|
|
24
9
|
"effect",
|
|
25
10
|
"reverb"
|
|
26
11
|
],
|
|
12
|
+
"license": "MIT",
|
|
27
13
|
"author": {
|
|
28
14
|
"name": "Logue",
|
|
29
15
|
"email": "logue@hotmail.co.jp",
|
|
@@ -37,40 +23,55 @@
|
|
|
37
23
|
"bugs": {
|
|
38
24
|
"url": "https://github.com/logue/Reverb.js/issues"
|
|
39
25
|
},
|
|
26
|
+
"directories": {
|
|
27
|
+
"doc": "docs"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"main": "./dist/reverb.umd.js",
|
|
33
|
+
"module": "./dist/reverb.es.js",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"import": "./dist/reverb.es.js",
|
|
37
|
+
"require": "./dist/reverb.umd.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"types": "./dist/Reverb.d.ts",
|
|
40
41
|
"engines": {
|
|
41
|
-
"node": ">=16"
|
|
42
|
+
"node": ">=16.16.0",
|
|
43
|
+
"yarn": ">=1.22.4"
|
|
42
44
|
},
|
|
43
|
-
"
|
|
45
|
+
"packageManager": "yarn@3.2.1",
|
|
44
46
|
"sideEffects": false,
|
|
45
47
|
"scripts": {
|
|
46
48
|
"dev": "vite",
|
|
47
|
-
"build": "vite build
|
|
49
|
+
"build": "vite build && tsc --declaration --emitDeclarationOnly",
|
|
48
50
|
"build:clean": "rimraf dist",
|
|
49
51
|
"lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
|
|
50
52
|
"prepare": "husky install"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"
|
|
57
|
-
"@typescript-eslint/parser": "^5.17.0",
|
|
58
|
-
"eslint": "^8.12.0",
|
|
55
|
+
"@types/node": "^18.0.6",
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
57
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
58
|
+
"eslint": "^8.20.0",
|
|
59
59
|
"eslint-config-google": "^0.14.0",
|
|
60
60
|
"eslint-config-prettier": "^8.5.0",
|
|
61
61
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
62
|
-
"eslint-import-resolver-typescript": "^
|
|
63
|
-
"eslint-plugin-import": "^2.
|
|
64
|
-
"eslint-plugin-
|
|
65
|
-
"eslint-plugin-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"prettier
|
|
70
|
-
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
62
|
+
"eslint-import-resolver-typescript": "^3.3.0",
|
|
63
|
+
"eslint-plugin-import": "^2.26.0",
|
|
64
|
+
"eslint-plugin-jsdoc": "^39.3.3",
|
|
65
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
66
|
+
"eslint-plugin-tsdoc": "^0.2.16",
|
|
67
|
+
"husky": "^8.0.1",
|
|
68
|
+
"lint-staged": "^13.0.3",
|
|
69
|
+
"prettier": "^2.7.1",
|
|
71
70
|
"rimraf": "^3.0.2",
|
|
72
|
-
"typescript": "^4.
|
|
73
|
-
"vite": "^
|
|
71
|
+
"typescript": "^4.7.4",
|
|
72
|
+
"vite": "^3.0.2",
|
|
73
|
+
"vite-plugin-banner": "^0.3.0",
|
|
74
|
+
"vite-plugin-checker": "^0.4.9"
|
|
74
75
|
},
|
|
75
76
|
"husky": {
|
|
76
77
|
"hooks": {
|
|
@@ -80,5 +81,8 @@
|
|
|
80
81
|
"lint-staged": {
|
|
81
82
|
"*.{js,ts,json,htm,html}": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint",
|
|
82
83
|
"*": "prettier -w -u"
|
|
84
|
+
},
|
|
85
|
+
"resolutions": {
|
|
86
|
+
"prettier": "^2.7.1"
|
|
83
87
|
}
|
|
84
88
|
}
|