@logue/reverb 1.4.3 → 1.4.6

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019-2025 Masashi Yoshikawa <https://logue.dev>
3
+ Copyright (c) 2019-2026 Masashi Yoshikawa <https://logue.dev>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -163,4 +163,4 @@ The dependent libraries [@thi.ng/colored-noise](https://www.jsdelivr.com/package
163
163
 
164
164
  ## License
165
165
 
166
- ©2019-2025 by Logue. Licensed under the [MIT License](LICENSE).
166
+ ©2019-2026 by Logue. Licensed under the [MIT License](LICENSE).
@@ -1,2 +1,4 @@
1
+ import { ColoredNoiseOpts } from '@thi.ng/colored-noise';
1
2
  /** Noise Type */
2
3
  export type NoiseType = 'blue' | 'brown' | 'green' | 'pink' | 'red' | 'violet' | 'white';
4
+ export declare const NoiseType: Record<NoiseType, (opts?: Partial<ColoredNoiseOpts>) => Generator<number, void, unknown>>;
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * @description JavaScript Reverb effect class
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.4.1
8
+ * @version 1.4.6
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"),u=require("@thi.ng/transducers"),f=require("@thi.ng/random");const d={version:"1.4.1",date:"2025-07-12T06:07:47.985Z"},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=d.version;static build=d.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(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),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]||s.white,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,a=this.ctx.createBuffer(2,t,e),l=new Float32Array(t),h=new Float32Array(t),c=this.getNoise(t),p=this.getNoise(t);for(let i=0;i<t;i++){let r=0;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]=(c[i]??0)*(1-r/t)**this.options.decay,h[i]=(p[i]??0)*(1-r/t)**this.options.decay}a.getChannelData(0).set(l),a.getChannelData(1).set(h),this.convolverNode.buffer=a}}exports.default=o;
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;
package/dist/Reverb.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { NoiseType } from './NoiseType';
2
1
  import { default as OptionInterface } from './interfaces/OptionInterface';
3
2
  import { INorm } from '@thi.ng/random';
3
+ import { NoiseType } from './NoiseType';
4
4
  /**
5
5
  * Reverb effect class
6
6
  */
package/dist/Reverb.es.js CHANGED
@@ -3,23 +3,31 @@
3
3
  *
4
4
  * @description JavaScript Reverb effect class
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.4.1
8
+ * @version 1.4.6
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
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
- import { take as v } from "@thi.ng/transducers";
14
- import { SYSTEM as w } from "@thi.ng/random";
15
- const c = {
16
- version: "1.4.1",
17
- date: "2025-07-12T06:07:47.985Z"
18
- }, y = {
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 = {
19
27
  noise: "white",
20
28
  scale: 1,
21
29
  peaks: 2,
22
- randomAlgorithm: w,
30
+ randomAlgorithm: v,
23
31
  decay: 2,
24
32
  delay: 0,
25
33
  reverse: !1,
@@ -32,9 +40,9 @@ const c = {
32
40
  };
33
41
  class s {
34
42
  /** Version strings */
35
- static version = c.version;
43
+ static version = u.version;
36
44
  /** Build date */
37
- static build = c.date;
45
+ static build = u.date;
38
46
  /** AudioContext */
39
47
  ctx;
40
48
  /** Wet Level (Reverberated node) */
@@ -52,20 +60,11 @@ class s {
52
60
  /** Connected flag */
53
61
  isConnected;
54
62
  /** Noise Generator */
55
- noise = l;
63
+ noise = d;
56
64
  /**
57
65
  * Map of noise types to their respective generator functions.
58
66
  */
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
- };
67
+ noiseMap = R;
69
68
  /**
70
69
  * Constructor
71
70
  *
@@ -73,7 +72,7 @@ class s {
73
72
  * @param options - Configure
74
73
  */
75
74
  constructor(e, t) {
76
- this.ctx = e, this.options = Object.assign(y, 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);
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);
77
76
  }
78
77
  /**
79
78
  * Connect the node for the reverb effect to the original sound node.
@@ -200,7 +199,7 @@ class s {
200
199
  */
201
200
  getNoise(e) {
202
201
  return [
203
- ...v(
202
+ ...g(
204
203
  e,
205
204
  this.noise({
206
205
  bins: this.options.peaks,
@@ -216,7 +215,33 @@ class s {
216
215
  * @param type - IR noise algorithm type.
217
216
  */
218
217
  setNoise(e) {
219
- this.options.noise = e, this.noise = this.noiseMap[e] || l, this.buildImpulse();
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();
220
245
  }
221
246
  /**
222
247
  * Set Random Algorythm
@@ -238,12 +263,12 @@ class s {
238
263
  }
239
264
  /** Utility function for building an impulse response from the module parameters. */
240
265
  buildImpulse() {
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);
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);
242
267
  for (let i = 0; i < t; i++) {
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;
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);
245
270
  }
246
- r.getChannelData(0).set(a), r.getChannelData(1).set(h), this.convolverNode.buffer = r;
271
+ h.getChannelData(0).set(l), h.getChannelData(1).set(c), this.convolverNode.buffer = h;
247
272
  }
248
273
  }
249
274
  export {
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * @description JavaScript Reverb effect class
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.4.1
8
+ * @version 1.4.6
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- var Reverb=function(a,s,u,p){"use strict";const c={version:"1.4.1",date:"2025-07-12T06:07:47.985Z"},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);
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);
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * @description JavaScript Reverb effect class
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2019-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.4.1
8
+ * @version 1.4.6
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,u,p){"use strict";const c={version:"1.4.1",date:"2025-07-12T06:07:47.985Z"},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})});
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})}));
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.3",
4
+ "version": "1.4.6",
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.18.3",
53
+ "packageManager": "pnpm@10.30.3",
54
54
  "sideEffects": false,
