@logue/reverb 1.3.15 → 1.4.0

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.
@@ -1,6 +1,2 @@
1
- /** Impulse response noise generation algorithm */
2
- declare const Noise: Record<NoiseType, string>;
3
1
  /** Noise Type */
4
2
  export type NoiseType = 'blue' | 'brown' | 'green' | 'pink' | 'red' | 'violet' | 'white';
5
- /** Noise */
6
- export default Noise;
package/dist/Reverb.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import { NoiseType } from './NoiseType';
1
2
  import { default as OptionInterface } from './interfaces/OptionInterface';
2
3
  import { INorm } from '@thi.ng/random';
3
- import { NoiseType } from './NoiseType';
4
4
  /**
5
5
  * Reverb effect class
6
6
  */
@@ -27,6 +27,10 @@ export default class Reverb {
27
27
  private isConnected;
28
28
  /** Noise Generator */
29
29
  private noise;
30
+ /**
31
+ * Map of noise types to their respective generator functions.
32
+ */
33
+ private readonly noiseMap;
30
34
  /**
31
35
  * Constructor
32
36
  *
@@ -107,11 +111,11 @@ export default class Reverb {
107
111
  */
108
112
  scale(s: number): void;
109
113
  /**
110
- * set IR source noise generator.
114
+ * Noise source
111
115
  *
112
- * @param a - Algorithm
116
+ * @param duration - length of IR.
113
117
  */
114
- randomAlgorithm(a: INorm): void;
118
+ private getNoise;
115
119
  /**
116
120
  * Inpulse Response Noise algorithm.
117
121
  *
@@ -123,7 +127,7 @@ export default class Reverb {
123
127
  *
124
128
  * @param algorithm - Algorythm
125
129
  */
126
- setRandomAlgorythm(algorithm: INorm): void;
130
+ setRandomAlgorithm(algorithm: INorm): void;
127
131
  /**
128
132
  * Return true if in range, otherwise false
129
133
  *
@@ -134,10 +138,4 @@ export default class Reverb {
134
138
  private static inRange;
135
139
  /** Utility function for building an impulse response from the module parameters. */
136
140
  private buildImpulse;
137
- /**
138
- * Noise source
139
- *
140
- * @param duration - length of IR.
141
- */
142
- private getNoise;
143
141
  }
package/dist/Reverb.es.js CHANGED
@@ -5,29 +5,16 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.15
8
+ * @version 1.4.0
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- import { white as c, violet as m, red as f, pink as b, green as N, blue as g } from "@thi.ng/colored-noise";
12
+ import { white as l, violet as f, red as d, pink as m, green as N, blue as g } from "@thi.ng/colored-noise";
13
13
  import { take as v } from "@thi.ng/transducers";
14
14
  import { SYSTEM as w } from "@thi.ng/random";
