@logue/reverb 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
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"}
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,CAexB,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
@@ -93,6 +93,12 @@ export default class Reverb {
93
93
  * @param q - Quality
94
94
  */
95
95
  filterQ(q: number): void;
96
+ /**
97
+ * set IR noise power multiplier.
98
+ *
99
+ * @param p - Power
100
+ */
101
+ power(p: number): void;
96
102
  /**
97
103
  * Inpulse Response Noise algorithm.
98
104
  *
@@ -109,5 +115,11 @@ export default class Reverb {
109
115
  private inRange;
110
116
  /** Utility function for building an impulse response from the module parameters. */
111
117
  private buildImpulse;
118
+ /**
119
+ * Noise source
120
+ *
121
+ * @param duration - length of IR.
122
+ */
123
+ private getNoise;
112
124
  }
113
125
  //# 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;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"}
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,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAK7B;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,SAAS;IA2B/B;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAIf,oFAAoF;IACpF,OAAO,CAAC,YAAY;IA6CpB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;CAKjB"}
package/dist/reverb.es.js CHANGED
@@ -5,20 +5,21 @@
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 1.0.0
8
+ * @version 1.0.1
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
12
- const E = {
13
- version: "1.0.0",
14
- date: "2022-08-29T12:34:03.524Z"
12
+ const g = {
13
+ version: "1.0.1",
14
+ date: "2022-08-29T23:50:47.342Z"
15
15
  }, l = {
16
16
  BLUE: "blue",
17
17
  GREEN: "green",
18
18
  PINK: "pink",
19
19
  RED: "red",
20
20
  VIOLET: "violet",
21
- WHITE: "white"
21
+ WHITE: "white",
22
+ BROWN: "red"
22
23
  }, 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
24
  class u {
24
25
  constructor(e) {
@@ -28,37 +29,37 @@ class u {
28
29
  return this.value;
29
30
  }
30
31
  }
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
+ const k = (t) => new u(t), C = (t) => t instanceof u, D = (t) => t instanceof u ? t : new u(t), N = (t) => t instanceof u ? t.deref() : t, j = (t, e) => [t, (i) => i, e];
32
33
  function q(t) {
33
34
  return t ? [...t] : j(() => [], (e, i) => (e.push(i), e));
34
35
  }
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);
36
+ function* B(t, e) {
37
+ const i = x(t)(q()), s = i[1], o = i[2];
38
+ for (let r of e) {
39
+ const n = o([], r);
39
40
  if (C(n)) {
40
- yield* R(s(n.deref()));
41
+ yield* N(s(n.deref()));
41
42
  return;
42
43
  }
43
44
  n.length && (yield* n);
44
45
  }
45
- yield* R(s([]));
46
+ yield* N(s([]));
46
47
  }
47
- const S = (t, e) => [t[0], t[1], e];
48
- function p(t, e) {
49
- return F(e) ? L(p(t), e) : (i) => {
48
+ const L = (t, e) => [t[0], t[1], e];
49
+ function E(t, e) {
50
+ return F(e) ? B(E(t), e) : (i) => {
50
51
  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));
52
+ let o = t;
53
+ return L(i, (r, n) => --o > 0 ? s(r, n) : o === 0 ? D(s(r, n)) : k(r));
53
54
  };
54
55
  }
55
- const N = 1 / 2 ** 32;
56
- class A {
56
+ const w = 1 / 2 ** 32;
57
+ class S {
57
58
  float(e = 1) {
58
- return this.int() * N * e;
59
+ return this.int() * w * e;
59
60
  }
60
61
  norm(e = 1) {
61
- return (this.int() * N - 0.5) * 2 * e;
62
+ return (this.int() * w - 0.5) * 2 * e;
62
63
  }
63
64
  minmax(e, i) {
64
65
  return this.float() * (i - e) + e;
@@ -67,67 +68,67 @@ class A {
67
68
  return e |= 0, i |= 0, e + (this.float() * (i - e) | 0);
68
69
  }
69
70
  }
70
- const d = Math.random;
71
- class B extends A {
71
+ const f = Math.random;
72
+ class W extends S {
72
73
  int() {
73
- return d() * 4294967296 >>> 0;
74
+ return f() * 4294967296 >>> 0;
74
75
  }
75
76
  float(e = 1) {
76
- return d() * e;
77
+ return f() * e;
77
78
  }
78
79
  norm(e = 1) {
79
- return (d() - 0.5) * 2 * e;
80
+ return (f() - 0.5) * 2 * e;
80
81
  }
81
82
  }
82
- const h = new B(), y = (t, e, i) => {
83
+ const h = new W(), v = (t, e, i) => {
83
84
  const s = new Array(t);
84
- for (let r = 0; r < t; r++)
85
- s[r] = i.norm(e);
85
+ for (let o = 0; o < t; o++)
86
+ s[o] = i.norm(e);
86
87
  return s;
87
88
  }, b = (t) => t.reduce((e, i) => e + i, 0);
88
89
  function* I(t, e) {
89
90
  const i = [t[Symbol.iterator](), e[Symbol.iterator]()];
90
91
  for (let s = 0; ; s ^= 1) {
91
- const r = i[s].next();
92
- if (r.done)
92
+ const o = i[s].next();
93
+ if (o.done)
93
94
  return;
94
- yield r.value;
95
+ yield o.value;
95
96
  }
96
97
  }
97
- function* m(t = 2, e = 1, i = h) {
98
- const s = y(t, e, i);
98
+ function* p(t = 2, e = 1, i = h) {
99
+ const s = v(t, e, i);
99
100
  s.forEach((n, a) => s[a] = a & 1 ? n : -n);
100
- const r = 1 / t;
101
- let o = b(s);
101
+ const o = 1 / t;
102
+ let r = b(s);
102
103
  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
+ r -= s[n], r += s[n] = a * i.norm(e), a ^= 4294967294, yield a * r * o;
104
105
  }
105
- const Q = (t = 2, e = 1, i = h) => I(m(t, e, i), m(t, e, i)), W = (t) => {
106
+ const A = (t = 2, e = 1, i = h) => I(p(t, e, i), p(t, e, i)), Q = (t) => {
106
107
  let e = 32;
107
108
  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;
108
109
  };
109
110
  function* M(t = 8, e = 1, i = h) {
110
- const s = y(t, e, i), r = 1 / t;
111
- let o = b(s);
111
+ const s = v(t, e, i), o = 1 / t;
112
+ let r = b(s);
112
113
  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;
114
+ const a = Q(n) % t;
115
+ r -= s[a], r += s[a] = i.norm(e), yield r * o;
115
116
  }
116
117
  }
117
- function* v(t = 2, e = 1, i = h) {
118
- const s = y(t, e, i), r = 1 / t;
119
- let o = b(s);
118
+ function* m(t = 2, e = 1, i = h) {
119
+ const s = v(t, e, i), o = 1 / t;
120
+ let r = b(s);
120
121
  for (let n = 0; ; ++n >= t && (n = 0))
121
- o -= s[n], o += s[n] = i.norm(e), yield o * r;
122
+ r -= s[n], r += s[n] = i.norm(e), yield r * o;
122
123
  }
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) {
124
+ const O = (t = 2, e = 1, i = h) => I(m(t, e, i), m(t, e, i));
125
+ function* R(t = 1, e = h) {
125
126
  for (; ; )
126
127
  yield e.norm(t);
127
128
  }
128
- class w {
129
+ class y {
129
130
  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);
131
+ this.noise = R, 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);
131
132
  }
132
133
  connect(e) {
133
134
  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);
@@ -171,26 +172,29 @@ class w {
171
172
  throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");
172
173
  this.options.filterQ = e, this.filterNode.Q.value = this.options.filterQ;
173
174
  }
175
+ power(e) {
176
+ this.options.power = e, this.buildImpulse();
177
+ }
174
178
  setNoise(e) {
175
179
  switch (this.options.noise = e, e) {
176
180
  case l.BLUE:
177
- this.noise = m;
181
+ this.noise = p;
178
182
  break;
179
183
  case l.GREEN:
180
- this.noise = Q;
184
+ this.noise = A;
181
185
  break;
182
186
  case l.PINK:
183
187
  this.noise = M;
184
188
  break;
185
189
  case l.RED:
186
190
  case l.BROWN:
187
- this.noise = v;
191
+ this.noise = m;
188
192
  break;
189
193
  case l.VIOLET:
190
- this.noise = H;
194
+ this.noise = O;
191
195
  break;
192
196
  default:
193
- this.noise = g;
197
+ this.noise = R;
194
198
  break;
195
199
  }
196
200
  this.buildImpulse();
@@ -199,17 +203,20 @@ class w {
199
203
  return (e - i) * (e - s) <= 0;
200
204
  }
201
205
  buildImpulse() {
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))];
206
+ const e = this.ctx.sampleRate, i = Math.max(e * this.options.time, 1), s = e * this.options.delay, o = this.ctx.createBuffer(2, i, e), r = new Float32Array(i), n = new Float32Array(i), a = this.getNoise(i), G = this.getNoise(i);
203
207
  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;
208
+ let d = 0;
209
+ c < s ? (r[c] = 0, n[c] = 0, d = this.options.reverse ? i - (c - s) : c - s) : d = this.options.reverse ? i - c : c, r[c] = a[c] * (1 - d / i) ** this.options.decay, n[c] = G[c] * (1 - d / i) ** this.options.decay;
206
210
  }
207
- r.getChannelData(0).set(o), r.getChannelData(1).set(n), this.convolverNode.buffer = r;
211
+ o.getChannelData(0).set(r), o.getChannelData(1).set(n), this.convolverNode.buffer = o;
212
+ }
213
+ getNoise(e) {
214
+ return [...E(e, this.noise())].map((i) => i * this.options.power);
208
215
  }
209
216
  }
210
- w.version = E.version;
211
- w.build = E.date;
212
- const O = {
217
+ y.version = g.version;
218
+ y.build = g.date;
219
+ const H = {
213
220
  noise: l.WHITE,
214
221
  power: 2,
215
222
  decay: 2,
@@ -222,7 +229,7 @@ const O = {
222
229
  mix: 0.5,
223
230
  once: !1
224
231
  };
225
- window.Reverb || (window.Reverb = w);
232
+ window.Reverb || (window.Reverb = y);
226
233
  export {
227
- w as default
234
+ y as default
228
235
  };
@@ -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 1.0.0
8
+ * @version 1.0.1
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
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}();
12
+ var Reverb=function(){"use strict";const N={version:"1.0.1",date:"2022-08-29T23:50:47.342Z"},l={BLUE:"blue",GREEN:"green",PINK:"pink",RED:"red",VIOLET:"violet",WHITE:"white",BROWN:"red"},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),R=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],o=i[2];for(let r of e){const n=o([],r);if(x(n)){yield*R(s(n.deref()));return}n.length&&(yield*n)}yield*R(s([]))}const B=(t,e)=>[t[0],t[1],e];function w(t,e){return F(e)?q(w(t),e):i=>{const s=i[2];let o=t;return B(i,(r,n)=>--o>0?s(r,n):o===0?C(s(r,n)):k(r))}}const g=1/2**32;class L{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 p=Math.random;class S extends L{int(){return p()*4294967296>>>0}float(e=1){return p()*e}norm(e=1){return(p()-.5)*2*e}}const h=new S,m=(t,e,i)=>{const s=new Array(t);for(let o=0;o<t;o++)s[o]=i.norm(e);return s},v=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 o=i[s].next();if(o.done)return;yield o.value}}function*b(t=2,e=1,i=h){const s=m(t,e,i);s.forEach((n,a)=>s[a]=a&1?n:-n);const o=1/t;let r=v(s);for(let n=0,a=-1;;++n>=t&&(n=0))r-=s[n],r+=s[n]=a*i.norm(e),a^=4294967294,yield a*r*o}const W=(t=2,e=1,i=h)=>E(b(t,e,i),b(t,e,i)),A=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*Q(t=8,e=1,i=h){const s=m(t,e,i),o=1/t;let r=v(s);for(let n=0;;n=n+1>>>0){const a=A(n)%t;r-=s[a],r+=s[a]=i.norm(e),yield r*o}}function*y(t=2,e=1,i=h){const s=m(t,e,i),o=1/t;let r=v(s);for(let n=0;;++n>=t&&(n=0))r-=s[n],r+=s[n]=i.norm(e),yield r*o}const M=(t=2,e=1,i=h)=>E(y(t,e,i),y(t,e,i));function*I(t=1,e=h){for(;;)yield e.norm(t)}class d{constructor(e,i){this.noise=I,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)}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}power(e){this.options.power=e,this.buildImpulse()}setNoise(e){switch(this.options.noise=e,e){case l.BLUE:this.noise=b;break;case l.GREEN:this.noise=W;break;case l.PINK:this.noise=Q;break;case l.RED:case l.BROWN:this.noise=y;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,o=this.ctx.createBuffer(2,i,e),r=new Float32Array(i),n=new Float32Array(i),a=this.getNoise(i),H=this.getNoise(i);for(let c=0;c<i;c++){let f=0;c<s?(r[c]=0,n[c]=0,f=this.options.reverse?i-(c-s):c-s):f=this.options.reverse?i-c:c,r[c]=a[c]*(1-f/i)**this.options.decay,n[c]=H[c]*(1-f/i)**this.options.decay}o.getChannelData(0).set(r),o.getChannelData(1).set(n),this.convolverNode.buffer=o}getNoise(e){return[...w(e,this.noise())].map(i=>i*this.options.power)}}d.version=N.version,d.build=N.date;const O={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}();
@@ -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 1.0.0
8
+ * @version 1.0.1
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
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});
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.1",date:"2022-08-29T23:50:47.342Z"},l={BLUE:"blue",GREEN:"green",PINK:"pink",RED:"red",VIOLET:"violet",WHITE:"white",BROWN:"red"},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 d{constructor(e){this.value=e}deref(){return this.value}}const F=t=>new d(t),k=t=>t instanceof d,C=t=>t instanceof d?t:new d(t),R=t=>t instanceof d?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],o=i[2];for(let r of e){const n=o([],r);if(k(n)){yield*R(s(n.deref()));return}n.length&&(yield*n)}yield*R(s([]))}const B=(t,e)=>[t[0],t[1],e];function w(t,e){return x(e)?q(w(t),e):i=>{const s=i[2];let o=t;return B(i,(r,n)=>--o>0?s(r,n):o===0?C(s(r,n)):F(r))}}const g=1/2**32;class L{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 S extends L{int(){return m()*4294967296>>>0}float(e=1){return m()*e}norm(e=1){return(m()-.5)*2*e}}const u=new S,b=(t,e,i)=>{const s=new Array(t);for(let o=0;o<t;o++)s[o]=i.norm(e);return s},v=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 o=i[s].next();if(o.done)return;yield o.value}}function*y(t=2,e=1,i=u){const s=b(t,e,i);s.forEach((n,a)=>s[a]=a&1?n:-n);const o=1/t;let r=v(s);for(let n=0,a=-1;;++n>=t&&(n=0))r-=s[n],r+=s[n]=a*i.norm(e),a^=4294967294,yield a*r*o}const W=(t=2,e=1,i=u)=>E(y(t,e,i),y(t,e,i)),A=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*Q(t=8,e=1,i=u){const s=b(t,e,i),o=1/t;let r=v(s);for(let n=0;;n=n+1>>>0){const a=A(n)%t;r-=s[a],r+=s[a]=i.norm(e),yield r*o}}function*N(t=2,e=1,i=u){const s=b(t,e,i),o=1/t;let r=v(s);for(let n=0;;++n>=t&&(n=0))r-=s[n],r+=s[n]=i.norm(e),yield r*o}const M=(t=2,e=1,i=u)=>E(N(t,e,i),N(t,e,i));function*I(t=1,e=u){for(;;)yield e.norm(t)}class f{constructor(e,i){this.noise=I,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)}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}power(e){this.options.power=e,this.buildImpulse()}setNoise(e){switch(this.options.noise=e,e){case l.BLUE:this.noise=y;break;case l.GREEN:this.noise=W;break;case l.PINK:this.noise=Q;break;case l.RED:case l.BROWN:this.noise=N;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,o=this.ctx.createBuffer(2,i,e),r=new Float32Array(i),n=new Float32Array(i),a=this.getNoise(i),H=this.getNoise(i);for(let c=0;c<i;c++){let p=0;c<s?(r[c]=0,n[c]=0,p=this.options.reverse?i-(c-s):c-s):p=this.options.reverse?i-c:c,r[c]=a[c]*(1-p/i)**this.options.decay,n[c]=H[c]*(1-p/i)**this.options.decay}o.getChannelData(0).set(r),o.getChannelData(1).set(n),this.convolverNode.buffer=o}getNoise(e){return[...w(e,this.noise())].map(i=>i*this.options.power)}}f.version=h.version,f.build=h.date;const O={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});
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.0.0",
4
+ "version": "1.0.1",
5
5
  "description": "JavaScript Reverb effect class",
6
6
  "keywords": [
7
7
  "webaudio",