55
55
  "scripts": {
56
56
  "dev": "vite",
@@ -61,12 +61,16 @@
61
61
  "build:analyze": "vite build --mode=analyze",
62
62
  "build:clean": "rimraf dist",
63
63
  "build-only": "vite build",
64
- "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
64
+ "lint": "run-s lint:*",
65
+ "lint:oxlint": "oxlint . --fix",
66
+ "lint:eslint": "eslint . --fix --cache --cache-location ./node_modules/.vite/eslint-cache",
67
+ "lint:prettier": "prettier \"./**/*.{js,ts,json,css,sass,scss,htm,html,vue,md}\" -w -u",
65
68
  "preview": "vite preview --mode=docs",
66
69
  "prepare": "husky",
67
70
  "test": "vitest",
68
71
  "test:run": "vitest run",
69
- "test:coverage": "vitest run --coverage"
72
+ "test:coverage": "vitest run --coverage",
73
+ "version": "auto-changelog -p && git add CHANGELOG.md"
70
74
  },
71
75
  "peerDependencies": {
72
76
  "@thi.ng/colored-noise": "^1.0.103",
@@ -74,34 +78,36 @@
74
78
  "@thi.ng/transducers": "^9.5.1"
75
79
  },
76
80
  "devDependencies": {
77
- "@eslint/js": "^9.38.0",
78
- "@tsconfig/node-lts": "^22.0.2",
79
- "@types/node": "^24.8.1",
80
- "@typescript-eslint/eslint-plugin": "^8.46.1",
81
- "@vitest/coverage-v8": "^3.2.4",
81
+ "@eslint/js": "^10.0.1",
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",
82
86
  "bootstrap": "^5.3.8",
83
- "eslint": "^9.38.0",
87
+ "eslint": "^10.0.2",
84
88
  "eslint-config-prettier": "^10.1.8",
85
89
  "eslint-import-resolver-custom-alias": "^1.3.2",
86
90
  "eslint-import-resolver-typescript": "^4.4.4",
87
- "eslint-plugin-import": "^2.32.0",
88
- "eslint-plugin-yaml": "^1.1.3",
89
- "globals": "^16.4.0",
90
- "happy-dom": "^20.0.5",
91
+ "eslint-plugin-import-x": "^4.16.1",
92
+ "eslint-plugin-oxlint": "^1.51.0",
93
+ "eslint-plugin-security": "^4.0.0",
94
+ "globals": "^17.4.0",
95
+ "happy-dom": "^20.8.3",
91
96
  "husky": "^9.1.7",
92
97
  "jiti": "^2.6.1",
93
- "lint-staged": "^16.2.4",
98
+ "lint-staged": "^16.3.2",
94
99
  "npm-run-all2": "^8.0.4",
95
- "prettier": "^3.6.2",
96
- "rimraf": "^6.0.1",
97
- "rollup-plugin-visualizer": "^6.0.5",
100
+ "oxlint": "^1.51.0",
101
+ "prettier": "^3.8.1",
102
+ "rimraf": "^6.1.3",
103
+ "rollup-plugin-visualizer": "^7.0.1",
98
104
  "typescript": "^5.9.3",
99
- "typescript-eslint": "^8.46.1",
100
- "vite": "^7.1.10",
105
+ "typescript-eslint": "^8.56.1",
106
+ "vite": "^7.3.1",
101
107
  "vite-plugin-banner": "^0.8.1",
102
- "vite-plugin-checker": "^0.11.0",
108
+ "vite-plugin-checker": "^0.12.0",
103
109
  "vite-plugin-dts": "^4.5.4",
104
- "vitest": "^3.2.4"
110
+ "vitest": "^4.0.18"
105
111
  },
106
112
  "husky": {
107
113
  "hooks": {
@@ -114,6 +120,7 @@
114
120
  },
115
121
  "resolutions": {
116
122
  "json5": ">=2.2.3",
117
- "yaml": ">=2.3.2"
123
+ "minimatch": ">=10.2.3",
124
+ "yaml": ">=2.6.0"
118
125
  }
119
- }
126
+ }