@logue/reverb 0.5.5 → 1.0.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.
package/README.md CHANGED
@@ -19,15 +19,32 @@ This script is originally a spin out of [sf2synth.js](https://github.com/logue/s
19
19
 
20
20
  ```js
21
21
  const reverb = new Reverb(ctx, {
22
- noise: 0, // Inpulse Response Noise algorithm (0: White noise, 1: Pink noise, 2: Brown noise)
23
- decay: 5, // Amount of IR (Inpulse Response) decay. 0~100
24
- delay: 0, // Delay time o IR. (NOT delay effect) 0~100 [sec]
25
- filterFreq: 2200, // Filter frequency. 20~5000 [Hz]
26
- filterQ: 1, // Filter quality. 0~10
27
- filterType: 'lowpass', // Filter type. 'bandpass' etc. See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode/type .
28
- mix: 0.5, // Dry (Original Sound) and Wet (Effected sound) raito. 0~1
29
- reverse: false, // Reverse IR.
30
- time: 3, // Time length of IR. 0~50 [sec]
22
+ /**
23
+ * IR (Inpulse Response) colord noise algorithm (BLUE, GREEN, PINK, RED, VIOLET, WHITE)
24
+ * @see {@link https://en.wikipedia.org/wiki/Colors_of_noise}
25
+ */
26
+ noise: Noise.WHITE,
27
+ /** IR noise power multiplier */
28
+ power: 2,
29
+ /** Amount of IR decay. 0~100 */
30
+ decay: 5,
31
+ /** Delay time o IR. (NOT delay effect) 0~100 [sec] */
32
+ delay: 0,
33
+ /** Filter frequency. 20~5000 [Hz] */
34
+ filterFreq: 2200,
35
+ /** Filter Q. 0~10 */
36
+ filterQ: 1,
37
+ /**
38
+ * Filter type. 'bandpass' etc.
39
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode/type}
40
+ */
41
+ filterType: 'lowpass',
42
+ /** Dry (Original Sound) and Wet (Effected sound) raito. 0~1 */
43
+ mix: 0.5,
44
+ /** Reverse IR. */
45
+ reverse: false,
46
+ /** Time length of IR. 0~50 [sec] */
47
+ time: 3,
31
48
  });
32
49
  ```
33
50
 
@@ -1,12 +1,5 @@
1
1
  /** Impulse response noise generation algorithm */
2
- declare const Noise: {
3
- /** White noise */
4
- readonly WHITE: "white";
5
- /** Pink noise */
6
- readonly PINK: "pink";
7
- /** Brown Noise */
8
- readonly BROWN: "brown";
9
- };
2
+ declare const Noise: Record<string, string>;
10
3
  /** Noise Type */
11
4
  export declare type NoiseType = typeof Noise[keyof typeof Noise];
12
5
  /** Noise */
@@ -1 +1 @@
1
- {"version":3,"file":"NoiseType.d.ts","sourceRoot":"","sources":["../src/NoiseType.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,QAAA,MAAM,KAAK;IACT,kBAAkB;;IAElB,iBAAiB;;IAEjB,kBAAkB;;CAGV,CAAC;AAEX,iBAAiB;AACjB,oBAAY,SAAS,GAAG,OAAO,KAAK,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAEzD,YAAY;AACZ,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"NoiseType.d.ts","sourceRoot":"","sources":["../src/NoiseType.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,QAAA,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOxB,CAAC;AAEX,iBAAiB;AACjB,oBAAY,SAAS,GAAG,OAAO,KAAK,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAEzD,YAAY;AACZ,eAAe,KAAK,CAAC"}
package/dist/Reverb.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import type OptionInterface from './interfaces/OptionInterface';
2
2
  import { type NoiseType } from './NoiseType';
3
3
  /**
4
- * JS reverb effect class
4
+ * Reverb effect class
5
5
  */
6
6
  export default class Reverb {
7
7
  /** Version strings */
8
- readonly version: string;
8
+ static version: string;
9
9
  /** Build date */
10
- readonly build: string;
10
+ static build: string;
11
11
  /** AudioContext */
12
12
  private readonly ctx;
13
13
  /** Wet Level (Reverberated node) */
@@ -21,16 +21,18 @@ export default class Reverb {
21
21
  /** Output nodse */
22
22
  private readonly outputNode;
23
23
  /** Option */
24
- private readonly _options;
24
+ private readonly options;
25
25
  /** Connected flag */
26
26
  private isConnected;
27
+ /** Noise Generator */
28
+ private noise;
27
29
  /**
28
30
  * Constructor
29
31
  *
30
32
  * @param ctx - Root AudioContext
31
33
  * @param options - Configure
32
34
  */
33
- constructor(ctx: AudioContext, options: OptionInterface | undefined);
35
+ constructor(ctx: AudioContext, options?: OptionInterface);
34
36
  /**
35
37
  * Connect the node for the reverb effect to the original sound node.
36
38
  *
@@ -107,7 +109,5 @@ export default class Reverb {
107
109
  private inRange;
108
110
  /** Utility function for building an impulse response from the module parameters. */
109
111
  private buildImpulse;
110
- /** Generate white noise */
111
- private static whiteNoise;
112
112
  }
113
113
  //# sourceMappingURL=Reverb.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Reverb.d.ts","sourceRoot":"","sources":["../src/Reverb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,8BAA8B,CAAC;AAChE,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,sBAAsB;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iBAAiB;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,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,mBAAmB;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IACtC,aAAa;IACb,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,qBAAqB;IACrB,OAAO,CAAC,WAAW,CAAU;IAE7B;;;;;OAKG;gBACS,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,SAAS;IAsBnE;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS;IAsBhD;;;;OAIG;IACI,UAAU,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;IAe3E;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAU7B;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWhC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAQtC;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAK/C;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAWrC;;;;OAIG;IACI,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAW/B;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,SAAS;IAM/B;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAIf,oFAAoF;IACpF,OAAO,CAAC,YAAY;IAoGpB,2BAA2B;IAC3B,OAAO,CAAC,MAAM,CAAC,UAAU;CAI1B"}
1
+ {"version":3,"file":"Reverb.d.ts","sourceRoot":"","sources":["../src/Reverb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,8BAA8B,CAAC;AAChE,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAIpD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,sBAAsB;IACtB,MAAM,CAAC,OAAO,EAAE,MAAM,CAAgB;IACtC,iBAAiB;IACjB,MAAM,CAAC,KAAK,EAAE,MAAM,CAAa;IACjC,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,mBAAmB;IACnB,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,CAAmB;IAEhC;;;;;OAKG;gBACS,GAAG,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,eAAe;IAoBxD;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS;IAsBhD;;;;OAIG;IACI,UAAU,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;IAe3E;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAU7B;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWhC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAQtC;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAK/C;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAWrC;;;;OAIG;IACI,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAW/B;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,SAAS;IA2B/B;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAIf,oFAAoF;IACpF,OAAO,CAAC,YAAY;CAgDrB"}
@@ -3,6 +3,8 @@ import { NoiseType } from '../NoiseType';
3
3
  export default interface OptionInterface {
4
4
  /** Types of impulse response noise generation algorithms */
5
5
  noise: NoiseType;
6
+ /** IR Power */
7
+ power: number;
6
8
  /** Decay */
7
9
  decay: number;
8
10
  /** Delay until impulse response is generated */
@@ -1 +1 @@
1
- {"version":3,"file":"OptionInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/OptionInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,oBAAoB;AACpB,MAAM,CAAC,OAAO,WAAW,eAAe;IACtC,4DAA4D;IAC5D,KAAK,EAAE,SAAS,CAAC;IACjB,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,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,EAAE,OAAO,CAAC;CACf"}
1
+ {"version":3,"file":"OptionInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/OptionInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,oBAAoB;AACpB,MAAM,CAAC,OAAO,WAAW,eAAe;IACtC,4DAA4D;IAC5D,KAAK,EAAE,SAAS,CAAC;IACjB,eAAe;IACf,KAAK,EAAE,MAAM,CAAC;IACd,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,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,EAAE,OAAO,CAAC;CACf"}
package/dist/reverb.es.js CHANGED
@@ -5,24 +5,132 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2019-2022 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 0.5.5
8
+ * @version 1.0.0
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- const d = {
13
- version: "0.5.5",
14
- date: "2022-07-21T01:15:40.735Z"
12
+ const E = {
13
+ version: "1.0.0",
14
+ date: "2022-08-29T12:34:03.524Z"
15
15
  }, l = {
16
- WHITE: "white",
16
+ BLUE: "blue",
17
+ GREEN: "green",
17
18
  PINK: "pink",
18
- BROWN: "brown"
19
+ RED: "red",
20
+ VIOLET: "violet",
21
+ WHITE: "white"
22
+ }, T = (t, e) => t != null && typeof t[e] == "function", x = (t) => T(t, "xform") ? t.xform() : t, F = (t) => t != null && typeof t[Symbol.iterator] == "function";
23
+ class u {
24
+ constructor(e) {
25
+ this.value = e;
26
+ }
27
+ deref() {
28
+ return this.value;
29
+ }
30
+ }
31
+ const k = (t) => new u(t), C = (t) => t instanceof u, D = (t) => t instanceof u ? t : new u(t), R = (t) => t instanceof u ? t.deref() : t, j = (t, e) => [t, (i) => i, e];
32
+ function q(t) {
33
+ return t ? [...t] : j(() => [], (e, i) => (e.push(i), e));
34
+ }
35
+ function* L(t, e) {
36
+ const i = x(t)(q()), s = i[1], r = i[2];
37
+ for (let o of e) {
38
+ const n = r([], o);
39
+ if (C(n)) {
40
+ yield* R(s(n.deref()));
41
+ return;
42
+ }
43
+ n.length && (yield* n);
44
+ }
45
+ yield* R(s([]));
46
+ }
47
+ const S = (t, e) => [t[0], t[1], e];
48
+ function p(t, e) {
49
+ return F(e) ? L(p(t), e) : (i) => {
50
+ const s = i[2];
51
+ let r = t;
52
+ return S(i, (o, n) => --r > 0 ? s(o, n) : r === 0 ? D(s(o, n)) : k(o));
53
+ };
54
+ }
55
+ const N = 1 / 2 ** 32;
56
+ class A {
57
+ float(e = 1) {
58
+ return this.int() * N * e;
59
+ }
60
+ norm(e = 1) {
61
+ return (this.int() * N - 0.5) * 2 * e;
62
+ }
63
+ minmax(e, i) {
64
+ return this.float() * (i - e) + e;
65
+ }
66
+ minmaxInt(e, i) {
67
+ return e |= 0, i |= 0, e + (this.float() * (i - e) | 0);
68
+ }
69
+ }
70
+ const d = Math.random;
71
+ class B extends A {
72
+ int() {
73
+ return d() * 4294967296 >>> 0;
74
+ }
75
+ float(e = 1) {
76
+ return d() * e;
77
+ }
78
+ norm(e = 1) {
79
+ return (d() - 0.5) * 2 * e;
80
+ }
81
+ }
82
+ const h = new B(), y = (t, e, i) => {
83
+ const s = new Array(t);
84
+ for (let r = 0; r < t; r++)
85
+ s[r] = i.norm(e);
86
+ return s;
87
+ }, b = (t) => t.reduce((e, i) => e + i, 0);
88
+ function* I(t, e) {
89
+ const i = [t[Symbol.iterator](), e[Symbol.iterator]()];
90
+ for (let s = 0; ; s ^= 1) {
91
+ const r = i[s].next();
92
+ if (r.done)
93
+ return;
94
+ yield r.value;
95
+ }
96
+ }
97
+ function* m(t = 2, e = 1, i = h) {
98
+ const s = y(t, e, i);
99
+ s.forEach((n, a) => s[a] = a & 1 ? n : -n);
100
+ const r = 1 / t;
101
+ let o = b(s);
102
+ for (let n = 0, a = -1; ; ++n >= t && (n = 0))
103
+ o -= s[n], o += s[n] = a * i.norm(e), a ^= 4294967294, yield a * o * r;
104
+ }
105
+ const Q = (t = 2, e = 1, i = h) => I(m(t, e, i), m(t, e, i)), W = (t) => {
106
+ let e = 32;
107
+ return t &= -t, t && e--, t & 65535 && (e -= 16), t & 16711935 && (e -= 8), t & 252645135 && (e -= 4), t & 858993459 && (e -= 2), t & 1431655765 && (e -= 1), e;
19
108
  };
20
- class s {
21
- constructor(e, o) {
22
- this.version = d.version, this.build = d.date, this.ctx = e, this._options = { ...u, ...o }, 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.buildImpulse(), this.mix(this._options.mix);
109
+ function* M(t = 8, e = 1, i = h) {
110
+ const s = y(t, e, i), r = 1 / t;
111
+ let o = b(s);
112
+ for (let n = 0; ; n = n + 1 >>> 0) {
113
+ const a = W(n) % t;
114
+ o -= s[a], o += s[a] = i.norm(e), yield o * r;
115
+ }
116
+ }
117
+ function* v(t = 2, e = 1, i = h) {
118
+ const s = y(t, e, i), r = 1 / t;
119
+ let o = b(s);
120
+ for (let n = 0; ; ++n >= t && (n = 0))
121
+ o -= s[n], o += s[n] = i.norm(e), yield o * r;
122
+ }
123
+ const H = (t = 2, e = 1, i = h) => I(v(t, e, i), v(t, e, i));
124
+ function* g(t = 1, e = h) {
125
+ for (; ; )
126
+ yield e.norm(t);
127
+ }
128
+ class w {
129
+ constructor(e, i) {
130
+ this.noise = g, this.ctx = e, this.options = { ...O, ...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.setNoise(l.WHITE), this.buildImpulse(), this.mix(this.options.mix);
23
131
  }
24
132
  connect(e) {
25
- 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);
133
+ 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);
26
134
  }
27
135
  disconnect(e) {
28
136
  return this.isConnected && (this.convolverNode.disconnect(this.filterNode), this.filterNode.disconnect(this.wetGainNode)), this.isConnected = !1, e;
@@ -30,71 +138,80 @@ class s {
30
138
  mix(e) {
31
139
  if (!this.inRange(e, 0, 1))
32
140
  throw new RangeError("Reverb.js: Dry/Wet ratio must be between 0 to 1.");
33
- this._options.mix = e, this.dryGainNode.gain.value = 1 - this._options.mix, this.wetGainNode.gain.value = this._options.mix;
141
+ this.options.mix = e, this.dryGainNode.gain.value = 1 - this.options.mix, this.wetGainNode.gain.value = this.options.mix;
34
142
  }
35
143
  time(e) {
36
144
  if (!this.inRange(e, 1, 50))
37
145
  throw new RangeError("Reverb.js: Time length of inpulse response must be less than 50sec.");
38
- this._options.time = e, this.buildImpulse();
146
+ this.options.time = e, this.buildImpulse();
39
147
  }
40
148
  decay(e) {
41
149
  if (!this.inRange(e, 0, 100))
42
150
  throw new RangeError("Reverb.js: Inpulse Response decay level must be less than 100.");
43
- this._options.decay = e, this.buildImpulse();
151
+ this.options.decay = e, this.buildImpulse();
44
152
  }
45
153
  delay(e) {
46
154
  if (!this.inRange(e, 0, 100))
47
155
  throw new RangeError("Reverb.js: Inpulse Response delay time must be less than 100.");
48
- this._options.delay = e, this.buildImpulse();
156
+ this.options.delay = e, this.buildImpulse();
49
157
  }
50
158
  reverse(e) {
51
- this._options.reverse = e, this.buildImpulse();
159
+ this.options.reverse = e, this.buildImpulse();
52
160
  }
53
161
  filterType(e) {
54
- this.filterNode.type = this._options.filterType = e;
162
+ this.filterNode.type = this.options.filterType = e;
55
163
  }
56
164
  filterFreq(e) {
57
165
  if (!this.inRange(e, 20, 5e3))
58
166
  throw new RangeError("Reverb.js: Filter frequrncy must be between 20 and 5000.");
59
- this._options.filterFreq = e, this.filterNode.frequency.value = this._options.filterFreq;
167
+ this.options.filterFreq = e, this.filterNode.frequency.value = this.options.filterFreq;
60
168
  }
61
169
  filterQ(e) {
62
170
  if (!this.inRange(e, 0, 10))
63
171
  throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");
64
- this._options.filterQ = e, this.filterNode.Q.value = this._options.filterQ;
172
+ this.options.filterQ = e, this.filterNode.Q.value = this.options.filterQ;
65
173
  }
66
174
  setNoise(e) {
67
- this._options.noise = e, this.buildImpulse();
175
+ switch (this.options.noise = e, e) {
176
+ case l.BLUE:
177
+ this.noise = m;
178
+ break;
179
+ case l.GREEN:
180
+ this.noise = Q;
181
+ break;
182
+ case l.PINK:
183
+ this.noise = M;
184
+ break;
185
+ case l.RED:
186
+ case l.BROWN:
187
+ this.noise = v;
188
+ break;
189
+ case l.VIOLET:
190
+ this.noise = H;
191
+ break;
192
+ default:
193
+ this.noise = g;
194
+ break;
195
+ }
196
+ this.buildImpulse();
68
197
  }
69
- inRange(e, o, r) {
70
- return (e - o) * (e - r) <= 0;
198
+ inRange(e, i, s) {
199
+ return (e - i) * (e - s) <= 0;
71
200
  }
72
201
  buildImpulse() {
73
- const e = this.ctx.sampleRate, o = Math.max(e * this._options.time, 1), r = e * this._options.delay, c = this.ctx.createBuffer(2, o, e), n = new Float32Array(o), h = new Float32Array(o), t = [0, 0, 0, 0, 0, 0, 0];
74
- for (let i = 0; i < o; i++) {
75
- let a = 0;
76
- switch (i < r ? (n[i] = 0, h[i] = 0, a = this._options.reverse ? o - (i - r) : i - r) : a = this._options.reverse ? o - i : i, this._options.noise) {
77
- case l.PINK:
78
- t[0] = 0.99886 * t[0] + s.whiteNoise() * 0.0555179, t[1] = 0.99332 * t[1] + s.whiteNoise() * 0.0750759, t[2] = 0.969 * t[2] + s.whiteNoise() * 0.153852, t[3] = 0.8665 * t[3] + s.whiteNoise() * 0.3104856, t[4] = 0.55 * t[4] + s.whiteNoise() * 0.5329522, t[5] = -0.7616 * t[5] - s.whiteNoise() * 0.016898, n[i] = t[0] + t[1] + t[2] + t[3] + t[4] + t[5] + t[6] + s.whiteNoise() * 0.5362, h[i] = t[0] + t[1] + t[2] + t[3] + t[4] + t[5] + t[6] + s.whiteNoise() * 0.5362, n[i] *= 0.11, h[i] *= 0.11, t[6] = s.whiteNoise() * 0.115926;
79
- break;
80
- case l.BROWN:
81
- n[i] = (t[0] + 0.02 * s.whiteNoise()) / 1.02, t[0] = n[i], h[i] = (t[1] + 0.02 * s.whiteNoise()) / 1.02, t[1] = h[i], n[i] *= 3.5, h[i] *= 3.5;
82
- break;
83
- case l.WHITE:
84
- default:
85
- n[i] = s.whiteNoise(), h[i] = s.whiteNoise();
86
- break;
87
- }
88
- n[i] *= (1 - a / o) ** this._options.decay, h[i] *= (1 - a / o) ** this._options.decay;
202
+ const e = this.ctx.sampleRate, i = Math.max(e * this.options.time, 1), s = e * this.options.delay, r = this.ctx.createBuffer(2, i, e), o = new Float32Array(i), n = new Float32Array(i), a = [...p(i, this.noise(1))], G = [...p(i, this.noise(1))];
203
+ for (let c = 0; c < i; c++) {
204
+ let f = 0;
205
+ c < s ? (o[c] = 0, n[c] = 0, f = this.options.reverse ? i - (c - s) : c - s) : f = this.options.reverse ? i - c : c, o[c] = 1 + a[c] * this.options.power, n[c] = 1 + G[c] * this.options.power, o[c] *= (1 - f / i) ** this.options.decay, n[c] *= (1 - f / i) ** this.options.decay;
89
206
  }
90
- c.getChannelData(0).set(n), c.getChannelData(1).set(h), this.convolverNode.buffer = c;
91
- }
92
- static whiteNoise() {
93
- return Math.random() * 2 - 1;
207
+ r.getChannelData(0).set(o), r.getChannelData(1).set(n), this.convolverNode.buffer = r;
94
208
  }
95
209
  }
96
- const u = {
210
+ w.version = E.version;
211
+ w.build = E.date;
212
+ const O = {
97
213
  noise: l.WHITE,
214
+ power: 2,
98
215
  decay: 2,
99
216
  delay: 0,
100
217
  reverse: !1,
@@ -105,7 +222,7 @@ const u = {
105
222
  mix: 0.5,
106
223
  once: !1
107
224
  };
108
- window.Reverb || (window.Reverb = s);
225
+ window.Reverb || (window.Reverb = w);
109
226
  export {
110
- s as default
227
+ w as default
111
228
  };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @logue/reverb
3
+ *
4
+ * @description JavaScript Reverb effect class
5
+ * @author Logue <logue@hotmail.co.jp>
6
+ * @copyright 2019-2022 By Masashi Yoshikawa All rights reserved.
7
+ * @license MIT
8
+ * @version 1.0.0
9
+ * @see {@link https://github.com/logue/Reverb.js}
10
+ */
11
+
12
+ var Reverb=function(){"use strict";const w={version:"1.0.0",date:"2022-08-29T12:34:03.524Z"},l={BLUE:"blue",GREEN:"green",PINK:"pink",RED:"red",VIOLET:"violet",WHITE:"white"},G=(t,e)=>t!=null&&typeof t[e]=="function",T=t=>G(t,"xform")?t.xform():t,F=t=>t!=null&&typeof t[Symbol.iterator]=="function";class u{constructor(e){this.value=e}deref(){return this.value}}const k=t=>new u(t),x=t=>t instanceof u,C=t=>t instanceof u?t:new u(t),N=t=>t instanceof u?t.deref():t,D=(t,e)=>[t,i=>i,e];function j(t){return t?[...t]:D(()=>[],(e,i)=>(e.push(i),e))}function*q(t,e){const i=T(t)(j()),s=i[1],r=i[2];for(let o of e){const n=r([],o);if(x(n)){yield*N(s(n.deref()));return}n.length&&(yield*n)}yield*N(s([]))}const L=(t,e)=>[t[0],t[1],e];function p(t,e){return F(e)?q(p(t),e):i=>{const s=i[2];let r=t;return L(i,(o,n)=>--r>0?s(o,n):r===0?C(s(o,n)):k(o))}}const g=1/2**32;class S{float(e=1){return this.int()*g*e}norm(e=1){return(this.int()*g-.5)*2*e}minmax(e,i){return this.float()*(i-e)+e}minmaxInt(e,i){return e|=0,i|=0,e+(this.float()*(i-e)|0)}}const m=Math.random;class A extends S{int(){return m()*4294967296>>>0}float(e=1){return m()*e}norm(e=1){return(m()-.5)*2*e}}const h=new A,v=(t,e,i)=>{const s=new Array(t);for(let r=0;r<t;r++)s[r]=i.norm(e);return s},b=t=>t.reduce((e,i)=>e+i,0);function*E(t,e){const i=[t[Symbol.iterator](),e[Symbol.iterator]()];for(let s=0;;s^=1){const r=i[s].next();if(r.done)return;yield r.value}}function*y(t=2,e=1,i=h){const s=v(t,e,i);s.forEach((n,a)=>s[a]=a&1?n:-n);const r=1/t;let o=b(s);for(let n=0,a=-1;;++n>=t&&(n=0))o-=s[n],o+=s[n]=a*i.norm(e),a^=4294967294,yield a*o*r}const B=(t=2,e=1,i=h)=>E(y(t,e,i),y(t,e,i)),Q=t=>{let e=32;return t&=-t,t&&e--,t&65535&&(e-=16),t&16711935&&(e-=8),t&252645135&&(e-=4),t&858993459&&(e-=2),t&1431655765&&(e-=1),e};function*W(t=8,e=1,i=h){const s=v(t,e,i),r=1/t;let o=b(s);for(let n=0;;n=n+1>>>0){const a=Q(n)%t;o-=s[a],o+=s[a]=i.norm(e),yield o*r}}function*R(t=2,e=1,i=h){const s=v(t,e,i),r=1/t;let o=b(s);for(let n=0;;++n>=t&&(n=0))o-=s[n],o+=s[n]=i.norm(e),yield o*r}const M=(t=2,e=1,i=h)=>E(R(t,e,i),R(t,e,i));function*I(t=1,e=h){for(;;)yield e.norm(t)}class f{constructor(e,i){this.noise=I,this.ctx=e,this.options={...H,...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.setNoise(l.WHITE),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(!this.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(!this.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(!this.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(!this.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){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!this.inRange(e,20,5e3))throw new RangeError("Reverb.js: Filter frequrncy must be between 20 and 5000.");this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq}filterQ(e){if(!this.inRange(e,0,10))throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ}setNoise(e){switch(this.options.noise=e,e){case l.BLUE:this.noise=y;break;case l.GREEN:this.noise=B;break;case l.PINK:this.noise=W;break;case l.RED:case l.BROWN:this.noise=R;break;case l.VIOLET:this.noise=M;break;default:this.noise=I;break}this.buildImpulse()}inRange(e,i,s){return(e-i)*(e-s)<=0}buildImpulse(){const e=this.ctx.sampleRate,i=Math.max(e*this.options.time,1),s=e*this.options.delay,r=this.ctx.createBuffer(2,i,e),o=new Float32Array(i),n=new Float32Array(i),a=[...p(i,this.noise(1))],O=[...p(i,this.noise(1))];for(let c=0;c<i;c++){let d=0;c<s?(o[c]=0,n[c]=0,d=this.options.reverse?i-(c-s):c-s):d=this.options.reverse?i-c:c,o[c]=1+a[c]*this.options.power,n[c]=1+O[c]*this.options.power,o[c]*=(1-d/i)**this.options.decay,n[c]*=(1-d/i)**this.options.decay}r.getChannelData(0).set(o),r.getChannelData(1).set(n),this.convolverNode.buffer=r}}f.version=w.version,f.build=w.date;const H={noise:l.WHITE,power:2,decay:2,delay:0,reverse:!1,time:2,filterType:"lowpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};return window.Reverb||(window.Reverb=f),f}();
@@ -5,8 +5,8 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2019-2022 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 0.5.5
8
+ * @version 1.0.0
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- (function(a,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(a=typeof globalThis<"u"?globalThis:a||self,a.Reverb=r())})(this,function(){"use strict";const a={version:"0.5.5",date:"2022-07-21T01:15:40.735Z"},r={WHITE:"white",PINK:"pink",BROWN:"brown"};class s{constructor(e,o){this.version=a.version,this.build=a.date,this.ctx=e,this._options={...u,...o},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.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(!this.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(!this.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(!this.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(!this.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){this.filterNode.type=this._options.filterType=e}filterFreq(e){if(!this.inRange(e,20,5e3))throw new RangeError("Reverb.js: Filter frequrncy must be between 20 and 5000.");this._options.filterFreq=e,this.filterNode.frequency.value=this._options.filterFreq}filterQ(e){if(!this.inRange(e,0,10))throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");this._options.filterQ=e,this.filterNode.Q.value=this._options.filterQ}setNoise(e){this._options.noise=e,this.buildImpulse()}inRange(e,o,l){return(e-o)*(e-l)<=0}buildImpulse(){const e=this.ctx.sampleRate,o=Math.max(e*this._options.time,1),l=e*this._options.delay,d=this.ctx.createBuffer(2,o,e),n=new Float32Array(o),h=new Float32Array(o),t=[0,0,0,0,0,0,0];for(let i=0;i<o;i++){let c=0;switch(i<l?(n[i]=0,h[i]=0,c=this._options.reverse?o-(i-l):i-l):c=this._options.reverse?o-i:i,this._options.noise){case r.PINK:t[0]=.99886*t[0]+s.whiteNoise()*.0555179,t[1]=.99332*t[1]+s.whiteNoise()*.0750759,t[2]=.969*t[2]+s.whiteNoise()*.153852,t[3]=.8665*t[3]+s.whiteNoise()*.3104856,t[4]=.55*t[4]+s.whiteNoise()*.5329522,t[5]=-.7616*t[5]-s.whiteNoise()*.016898,n[i]=t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+s.whiteNoise()*.5362,h[i]=t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+s.whiteNoise()*.5362,n[i]*=.11,h[i]*=.11,t[6]=s.whiteNoise()*.115926;break;case r.BROWN:n[i]=(t[0]+.02*s.whiteNoise())/1.02,t[0]=n[i],h[i]=(t[1]+.02*s.whiteNoise())/1.02,t[1]=h[i],n[i]*=3.5,h[i]*=3.5;break;case r.WHITE:default:n[i]=s.whiteNoise(),h[i]=s.whiteNoise();break}n[i]*=(1-c/o)**this._options.decay,h[i]*=(1-c/o)**this._options.decay}d.getChannelData(0).set(n),d.getChannelData(1).set(h),this.convolverNode.buffer=d}static whiteNoise(){return Math.random()*2-1}}const u={noise:r.WHITE,decay:2,delay:0,reverse:!1,time:2,filterType:"lowpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};return window.Reverb||(window.Reverb=s),s});
12
+ (function(h,l){typeof exports=="object"&&typeof module<"u"?module.exports=l():typeof define=="function"&&define.amd?define(l):(h=typeof globalThis<"u"?globalThis:h||self,h.Reverb=l())})(this,function(){"use strict";const h={version:"1.0.0",date:"2022-08-29T12:34:03.524Z"},l={BLUE:"blue",GREEN:"green",PINK:"pink",RED:"red",VIOLET:"violet",WHITE:"white"},T=(t,e)=>t!=null&&typeof t[e]=="function",G=t=>T(t,"xform")?t.xform():t,x=t=>t!=null&&typeof t[Symbol.iterator]=="function";class f{constructor(e){this.value=e}deref(){return this.value}}const F=t=>new f(t),k=t=>t instanceof f,C=t=>t instanceof f?t:new f(t),N=t=>t instanceof f?t.deref():t,j=(t,e)=>[t,i=>i,e];function D(t){return t?[...t]:j(()=>[],(e,i)=>(e.push(i),e))}function*q(t,e){const i=G(t)(D()),s=i[1],r=i[2];for(let o of e){const n=r([],o);if(k(n)){yield*N(s(n.deref()));return}n.length&&(yield*n)}yield*N(s([]))}const L=(t,e)=>[t[0],t[1],e];function m(t,e){return x(e)?q(m(t),e):i=>{const s=i[2];let r=t;return L(i,(o,n)=>--r>0?s(o,n):r===0?C(s(o,n)):F(o))}}const g=1/2**32;class S{float(e=1){return this.int()*g*e}norm(e=1){return(this.int()*g-.5)*2*e}minmax(e,i){return this.float()*(i-e)+e}minmaxInt(e,i){return e|=0,i|=0,e+(this.float()*(i-e)|0)}}const v=Math.random;class A extends S{int(){return v()*4294967296>>>0}float(e=1){return v()*e}norm(e=1){return(v()-.5)*2*e}}const u=new A,y=(t,e,i)=>{const s=new Array(t);for(let r=0;r<t;r++)s[r]=i.norm(e);return s},b=t=>t.reduce((e,i)=>e+i,0);function*E(t,e){const i=[t[Symbol.iterator](),e[Symbol.iterator]()];for(let s=0;;s^=1){const r=i[s].next();if(r.done)return;yield r.value}}function*R(t=2,e=1,i=u){const s=y(t,e,i);s.forEach((n,a)=>s[a]=a&1?n:-n);const r=1/t;let o=b(s);for(let n=0,a=-1;;++n>=t&&(n=0))o-=s[n],o+=s[n]=a*i.norm(e),a^=4294967294,yield a*o*r}const B=(t=2,e=1,i=u)=>E(R(t,e,i),R(t,e,i)),Q=t=>{let e=32;return t&=-t,t&&e--,t&65535&&(e-=16),t&16711935&&(e-=8),t&252645135&&(e-=4),t&858993459&&(e-=2),t&1431655765&&(e-=1),e};function*W(t=8,e=1,i=u){const s=y(t,e,i),r=1/t;let o=b(s);for(let n=0;;n=n+1>>>0){const a=Q(n)%t;o-=s[a],o+=s[a]=i.norm(e),yield o*r}}function*w(t=2,e=1,i=u){const s=y(t,e,i),r=1/t;let o=b(s);for(let n=0;;++n>=t&&(n=0))o-=s[n],o+=s[n]=i.norm(e),yield o*r}const M=(t=2,e=1,i=u)=>E(w(t,e,i),w(t,e,i));function*I(t=1,e=u){for(;;)yield e.norm(t)}class d{constructor(e,i){this.noise=I,this.ctx=e,this.options={...H,...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.setNoise(l.WHITE),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(!this.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(!this.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(!this.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(!this.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){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!this.inRange(e,20,5e3))throw new RangeError("Reverb.js: Filter frequrncy must be between 20 and 5000.");this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq}filterQ(e){if(!this.inRange(e,0,10))throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ}setNoise(e){switch(this.options.noise=e,e){case l.BLUE:this.noise=R;break;case l.GREEN:this.noise=B;break;case l.PINK:this.noise=W;break;case l.RED:case l.BROWN:this.noise=w;break;case l.VIOLET:this.noise=M;break;default:this.noise=I;break}this.buildImpulse()}inRange(e,i,s){return(e-i)*(e-s)<=0}buildImpulse(){const e=this.ctx.sampleRate,i=Math.max(e*this.options.time,1),s=e*this.options.delay,r=this.ctx.createBuffer(2,i,e),o=new Float32Array(i),n=new Float32Array(i),a=[...m(i,this.noise(1))],O=[...m(i,this.noise(1))];for(let c=0;c<i;c++){let p=0;c<s?(o[c]=0,n[c]=0,p=this.options.reverse?i-(c-s):c-s):p=this.options.reverse?i-c:c,o[c]=1+a[c]*this.options.power,n[c]=1+O[c]*this.options.power,o[c]*=(1-p/i)**this.options.decay,n[c]*=(1-p/i)**this.options.decay}r.getChannelData(0).set(o),r.getChannelData(1).set(n),this.convolverNode.buffer=r}}d.version=h.version,d.build=h.date;const H={noise:l.WHITE,power:2,decay:2,delay:0,reverse:!1,time:2,filterType:"lowpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};return window.Reverb||(window.Reverb=d),d});
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": "0.5.5",
4
+ "version": "1.0.0",
5
5
  "description": "JavaScript Reverb effect class",
6
6
  "keywords": [
7
7
  "webaudio",
@@ -29,20 +29,21 @@
29
29
  "files": [
30
30
  "dist"
31
31
  ],
32
- "main": "./dist/reverb.umd.js",
33
- "module": "./dist/reverb.es.js",
32
+ "main": "dist/reverb.umd.js",
33
+ "module": "dist/reverb.es.js",
34
+ "browser": "dist/reverb.iife.js",
35
+ "types": "dist/Reverb.d.ts",
34
36
  "exports": {
35
37
  ".": {
36
38
  "import": "./dist/reverb.es.js",
37
39
  "require": "./dist/reverb.umd.js"
38
40
  }
39
41
  },
40
- "types": "./dist/Reverb.d.ts",
41
42
  "engines": {
42
- "node": ">=16.16.0",
43
- "yarn": ">=1.22.4"
43
+ "node": ">=16.17.0",
44
+ "yarn": ">=1.22.10"
44
45
  },
45
- "packageManager": "yarn@3.2.1",
46
+ "packageManager": "yarn@3.2.3",
46
47
  "sideEffects": false,
47
48
  "scripts": {
48
49
  "dev": "vite",
@@ -52,16 +53,16 @@
52
53
  "prepare": "husky install"
53
54
  },
54
55
  "devDependencies": {
55
- "@types/node": "^18.0.6",
56
- "@typescript-eslint/eslint-plugin": "^5.30.7",
57
- "@typescript-eslint/parser": "^5.30.7",
58
- "eslint": "^8.20.0",
56
+ "@types/node": "^18.7.13",
57
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
58
+ "@typescript-eslint/parser": "^5.35.1",
59
+ "eslint": "^8.23.0",
59
60
  "eslint-config-google": "^0.14.0",
60
61
  "eslint-config-prettier": "^8.5.0",
61
62
  "eslint-import-resolver-alias": "^1.1.2",
62
- "eslint-import-resolver-typescript": "^3.3.0",
63
+ "eslint-import-resolver-typescript": "^3.5.0",
63
64
  "eslint-plugin-import": "^2.26.0",
64
- "eslint-plugin-jsdoc": "^39.3.3",
65
+ "eslint-plugin-jsdoc": "^39.3.6",
65
66
  "eslint-plugin-prettier": "^4.2.1",
66
67
  "eslint-plugin-tsdoc": "^0.2.16",
67
68
  "husky": "^8.0.1",
@@ -69,9 +70,9 @@
69
70
  "prettier": "^2.7.1",
70
71
  "rimraf": "^3.0.2",
71
72
  "typescript": "^4.7.4",
72
- "vite": "^3.0.2",
73
- "vite-plugin-banner": "^0.3.0",
74
- "vite-plugin-checker": "^0.4.9"
73
+ "vite": "^3.0.9",
74
+ "vite-plugin-banner": "^0.4.0",
75
+ "vite-plugin-checker": "^0.5.0"
75
76
  },
76
77
  "husky": {
77
78
  "hooks": {
@@ -84,5 +85,9 @@
84
85
  },
85
86
  "resolutions": {
86
87
  "prettier": "^2.7.1"
88
+ },
89
+ "dependencies": {
90
+ "@thi.ng/colored-noise": "^0.3.16",
91
+ "@thi.ng/transducers": "^8.3.13"
87
92
  }
88
93
  }