@logue/reverb 1.4.7 → 1.5.1
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/dist/Reverb.d.ts +4 -4
- package/dist/demo.d.ts +1 -0
- package/dist/interfaces/OptionInterface.d.ts +1 -1
- package/dist/{Reverb.es.js → reverb.es.js} +183 -27
- package/dist/reverb.iife.js +12 -0
- package/dist/reverb.umd.js +12 -0
- package/package.json +23 -24
- package/dist/Reverb.cjs.js +0 -12
- package/dist/Reverb.iife.js +0 -12
- package/dist/Reverb.umd.js +0 -12
package/dist/Reverb.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export default class Reverb {
|
|
|
37
37
|
* @param ctx - Root AudioContext
|
|
38
38
|
* @param options - Configure
|
|
39
39
|
*/
|
|
40
|
-
constructor(ctx: AudioContext, options
|
|
40
|
+
constructor(ctx: AudioContext, options?: Partial<OptionInterface>);
|
|
41
41
|
/**
|
|
42
42
|
* Connect the node for the reverb effect to the original sound node.
|
|
43
43
|
*
|
|
@@ -123,9 +123,9 @@ export default class Reverb {
|
|
|
123
123
|
*/
|
|
124
124
|
setNoise(type: NoiseType): void;
|
|
125
125
|
/**
|
|
126
|
-
* Set
|
|
126
|
+
* Set the random number algorithm used for noise generation.
|
|
127
127
|
*
|
|
128
|
-
* @param algorithm -
|
|
128
|
+
* @param algorithm - Random algorithm implementing {@link INorm}
|
|
129
129
|
*/
|
|
130
130
|
setRandomAlgorithm(algorithm: INorm): void;
|
|
131
131
|
/**
|
|
@@ -136,6 +136,6 @@ export default class Reverb {
|
|
|
136
136
|
* @param max - Maximum value
|
|
137
137
|
*/
|
|
138
138
|
private static inRange;
|
|
139
|
-
/**
|
|
139
|
+
/** Builds the impulse response buffer from the current options. */
|
|
140
140
|
private buildImpulse;
|
|
141
141
|
}
|
package/dist/demo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,30 +5,186 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.
|
|
8
|
+
* @version 1.5.1
|
|
9
9
|
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
//#region node_modules/.pnpm/@thi.ng+random@4.1.48/node_modules/@thi.ng/random/arandom.js
|
|
13
|
+
var e = 1 / 2 ** 32, t = class {
|
|
14
|
+
float(t = 1) {
|
|
15
|
+
return this.int() * e * t;
|
|
16
|
+
}
|
|
17
|
+
probability(e) {
|
|
18
|
+
return this.float() < e;
|
|
19
|
+
}
|
|
20
|
+
norm(t = 1) {
|
|
21
|
+
return (this.int() * e - .5) * 2 * t;
|
|
22
|
+
}
|
|
23
|
+
normMinMax(e, t) {
|
|
24
|
+
let n = this.minmax(e, t);
|
|
25
|
+
return this.float() < .5 ? n : -n;
|
|
26
|
+
}
|
|
27
|
+
minmax(e, t) {
|
|
28
|
+
return this.float() * (t - e) + e;
|
|
29
|
+
}
|
|
30
|
+
minmaxInt(e, t) {
|
|
31
|
+
e |= 0;
|
|
32
|
+
let n = (t | 0) - e;
|
|
33
|
+
return n ? e + this.int() % n : e;
|
|
34
|
+
}
|
|
35
|
+
minmaxUint(e, t) {
|
|
36
|
+
e >>>= 0;
|
|
37
|
+
let n = (t >>> 0) - e;
|
|
38
|
+
return n ? e + this.int() % n : e;
|
|
39
|
+
}
|
|
40
|
+
}, n = new class extends t {
|
|
41
|
+
constructor(e) {
|
|
42
|
+
super(), this.rnd = e;
|
|
43
|
+
}
|
|
44
|
+
rnd;
|
|
45
|
+
float(e = 1) {
|
|
46
|
+
return this.rnd() * e;
|
|
47
|
+
}
|
|
48
|
+
norm(e = 1) {
|
|
49
|
+
return (this.rnd() - .5) * 2 * e;
|
|
50
|
+
}
|
|
51
|
+
int() {
|
|
52
|
+
return this.rnd() * 4294967296 >>> 0;
|
|
53
|
+
}
|
|
54
|
+
}(Math.random), r = {
|
|
55
|
+
bins: 2,
|
|
56
|
+
scale: 1,
|
|
57
|
+
rnd: n
|
|
58
|
+
}, i = (e, t, n) => {
|
|
59
|
+
let r = Array(e);
|
|
60
|
+
for (let i = 0; i < e; i++) r[i] = n.norm(t);
|
|
61
|
+
return r;
|
|
62
|
+
}, a = (e) => e.reduce((e, t) => e + t, 0);
|
|
63
|
+
function* o(e, t) {
|
|
64
|
+
let n = [e[Symbol.iterator](), t[Symbol.iterator]()];
|
|
65
|
+
for (let e = 0;; e ^= 1) {
|
|
66
|
+
let t = n[e].next();
|
|
67
|
+
if (t.done) return;
|
|
68
|
+
yield t.value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region node_modules/.pnpm/@thi.ng+colored-noise@1.0.132/node_modules/@thi.ng/colored-noise/blue.js
|
|
73
|
+
function* s(e) {
|
|
74
|
+
let { bins: t, scale: n, rnd: o } = {
|
|
75
|
+
...r,
|
|
76
|
+
...e
|
|
77
|
+
}, s = i(t, n, o);
|
|
78
|
+
s.forEach((e, t) => s[t] = t & 1 ? e : -e);
|
|
79
|
+
let c = 1 / t, l = a(s);
|
|
80
|
+
for (let e = 0, r = -1;; ++e >= t && (e = 0)) l -= s[e], l += s[e] = r * o.norm(n), r ^= 4294967294, yield r * l * c;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region node_modules/.pnpm/@thi.ng+colored-noise@1.0.132/node_modules/@thi.ng/colored-noise/green.js
|
|
84
|
+
var c = (e) => o(s(e), s(e)), l = (e) => {
|
|
85
|
+
let t = 32;
|
|
86
|
+
return e &= -e, e && t--, e & 65535 && (t -= 16), e & 16711935 && (t -= 8), e & 252645135 && (t -= 4), e & 858993459 && (t -= 2), e & 1431655765 && --t, t;
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region node_modules/.pnpm/@thi.ng+colored-noise@1.0.132/node_modules/@thi.ng/colored-noise/pink.js
|
|
90
|
+
function* u(e) {
|
|
91
|
+
let { bins: t = 8, scale: n, rnd: o } = {
|
|
92
|
+
...r,
|
|
93
|
+
...e
|
|
94
|
+
}, s = i(t, n, o), c = 1 / t, u = a(s);
|
|
95
|
+
for (let e = 0;; e = e + 1 >>> 0) {
|
|
96
|
+
let r = l(e) % t;
|
|
97
|
+
u -= s[r], u += s[r] = o.norm(n), yield u * c;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region node_modules/.pnpm/@thi.ng+colored-noise@1.0.132/node_modules/@thi.ng/colored-noise/red.js
|
|
102
|
+
function* d(e) {
|
|
103
|
+
let { bins: t, scale: n, rnd: o } = {
|
|
104
|
+
...r,
|
|
105
|
+
...e
|
|
106
|
+
}, s = i(t, n, o), c = 1 / t, l = a(s);
|
|
107
|
+
for (let e = 0;; ++e >= t && (e = 0)) l -= s[e], l += s[e] = o.norm(n), yield l * c;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region node_modules/.pnpm/@thi.ng+colored-noise@1.0.132/node_modules/@thi.ng/colored-noise/violet.js
|
|
111
|
+
var f = (e) => o(d(e), d(e));
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region node_modules/.pnpm/@thi.ng+colored-noise@1.0.132/node_modules/@thi.ng/colored-noise/white.js
|
|
114
|
+
function* p(e) {
|
|
115
|
+
let { scale: t, rnd: n } = {
|
|
116
|
+
...r,
|
|
117
|
+
...e
|
|
118
|
+
};
|
|
119
|
+
for (;;) yield n.norm(t);
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region node_modules/.pnpm/@thi.ng+checks@3.9.2/node_modules/@thi.ng/checks/implements-function.js
|
|
123
|
+
var m = (e, t) => typeof e?.[t] == "function", h = (e) => m(e, "xform") ? e.xform() : e, g = (e) => typeof e?.[Symbol.iterator] == "function", _ = (e) => e, v = class {
|
|
124
|
+
value;
|
|
125
|
+
constructor(e) {
|
|
126
|
+
this.value = e;
|
|
127
|
+
}
|
|
128
|
+
deref() {
|
|
129
|
+
return this.value;
|
|
130
|
+
}
|
|
131
|
+
}, y = (e) => new v(e), b = (e) => e instanceof v, x = (e) => e instanceof v ? e : new v(e), S = (e) => e instanceof v ? e.deref() : e, C = (e, t) => [
|
|
132
|
+
e,
|
|
133
|
+
_,
|
|
134
|
+
t
|
|
135
|
+
];
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region node_modules/.pnpm/@thi.ng+transducers@9.6.36/node_modules/@thi.ng/transducers/push.js
|
|
138
|
+
function w(e) {
|
|
139
|
+
return e ? [...e] : C(() => [], (e, t) => (e.push(t), e));
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region node_modules/.pnpm/@thi.ng+transducers@9.6.36/node_modules/@thi.ng/transducers/iterator.js
|
|
143
|
+
function* T(e, t) {
|
|
144
|
+
let n = h(e)(w()), r = n[1], i = n[2];
|
|
145
|
+
for (let e of t) {
|
|
146
|
+
let t = i([], e);
|
|
147
|
+
if (b(t)) {
|
|
148
|
+
yield* S(r(t.deref()));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
t.length && (yield* t);
|
|
152
|
+
}
|
|
153
|
+
yield* S(r([]));
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region node_modules/.pnpm/@thi.ng+transducers@9.6.36/node_modules/@thi.ng/transducers/compr.js
|
|
157
|
+
var E = (e, t) => [
|
|
158
|
+
e[0],
|
|
159
|
+
e[1],
|
|
160
|
+
t
|
|
161
|
+
];
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region node_modules/.pnpm/@thi.ng+transducers@9.6.36/node_modules/@thi.ng/transducers/take.js
|
|
164
|
+
function D(e, t) {
|
|
165
|
+
return g(t) ? T(D(e), t) : (t) => {
|
|
166
|
+
let n = t[2], r = e;
|
|
167
|
+
return E(t, (e, t) => --r > 0 ? n(e, t) : r === 0 ? x(n(e, t)) : y(e));
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
15
171
|
//#region src/Meta.ts
|
|
16
|
-
var
|
|
17
|
-
version: "1.
|
|
18
|
-
date: "2026-
|
|
19
|
-
},
|
|
20
|
-
blue:
|
|
21
|
-
brown:
|
|
22
|
-
green:
|
|
23
|
-
pink:
|
|
24
|
-
red:
|
|
25
|
-
violet:
|
|
26
|
-
white:
|
|
27
|
-
},
|
|
172
|
+
var O = {
|
|
173
|
+
version: "1.5.1",
|
|
174
|
+
date: "2026-05-14T15:40:37.745Z"
|
|
175
|
+
}, k = {
|
|
176
|
+
blue: s,
|
|
177
|
+
brown: d,
|
|
178
|
+
green: c,
|
|
179
|
+
pink: u,
|
|
180
|
+
red: d,
|
|
181
|
+
violet: f,
|
|
182
|
+
white: p
|
|
183
|
+
}, A = {
|
|
28
184
|
noise: "white",
|
|
29
185
|
scale: 1,
|
|
30
186
|
peaks: 2,
|
|
31
|
-
randomAlgorithm:
|
|
187
|
+
randomAlgorithm: n,
|
|
32
188
|
decay: 2,
|
|
33
189
|
delay: 0,
|
|
34
190
|
reverse: !1,
|
|
@@ -38,9 +194,9 @@ var c = {
|
|
|
38
194
|
filterQ: 1,
|
|
39
195
|
mix: .5,
|
|
40
196
|
once: !1
|
|
41
|
-
},
|
|
42
|
-
static version =
|
|
43
|
-
static build =
|
|
197
|
+
}, j = class e {
|
|
198
|
+
static version = O.version;
|
|
199
|
+
static build = O.date;
|
|
44
200
|
ctx;
|
|
45
201
|
wetGainNode;
|
|
46
202
|
dryGainNode;
|
|
@@ -49,10 +205,10 @@ var c = {
|
|
|
49
205
|
outputNode;
|
|
50
206
|
options;
|
|
51
207
|
isConnected;
|
|
52
|
-
noise =
|
|
53
|
-
noiseMap =
|
|
54
|
-
constructor(e, t) {
|
|
55
|
-
this.ctx = e, this.options = Object.assign({},
|
|
208
|
+
noise = p;
|
|
209
|
+
noiseMap = k;
|
|
210
|
+
constructor(e, t = {}) {
|
|
211
|
+
this.ctx = e, this.options = Object.assign({}, A, t), 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.filterType(this.options.filterType), this.setNoise(this.options.noise), this.buildImpulse(), this.mix(this.options.mix);
|
|
56
212
|
}
|
|
57
213
|
connect(e) {
|
|
58
214
|
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), e.connect(this.wetGainNode), this.dryGainNode.connect(this.outputNode), this.wetGainNode.connect(this.outputNode), this.isConnected = !0, this.outputNode);
|
|
@@ -97,7 +253,7 @@ var c = {
|
|
|
97
253
|
this.options.scale = e, this.buildImpulse(), console.debug(`[Reverb.js] Set IR source noise scale to ${e}.`);
|
|
98
254
|
}
|
|
99
255
|
getNoise(e) {
|
|
100
|
-
return [...
|
|
256
|
+
return [...D(e, this.noise({
|
|
101
257
|
bins: this.options.peaks,
|
|
102
258
|
scale: this.options.scale,
|
|
103
259
|
rnd: this.options.randomAlgorithm
|
|
@@ -127,7 +283,7 @@ var c = {
|
|
|
127
283
|
this.noise = this.noiseMap.white;
|
|
128
284
|
break;
|
|
129
285
|
default:
|
|
130
|
-
this.noise =
|
|
286
|
+
this.noise = p;
|
|
131
287
|
break;
|
|
132
288
|
}
|
|
133
289
|
this.buildImpulse(), console.debug(`[Reverb.js] Set IR generator source noise type to ${e}.`);
|
|
@@ -148,4 +304,4 @@ var c = {
|
|
|
148
304
|
}
|
|
149
305
|
};
|
|
150
306
|
//#endregion
|
|
151
|
-
export {
|
|
307
|
+
export { j as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @logue/reverb
|
|
3
|
+
*
|
|
4
|
+
* @description JavaScript Reverb effect class
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @version 1.5.1
|
|
9
|
+
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var Reverb=(function(){var e=1/2**32,t=class{float(t=1){return this.int()*e*t}probability(e){return this.float()<e}norm(t=1){return(this.int()*e-.5)*2*t}normMinMax(e,t){let n=this.minmax(e,t);return this.float()<.5?n:-n}minmax(e,t){return this.float()*(t-e)+e}minmaxInt(e,t){e|=0;let n=(t|0)-e;return n?e+this.int()%n:e}minmaxUint(e,t){e>>>=0;let n=(t>>>0)-e;return n?e+this.int()%n:e}},n=new class extends t{constructor(e){super(),this.rnd=e}rnd;float(e=1){return this.rnd()*e}norm(e=1){return(this.rnd()-.5)*2*e}int(){return this.rnd()*4294967296>>>0}}(Math.random),r={bins:2,scale:1,rnd:n},i=(e,t,n)=>{let r=Array(e);for(let i=0;i<e;i++)r[i]=n.norm(t);return r},a=e=>e.reduce((e,t)=>e+t,0);function*o(e,t){let n=[e[Symbol.iterator](),t[Symbol.iterator]()];for(let e=0;;e^=1){let t=n[e].next();if(t.done)return;yield t.value}}function*s(e){let{bins:t,scale:n,rnd:o}={...r,...e},s=i(t,n,o);s.forEach((e,t)=>s[t]=t&1?e:-e);let c=1/t,l=a(s);for(let e=0,r=-1;;++e>=t&&(e=0))l-=s[e],l+=s[e]=r*o.norm(n),r^=4294967294,yield r*l*c}var c=e=>o(s(e),s(e)),l=e=>{let t=32;return e&=-e,e&&t--,e&65535&&(t-=16),e&16711935&&(t-=8),e&252645135&&(t-=4),e&858993459&&(t-=2),e&1431655765&&--t,t};function*u(e){let{bins:t=8,scale:n,rnd:o}={...r,...e},s=i(t,n,o),c=1/t,u=a(s);for(let e=0;;e=e+1>>>0){let r=l(e)%t;u-=s[r],u+=s[r]=o.norm(n),yield u*c}}function*d(e){let{bins:t,scale:n,rnd:o}={...r,...e},s=i(t,n,o),c=1/t,l=a(s);for(let e=0;;++e>=t&&(e=0))l-=s[e],l+=s[e]=o.norm(n),yield l*c}var f=e=>o(d(e),d(e));function*p(e){let{scale:t,rnd:n}={...r,...e};for(;;)yield n.norm(t)}var m=(e,t)=>typeof e?.[t]==`function`,h=e=>m(e,`xform`)?e.xform():e,g=e=>typeof e?.[Symbol.iterator]==`function`,_=e=>e,v=class{value;constructor(e){this.value=e}deref(){return this.value}},y=e=>new v(e),b=e=>e instanceof v,x=e=>e instanceof v?e:new v(e),S=e=>e instanceof v?e.deref():e,C=(e,t)=>[e,_,t];function w(e){return e?[...e]:C(()=>[],(e,t)=>(e.push(t),e))}function*T(e,t){let n=h(e)(w()),r=n[1],i=n[2];for(let e of t){let t=i([],e);if(b(t)){yield*S(r(t.deref()));return}t.length&&(yield*t)}yield*S(r([]))}var E=(e,t)=>[e[0],e[1],t];function D(e,t){return g(t)?T(D(e),t):t=>{let n=t[2],r=e;return E(t,(e,t)=>--r>0?n(e,t):r===0?x(n(e,t)):y(e))}}var O={version:`1.5.1`,date:`2026-05-14T15:40:37.745Z`},k={blue:s,brown:d,green:c,pink:u,red:d,violet:f,white:p},A={noise:`white`,scale:1,peaks:2,randomAlgorithm:n,decay:2,delay:0,reverse:!1,time:2,filterType:`allpass`,filterFreq:2200,filterQ:1,mix:.5,once:!1};return class e{static version=O.version;static build=O.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=p;noiseMap=k;constructor(e,t={}){this.ctx=e,this.options=Object.assign({},A,t),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.filterType(this.options.filterType),this.setNoise(this.options.noise),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),e.connect(this.wetGainNode),this.dryGainNode.connect(this.outputNode),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(t){if(!e.inRange(t,0,1))throw RangeError(`[Reverb.js] Dry/Wet ratio must be between 0 to 1.`);this.options.mix=t,this.dryGainNode.gain.value=1-t,this.wetGainNode.gain.value=t,console.debug(`[Reverb.js] Set dry/wet ratio to ${t*100}%`)}time(t){if(!e.inRange(t,1,50))throw RangeError(`[Reverb.js] Time length of impulse response must be less than 50sec.`);this.options.time=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response time length to ${t}sec.`)}decay(t){if(!e.inRange(t,0,100))throw RangeError(`[Reverb.js] Impulse Response decay level must be less than 100.`);this.options.decay=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response decay level to ${t}.`)}delay(t){if(!e.inRange(t,0,100))throw RangeError(`[Reverb.js] Impulse Response delay time must be less than 100.`);this.options.delay=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response delay time to ${t}sec.`)}reverse(e){this.options.reverse=e,this.buildImpulse(),console.debug(`[Reverb.js] Inpulse response is ${e?``:`not `}reversed.`)}filterType(e=`allpass`){this.filterNode.type=this.options.filterType=e,console.debug(`[Reverb.js] Set filter type to ${e}`)}filterFreq(t){if(!e.inRange(t,20,2e4))throw RangeError(`[Reverb.js] Filter frequrncy must be between 20 and 20000.`);this.options.filterFreq=t,this.filterNode.frequency.value=this.options.filterFreq,console.debug(`[Reverb.js] Set filter frequency to ${t}Hz.`)}filterQ(t){if(!e.inRange(t,0,10))throw RangeError(`[Reverb.js] Filter Q value must be between 0 and 10.`);this.options.filterQ=t,this.filterNode.Q.value=this.options.filterQ,console.debug(`[Reverb.js] Set filter Q to ${t}.`)}peaks(e){this.options.peaks=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise peaks to ${e}.`)}scale(e){this.options.scale=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise scale to ${e}.`)}getNoise(e){return[...D(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}setNoise(e){switch(this.options.noise=e,e){case`blue`:this.noise=this.noiseMap.blue;break;case`brown`:this.noise=this.noiseMap.brown;break;case`green`:this.noise=this.noiseMap.green;break;case`pink`:this.noise=this.noiseMap.pink;break;case`red`:this.noise=this.noiseMap.red;break;case`violet`:this.noise=this.noiseMap.violet;break;case`white`:this.noise=this.noiseMap.white;break;default:this.noise=p;break}this.buildImpulse(),console.debug(`[Reverb.js] Set IR generator source noise type to ${e}.`)}setRandomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise generator.`)}static inRange(e,t,n){return e>=t&&e<=n}buildImpulse(){let e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),n=e*this.options.delay,r=this.ctx.createBuffer(2,t,e),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(1),s=new Float32Array(1),c=this.getNoise(t),l=this.getNoise(t);for(let e=0;e<t;e++){let r;e<n?(o[0]=0,s[0]=0,i.set(o,e),a.set(s,e),r=this.options.reverse??!1?t-(e-n):e-n):r=this.options.reverse??!1?t-e:e,o[0]=(c.at(e)??0)*(1-r/t)**this.options.decay,s[0]=(l.at(e)??0)*(1-r/t)**this.options.decay,i.set(o,e),a.set(s,e)}r.getChannelData(0).set(i),r.getChannelData(1).set(a),this.convolverNode.buffer=r}}})();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @logue/reverb
|
|
3
|
+
*
|
|
4
|
+
* @description JavaScript Reverb effect class
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @version 1.5.1
|
|
9
|
+
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.Reverb=t())})(this,function(){var e=1/2**32,t=class{float(t=1){return this.int()*e*t}probability(e){return this.float()<e}norm(t=1){return(this.int()*e-.5)*2*t}normMinMax(e,t){let n=this.minmax(e,t);return this.float()<.5?n:-n}minmax(e,t){return this.float()*(t-e)+e}minmaxInt(e,t){e|=0;let n=(t|0)-e;return n?e+this.int()%n:e}minmaxUint(e,t){e>>>=0;let n=(t>>>0)-e;return n?e+this.int()%n:e}},n=new class extends t{constructor(e){super(),this.rnd=e}rnd;float(e=1){return this.rnd()*e}norm(e=1){return(this.rnd()-.5)*2*e}int(){return this.rnd()*4294967296>>>0}}(Math.random),r={bins:2,scale:1,rnd:n},i=(e,t,n)=>{let r=Array(e);for(let i=0;i<e;i++)r[i]=n.norm(t);return r},a=e=>e.reduce((e,t)=>e+t,0);function*o(e,t){let n=[e[Symbol.iterator](),t[Symbol.iterator]()];for(let e=0;;e^=1){let t=n[e].next();if(t.done)return;yield t.value}}function*s(e){let{bins:t,scale:n,rnd:o}={...r,...e},s=i(t,n,o);s.forEach((e,t)=>s[t]=t&1?e:-e);let c=1/t,l=a(s);for(let e=0,r=-1;;++e>=t&&(e=0))l-=s[e],l+=s[e]=r*o.norm(n),r^=4294967294,yield r*l*c}var c=e=>o(s(e),s(e)),l=e=>{let t=32;return e&=-e,e&&t--,e&65535&&(t-=16),e&16711935&&(t-=8),e&252645135&&(t-=4),e&858993459&&(t-=2),e&1431655765&&--t,t};function*u(e){let{bins:t=8,scale:n,rnd:o}={...r,...e},s=i(t,n,o),c=1/t,u=a(s);for(let e=0;;e=e+1>>>0){let r=l(e)%t;u-=s[r],u+=s[r]=o.norm(n),yield u*c}}function*d(e){let{bins:t,scale:n,rnd:o}={...r,...e},s=i(t,n,o),c=1/t,l=a(s);for(let e=0;;++e>=t&&(e=0))l-=s[e],l+=s[e]=o.norm(n),yield l*c}var f=e=>o(d(e),d(e));function*p(e){let{scale:t,rnd:n}={...r,...e};for(;;)yield n.norm(t)}var m=(e,t)=>typeof e?.[t]==`function`,h=e=>m(e,`xform`)?e.xform():e,g=e=>typeof e?.[Symbol.iterator]==`function`,_=e=>e,v=class{value;constructor(e){this.value=e}deref(){return this.value}},y=e=>new v(e),b=e=>e instanceof v,x=e=>e instanceof v?e:new v(e),S=e=>e instanceof v?e.deref():e,C=(e,t)=>[e,_,t];function w(e){return e?[...e]:C(()=>[],(e,t)=>(e.push(t),e))}function*T(e,t){let n=h(e)(w()),r=n[1],i=n[2];for(let e of t){let t=i([],e);if(b(t)){yield*S(r(t.deref()));return}t.length&&(yield*t)}yield*S(r([]))}var E=(e,t)=>[e[0],e[1],t];function D(e,t){return g(t)?T(D(e),t):t=>{let n=t[2],r=e;return E(t,(e,t)=>--r>0?n(e,t):r===0?x(n(e,t)):y(e))}}var O={version:`1.5.1`,date:`2026-05-14T15:40:37.745Z`},k={blue:s,brown:d,green:c,pink:u,red:d,violet:f,white:p},A={noise:`white`,scale:1,peaks:2,randomAlgorithm:n,decay:2,delay:0,reverse:!1,time:2,filterType:`allpass`,filterFreq:2200,filterQ:1,mix:.5,once:!1};return class e{static version=O.version;static build=O.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=p;noiseMap=k;constructor(e,t={}){this.ctx=e,this.options=Object.assign({},A,t),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.filterType(this.options.filterType),this.setNoise(this.options.noise),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),e.connect(this.wetGainNode),this.dryGainNode.connect(this.outputNode),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(t){if(!e.inRange(t,0,1))throw RangeError(`[Reverb.js] Dry/Wet ratio must be between 0 to 1.`);this.options.mix=t,this.dryGainNode.gain.value=1-t,this.wetGainNode.gain.value=t,console.debug(`[Reverb.js] Set dry/wet ratio to ${t*100}%`)}time(t){if(!e.inRange(t,1,50))throw RangeError(`[Reverb.js] Time length of impulse response must be less than 50sec.`);this.options.time=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response time length to ${t}sec.`)}decay(t){if(!e.inRange(t,0,100))throw RangeError(`[Reverb.js] Impulse Response decay level must be less than 100.`);this.options.decay=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response decay level to ${t}.`)}delay(t){if(!e.inRange(t,0,100))throw RangeError(`[Reverb.js] Impulse Response delay time must be less than 100.`);this.options.delay=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response delay time to ${t}sec.`)}reverse(e){this.options.reverse=e,this.buildImpulse(),console.debug(`[Reverb.js] Inpulse response is ${e?``:`not `}reversed.`)}filterType(e=`allpass`){this.filterNode.type=this.options.filterType=e,console.debug(`[Reverb.js] Set filter type to ${e}`)}filterFreq(t){if(!e.inRange(t,20,2e4))throw RangeError(`[Reverb.js] Filter frequrncy must be between 20 and 20000.`);this.options.filterFreq=t,this.filterNode.frequency.value=this.options.filterFreq,console.debug(`[Reverb.js] Set filter frequency to ${t}Hz.`)}filterQ(t){if(!e.inRange(t,0,10))throw RangeError(`[Reverb.js] Filter Q value must be between 0 and 10.`);this.options.filterQ=t,this.filterNode.Q.value=this.options.filterQ,console.debug(`[Reverb.js] Set filter Q to ${t}.`)}peaks(e){this.options.peaks=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise peaks to ${e}.`)}scale(e){this.options.scale=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise scale to ${e}.`)}getNoise(e){return[...D(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}setNoise(e){switch(this.options.noise=e,e){case`blue`:this.noise=this.noiseMap.blue;break;case`brown`:this.noise=this.noiseMap.brown;break;case`green`:this.noise=this.noiseMap.green;break;case`pink`:this.noise=this.noiseMap.pink;break;case`red`:this.noise=this.noiseMap.red;break;case`violet`:this.noise=this.noiseMap.violet;break;case`white`:this.noise=this.noiseMap.white;break;default:this.noise=p;break}this.buildImpulse(),console.debug(`[Reverb.js] Set IR generator source noise type to ${e}.`)}setRandomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise generator.`)}static inRange(e,t,n){return e>=t&&e<=n}buildImpulse(){let e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),n=e*this.options.delay,r=this.ctx.createBuffer(2,t,e),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(1),s=new Float32Array(1),c=this.getNoise(t),l=this.getNoise(t);for(let e=0;e<t;e++){let r;e<n?(o[0]=0,s[0]=0,i.set(o,e),a.set(s,e),r=this.options.reverse??!1?t-(e-n):e-n):r=this.options.reverse??!1?t-e:e,o[0]=(c.at(e)??0)*(1-r/t)**this.options.decay,s[0]=(l.at(e)??0)*(1-r/t)**this.options.decay,i.set(o,e),a.set(s,e)}r.getChannelData(0).set(i),r.getChannelData(1).set(a),this.convolverNode.buffer=r}}});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@logue/reverb",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"description": "JavaScript Reverb effect class",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"webaudio",
|
|
@@ -47,10 +47,9 @@
|
|
|
47
47
|
"./package.json": "./package.json"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
|
-
"node": "
|
|
51
|
-
"pnpm": ">=10.2.0"
|
|
50
|
+
"node": ">=24.13.0"
|
|
52
51
|
},
|
|
53
|
-
"packageManager": "pnpm@
|
|
52
|
+
"packageManager": "pnpm@11.1.2",
|
|
54
53
|
"sideEffects": false,
|
|
55
54
|
"scripts": {
|
|
56
55
|
"dev": "vite",
|
|
@@ -73,41 +72,44 @@
|
|
|
73
72
|
"version": "auto-changelog -p && git add CHANGELOG.md"
|
|
74
73
|
},
|
|
75
74
|
"peerDependencies": {
|
|
76
|
-
"@thi.ng/colored-noise": "^1
|
|
77
|
-
"@thi.ng/random": "^4
|
|
78
|
-
"@thi.ng/transducers": "^9
|
|
75
|
+
"@thi.ng/colored-noise": "^1",
|
|
76
|
+
"@thi.ng/random": "^4",
|
|
77
|
+
"@thi.ng/transducers": "^9"
|
|
79
78
|
},
|
|
80
79
|
"devDependencies": {
|
|
80
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
|
|
81
81
|
"@eslint/js": "^10.0.1",
|
|
82
|
+
"@eslint/markdown": "^8.0.1",
|
|
82
83
|
"@tsconfig/node-lts": "^24.0.0",
|
|
83
|
-
"@types/node": "^25.
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
85
|
-
"@vitest/coverage-v8": "^4.1.
|
|
84
|
+
"@types/node": "^25.8.0",
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
|
86
|
+
"@vitest/coverage-v8": "^4.1.6",
|
|
87
|
+
"@vitest/eslint-plugin": "^1.6.17",
|
|
86
88
|
"bootstrap": "^5.3.8",
|
|
87
|
-
"eslint": "^10.
|
|
89
|
+
"eslint": "^10.4.0",
|
|
88
90
|
"eslint-config-prettier": "^10.1.8",
|
|
89
91
|
"eslint-import-resolver-custom-alias": "^1.3.2",
|
|
90
92
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
91
93
|
"eslint-plugin-import-x": "^4.16.2",
|
|
92
|
-
"eslint-plugin-oxlint": "^1.
|
|
94
|
+
"eslint-plugin-oxlint": "^1.65.0",
|
|
93
95
|
"eslint-plugin-security": "^4.0.0",
|
|
94
|
-
"globals": "^17.
|
|
96
|
+
"globals": "^17.6.0",
|
|
95
97
|
"happy-dom": "^20.9.0",
|
|
96
98
|
"husky": "^9.1.7",
|
|
97
|
-
"jiti": "^2.
|
|
98
|
-
"lint-staged": "^
|
|
99
|
+
"jiti": "^2.7.0",
|
|
100
|
+
"lint-staged": "^17.0.5",
|
|
99
101
|
"npm-run-all2": "^8.0.4",
|
|
100
|
-
"oxlint": "^1.
|
|
102
|
+
"oxlint": "^1.65.0",
|
|
101
103
|
"prettier": "^3.8.3",
|
|
102
104
|
"rimraf": "^6.1.3",
|
|
103
105
|
"rollup-plugin-visualizer": "^7.0.1",
|
|
104
106
|
"typescript": "^6.0.3",
|
|
105
|
-
"typescript-eslint": "^8.
|
|
106
|
-
"vite": "^8.0.
|
|
107
|
+
"typescript-eslint": "^8.59.3",
|
|
108
|
+
"vite": "^8.0.13",
|
|
107
109
|
"vite-plugin-banner": "^0.8.1",
|
|
108
110
|
"vite-plugin-checker": "^0.13.0",
|
|
109
|
-
"vite-plugin-dts": "^
|
|
110
|
-
"vitest": "^4.1.
|
|
111
|
+
"vite-plugin-dts": "^5.0.0",
|
|
112
|
+
"vitest": "^4.1.6"
|
|
111
113
|
},
|
|
112
114
|
"husky": {
|
|
113
115
|
"hooks": {
|
|
@@ -117,8 +119,5 @@
|
|
|
117
119
|
"lint-staged": {
|
|
118
120
|
"*.{js,ts,json,htm,html}": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint",
|
|
119
121
|
"*": "prettier -w -u"
|
|
120
|
-
},
|
|
121
|
-
"resolutions": {
|
|
122
|
-
"rollup": ">=4.60.2"
|
|
123
122
|
}
|
|
124
|
-
}
|
|
123
|
+
}
|
package/dist/Reverb.cjs.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @logue/reverb
|
|
3
|
-
*
|
|
4
|
-
* @description JavaScript Reverb effect class
|
|
5
|
-
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
|
-
* @license MIT
|
|
8
|
-
* @version 1.4.7
|
|
9
|
-
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`@thi.ng/colored-noise`),t=require(`@thi.ng/transducers`),n=require(`@thi.ng/random`);var r={version:`1.4.7`,date:`2026-04-19T23:22:26.611Z`},i={blue:e.blue,brown:e.red,green:e.green,pink:e.pink,red:e.red,violet:e.violet,white:e.white},a={noise:`white`,scale:1,peaks:2,randomAlgorithm:n.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:`allpass`,filterFreq:2200,filterQ:1,mix:.5,once:!1},o=class n{static version=r.version;static build=r.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=e.white;noiseMap=i;constructor(e,t){this.ctx=e,this.options=Object.assign({},a,t),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.filterType(this.options.filterType),this.setNoise(this.options.noise),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),e.connect(this.wetGainNode),this.dryGainNode.connect(this.outputNode),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(!n.inRange(e,0,1))throw RangeError(`[Reverb.js] Dry/Wet ratio must be between 0 to 1.`);this.options.mix=e,this.dryGainNode.gain.value=1-e,this.wetGainNode.gain.value=e,console.debug(`[Reverb.js] Set dry/wet ratio to ${e*100}%`)}time(e){if(!n.inRange(e,1,50))throw RangeError(`[Reverb.js] Time length of impulse response must be less than 50sec.`);this.options.time=e,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response time length to ${e}sec.`)}decay(e){if(!n.inRange(e,0,100))throw RangeError(`[Reverb.js] Impulse Response decay level must be less than 100.`);this.options.decay=e,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response decay level to ${e}.`)}delay(e){if(!n.inRange(e,0,100))throw RangeError(`[Reverb.js] Impulse Response delay time must be less than 100.`);this.options.delay=e,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response delay time to ${e}sec.`)}reverse(e){this.options.reverse=e,this.buildImpulse(),console.debug(`[Reverb.js] Inpulse response is ${e?``:`not `}reversed.`)}filterType(e=`allpass`){this.filterNode.type=this.options.filterType=e,console.debug(`[Reverb.js] Set filter type to ${e}`)}filterFreq(e){if(!n.inRange(e,20,2e4))throw RangeError(`[Reverb.js] Filter frequrncy must be between 20 and 20000.`);this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq,console.debug(`[Reverb.js] Set filter frequency to ${e}Hz.`)}filterQ(e){if(!n.inRange(e,0,10))throw RangeError(`[Reverb.js] Filter Q value must be between 0 and 10.`);this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ,console.debug(`[Reverb.js] Set filter Q to ${e}.`)}peaks(e){this.options.peaks=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise peaks to ${e}.`)}scale(e){this.options.scale=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise scale to ${e}.`)}getNoise(e){return[...(0,t.take)(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}setNoise(t){switch(this.options.noise=t,t){case`blue`:this.noise=this.noiseMap.blue;break;case`brown`:this.noise=this.noiseMap.brown;break;case`green`:this.noise=this.noiseMap.green;break;case`pink`:this.noise=this.noiseMap.pink;break;case`red`:this.noise=this.noiseMap.red;break;case`violet`:this.noise=this.noiseMap.violet;break;case`white`:this.noise=this.noiseMap.white;break;default:this.noise=e.white;break}this.buildImpulse(),console.debug(`[Reverb.js] Set IR generator source noise type to ${t}.`)}setRandomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise generator.`)}static inRange(e,t,n){return e>=t&&e<=n}buildImpulse(){let e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),n=e*this.options.delay,r=this.ctx.createBuffer(2,t,e),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(1),s=new Float32Array(1),c=this.getNoise(t),l=this.getNoise(t);for(let e=0;e<t;e++){let r;e<n?(o[0]=0,s[0]=0,i.set(o,e),a.set(s,e),r=this.options.reverse??!1?t-(e-n):e-n):r=this.options.reverse??!1?t-e:e,o[0]=(c.at(e)??0)*(1-r/t)**this.options.decay,s[0]=(l.at(e)??0)*(1-r/t)**this.options.decay,i.set(o,e),a.set(s,e)}r.getChannelData(0).set(i),r.getChannelData(1).set(a),this.convolverNode.buffer=r}};exports.default=o;
|
package/dist/Reverb.iife.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @logue/reverb
|
|
3
|
-
*
|
|
4
|
-
* @description JavaScript Reverb effect class
|
|
5
|
-
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
|
-
* @license MIT
|
|
8
|
-
* @version 1.4.7
|
|
9
|
-
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
var Reverb=(function(e,t,n,r){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var i={version:`1.4.7`,date:`2026-04-19T23:22:26.611Z`},a={blue:t.blue,brown:t.red,green:t.green,pink:t.pink,red:t.red,violet:t.violet,white:t.white},o={noise:`white`,scale:1,peaks:2,randomAlgorithm:r.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:`allpass`,filterFreq:2200,filterQ:1,mix:.5,once:!1};return e.default=class e{static version=i.version;static build=i.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=t.white;noiseMap=a;constructor(e,t){this.ctx=e,this.options=Object.assign({},o,t),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.filterType(this.options.filterType),this.setNoise(this.options.noise),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),e.connect(this.wetGainNode),this.dryGainNode.connect(this.outputNode),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(t){if(!e.inRange(t,0,1))throw RangeError(`[Reverb.js] Dry/Wet ratio must be between 0 to 1.`);this.options.mix=t,this.dryGainNode.gain.value=1-t,this.wetGainNode.gain.value=t,console.debug(`[Reverb.js] Set dry/wet ratio to ${t*100}%`)}time(t){if(!e.inRange(t,1,50))throw RangeError(`[Reverb.js] Time length of impulse response must be less than 50sec.`);this.options.time=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response time length to ${t}sec.`)}decay(t){if(!e.inRange(t,0,100))throw RangeError(`[Reverb.js] Impulse Response decay level must be less than 100.`);this.options.decay=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response decay level to ${t}.`)}delay(t){if(!e.inRange(t,0,100))throw RangeError(`[Reverb.js] Impulse Response delay time must be less than 100.`);this.options.delay=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response delay time to ${t}sec.`)}reverse(e){this.options.reverse=e,this.buildImpulse(),console.debug(`[Reverb.js] Inpulse response is ${e?``:`not `}reversed.`)}filterType(e=`allpass`){this.filterNode.type=this.options.filterType=e,console.debug(`[Reverb.js] Set filter type to ${e}`)}filterFreq(t){if(!e.inRange(t,20,2e4))throw RangeError(`[Reverb.js] Filter frequrncy must be between 20 and 20000.`);this.options.filterFreq=t,this.filterNode.frequency.value=this.options.filterFreq,console.debug(`[Reverb.js] Set filter frequency to ${t}Hz.`)}filterQ(t){if(!e.inRange(t,0,10))throw RangeError(`[Reverb.js] Filter Q value must be between 0 and 10.`);this.options.filterQ=t,this.filterNode.Q.value=this.options.filterQ,console.debug(`[Reverb.js] Set filter Q to ${t}.`)}peaks(e){this.options.peaks=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise peaks to ${e}.`)}scale(e){this.options.scale=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise scale to ${e}.`)}getNoise(e){return[...(0,n.take)(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}setNoise(e){switch(this.options.noise=e,e){case`blue`:this.noise=this.noiseMap.blue;break;case`brown`:this.noise=this.noiseMap.brown;break;case`green`:this.noise=this.noiseMap.green;break;case`pink`:this.noise=this.noiseMap.pink;break;case`red`:this.noise=this.noiseMap.red;break;case`violet`:this.noise=this.noiseMap.violet;break;case`white`:this.noise=this.noiseMap.white;break;default:this.noise=t.white;break}this.buildImpulse(),console.debug(`[Reverb.js] Set IR generator source noise type to ${e}.`)}setRandomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise generator.`)}static inRange(e,t,n){return e>=t&&e<=n}buildImpulse(){let e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),n=e*this.options.delay,r=this.ctx.createBuffer(2,t,e),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(1),s=new Float32Array(1),c=this.getNoise(t),l=this.getNoise(t);for(let e=0;e<t;e++){let r;e<n?(o[0]=0,s[0]=0,i.set(o,e),a.set(s,e),r=this.options.reverse??!1?t-(e-n):e-n):r=this.options.reverse??!1?t-e:e,o[0]=(c.at(e)??0)*(1-r/t)**this.options.decay,s[0]=(l.at(e)??0)*(1-r/t)**this.options.decay,i.set(o,e),a.set(s,e)}r.getChannelData(0).set(i),r.getChannelData(1).set(a),this.convolverNode.buffer=r}},e})({},coloredNoise,transducers,random);
|
package/dist/Reverb.umd.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @logue/reverb
|
|
3
|
-
*
|
|
4
|
-
* @description JavaScript Reverb effect class
|
|
5
|
-
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
|
-
* @license MIT
|
|
8
|
-
* @version 1.4.7
|
|
9
|
-
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@thi.ng/colored-noise`),require(`@thi.ng/transducers`),require(`@thi.ng/random`)):typeof define==`function`&&define.amd?define([`exports`,`@thi.ng/colored-noise`,`@thi.ng/transducers`,`@thi.ng/random`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Reverb={},e.coloredNoise,e.transducers,e.random))})(this,function(e,t,n,r){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var i={version:`1.4.7`,date:`2026-04-19T23:22:26.611Z`},a={blue:t.blue,brown:t.red,green:t.green,pink:t.pink,red:t.red,violet:t.violet,white:t.white},o={noise:`white`,scale:1,peaks:2,randomAlgorithm:r.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:`allpass`,filterFreq:2200,filterQ:1,mix:.5,once:!1};e.default=class e{static version=i.version;static build=i.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=t.white;noiseMap=a;constructor(e,t){this.ctx=e,this.options=Object.assign({},o,t),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.filterType(this.options.filterType),this.setNoise(this.options.noise),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),e.connect(this.wetGainNode),this.dryGainNode.connect(this.outputNode),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(t){if(!e.inRange(t,0,1))throw RangeError(`[Reverb.js] Dry/Wet ratio must be between 0 to 1.`);this.options.mix=t,this.dryGainNode.gain.value=1-t,this.wetGainNode.gain.value=t,console.debug(`[Reverb.js] Set dry/wet ratio to ${t*100}%`)}time(t){if(!e.inRange(t,1,50))throw RangeError(`[Reverb.js] Time length of impulse response must be less than 50sec.`);this.options.time=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response time length to ${t}sec.`)}decay(t){if(!e.inRange(t,0,100))throw RangeError(`[Reverb.js] Impulse Response decay level must be less than 100.`);this.options.decay=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response decay level to ${t}.`)}delay(t){if(!e.inRange(t,0,100))throw RangeError(`[Reverb.js] Impulse Response delay time must be less than 100.`);this.options.delay=t,this.buildImpulse(),console.debug(`[Reverb.js] Set impulse response delay time to ${t}sec.`)}reverse(e){this.options.reverse=e,this.buildImpulse(),console.debug(`[Reverb.js] Inpulse response is ${e?``:`not `}reversed.`)}filterType(e=`allpass`){this.filterNode.type=this.options.filterType=e,console.debug(`[Reverb.js] Set filter type to ${e}`)}filterFreq(t){if(!e.inRange(t,20,2e4))throw RangeError(`[Reverb.js] Filter frequrncy must be between 20 and 20000.`);this.options.filterFreq=t,this.filterNode.frequency.value=this.options.filterFreq,console.debug(`[Reverb.js] Set filter frequency to ${t}Hz.`)}filterQ(t){if(!e.inRange(t,0,10))throw RangeError(`[Reverb.js] Filter Q value must be between 0 and 10.`);this.options.filterQ=t,this.filterNode.Q.value=this.options.filterQ,console.debug(`[Reverb.js] Set filter Q to ${t}.`)}peaks(e){this.options.peaks=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise peaks to ${e}.`)}scale(e){this.options.scale=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise scale to ${e}.`)}getNoise(e){return[...(0,n.take)(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}setNoise(e){switch(this.options.noise=e,e){case`blue`:this.noise=this.noiseMap.blue;break;case`brown`:this.noise=this.noiseMap.brown;break;case`green`:this.noise=this.noiseMap.green;break;case`pink`:this.noise=this.noiseMap.pink;break;case`red`:this.noise=this.noiseMap.red;break;case`violet`:this.noise=this.noiseMap.violet;break;case`white`:this.noise=this.noiseMap.white;break;default:this.noise=t.white;break}this.buildImpulse(),console.debug(`[Reverb.js] Set IR generator source noise type to ${e}.`)}setRandomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse(),console.debug(`[Reverb.js] Set IR source noise generator.`)}static inRange(e,t,n){return e>=t&&e<=n}buildImpulse(){let e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),n=e*this.options.delay,r=this.ctx.createBuffer(2,t,e),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(1),s=new Float32Array(1),c=this.getNoise(t),l=this.getNoise(t);for(let e=0;e<t;e++){let r;e<n?(o[0]=0,s[0]=0,i.set(o,e),a.set(s,e),r=this.options.reverse??!1?t-(e-n):e-n):r=this.options.reverse??!1?t-e:e,o[0]=(c.at(e)??0)*(1-r/t)**this.options.decay,s[0]=(l.at(e)??0)*(1-r/t)**this.options.decay,i.set(o,e),a.set(s,e)}r.getChannelData(0).set(i),r.getChannelData(1).set(a),this.convolverNode.buffer=r}}});
|