@logue/reverb 1.3.11 → 1.3.13

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-2023 Masashi Yoshikawa <https://logue.dev>
3
+ Copyright (c) 2019-2025 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
@@ -103,4 +103,4 @@ The dependent libraries [@thi.ng/colored-noise](https://www.jsdelivr.com/package
103
103
 
104
104
  ## License
105
105
 
106
- ©2019-2024 by Logue. Licensed under the [MIT License](LICENSE).
106
+ ©2019-2025 by Logue. Licensed under the [MIT License](LICENSE).
package/dist/Meta.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { default as MetaInterface } from './interfaces/MetaInterface';
2
+ declare const meta: MetaInterface;
3
+ export default meta;
4
+ //# sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAC;AAG1D,QAAA,MAAM,IAAI,EAAE,aAGX,CAAC;AACF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** Impulse response noise generation algorithm */
2
+ declare const Noise: Record<NoiseType, string>;
3
+ /** Noise Type */
4
+ export type NoiseType = 'blue' | 'brown' | 'green' | 'pink' | 'red' | 'violet' | 'white';
5
+ /** Noise */
6
+ export default Noise;
7
+ //# sourceMappingURL=NoiseType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NoiseType.d.ts","sourceRoot":"","sources":["../src/NoiseType.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,QAAA,MAAM,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAe3B,CAAC;AAEX,iBAAiB;AACjB,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,OAAO,GACP,OAAO,GACP,MAAM,GACN,KAAK,GACL,QAAQ,GACR,OAAO,CAAC;AAEZ,YAAY;AACZ,eAAe,KAAK,CAAC"}
@@ -0,0 +1,144 @@
1
+ import { default as OptionInterface } from './interfaces/OptionInterface';
2
+ import { INorm } from '@thi.ng/random';
3
+ import { NoiseType } from './NoiseType';
4
+ /**
5
+ * Reverb effect class
6
+ */
7
+ export default class Reverb {
8
+ /** Version strings */
9
+ static readonly version: string;
10
+ /** Build date */
11
+ static readonly build: string;
12
+ /** AudioContext */
13
+ private readonly ctx;
14
+ /** Wet Level (Reverberated node) */
15
+ private readonly wetGainNode;
16
+ /** Dry Level (Original sound node) */
17
+ private readonly dryGainNode;
18
+ /** Impulse response filter */
19
+ private readonly filterNode;
20
+ /** Convolution node for applying impulse response */
21
+ private readonly convolverNode;
22
+ /** Output gain node */
23
+ private readonly outputNode;
24
+ /** Option */
25
+ private readonly options;
26
+ /** Connected flag */
27
+ private isConnected;
28
+ /** Noise Generator */
29
+ private noise;
30
+ /**
31
+ * Constructor
32
+ *
33
+ * @param ctx - Root AudioContext
34
+ * @param options - Configure
35
+ */
36
+ constructor(ctx: AudioContext, options: Partial<OptionInterface>);
37
+ /**
38
+ * Connect the node for the reverb effect to the original sound node.
39
+ *
40
+ * @param sourceNode - Input source node
41
+ */
42
+ connect(sourceNode: AudioNode): AudioNode;
43
+ /**
44
+ * Disconnect the reverb node
45
+ *
46
+ * @param sourceNode - Input source node
47
+ */
48
+ disconnect(sourceNode?: AudioNode): AudioNode | undefined;
49
+ /**
50
+ * Dry/Wet ratio
51
+ *
52
+ * @param mix - Ratio (0~1)
53
+ */
54
+ mix(mix: number): void;
55
+ /**
56
+ * Set Impulse Response time length (second)
57
+ *
58
+ * @param value - IR length
59
+ */
60
+ time(value: number): void;
61
+ /**
62
+ * Impulse response decay rate.
63
+ *
64
+ * @param value - Decay value
65
+ */
66
+ decay(value: number): void;
67
+ /**
68
+ * Delay before reverberation starts
69
+ *
70
+ * @param value - Time[ms]
71
+ */
72
+ delay(value: number): void;
73
+ /**
74
+ * Reverse the impulse response.
75
+ *
76
+ * @param reverse - Reverse IR
77
+ */
78
+ reverse(reverse: boolean): void;
79
+ /**
80
+ * Filter for impulse response
81
+ *
82
+ * @param type - Filiter Type
83
+ */
84
+ filterType(type?: BiquadFilterType): void;
85
+ /**
86
+ * Filter frequency applied to impulse response
87
+ *
88
+ * @param freq - Frequency
89
+ */
90
+ filterFreq(freq: number): void;
91
+ /**
92
+ * Filter quality.
93
+ *
94
+ * @param q - Quality
95
+ */
96
+ filterQ(q: number): void;
97
+ /**
98
+ * set IR source noise peaks
99
+ *
100
+ * @param p - Peaks
101
+ */
102
+ peaks(p: number): void;
103
+ /**
104
+ * set IR source noise scale.
105
+ *
106
+ * @param s - Scale
107
+ */
108
+ scale(s: number): void;
109
+ /**
110
+ * set IR source noise generator.
111
+ *
112
+ * @param a - Algorithm
113
+ */
114
+ randomAlgorithm(a: INorm): void;
115
+ /**
116
+ * Inpulse Response Noise algorithm.
117
+ *
118
+ * @param type - IR noise algorithm type.
119
+ */
120
+ setNoise(type: NoiseType): void;
121
+ /**
122
+ * Set Random Algorythm
123
+ *
124
+ * @param algorithm - Algorythm
125
+ */
126
+ setRandomAlgorythm(algorithm: INorm): void;
127
+ /**
128
+ * Return true if in range, otherwise false
129
+ *
130
+ * @param x - Target value
131
+ * @param min - Minimum value
132
+ * @param max - Maximum value
133
+ */
134
+ private static inRange;
135
+ /** Utility function for building an impulse response from the module parameters. */
136
+ private buildImpulse;
137
+ /**
138
+ * Noise source
139
+ *
140
+ * @param duration - length of IR.
141
+ */
142
+ private getNoise;
143
+ }
144
+ //# sourceMappingURL=Reverb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Reverb.d.ts","sourceRoot":"","sources":["../src/Reverb.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,eAAe,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAGpD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,sBAAsB;IACtB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAgB;IAC/C,iBAAiB;IACjB,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAa;IAC1C,mBAAmB;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,oCAAoC;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAW;IACvC,sCAAsC;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAW;IACvC,8BAA8B;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,uBAAuB;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IACtC,aAAa;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,qBAAqB;IACrB,OAAO,CAAC,WAAW,CAAU;IAC7B,sBAAsB;IACtB,OAAO,CAAC,KAAK,CAEiC;IAE9C;;;;;OAKG;gBACS,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC;IAoBhE;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS;IAsBhD;;;;OAIG;IACI,UAAU,CAAC,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS;IAehE;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAU7B;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAahC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAajC;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAQtC;;;;OAIG;IACI,UAAU,CAAC,IAAI,GAAE,gBAA4B,GAAG,IAAI;IAK3D;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAWrC;;;;OAIG;IACI,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAW/B;;;;OAIG;IACI,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAM7B;;;;OAIG;IACI,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAM7B;;;;OAIG;IACI,eAAe,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;IAMtC;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IA0BtC;;;;OAIG;IACI,kBAAkB,CAAC,SAAS,EAAE,KAAK,GAAG,IAAI;IAKjD;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,OAAO;IAItB,oFAAoF;IACpF,OAAO,CAAC,YAAY;IA+CpB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;CAYjB"}
package/dist/Reverb.es.js CHANGED
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * @description JavaScript Reverb effect class
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2019-2024 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.11
8
+ * @version 1.3.13
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
@@ -13,8 +13,8 @@ import { white as c, violet as m, red as f, pink as b, green as N, blue as g } f
13
13
  import { take as v } from "@thi.ng/transducers";
14
14
  import { SYSTEM as w } from "@thi.ng/random";
15
15
  const d = {
16
- version: "1.3.11",
17
- date: "2024-09-28T15:49:37.962Z"
16
+ version: "1.3.13",
17
+ date: "2025-01-06T13:47:25.170Z"
18
18
  }, o = {
19
19
  /** Blue noise */
20
20
  blue: "blue",
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * @description JavaScript Reverb effect class
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2019-2024 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.11
8
+ * @version 1.3.13
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- var Reverb=function(n,p,u){"use strict";const d={version:"1.3.11",date:"2024-09-28T15:49:37.962Z"},o={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet",white:"white"},f={noise:"white",scale:1,peaks:2,randomAlgorithm:u.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class s{static version=d.version;static build=d.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=n.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).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,h=this.ctx.createBuffer(2,t,e),l=new Float32Array(t),c=new Float32Array(t),m=this.getNoise(t),b=this.getNoise(t);for(let i=0;i<t;i++){let a=0;i<r?(l[i]=0,c[i]=0,a=this.options.reverse??!1?t-(i-r):i-r):a=this.options.reverse??!1?t-i:i,l[i]=(m[i]??0)*(1-a/t)**this.options.decay,c[i]=(b[i]??0)*(1-a/t)**this.options.decay}h.getChannelData(0).set(l),h.getChannelData(1).set(c),this.convolverNode.buffer=h}getNoise(e){return[...p.take(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}}return s}(coloredNoise,transducers,random);
12
+ var Reverb=function(h,n,p,f){"use strict";const u={version:"1.3.13",date:"2025-01-06T13:47:25.170Z"},o={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet",white:"white"},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);
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * @description JavaScript Reverb effect class
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2019-2024 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2019-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.11
8
+ * @version 1.3.13
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- (function(t,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("@thi.ng/colored-noise"),require("@thi.ng/transducers"),require("@thi.ng/random")):typeof define=="function"&&define.amd?define(["@thi.ng/colored-noise","@thi.ng/transducers","@thi.ng/random"],r):(t=typeof globalThis<"u"?globalThis:t||self,t.Reverb=r(t.coloredNoise,t.transducers,t.random))})(this,function(t,r,p){"use strict";const u={version:"1.3.11",date:"2024-09-28T15:49:37.962Z"},o={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet",white:"white"},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=u.version;static build=u.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=t.white;constructor(e,i){this.ctx=e,this.options=Object.assign(f,i),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(!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-this.options.mix,this.wetGainNode.gain.value=this.options.mix}time(e){if(!n.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(!n.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(!n.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(!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()}randomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}setNoise(e){switch(this.options.noise=e,e){case o.blue:this.noise=t.blue;break;case o.green:this.noise=t.green;break;case o.pink:this.noise=t.pink;break;case o.red:case o.brown:this.noise=t.red;break;case o.violet:this.noise=t.violet;break;default:this.noise=t.white}this.buildImpulse()}setRandomAlgorythm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,i,h){return(e-i)*(e-h)<=0}buildImpulse(){const e=this.ctx.sampleRate,i=Math.max(e*this.options.time,1),h=e*this.options.delay,l=this.ctx.createBuffer(2,i,e),d=new Float32Array(i),c=new Float32Array(i),m=this.getNoise(i),b=this.getNoise(i);for(let s=0;s<i;s++){let a=0;s<h?(d[s]=0,c[s]=0,a=this.options.reverse??!1?i-(s-h):s-h):a=this.options.reverse??!1?i-s:s,d[s]=(m[s]??0)*(1-a/i)**this.options.decay,c[s]=(b[s]??0)*(1-a/i)**this.options.decay}l.getChannelData(0).set(d),l.getChannelData(1).set(c),this.convolverNode.buffer=l}getNoise(e){return[...r.take(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}}return n});
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.13",date:"2025-01-06T13:47:25.170Z"},r={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet",white:"white"},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})});
package/dist/demo.flac ADDED
Binary file
@@ -0,0 +1,8 @@
1
+ /** Meta Information Interface */
2
+ export default interface MetaInterface {
3
+ /** Version */
4
+ version: string;
5
+ /** Build Date */
6
+ date: string;
7
+ }
8
+ //# sourceMappingURL=MetaInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetaInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/MetaInterface.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,MAAM,CAAC,OAAO,WAAW,aAAa;IACpC,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,40 @@
1
+ import { NoiseType } from '../NoiseType';
2
+ import { INorm } from '@thi.ng/random';
3
+ /** Reverb Option */
4
+ export default interface OptionInterface {
5
+ /**
6
+ * IR (Inpulse Response) colord noise algorithm (BLUE, GREEN, PINK, RED, VIOLET, WHITE)
7
+ * @see {@link https://github.com/thi-ng/umbrella/tree/develop/packages/colored-noise}
8
+ */
9
+ noise: NoiseType;
10
+ /** IR source noise scale */
11
+ scale: number;
12
+ /** Number of IR source noise peaks */
13
+ peaks: number;
14
+ /**
15
+ * Randam noise algorythm
16
+ * @see {@link https://github.com/thi-ng/umbrella/tree/develop/packages/random}
17
+ */
18
+ randomAlgorithm: INorm;
19
+ /** Decay */
20
+ decay: number;
21
+ /** Delay until impulse response is generated */
22
+ delay: number;
23
+ /** Filter frequency applied to impulse response[Hz] */
24
+ filterFreq: number;
25
+ /** Filter quality for impulse response */
26
+ filterQ: number;
27
+ /** Filter type for impulse response */
28
+ filterType: BiquadFilterType;
29
+ /** Dry/Wet ratio */
30
+ mix: number;
31
+ /** Invert the impulse response */
32
+ reverse?: boolean;
33
+ /** Impulse response length */
34
+ time: number;
35
+ /** Prevents multiple effectors from being connected. */
36
+ once: boolean;
37
+ }
38
+ /** Default Value */
39
+ export declare const defaults: OptionInterface;
40
+ //# sourceMappingURL=OptionInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/OptionInterface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,oBAAoB;AACpB,MAAM,CAAC,OAAO,WAAW,eAAe;IACtC;;;OAGG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,eAAe,EAAE,KAAK,CAAC;IACvB,YAAY;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,EAAE,OAAO,CAAC;CACf;AAED,oBAAoB;AACpB,eAAO,MAAM,QAAQ,EAAE,eActB,CAAC"}
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.11",
4
+ "version": "1.3.13",
5
5
  "description": "JavaScript Reverb effect class",
6
6
  "keywords": [
7
7
  "webaudio",
@@ -30,20 +30,18 @@
30
30
  "main": "dist/Reverb.umd.js",
31
31
  "module": "dist/Reverb.es.js",
32
32
  "browser": "dist/Reverb.iife.js",
33
- "types": "dist/Reverb.d.ts",
33
+ "types": "dist/src/Reverb.d.ts",
34
34
  "exports": {
35
35
  ".": {
36
36
  "import": "./dist/Reverb.es.js",
37
- "require": "./dist/Reverb.umd.js",
38
- "browser": "./dist/Reverb.iife.js",
39
- "types": "./dist/Reverb.d.ts"
37
+ "require": "./dist/Reverb.umd.js"
40
38
  }
41
39
  },
42
40
  "engines": {
43
- "node": ">=22.7.4",
44
- "pnpm": ">=9.11.0"
41
+ "node": ">=22.0.0",
42
+ "pnpm": ">=9.15.0"
45
43
  },
46
- "packageManager": "pnpm@9.11.0",
44
+ "packageManager": "pnpm@9.15.3",
47
45
  "sideEffects": false,
48
46
  "scripts": {
49
47
  "dev": "vite",
@@ -59,38 +57,39 @@
59
57
  "prepare": "husky"
60
58
  },
61
59
  "dependencies": {
62
- "@thi.ng/colored-noise": "^1.0.80",
63
- "@thi.ng/transducers": "^9.2.4"
60
+ "@thi.ng/colored-noise": "^1.0.89",
61
+ "@thi.ng/random": "^4.1.7",
62
+ "@thi.ng/transducers": "^9.2.12"
64
63
  },
65
64
  "devDependencies": {
66
- "@eslint/js": "^9.11.1",
67
- "@tsconfig/node-lts": "^20.1.3",
68
- "@types/node": "^22.7.4",
69
- "@typescript-eslint/eslint-plugin": "^8.7.0",
65
+ "@eslint/js": "^9.17.0",
66
+ "@tsconfig/node-lts": "^22.0.1",
67
+ "@types/node": "^22.10.5",
68
+ "@typescript-eslint/eslint-plugin": "^8.19.0",
70
69
  "bootstrap": "^5.3.3",
71
- "eslint": "^9.11.1",
70
+ "eslint": "^9.17.0",
72
71
  "eslint-config-prettier": "^9.1.0",
73
72
  "eslint-import-resolver-alias": "^1.1.2",
74
- "eslint-import-resolver-typescript": "^3.6.3",
73
+ "eslint-import-resolver-typescript": "^3.7.0",
75
74
  "eslint-plugin-html": "^8.1.2",
76
- "eslint-plugin-import": "^2.30.0",
77
- "eslint-plugin-n": "^17.10.3",
78
- "eslint-plugin-promise": "^7.1.0",
79
- "eslint-plugin-tsdoc": "^0.3.0",
75
+ "eslint-plugin-import": "^2.31.0",
76
+ "eslint-plugin-n": "^17.15.1",
77
+ "eslint-plugin-promise": "^7.2.1",
78
+ "eslint-plugin-tsdoc": "^0.4.0",
80
79
  "eslint-plugin-yaml": "^1.0.3",
81
- "globals": "^15.9.0",
82
- "husky": "^9.1.6",
83
- "lint-staged": "^15.2.10",
80
+ "globals": "^15.14.0",
81
+ "husky": "^9.1.7",
82
+ "lint-staged": "^15.3.0",
84
83
  "npm-run-all": "^4.1.5",
85
- "prettier": "^3.3.3",
84
+ "prettier": "^3.4.2",
86
85
  "rimraf": "^6.0.1",
87
- "rollup-plugin-visualizer": "^5.12.0",
88
- "typescript": "^5.6.2",
89
- "typescript-eslint": "^8.7.0",
90
- "vite": "^5.4.8",
86
+ "rollup-plugin-visualizer": "^5.13.1",
87
+ "typescript": "^5.7.2",
88
+ "typescript-eslint": "^8.19.0",
89
+ "vite": "^6.0.7",
91
90
  "vite-plugin-banner": "^0.8.0",
92
91
  "vite-plugin-checker": "^0.8.0",
93
- "vite-plugin-dts": "^4.2.2"
92
+ "vite-plugin-dts": "^4.4.0"
94
93
  },
95
94
  "husky": {
96
95
  "hooks": {
@@ -103,11 +102,6 @@
103
102
  },
104
103
  "resolutions": {
105
104
  "json5": ">=2.2.3",
106
- "ip": ">=2.0.1",
107
- "lodash": ">=4.17.21",
108
- "postcss": ">=8.4.31",
109
- "semver": ">=7.5.3",
110
- "tar": ">=6.2.1",
111
105
  "yaml": ">=2.3.2"
112
106
  }
113
107
  }