15
- const d = {
16
- version: "1.3.15",
17
- date: "2025-03-02T14:58:09.789Z"
18
- }, o = {
19
- /** Blue noise */
20
- blue: "blue",
21
- /** Brown noise (same as red noise) */
22
- brown: "red",
23
- /** Green noise */
24
- green: "green",
25
- /** Pink noise */
26
- pink: "pink",
27
- /** Red noise */
28
- red: "red",
29
- /** Violet noise */
30
- violet: "violet"
15
+ const c = {
16
+ version: "1.4.0",
17
+ date: "2025-06-01T11:08:05.639Z"
31
18
  }, y = {
32
19
  noise: "white",
33
20
  scale: 1,
@@ -45,9 +32,9 @@ const d = {
45
32
  };
46
33
  class s {
47
34
  /** Version strings */
48
- static version = d.version;
35
+ static version = c.version;
49
36
  /** Build date */
50
- static build = d.date;
37
+ static build = c.date;
51
38
  /** AudioContext */
52
39
  ctx;
53
40
  /** Wet Level (Reverberated node) */
@@ -65,7 +52,20 @@ class s {
65
52
  /** Connected flag */
66
53
  isConnected;
67
54
  /** Noise Generator */
68
- noise = c;
55
+ noise = l;
56
+ /**
57
+ * Map of noise types to their respective generator functions.
58
+ */
59
+ noiseMap = {
60
+ blue: g,
61
+ green: N,
62
+ pink: m,
63
+ red: d,
64
+ brown: d,
65
+ // brown is an alias for red
66
+ violet: f,
67
+ white: l
68
+ };
69
69
  /**
70
70
  * Constructor
71
71
  *
@@ -81,7 +81,7 @@ class s {
81
81
  * @param sourceNode - Input source node
82
82
  */
83
83
  connect(e) {
84
- return this.isConnected && this.options.once ? (this.isConnected = !1, this.outputNode) : (this.convolverNode.connect(this.filterNode), this.filterNode.connect(this.wetGainNode), e.connect(this.convolverNode), e.connect(this.dryGainNode).connect(this.outputNode), e.connect(this.wetGainNode).connect(this.outputNode), this.isConnected = !0, this.outputNode);
84
+ 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);
85
85
  }
86
86
  /**
87
87
  * Disconnect the reverb node
@@ -99,7 +99,7 @@ class s {
99
99
  mix(e) {
100
100
  if (!s.inRange(e, 0, 1))
101
101
  throw new RangeError("[Reverb.js] Dry/Wet ratio must be between 0 to 1.");
102
- this.options.mix = e, this.dryGainNode.gain.value = 1 - this.options.mix, this.wetGainNode.gain.value = this.options.mix;
102
+ this.options.mix = e, this.dryGainNode.gain.value = 1 - e, this.wetGainNode.gain.value = e;
103
103
  }
104
104
  /**
105
105
  * Set Impulse Response time length (second)
@@ -109,7 +109,7 @@ class s {
109
109
  time(e) {
110
110
  if (!s.inRange(e, 1, 50))
111
111
  throw new RangeError(
112
- "[Reverb.js] Time length of inpulse response must be less than 50sec."
112
+ "[Reverb.js] Time length of impulse response must be less than 50sec."
113
113
  );
114
114
  this.options.time = e, this.buildImpulse();
115
115
  }
@@ -121,7 +121,7 @@ class s {
121
121
  decay(e) {
122
122
  if (!s.inRange(e, 0, 100))
123
123
  throw new RangeError(
124
- "[Reverb.js] Inpulse Response decay level must be less than 100."
124
+ "[Reverb.js] Impulse Response decay level must be less than 100."
125
125
  );
126
126
  this.options.decay = e, this.buildImpulse();
127
127
  }
@@ -133,7 +133,7 @@ class s {
133
133
  delay(e) {
134
134
  if (!s.inRange(e, 0, 100))
135
135
  throw new RangeError(
136
- "[Reverb.js] Inpulse Response delay time must be less than 100."
136
+ "[Reverb.js] Impulse Response delay time must be less than 100."
137
137
  );
138
138
  this.options.delay = e, this.buildImpulse();
139
139
  }
@@ -194,12 +194,21 @@ class s {
194
194
  this.options.scale = e, this.buildImpulse();
195
195
  }
196
196
  /**
197
- * set IR source noise generator.
197
+ * Noise source
198
198
  *
199
- * @param a - Algorithm
199
+ * @param duration - length of IR.
200
200
  */
201
- randomAlgorithm(e) {
202
- this.options.randomAlgorithm = e, this.buildImpulse();
201
+ getNoise(e) {
202
+ return [
203
+ ...v(
204
+ e,
205
+ this.noise({
206
+ bins: this.options.peaks,
207
+ scale: this.options.scale,
208
+ rnd: this.options.randomAlgorithm
209
+ })
210
+ )
211
+ ];
203
212
  }
204
213
  /**
205
214
  * Inpulse Response Noise algorithm.
@@ -207,34 +216,14 @@ class s {
207
216
  * @param type - IR noise algorithm type.
208
217
  */
209
218
  setNoise(e) {
210
- switch (this.options.noise = e, e) {
211
- case o.blue:
212
- this.noise = g;
213
- break;
214
- case o.green:
215
- this.noise = N;
216
- break;
217
- case o.pink:
218
- this.noise = b;
219
- break;
220
- case o.red:
221
- case o.brown:
222
- this.noise = f;
223
- break;
224
- case o.violet:
225
- this.noise = m;
226
- break;
227
- default:
228
- this.noise = c;
229
- }
230
- this.buildImpulse();
219
+ this.options.noise = e, this.noise = this.noiseMap[e] || l, this.buildImpulse();
231
220
  }
232
221
  /**
233
222
  * Set Random Algorythm
234
223
  *
235
224
  * @param algorithm - Algorythm
236
225
  */
237
- setRandomAlgorythm(e) {
226
+ setRandomAlgorithm(e) {
238
227
  this.options.randomAlgorithm = e, this.buildImpulse();
239
228
  }
240
229
  /**
@@ -244,34 +233,17 @@ class s {
244
233
  * @param min - Minimum value
245
234
  * @param max - Maximum value
246
235
  */
247
- static inRange(e, t, n) {
248
- return (e - t) * (e - n) <= 0;
236
+ static inRange(e, t, o) {
237
+ return e >= t && e <= o;
249
238
  }
250
239
  /** Utility function for building an impulse response from the module parameters. */
251
240
  buildImpulse() {
252
- const e = this.ctx.sampleRate, t = Math.max(e * this.options.time, 1), n = e * this.options.delay, a = this.ctx.createBuffer(2, t, e), l = new Float32Array(t), h = new Float32Array(t), p = this.getNoise(t), u = this.getNoise(t);
241
+ const e = this.ctx.sampleRate, t = Math.max(e * this.options.time, 1), o = e * this.options.delay, r = this.ctx.createBuffer(2, t, e), a = new Float32Array(t), h = new Float32Array(t), p = this.getNoise(t), u = this.getNoise(t);
253
242
  for (let i = 0; i < t; i++) {
254
- let r = 0;
255
- i < n ? (l[i] = 0, h[i] = 0, r = this.options.reverse ?? !1 ? t - (i - n) : i - n) : r = this.options.reverse ?? !1 ? t - i : i, l[i] = (p[i] ?? 0) * (1 - r / t) ** this.options.decay, h[i] = (u[i] ?? 0) * (1 - r / t) ** this.options.decay;
243
+ let n = 0;
244
+ i < o ? (a[i] = 0, h[i] = 0, n = this.options.reverse ?? !1 ? t - (i - o) : i - o) : n = this.options.reverse ?? !1 ? t - i : i, a[i] = (p[i] ?? 0) * (1 - n / t) ** this.options.decay, h[i] = (u[i] ?? 0) * (1 - n / t) ** this.options.decay;
256
245
  }
257
- a.getChannelData(0).set(l), a.getChannelData(1).set(h), this.convolverNode.buffer = a;
258
- }
259
- /**
260
- * Noise source
261
- *
262
- * @param duration - length of IR.
263
- */
264
- getNoise(e) {
265
- return [
266
- ...v(
267
- e,
268
- this.noise({
269
- bins: this.options.peaks,
270
- scale: this.options.scale,
271
- rnd: this.options.randomAlgorithm
272
- })
273
- )
274
- ];
246
+ r.getChannelData(0).set(a), r.getChannelData(1).set(h), this.convolverNode.buffer = r;
275
247
  }
276
248
  }
277
249
  export {
@@ -5,8 +5,8 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.15
8
+ * @version 1.4.0
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- var Reverb=function(h,n,p,f){"use strict";const u={version:"1.3.15",date:"2025-03-02T14:58:09.789Z"},o={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet"},m={noise:"white",scale:1,peaks:2,randomAlgorithm:f.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class s{static version=u.version;static build=u.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=n.white;constructor(e,t){this.ctx=e,this.options=Object.assign(m,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).connect(this.outputNode),e.connect(this.wetGainNode).connect(this.outputNode),this.isConnected=!0,this.outputNode)}disconnect(e){return this.isConnected&&(this.convolverNode.disconnect(this.filterNode),this.filterNode.disconnect(this.wetGainNode)),this.isConnected=!1,e}mix(e){if(!s.inRange(e,0,1))throw new RangeError("[Reverb.js] Dry/Wet ratio must be between 0 to 1.");this.options.mix=e,this.dryGainNode.gain.value=1-this.options.mix,this.wetGainNode.gain.value=this.options.mix}time(e){if(!s.inRange(e,1,50))throw new RangeError("[Reverb.js] Time length of inpulse response must be less than 50sec.");this.options.time=e,this.buildImpulse()}decay(e){if(!s.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response decay level must be less than 100.");this.options.decay=e,this.buildImpulse()}delay(e){if(!s.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response delay time must be less than 100.");this.options.delay=e,this.buildImpulse()}reverse(e){this.options.reverse=e,this.buildImpulse()}filterType(e="allpass"){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!s.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(!s.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()}randomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}setNoise(e){switch(this.options.noise=e,e){case o.blue:this.noise=n.blue;break;case o.green:this.noise=n.green;break;case o.pink:this.noise=n.pink;break;case o.red:case o.brown:this.noise=n.red;break;case o.violet:this.noise=n.violet;break;default:this.noise=n.white}this.buildImpulse()}setRandomAlgorythm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,t,r){return(e-t)*(e-r)<=0}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),r=e*this.options.delay,l=this.ctx.createBuffer(2,t,e),c=new Float32Array(t),d=new Float32Array(t),b=this.getNoise(t),v=this.getNoise(t);for(let i=0;i<t;i++){let a=0;i<r?(c[i]=0,d[i]=0,a=this.options.reverse??!1?t-(i-r):i-r):a=this.options.reverse??!1?t-i:i,c[i]=(b[i]??0)*(1-a/t)**this.options.decay,d[i]=(v[i]??0)*(1-a/t)**this.options.decay}l.getChannelData(0).set(c),l.getChannelData(1).set(d),this.convolverNode.buffer=l}getNoise(e){return[...p.take(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}}return h.default=s,Object.defineProperty(h,"__esModule",{value:!0}),h}({},coloredNoise,transducers,random);
12
+ var Reverb=function(a,s,u,p){"use strict";const c={version:"1.4.0",date:"2025-06-01T11:08:05.639Z"},f={noise:"white",scale:1,peaks:2,randomAlgorithm:p.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class n{static version=c.version;static build=c.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=s.white;noiseMap={blue:s.blue,green:s.green,pink:s.pink,red:s.red,brown:s.red,violet:s.violet,white:s.white};constructor(e,t){this.ctx=e,this.options=Object.assign(f,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[...u.take(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}setNoise(e){this.options.noise=e,this.noise=this.noiseMap[e]||s.white,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,h=this.ctx.createBuffer(2,t,e),l=new Float32Array(t),d=new Float32Array(t),m=this.getNoise(t),v=this.getNoise(t);for(let i=0;i<t;i++){let r=0;i<o?(l[i]=0,d[i]=0,r=this.options.reverse??!1?t-(i-o):i-o):r=this.options.reverse??!1?t-i:i,l[i]=(m[i]??0)*(1-r/t)**this.options.decay,d[i]=(v[i]??0)*(1-r/t)**this.options.decay}h.getChannelData(0).set(l),h.getChannelData(1).set(d),this.convolverNode.buffer=h}}return a.default=n,Object.defineProperty(a,"__esModule",{value:!0}),a}({},coloredNoise,transducers,random);
@@ -5,8 +5,8 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.15
8
+ * @version 1.4.0
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- (function(n,s){typeof exports=="object"&&typeof module<"u"?s(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"],s):(n=typeof globalThis<"u"?globalThis:n||self,s(n.Reverb={},n.coloredNoise,n.transducers,n.random))})(this,function(n,s,p,f){"use strict";const u={version:"1.3.15",date:"2025-03-02T14:58:09.789Z"},r={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet"},m={noise:"white",scale:1,peaks:2,randomAlgorithm:f.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=s.white;constructor(e,t){this.ctx=e,this.options=Object.assign(m,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).connect(this.outputNode),e.connect(this.wetGainNode).connect(this.outputNode),this.isConnected=!0,this.outputNode)}disconnect(e){return this.isConnected&&(this.convolverNode.disconnect(this.filterNode),this.filterNode.disconnect(this.wetGainNode)),this.isConnected=!1,e}mix(e){if(!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-this.options.mix,this.wetGainNode.gain.value=this.options.mix}time(e){if(!o.inRange(e,1,50))throw new RangeError("[Reverb.js] Time length of inpulse response must be less than 50sec.");this.options.time=e,this.buildImpulse()}decay(e){if(!o.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response decay level must be less than 100.");this.options.decay=e,this.buildImpulse()}delay(e){if(!o.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response delay time must be less than 100.");this.options.delay=e,this.buildImpulse()}reverse(e){this.options.reverse=e,this.buildImpulse()}filterType(e="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()}randomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}setNoise(e){switch(this.options.noise=e,e){case r.blue:this.noise=s.blue;break;case r.green:this.noise=s.green;break;case r.pink:this.noise=s.pink;break;case r.red:case r.brown:this.noise=s.red;break;case r.violet:this.noise=s.violet;break;default:this.noise=s.white}this.buildImpulse()}setRandomAlgorythm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,t,h){return(e-t)*(e-h)<=0}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),h=e*this.options.delay,l=this.ctx.createBuffer(2,t,e),d=new Float32Array(t),c=new Float32Array(t),b=this.getNoise(t),g=this.getNoise(t);for(let i=0;i<t;i++){let a=0;i<h?(d[i]=0,c[i]=0,a=this.options.reverse??!1?t-(i-h):i-h):a=this.options.reverse??!1?t-i:i,d[i]=(b[i]??0)*(1-a/t)**this.options.decay,c[i]=(g[i]??0)*(1-a/t)**this.options.decay}l.getChannelData(0).set(d),l.getChannelData(1).set(c),this.convolverNode.buffer=l}getNoise(e){return[...p.take(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}}n.default=o,Object.defineProperty(n,"__esModule",{value:!0})});
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,u,p){"use strict";const c={version:"1.4.0",date:"2025-06-01T11:08:05.639Z"},f={noise:"white",scale:1,peaks:2,randomAlgorithm:p.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class o{static version=c.version;static build=c.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=i.white;noiseMap={blue:i.blue,green:i.green,pink:i.pink,red:i.red,brown:i.red,violet:i.violet,white:i.white};constructor(e,t){this.ctx=e,this.options=Object.assign(f,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[...u.take(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}setNoise(e){this.options.noise=e,this.noise=this.noiseMap[e]||i.white,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,a=this.ctx.createBuffer(2,t,e),l=new Float32Array(t),d=new Float32Array(t),m=this.getNoise(t),g=this.getNoise(t);for(let s=0;s<t;s++){let h=0;s<r?(l[s]=0,d[s]=0,h=this.options.reverse??!1?t-(s-r):s-r):h=this.options.reverse??!1?t-s:s,l[s]=(m[s]??0)*(1-h/t)**this.options.decay,d[s]=(g[s]??0)*(1-h/t)**this.options.decay}a.getChannelData(0).set(l),a.getChannelData(1).set(d),this.convolverNode.buffer=a}}n.default=o,Object.defineProperty(n,"__esModule",{value:!0})});
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.3.15",
4
+ "version": "1.4.0",
5
5
  "description": "JavaScript Reverb effect class",
6
6
  "keywords": [
7
7
  "webaudio",
@@ -41,7 +41,7 @@
41
41
  "node": ">=22.0.1",
42
42
  "pnpm": ">=10.3.0"
43
43
  },
44
- "packageManager": "pnpm@10.5.2",
44
+ "packageManager": "pnpm@10.11.0",
45
45
  "sideEffects": false,
46
46
  "scripts": {
47
47
  "dev": "vite",
@@ -57,39 +57,36 @@
57
57
  "prepare": "husky"
58
58
  },
59
59
  "dependencies": {
60
- "@thi.ng/colored-noise": "^1.0.94",
61
- "@thi.ng/random": "^4.1.12",
62
- "@thi.ng/transducers": "^9.2.21"
60
+ "@thi.ng/colored-noise": "^1.0.101",
61
+ "@thi.ng/random": "^4.1.19",
62
+ "@thi.ng/transducers": "^9.3.1"
63
63
  },
64
64
  "devDependencies": {
65
- "@eslint/js": "^9.21.0",
65
+ "@eslint/js": "^9.28.0",
66
66
  "@tsconfig/node-lts": "^22.0.1",
67
- "@types/node": "^22.13.8",
68
- "@typescript-eslint/eslint-plugin": "^8.25.0",
69
- "bootstrap": "^5.3.3",
70
- "eslint": "^9.21.0",
71
- "eslint-config-prettier": "^10.0.2",
72
- "eslint-import-resolver-alias": "^1.1.2",
73
- "eslint-import-resolver-typescript": "^3.8.3",
74
- "eslint-plugin-html": "^8.1.2",
67
+ "@types/node": "^22.15.29",
68
+ "@typescript-eslint/eslint-plugin": "^8.33.0",
69
+ "bootstrap": "^5.3.6",
70
+ "eslint": "^9.28.0",
71
+ "eslint-config-prettier": "^10.1.5",
72
+ "eslint-import-resolver-custom-alias": "^1.3.2",
73
+ "eslint-import-resolver-typescript": "^4.4.2",
75
74
  "eslint-plugin-import": "^2.31.0",
76
- "eslint-plugin-n": "^17.16.1",
77
- "eslint-plugin-promise": "^7.2.1",
78
- "eslint-plugin-tsdoc": "^0.4.0",
79
- "eslint-plugin-yaml": "^1.0.3",
80
- "globals": "^16.0.0",
75
+ "eslint-plugin-yaml": "^1.1.2",
76
+ "globals": "^16.2.0",
81
77
  "husky": "^9.1.7",
82
- "lint-staged": "^15.4.3",
83
- "npm-run-all": "^4.1.5",
84
- "prettier": "^3.5.2",
78
+ "jiti": "^2.4.2",
79
+ "lint-staged": "^16.1.0",
80
+ "npm-run-all2": "^8.0.4",
81
+ "prettier": "^3.5.3",
85
82
  "rimraf": "^6.0.1",
86
- "rollup-plugin-visualizer": "^5.14.0",
87
- "typescript": "^5.8.2",
88
- "typescript-eslint": "^8.25.0",
89
- "vite": "^6.2.0",
90
- "vite-plugin-banner": "^0.8.0",
91
- "vite-plugin-checker": "^0.9.0",
92
- "vite-plugin-dts": "^4.5.1"
83
+ "rollup-plugin-visualizer": "^6.0.1",
84
+ "typescript": "^5.8.3",
85
+ "typescript-eslint": "^8.33.0",
86
+ "vite": "^6.3.5",
87
+ "vite-plugin-banner": "^0.8.1",
88
+ "vite-plugin-checker": "^0.9.3",
89
+ "vite-plugin-dts": "^4.5.4"
93
90
  },
94
91
  "husky": {
95
92
  "hooks": {
@@ -106,7 +103,8 @@
106
103
  },
107
104
  "pnpm": {
108
105
  "onlyBuiltDependencies": [
109
- "esbuild"
106
+ "esbuild",
107
+ "unrs-resolver"
110
108
  ]
111
109
  }
112
- }
110
+ }