@logue/reverb 1.4.6 → 1.4.7

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 CHANGED
@@ -164,3 +164,11 @@ The dependent libraries [@thi.ng/colored-noise](https://www.jsdelivr.com/package
164
164
  ## License
165
165
 
166
166
  ©2019-2026 by Logue. Licensed under the [MIT License](LICENSE).
167
+
168
+ ## 🎨 Crafted for Developers
169
+
170
+ This library is built with a focus **modern developer experience**. Maintaining it involves constant testing and updates to ensure everything works seamlessly.
171
+
172
+ If you appreciate the attention to detail in this project, a small sponsorship would go a long way in supporting my work across the Vue.js and Metaverse ecosystems.
173
+
174
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/logue?label=Sponsor&logo=github&color=ea4aaa)](https://github.com/sponsors/logue)
@@ -5,8 +5,8 @@
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.4.6
8
+ * @version 1.4.7
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var s=require("@thi.ng/colored-noise"),m=require("@thi.ng/transducers"),b=require("@thi.ng/random");const p={version:"1.4.6",date:"2026-03-06T12:11:28.691Z"},N={blue:s.blue,brown:s.red,green:s.green,pink:s.pink,red:s.red,violet:s.violet,white:s.white},w={noise:"white",scale:1,peaks:2,randomAlgorithm:b.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class o{static version=p.version;static build=p.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=s.white;noiseMap=N;constructor(e,t){this.ctx=e,this.options=Object.assign({},w,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(!o.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-e,this.wetGainNode.gain.value=e}time(e){if(!o.inRange(e,1,50))throw new RangeError("[Reverb.js] Time length of impulse response must be less than 50sec.");this.options.time=e,this.buildImpulse()}decay(e){if(!o.inRange(e,0,100))throw new RangeError("[Reverb.js] Impulse Response decay level must be less than 100.");this.options.decay=e,this.buildImpulse()}delay(e){if(!o.inRange(e,0,100))throw new RangeError("[Reverb.js] Impulse Response delay time must be less than 100.");this.options.delay=e,this.buildImpulse()}reverse(e){this.options.reverse=e,this.buildImpulse()}filterType(e="allpass"){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!o.inRange(e,20,2e4))throw new RangeError("[Reverb.js] Filter frequrncy must be between 20 and 20000.");this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq}filterQ(e){if(!o.inRange(e,0,10))throw new RangeError("[Reverb.js] Filter Q value must be between 0 and 10.");this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ}peaks(e){this.options.peaks=e,this.buildImpulse()}scale(e){this.options.scale=e,this.buildImpulse()}getNoise(e){return[...m.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=s.white;break}this.buildImpulse()}setRandomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,t,n){return e>=t&&e<=n}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),n=e*this.options.delay,l=this.ctx.createBuffer(2,t,e),c=new Float32Array(t),d=new Float32Array(t),r=new Float32Array(1),a=new Float32Array(1),u=this.getNoise(t),f=this.getNoise(t);for(let i=0;i<t;i++){let h;i<n?(r[0]=0,a[0]=0,c.set(r,i),d.set(a,i),h=this.options.reverse??!1?t-(i-n):i-n):h=this.options.reverse??!1?t-i:i,r[0]=(u.at(i)??0)*(1-h/t)**this.options.decay,a[0]=(f.at(i)??0)*(1-h/t)**this.options.decay,c.set(r,i),d.set(a,i)}l.getChannelData(0).set(c),l.getChannelData(1).set(d),this.convolverNode.buffer=l}}exports.default=o;
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.es.js CHANGED
@@ -5,272 +5,147 @@
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.4.6
8
+ * @version 1.4.7
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- import { white as d, violet as b, red as p, pink as N, green as w, blue as y } from "@thi.ng/colored-noise";
13
- import { take as g } from "@thi.ng/transducers";
14
- import { SYSTEM as v } from "@thi.ng/random";
15
- const u = {
16
- version: "1.4.6",
17
- date: "2026-03-06T12:11:28.691Z"
18
- }, R = {
19
- blue: y,
20
- brown: p,
21
- green: w,
22
- pink: N,
23
- red: p,
24
- violet: b,
25
- white: d
26
- }, k = {
27
- noise: "white",
28
- scale: 1,
29
- peaks: 2,
30
- randomAlgorithm: v,
31
- decay: 2,
32
- delay: 0,
33
- reverse: !1,
34
- time: 2,
35
- filterType: "allpass",
36
- filterFreq: 2200,
37
- filterQ: 1,
38
- mix: 0.5,
39
- once: !1
40
- };
41
- class s {
42
- /** Version strings */
43
- static version = u.version;
44
- /** Build date */
45
- static build = u.date;
46
- /** AudioContext */
47
- ctx;
48
- /** Wet Level (Reverberated node) */
49
- wetGainNode;
50
- /** Dry Level (Original sound node) */
51
- dryGainNode;
52
- /** Impulse response filter */
53
- filterNode;
54
- /** Convolution node for applying impulse response */
55
- convolverNode;
56
- /** Output gain node */
57
- outputNode;
58
- /** Option */
59
- options;
60
- /** Connected flag */
61
- isConnected;
62
- /** Noise Generator */
63
- noise = d;
64
- /**
65
- * Map of noise types to their respective generator functions.
66
- */
67
- noiseMap = R;
68
- /**
69
- * Constructor
70
- *
71
- * @param ctx - Root AudioContext
72
- * @param options - Configure
73
- */
74
- constructor(e, t) {
75
- this.ctx = e, this.options = Object.assign({}, k, 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);
76
- }
77
- /**
78
- * Connect the node for the reverb effect to the original sound node.
79
- *
80
- * @param sourceNode - Input source node
81
- */
82
- connect(e) {
83
- 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);
84
- }
85
- /**
86
- * Disconnect the reverb node
87
- *
88
- * @param sourceNode - Input source node
89
- */
90
- disconnect(e) {
91
- return this.isConnected && (this.convolverNode.disconnect(this.filterNode), this.filterNode.disconnect(this.wetGainNode)), this.isConnected = !1, e;
92
- }
93
- /**
94
- * Dry/Wet ratio
95
- *
96
- * @param mix - Ratio (0~1)
97
- */
98
- mix(e) {
99
- if (!s.inRange(e, 0, 1))
100
- throw new RangeError("[Reverb.js] Dry/Wet ratio must be between 0 to 1.");
101
- this.options.mix = e, this.dryGainNode.gain.value = 1 - e, this.wetGainNode.gain.value = e;
102
- }
103
- /**
104
- * Set Impulse Response time length (second)
105
- *
106
- * @param value - IR length
107
- */
108
- time(e) {
109
- if (!s.inRange(e, 1, 50))
110
- throw new RangeError(
111
- "[Reverb.js] Time length of impulse response must be less than 50sec."
112
- );
113
- this.options.time = e, this.buildImpulse();
114
- }
115
- /**
116
- * Impulse response decay rate.
117
- *
118
- * @param value - Decay value
119
- */
120
- decay(e) {
121
- if (!s.inRange(e, 0, 100))
122
- throw new RangeError(
123
- "[Reverb.js] Impulse Response decay level must be less than 100."
124
- );
125
- this.options.decay = e, this.buildImpulse();
126
- }
127
- /**
128
- * Delay before reverberation starts
129
- *
130
- * @param value - Time[ms]
131
- */
132
- delay(e) {
133
- if (!s.inRange(e, 0, 100))
134
- throw new RangeError(
135
- "[Reverb.js] Impulse Response delay time must be less than 100."
136
- );
137
- this.options.delay = e, this.buildImpulse();
138
- }
139
- /**
140
- * Reverse the impulse response.
141
- *
142
- * @param reverse - Reverse IR
143
- */
144
- reverse(e) {
145
- this.options.reverse = e, this.buildImpulse();
146
- }
147
- /**
148
- * Filter for impulse response
149
- *
150
- * @param type - Filiter Type
151
- */
152
- filterType(e = "allpass") {
153
- this.filterNode.type = this.options.filterType = e;
154
- }
155
- /**
156
- * Filter frequency applied to impulse response
157
- *
158
- * @param freq - Frequency
159
- */
160
- filterFreq(e) {
161
- if (!s.inRange(e, 20, 2e4))
162
- throw new RangeError(
163
- "[Reverb.js] Filter frequrncy must be between 20 and 20000."
164
- );
165
- this.options.filterFreq = e, this.filterNode.frequency.value = this.options.filterFreq;
166
- }
167
- /**
168
- * Filter quality.
169
- *
170
- * @param q - Quality
171
- */
172
- filterQ(e) {
173
- if (!s.inRange(e, 0, 10))
174
- throw new RangeError(
175
- "[Reverb.js] Filter Q value must be between 0 and 10."
176
- );
177
- this.options.filterQ = e, this.filterNode.Q.value = this.options.filterQ;
178
- }
179
- /**
180
- * set IR source noise peaks
181
- *
182
- * @param p - Peaks
183
- */
184
- peaks(e) {
185
- this.options.peaks = e, this.buildImpulse();
186
- }
187
- /**
188
- * set IR source noise scale.
189
- *
190
- * @param s - Scale
191
- */
192
- scale(e) {
193
- this.options.scale = e, this.buildImpulse();
194
- }
195
- /**
196
- * Noise source
197
- *
198
- * @param duration - length of IR.
199
- */
200
- getNoise(e) {
201
- return [
202
- ...g(
203
- e,
204
- this.noise({
205
- bins: this.options.peaks,
206
- scale: this.options.scale,
207
- rnd: this.options.randomAlgorithm
208
- })
209
- )
210
- ];
211
- }
212
- /**
213
- * Inpulse Response Noise algorithm.
214
- *
215
- * @param type - IR noise algorithm type.
216
- */
217
- setNoise(e) {
218
- switch (this.options.noise = e, e) {
219
- case "blue":
220
- this.noise = this.noiseMap.blue;
221
- break;
222
- case "brown":
223
- this.noise = this.noiseMap.brown;
224
- break;
225
- case "green":
226
- this.noise = this.noiseMap.green;
227
- break;
228
- case "pink":
229
- this.noise = this.noiseMap.pink;
230
- break;
231
- case "red":
232
- this.noise = this.noiseMap.red;
233
- break;
234
- case "violet":
235
- this.noise = this.noiseMap.violet;
236
- break;
237
- case "white":
238
- this.noise = this.noiseMap.white;
239
- break;
240
- default:
241
- this.noise = d;
242
- break;
243
- }
244
- this.buildImpulse();
245
- }
246
- /**
247
- * Set Random Algorythm
248
- *
249
- * @param algorithm - Algorythm
250
- */
251
- setRandomAlgorithm(e) {
252
- this.options.randomAlgorithm = e, this.buildImpulse();
253
- }
254
- /**
255
- * Return true if in range, otherwise false
256
- *
257
- * @param x - Target value
258
- * @param min - Minimum value
259
- * @param max - Maximum value
260
- */
261
- static inRange(e, t, o) {
262
- return e >= t && e <= o;
263
- }
264
- /** Utility function for building an impulse response from the module parameters. */
265
- buildImpulse() {
266
- const e = this.ctx.sampleRate, t = Math.max(e * this.options.time, 1), o = e * this.options.delay, h = this.ctx.createBuffer(2, t, e), l = new Float32Array(t), c = new Float32Array(t), n = new Float32Array(1), r = new Float32Array(1), f = this.getNoise(t), m = this.getNoise(t);
267
- for (let i = 0; i < t; i++) {
268
- let a;
269
- i < o ? (n[0] = 0, r[0] = 0, l.set(n, i), c.set(r, i), a = this.options.reverse ?? !1 ? t - (i - o) : i - o) : a = this.options.reverse ?? !1 ? t - i : i, n[0] = (f.at(i) ?? 0) * (1 - a / t) ** this.options.decay, r[0] = (m.at(i) ?? 0) * (1 - a / t) ** this.options.decay, l.set(n, i), c.set(r, i);
270
- }
271
- h.getChannelData(0).set(l), h.getChannelData(1).set(c), this.convolverNode.buffer = h;
272
- }
273
- }
274
- export {
275
- s as default
12
+ import { blue as e, green as t, pink as n, red as r, violet as i, white as a } from "@thi.ng/colored-noise";
13
+ import { take as o } from "@thi.ng/transducers";
14
+ import { SYSTEM as s } from "@thi.ng/random";
15
+ //#region src/Meta.ts
16
+ var c = {
17
+ version: "1.4.7",
18
+ date: "2026-04-19T23:22:26.611Z"
19
+ }, l = {
20
+ blue: e,
21
+ brown: r,
22
+ green: t,
23
+ pink: n,
24
+ red: r,
25
+ violet: i,
26
+ white: a
27
+ }, u = {
28
+ noise: "white",
29
+ scale: 1,
30
+ peaks: 2,
31
+ randomAlgorithm: s,
32
+ decay: 2,
33
+ delay: 0,
34
+ reverse: !1,
35
+ time: 2,
36
+ filterType: "allpass",
37
+ filterFreq: 2200,
38
+ filterQ: 1,
39
+ mix: .5,
40
+ once: !1
41
+ }, d = class e {
42
+ static version = c.version;
43
+ static build = c.date;
44
+ ctx;
45
+ wetGainNode;
46
+ dryGainNode;
47
+ filterNode;
48
+ convolverNode;
49
+ outputNode;
50
+ options;
51
+ isConnected;
52
+ noise = a;
53
+ noiseMap = l;
54
+ constructor(e, t) {
55
+ this.ctx = e, this.options = Object.assign({}, u, 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
+ }
57
+ connect(e) {
58
+ 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);
59
+ }
60
+ disconnect(e) {
61
+ return this.isConnected && (this.convolverNode.disconnect(this.filterNode), this.filterNode.disconnect(this.wetGainNode)), this.isConnected = !1, e;
62
+ }
63
+ mix(t) {
64
+ if (!e.inRange(t, 0, 1)) throw RangeError("[Reverb.js] Dry/Wet ratio must be between 0 to 1.");
65
+ 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}%`);
66
+ }
67
+ time(t) {
68
+ if (!e.inRange(t, 1, 50)) throw RangeError("[Reverb.js] Time length of impulse response must be less than 50sec.");
69
+ this.options.time = t, this.buildImpulse(), console.debug(`[Reverb.js] Set impulse response time length to ${t}sec.`);
70
+ }
71
+ decay(t) {
72
+ if (!e.inRange(t, 0, 100)) throw RangeError("[Reverb.js] Impulse Response decay level must be less than 100.");
73
+ this.options.decay = t, this.buildImpulse(), console.debug(`[Reverb.js] Set impulse response decay level to ${t}.`);
74
+ }
75
+ delay(t) {
76
+ if (!e.inRange(t, 0, 100)) throw RangeError("[Reverb.js] Impulse Response delay time must be less than 100.");
77
+ this.options.delay = t, this.buildImpulse(), console.debug(`[Reverb.js] Set impulse response delay time to ${t}sec.`);
78
+ }
79
+ reverse(e) {
80
+ this.options.reverse = e, this.buildImpulse(), console.debug(`[Reverb.js] Inpulse response is ${e ? "" : "not "}reversed.`);
81
+ }
82
+ filterType(e = "allpass") {
83
+ this.filterNode.type = this.options.filterType = e, console.debug(`[Reverb.js] Set filter type to ${e}`);
84
+ }
85
+ filterFreq(t) {
86
+ if (!e.inRange(t, 20, 2e4)) throw RangeError("[Reverb.js] Filter frequrncy must be between 20 and 20000.");
87
+ this.options.filterFreq = t, this.filterNode.frequency.value = this.options.filterFreq, console.debug(`[Reverb.js] Set filter frequency to ${t}Hz.`);
88
+ }
89
+ filterQ(t) {
90
+ if (!e.inRange(t, 0, 10)) throw RangeError("[Reverb.js] Filter Q value must be between 0 and 10.");
91
+ this.options.filterQ = t, this.filterNode.Q.value = this.options.filterQ, console.debug(`[Reverb.js] Set filter Q to ${t}.`);
92
+ }
93
+ peaks(e) {
94
+ this.options.peaks = e, this.buildImpulse(), console.debug(`[Reverb.js] Set IR source noise peaks to ${e}.`);
95
+ }
96
+ scale(e) {
97
+ this.options.scale = e, this.buildImpulse(), console.debug(`[Reverb.js] Set IR source noise scale to ${e}.`);
98
+ }
99
+ getNoise(e) {
100
+ return [...o(e, this.noise({
101
+ bins: this.options.peaks,
102
+ scale: this.options.scale,
103
+ rnd: this.options.randomAlgorithm
104
+ }))];
105
+ }
106
+ setNoise(e) {
107
+ switch (this.options.noise = e, e) {
108
+ case "blue":
109
+ this.noise = this.noiseMap.blue;
110
+ break;
111
+ case "brown":
112
+ this.noise = this.noiseMap.brown;
113
+ break;
114
+ case "green":
115
+ this.noise = this.noiseMap.green;
116
+ break;
117
+ case "pink":
118
+ this.noise = this.noiseMap.pink;
119
+ break;
120
+ case "red":
121
+ this.noise = this.noiseMap.red;
122
+ break;
123
+ case "violet":
124
+ this.noise = this.noiseMap.violet;
125
+ break;
126
+ case "white":
127
+ this.noise = this.noiseMap.white;
128
+ break;
129
+ default:
130
+ this.noise = a;
131
+ break;
132
+ }
133
+ this.buildImpulse(), console.debug(`[Reverb.js] Set IR generator source noise type to ${e}.`);
134
+ }
135
+ setRandomAlgorithm(e) {
136
+ this.options.randomAlgorithm = e, this.buildImpulse(), console.debug("[Reverb.js] Set IR source noise generator.");
137
+ }
138
+ static inRange(e, t, n) {
139
+ return e >= t && e <= n;
140
+ }
141
+ buildImpulse() {
142
+ 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);
143
+ for (let e = 0; e < t; e++) {
144
+ let r;
145
+ 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);
146
+ }
147
+ r.getChannelData(0).set(i), r.getChannelData(1).set(a), this.convolverNode.buffer = r;
148
+ }
276
149
  };
150
+ //#endregion
151
+ export { d as default };
@@ -5,8 +5,8 @@
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.4.6
8
+ * @version 1.4.7
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- var Reverb=(function(l,s,f,m){"use strict";const u={version:"1.4.6",date:"2026-03-06T12:11:28.691Z"},b={blue:s.blue,brown:s.red,green:s.green,pink:s.pink,red:s.red,violet:s.violet,white:s.white},w={noise:"white",scale:1,peaks:2,randomAlgorithm:m.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class n{static version=u.version;static build=u.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=s.white;noiseMap=b;constructor(e,t){this.ctx=e,this.options=Object.assign({},w,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 new 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}time(e){if(!n.inRange(e,1,50))throw new RangeError("[Reverb.js] Time length of impulse response must be less than 50sec.");this.options.time=e,this.buildImpulse()}decay(e){if(!n.inRange(e,0,100))throw new RangeError("[Reverb.js] Impulse Response decay level must be less than 100.");this.options.decay=e,this.buildImpulse()}delay(e){if(!n.inRange(e,0,100))throw new RangeError("[Reverb.js] Impulse Response delay time must be less than 100.");this.options.delay=e,this.buildImpulse()}reverse(e){this.options.reverse=e,this.buildImpulse()}filterType(e="allpass"){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!n.inRange(e,20,2e4))throw new RangeError("[Reverb.js] Filter frequrncy must be between 20 and 20000.");this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq}filterQ(e){if(!n.inRange(e,0,10))throw new RangeError("[Reverb.js] Filter Q value must be between 0 and 10.");this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ}peaks(e){this.options.peaks=e,this.buildImpulse()}scale(e){this.options.scale=e,this.buildImpulse()}getNoise(e){return[...f.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=s.white;break}this.buildImpulse()}setRandomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,t,o){return e>=t&&e<=o}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),o=e*this.options.delay,c=this.ctx.createBuffer(2,t,e),d=new Float32Array(t),p=new Float32Array(t),a=new Float32Array(1),r=new Float32Array(1),v=this.getNoise(t),y=this.getNoise(t);for(let i=0;i<t;i++){let h;i<o?(a[0]=0,r[0]=0,d.set(a,i),p.set(r,i),h=this.options.reverse??!1?t-(i-o):i-o):h=this.options.reverse??!1?t-i:i,a[0]=(v.at(i)??0)*(1-h/t)**this.options.decay,r[0]=(y.at(i)??0)*(1-h/t)**this.options.decay,d.set(a,i),p.set(r,i)}c.getChannelData(0).set(d),c.getChannelData(1).set(p),this.convolverNode.buffer=c}}return l.default=n,Object.defineProperty(l,"__esModule",{value:!0}),l})({},coloredNoise,transducers,random);
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);
@@ -5,8 +5,8 @@
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.4.6
8
+ * @version 1.4.7
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(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"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.Reverb={},n.coloredNoise,n.transducers,n.random))})(this,(function(n,i,f,m){"use strict";const u={version:"1.4.6",date:"2026-03-06T12:11:28.691Z"},b={blue:i.blue,brown:i.red,green:i.green,pink:i.pink,red:i.red,violet:i.violet,white:i.white},w={noise:"white",scale:1,peaks:2,randomAlgorithm:m.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class o{static version=u.version;static build=u.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=i.white;noiseMap=b;constructor(e,t){this.ctx=e,this.options=Object.assign({},w,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(!o.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-e,this.wetGainNode.gain.value=e}time(e){if(!o.inRange(e,1,50))throw new RangeError("[Reverb.js] Time length of impulse response must be less than 50sec.");this.options.time=e,this.buildImpulse()}decay(e){if(!o.inRange(e,0,100))throw new RangeError("[Reverb.js] Impulse Response decay level must be less than 100.");this.options.decay=e,this.buildImpulse()}delay(e){if(!o.inRange(e,0,100))throw new RangeError("[Reverb.js] Impulse Response delay time must be less than 100.");this.options.delay=e,this.buildImpulse()}reverse(e){this.options.reverse=e,this.buildImpulse()}filterType(e="allpass"){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!o.inRange(e,20,2e4))throw new RangeError("[Reverb.js] Filter frequrncy must be between 20 and 20000.");this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq}filterQ(e){if(!o.inRange(e,0,10))throw new RangeError("[Reverb.js] Filter Q value must be between 0 and 10.");this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ}peaks(e){this.options.peaks=e,this.buildImpulse()}scale(e){this.options.scale=e,this.buildImpulse()}getNoise(e){return[...f.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=i.white;break}this.buildImpulse()}setRandomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,t,r){return e>=t&&e<=r}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),r=e*this.options.delay,d=this.ctx.createBuffer(2,t,e),c=new Float32Array(t),p=new Float32Array(t),a=new Float32Array(1),h=new Float32Array(1),g=this.getNoise(t),y=this.getNoise(t);for(let s=0;s<t;s++){let l;s<r?(a[0]=0,h[0]=0,c.set(a,s),p.set(h,s),l=this.options.reverse??!1?t-(s-r):s-r):l=this.options.reverse??!1?t-s:s,a[0]=(g.at(s)??0)*(1-l/t)**this.options.decay,h[0]=(y.at(s)??0)*(1-l/t)**this.options.decay,c.set(a,s),p.set(h,s)}d.getChannelData(0).set(c),d.getChannelData(1).set(p),this.convolverNode.buffer=d}}n.default=o,Object.defineProperty(n,"__esModule",{value:!0})}));
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}}});
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.6",
4
+ "version": "1.4.7",
5
5
  "description": "JavaScript Reverb effect class",
6
6
  "keywords": [
7
7
  "webaudio",
@@ -50,7 +50,7 @@
50
50
  "node": "^20.19.0 || >=22.12.0",
51
51
  "pnpm": ">=10.2.0"
52
52
  },
53
- "packageManager": "pnpm@10.30.3",
53
+ "packageManager": "pnpm@10.33.0",
54
54
  "sideEffects": false,
55
55
  "scripts": {
56
56
  "dev": "vite",
@@ -80,34 +80,34 @@
80
80
  "devDependencies": {
81
81
  "@eslint/js": "^10.0.1",
82
82
  "@tsconfig/node-lts": "^24.0.0",
83
- "@types/node": "^25.3.5",
84
- "@typescript-eslint/eslint-plugin": "^8.56.1",
85
- "@vitest/coverage-v8": "^4.0.18",
83
+ "@types/node": "^25.6.0",
84
+ "@typescript-eslint/eslint-plugin": "^8.58.2",
85
+ "@vitest/coverage-v8": "^4.1.4",
86
86
  "bootstrap": "^5.3.8",
87
- "eslint": "^10.0.2",
87
+ "eslint": "^10.2.1",
88
88
  "eslint-config-prettier": "^10.1.8",
89
89
  "eslint-import-resolver-custom-alias": "^1.3.2",
90
90
  "eslint-import-resolver-typescript": "^4.4.4",
91
- "eslint-plugin-import-x": "^4.16.1",
92
- "eslint-plugin-oxlint": "^1.51.0",
91
+ "eslint-plugin-import-x": "^4.16.2",
92
+ "eslint-plugin-oxlint": "^1.60.0",
93
93
  "eslint-plugin-security": "^4.0.0",
94
- "globals": "^17.4.0",
95
- "happy-dom": "^20.8.3",
94
+ "globals": "^17.5.0",
95
+ "happy-dom": "^20.9.0",
96
96
  "husky": "^9.1.7",
97
97
  "jiti": "^2.6.1",
98
- "lint-staged": "^16.3.2",
98
+ "lint-staged": "^16.4.0",
99
99
  "npm-run-all2": "^8.0.4",
100
- "oxlint": "^1.51.0",
101
- "prettier": "^3.8.1",
100
+ "oxlint": "^1.60.0",
101
+ "prettier": "^3.8.3",
102
102
  "rimraf": "^6.1.3",
103
103
  "rollup-plugin-visualizer": "^7.0.1",
104
- "typescript": "^5.9.3",
105
- "typescript-eslint": "^8.56.1",
106
- "vite": "^7.3.1",
104
+ "typescript": "^6.0.3",
105
+ "typescript-eslint": "^8.58.2",
106
+ "vite": "^8.0.8",
107
107
  "vite-plugin-banner": "^0.8.1",
108
- "vite-plugin-checker": "^0.12.0",
108
+ "vite-plugin-checker": "^0.13.0",
109
109
  "vite-plugin-dts": "^4.5.4",
110
- "vitest": "^4.0.18"
110
+ "vitest": "^4.1.4"
111
111
  },
112
112
  "husky": {
113
113
  "hooks": {
@@ -119,8 +119,6 @@
119
119
  "*": "prettier -w -u"
120
120
  },
121
121
  "resolutions": {
122
- "json5": ">=2.2.3",
123
- "minimatch": ">=10.2.3",
124
- "yaml": ">=2.6.0"
122
+ "rollup": ">=4.60.2"
125
123
  }
126
- }
124
+ }