@logue/reverb 1.0.2 → 1.2.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 +14 -5
- package/dist/Reverb.d.ts +26 -7
- package/dist/Reverb.d.ts.map +1 -1
- package/dist/Reverb.es.js +427 -175
- package/dist/Reverb.iife.js +498 -2
- package/dist/Reverb.umd.js +499 -2
- package/dist/interfaces/OptionInterface.d.ts +17 -4
- package/dist/interfaces/OptionInterface.d.ts.map +1 -1
- package/package.json +17 -15
package/dist/Reverb.iife.js
CHANGED
|
@@ -5,8 +5,504 @@
|
|
|
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.
|
|
8
|
+
* @version 1.1.2
|
|
9
9
|
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
var Reverb
|
|
12
|
+
var Reverb = (function (exports) {
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const Noise = {
|
|
16
|
+
BLUE: "blue",
|
|
17
|
+
GREEN: "green",
|
|
18
|
+
PINK: "pink",
|
|
19
|
+
RED: "red",
|
|
20
|
+
VIOLET: "violet",
|
|
21
|
+
WHITE: "white",
|
|
22
|
+
BROWN: "red"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const INV_MAX = 1 / 2 ** 32;
|
|
26
|
+
class ARandom {
|
|
27
|
+
float(norm = 1) {
|
|
28
|
+
return this.int() * INV_MAX * norm;
|
|
29
|
+
}
|
|
30
|
+
norm(norm = 1) {
|
|
31
|
+
return (this.int() * INV_MAX - 0.5) * 2 * norm;
|
|
32
|
+
}
|
|
33
|
+
minmax(min, max) {
|
|
34
|
+
return this.float() * (max - min) + min;
|
|
35
|
+
}
|
|
36
|
+
minmaxInt(min, max) {
|
|
37
|
+
min |= 0;
|
|
38
|
+
max |= 0;
|
|
39
|
+
return min + ((this.float() * (max - min)) | 0);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const random = Math.random;
|
|
44
|
+
/**
|
|
45
|
+
* A `Math.random()` based {@link IRandom} implementation. Also @see
|
|
46
|
+
* {@link SYSTEM}.
|
|
47
|
+
*/
|
|
48
|
+
class SystemRandom extends ARandom {
|
|
49
|
+
int() {
|
|
50
|
+
return (random() * 4294967296) /* 2**32 */ >>> 0;
|
|
51
|
+
}
|
|
52
|
+
float(norm = 1) {
|
|
53
|
+
return random() * norm;
|
|
54
|
+
}
|
|
55
|
+
norm(norm = 1) {
|
|
56
|
+
return (random() - 0.5) * 2 * norm;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Used as default PRNG throughout most other thi.ng projects, though usually is
|
|
61
|
+
* configurable.
|
|
62
|
+
*/
|
|
63
|
+
const SYSTEM = new SystemRandom();
|
|
64
|
+
|
|
65
|
+
const defaults = {
|
|
66
|
+
noise: Noise.WHITE,
|
|
67
|
+
scale: 1,
|
|
68
|
+
peaks: 2,
|
|
69
|
+
randomAlgorithm: SYSTEM,
|
|
70
|
+
decay: 2,
|
|
71
|
+
delay: 0,
|
|
72
|
+
reverse: false,
|
|
73
|
+
time: 2,
|
|
74
|
+
filterType: "allpass",
|
|
75
|
+
filterFreq: 2200,
|
|
76
|
+
filterQ: 1,
|
|
77
|
+
mix: 0.5,
|
|
78
|
+
once: false
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const meta = {
|
|
82
|
+
version: "1.1.2",
|
|
83
|
+
date: "2022-11-06T12:24:34.397Z"
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const preseed = (n, scale, rnd) => {
|
|
87
|
+
const state = new Array(n);
|
|
88
|
+
for (let i = 0; i < n; i++) {
|
|
89
|
+
state[i] = rnd.norm(scale);
|
|
90
|
+
}
|
|
91
|
+
return state;
|
|
92
|
+
};
|
|
93
|
+
const sum = (src) => src.reduce((sum, x) => sum + x, 0);
|
|
94
|
+
function* interleave(a, b) {
|
|
95
|
+
const src = [a[Symbol.iterator](), b[Symbol.iterator]()];
|
|
96
|
+
for (let i = 0; true; i ^= 1) {
|
|
97
|
+
const next = src[i].next();
|
|
98
|
+
if (next.done)
|
|
99
|
+
return;
|
|
100
|
+
yield next.value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* High-pass filtered noise. Opposite of {@link red}.
|
|
106
|
+
*
|
|
107
|
+
* @param n -
|
|
108
|
+
* @param scale -
|
|
109
|
+
* @param rnd -
|
|
110
|
+
*/
|
|
111
|
+
function* blue(n = 2, scale = 1, rnd = SYSTEM) {
|
|
112
|
+
const state = preseed(n, scale, rnd);
|
|
113
|
+
state.forEach((x, i) => (state[i] = i & 1 ? x : -x));
|
|
114
|
+
const invN = 1 / n;
|
|
115
|
+
let acc = sum(state);
|
|
116
|
+
for (let i = 0, sign = -1; true; ++i >= n && (i = 0)) {
|
|
117
|
+
acc -= state[i];
|
|
118
|
+
acc += state[i] = sign * rnd.norm(scale);
|
|
119
|
+
sign ^= 0xfffffffe;
|
|
120
|
+
yield sign * acc * invN;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Band-pass filtered noise (interleaved blue noise). Opposite of
|
|
126
|
+
* {@link violet}.
|
|
127
|
+
*
|
|
128
|
+
* @param n -
|
|
129
|
+
* @param scale -
|
|
130
|
+
* @param rnd -
|
|
131
|
+
*/
|
|
132
|
+
const green = (n = 2, scale = 1, rnd = SYSTEM) => interleave(blue(n, scale, rnd), blue(n, scale, rnd));
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns number of 1 bits in `x`.
|
|
136
|
+
*
|
|
137
|
+
* @param x -
|
|
138
|
+
*/
|
|
139
|
+
const ctz32 = (x) => {
|
|
140
|
+
let c = 32;
|
|
141
|
+
x &= -x;
|
|
142
|
+
x && c--;
|
|
143
|
+
x & 0x0000ffff && (c -= 16);
|
|
144
|
+
x & 0x00ff00ff && (c -= 8);
|
|
145
|
+
x & 0x0f0f0f0f && (c -= 4);
|
|
146
|
+
x & 0x33333333 && (c -= 2);
|
|
147
|
+
x & 0x55555555 && (c -= 1);
|
|
148
|
+
return c;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Exponential decay (1/f) noise, based on Voss-McCarthy algorithm.
|
|
153
|
+
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* The number of internal states should be in the [4..32] range (default: 8).
|
|
156
|
+
* Due to JS integer limitations, `n` > 32 are meaningless.
|
|
157
|
+
*
|
|
158
|
+
* References:
|
|
159
|
+
*
|
|
160
|
+
* - https://www.dsprelated.com/showarticle/908.php
|
|
161
|
+
* - https://www.firstpr.com.au/dsp/pink-noise/#Voss-McCartney
|
|
162
|
+
*
|
|
163
|
+
* @param n -
|
|
164
|
+
* @param scale -
|
|
165
|
+
* @param rnd -
|
|
166
|
+
*/
|
|
167
|
+
function* pink(n = 8, scale = 1, rnd = SYSTEM) {
|
|
168
|
+
const state = preseed(n, scale, rnd);
|
|
169
|
+
const invN = 1 / n;
|
|
170
|
+
let acc = sum(state);
|
|
171
|
+
for (let i = 0; true; i = (i + 1) >>> 0) {
|
|
172
|
+
const id = ctz32(i) % n;
|
|
173
|
+
acc -= state[id];
|
|
174
|
+
acc += state[id] = rnd.norm(scale);
|
|
175
|
+
yield acc * invN;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Low-pass filtered noise (same as brown noise). Opposite of {@link blue}.
|
|
181
|
+
*
|
|
182
|
+
* @param n -
|
|
183
|
+
* @param scale -
|
|
184
|
+
* @param rnd -
|
|
185
|
+
*/
|
|
186
|
+
function* red(n = 2, scale = 1, rnd = SYSTEM) {
|
|
187
|
+
const state = preseed(n, scale, rnd);
|
|
188
|
+
const invN = 1 / n;
|
|
189
|
+
let acc = sum(state);
|
|
190
|
+
for (let i = 0; true; ++i >= n && (i = 0)) {
|
|
191
|
+
acc -= state[i];
|
|
192
|
+
acc += state[i] = rnd.norm(scale);
|
|
193
|
+
yield acc * invN;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Band-stop filtered noise (interleaved red noise). Opposite of {@link green}.
|
|
199
|
+
*
|
|
200
|
+
* @param n -
|
|
201
|
+
* @param scale -
|
|
202
|
+
* @param rnd -
|
|
203
|
+
*/
|
|
204
|
+
const violet = (n = 2, scale = 1, rnd = SYSTEM) => interleave(red(n, scale, rnd), red(n, scale, rnd));
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Unfiltered noise w/ uniform distribution. Merely yields samples from
|
|
208
|
+
* given PRNG.
|
|
209
|
+
*
|
|
210
|
+
* @param scale -
|
|
211
|
+
* @param rnd -
|
|
212
|
+
*/
|
|
213
|
+
function* white(scale = 1, rnd = SYSTEM) {
|
|
214
|
+
while (true) {
|
|
215
|
+
yield rnd.norm(scale);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const implementsFunction = (x, fn) => x != null && typeof x[fn] === "function";
|
|
220
|
+
|
|
221
|
+
const ensureTransducer = (x) => implementsFunction(x, "xform") ? x.xform() : x;
|
|
222
|
+
|
|
223
|
+
const isIterable = (x) => x != null && typeof x[Symbol.iterator] === "function";
|
|
224
|
+
|
|
225
|
+
class Reduced {
|
|
226
|
+
constructor(val) {
|
|
227
|
+
this.value = val;
|
|
228
|
+
}
|
|
229
|
+
deref() {
|
|
230
|
+
return this.value;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const reduced = (x) => new Reduced(x);
|
|
234
|
+
const isReduced = (x) => x instanceof Reduced;
|
|
235
|
+
const ensureReduced = (x) => x instanceof Reduced ? x : new Reduced(x);
|
|
236
|
+
const unreduced = (x) => (x instanceof Reduced ? x.deref() : x);
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Convenience helper for building a full {@link Reducer} using the identity
|
|
240
|
+
* function (i.e. `(x) => x`) as completion step (true for 90% of all
|
|
241
|
+
* bundled transducers).
|
|
242
|
+
*
|
|
243
|
+
* @param init - init step of reducer
|
|
244
|
+
* @param rfn - reduction step of reducer
|
|
245
|
+
*/
|
|
246
|
+
const reducer = (init, rfn) => [init, (acc) => acc, rfn];
|
|
247
|
+
|
|
248
|
+
function push(xs) {
|
|
249
|
+
return xs
|
|
250
|
+
? [...xs]
|
|
251
|
+
: reducer(() => [], (acc, x) => (acc.push(x), acc));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Takes a transducer and input iterable. Returns iterator of
|
|
256
|
+
* transformed results.
|
|
257
|
+
*
|
|
258
|
+
* @param xform -
|
|
259
|
+
* @param xs -
|
|
260
|
+
*/
|
|
261
|
+
function* iterator(xform, xs) {
|
|
262
|
+
const rfn = ensureTransducer(xform)(push());
|
|
263
|
+
const complete = rfn[1];
|
|
264
|
+
const reduce = rfn[2];
|
|
265
|
+
for (let x of xs) {
|
|
266
|
+
const y = reduce([], x);
|
|
267
|
+
if (isReduced(y)) {
|
|
268
|
+
yield* unreduced(complete(y.deref()));
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (y.length) {
|
|
272
|
+
yield* y;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
yield* unreduced(complete([]));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Reducer composition helper, internally used by various transducers
|
|
280
|
+
* during initialization. Takes existing reducer `rfn` (a 3-tuple) and a
|
|
281
|
+
* reducing function `fn`. Returns a new reducer tuple.
|
|
282
|
+
*
|
|
283
|
+
* @remarks
|
|
284
|
+
* `rfn[2]` reduces values of type `B` into an accumulator of type `A`.
|
|
285
|
+
* `fn` accepts values of type `C` and produces interim results of type
|
|
286
|
+
* `B`, which are then (possibly) passed to the "inner" `rfn[2]`
|
|
287
|
+
* function. Therefore the resulting reducer takes inputs of `C` and an
|
|
288
|
+
* accumulator of type `A`.
|
|
289
|
+
*
|
|
290
|
+
* It is assumed that `fn` internally calls `rfn[2]` to pass its own
|
|
291
|
+
* results for further processing by the nested reducer `rfn`.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* compR(rfn, fn)
|
|
296
|
+
* // [rfn[0], rfn[1], fn]
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @param rfn -
|
|
300
|
+
* @param fn -
|
|
301
|
+
*/
|
|
302
|
+
const compR = (rfn, fn) => [rfn[0], rfn[1], fn];
|
|
303
|
+
|
|
304
|
+
function take(n, src) {
|
|
305
|
+
return isIterable(src)
|
|
306
|
+
? iterator(take(n), src)
|
|
307
|
+
: (rfn) => {
|
|
308
|
+
const r = rfn[2];
|
|
309
|
+
let m = n;
|
|
310
|
+
return compR(rfn, (acc, x) => --m > 0
|
|
311
|
+
? r(acc, x)
|
|
312
|
+
: m === 0
|
|
313
|
+
? ensureReduced(r(acc, x))
|
|
314
|
+
: reduced(acc));
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
class Reverb {
|
|
319
|
+
constructor(ctx, options) {
|
|
320
|
+
this.noise = white;
|
|
321
|
+
this.ctx = ctx;
|
|
322
|
+
this.options = { ...defaults, ...options };
|
|
323
|
+
this.wetGainNode = this.ctx.createGain();
|
|
324
|
+
this.dryGainNode = this.ctx.createGain();
|
|
325
|
+
this.filterNode = this.ctx.createBiquadFilter();
|
|
326
|
+
this.convolverNode = this.ctx.createConvolver();
|
|
327
|
+
this.outputNode = this.ctx.createGain();
|
|
328
|
+
this.isConnected = false;
|
|
329
|
+
this.filterType(this.options.filterType);
|
|
330
|
+
this.setNoise(this.options.noise);
|
|
331
|
+
this.buildImpulse();
|
|
332
|
+
this.mix(this.options.mix);
|
|
333
|
+
}
|
|
334
|
+
connect(sourceNode) {
|
|
335
|
+
if (this.isConnected && this.options.once) {
|
|
336
|
+
this.isConnected = false;
|
|
337
|
+
return this.outputNode;
|
|
338
|
+
}
|
|
339
|
+
this.convolverNode.connect(this.filterNode);
|
|
340
|
+
this.filterNode.connect(this.wetGainNode);
|
|
341
|
+
sourceNode.connect(this.convolverNode);
|
|
342
|
+
sourceNode.connect(this.dryGainNode).connect(this.outputNode);
|
|
343
|
+
sourceNode.connect(this.wetGainNode).connect(this.outputNode);
|
|
344
|
+
this.isConnected = true;
|
|
345
|
+
return this.outputNode;
|
|
346
|
+
}
|
|
347
|
+
disconnect(sourceNode) {
|
|
348
|
+
if (this.isConnected) {
|
|
349
|
+
this.convolverNode.disconnect(this.filterNode);
|
|
350
|
+
this.filterNode.disconnect(this.wetGainNode);
|
|
351
|
+
}
|
|
352
|
+
this.isConnected = false;
|
|
353
|
+
return sourceNode;
|
|
354
|
+
}
|
|
355
|
+
mix(mix) {
|
|
356
|
+
if (!this.inRange(mix, 0, 1)) {
|
|
357
|
+
throw new RangeError("[Reverb.js] Dry/Wet ratio must be between 0 to 1.");
|
|
358
|
+
}
|
|
359
|
+
this.options.mix = mix;
|
|
360
|
+
this.dryGainNode.gain.value = 1 - this.options.mix;
|
|
361
|
+
this.wetGainNode.gain.value = this.options.mix;
|
|
362
|
+
}
|
|
363
|
+
time(value) {
|
|
364
|
+
if (!this.inRange(value, 1, 50)) {
|
|
365
|
+
throw new RangeError(
|
|
366
|
+
"[Reverb.js] Time length of inpulse response must be less than 50sec."
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
this.options.time = value;
|
|
370
|
+
this.buildImpulse();
|
|
371
|
+
}
|
|
372
|
+
decay(value) {
|
|
373
|
+
if (!this.inRange(value, 0, 100)) {
|
|
374
|
+
throw new RangeError(
|
|
375
|
+
"[Reverb.js] Inpulse Response decay level must be less than 100."
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
this.options.decay = value;
|
|
379
|
+
this.buildImpulse();
|
|
380
|
+
}
|
|
381
|
+
delay(value) {
|
|
382
|
+
if (!this.inRange(value, 0, 100)) {
|
|
383
|
+
throw new RangeError(
|
|
384
|
+
"[Reverb.js] Inpulse Response delay time must be less than 100."
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
this.options.delay = value;
|
|
388
|
+
this.buildImpulse();
|
|
389
|
+
}
|
|
390
|
+
reverse(reverse) {
|
|
391
|
+
this.options.reverse = reverse;
|
|
392
|
+
this.buildImpulse();
|
|
393
|
+
}
|
|
394
|
+
filterType(type = "allpass") {
|
|
395
|
+
this.filterNode.type = this.options.filterType = type;
|
|
396
|
+
}
|
|
397
|
+
filterFreq(freq) {
|
|
398
|
+
if (!this.inRange(freq, 20, 2e4)) {
|
|
399
|
+
throw new RangeError(
|
|
400
|
+
"[Reverb.js] Filter frequrncy must be between 20 and 20000."
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
this.options.filterFreq = freq;
|
|
404
|
+
this.filterNode.frequency.value = this.options.filterFreq;
|
|
405
|
+
}
|
|
406
|
+
filterQ(q) {
|
|
407
|
+
if (!this.inRange(q, 0, 10)) {
|
|
408
|
+
throw new RangeError(
|
|
409
|
+
"[Reverb.js] Filter quality value must be between 0 and 10."
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
this.options.filterQ = q;
|
|
413
|
+
this.filterNode.Q.value = this.options.filterQ;
|
|
414
|
+
}
|
|
415
|
+
peaks(p) {
|
|
416
|
+
this.options.peaks = p;
|
|
417
|
+
this.buildImpulse();
|
|
418
|
+
}
|
|
419
|
+
scale(s) {
|
|
420
|
+
this.options.scale = s;
|
|
421
|
+
this.buildImpulse();
|
|
422
|
+
}
|
|
423
|
+
randomAlgorithm(a) {
|
|
424
|
+
this.options.randomAlgorithm = a;
|
|
425
|
+
this.buildImpulse();
|
|
426
|
+
}
|
|
427
|
+
setNoise(type) {
|
|
428
|
+
this.options.noise = type;
|
|
429
|
+
switch (type) {
|
|
430
|
+
case Noise.BLUE:
|
|
431
|
+
this.noise = blue;
|
|
432
|
+
break;
|
|
433
|
+
case Noise.GREEN:
|
|
434
|
+
this.noise = green;
|
|
435
|
+
break;
|
|
436
|
+
case Noise.PINK:
|
|
437
|
+
this.noise = pink;
|
|
438
|
+
break;
|
|
439
|
+
case Noise.RED:
|
|
440
|
+
case Noise.BROWN:
|
|
441
|
+
this.noise = red;
|
|
442
|
+
break;
|
|
443
|
+
case Noise.VIOLET:
|
|
444
|
+
this.noise = violet;
|
|
445
|
+
break;
|
|
446
|
+
default:
|
|
447
|
+
this.noise = white;
|
|
448
|
+
}
|
|
449
|
+
this.buildImpulse();
|
|
450
|
+
}
|
|
451
|
+
setRandomAlgorythm(algorithm) {
|
|
452
|
+
this.options.randomAlgorithm = algorithm;
|
|
453
|
+
this.buildImpulse();
|
|
454
|
+
}
|
|
455
|
+
inRange(x, min, max) {
|
|
456
|
+
return (x - min) * (x - max) <= 0;
|
|
457
|
+
}
|
|
458
|
+
buildImpulse() {
|
|
459
|
+
const rate = this.ctx.sampleRate;
|
|
460
|
+
const duration = Math.max(rate * this.options.time, 1);
|
|
461
|
+
const delayDuration = rate * this.options.delay;
|
|
462
|
+
const impulse = this.ctx.createBuffer(2, duration, rate);
|
|
463
|
+
const impulseL = new Float32Array(duration);
|
|
464
|
+
const impulseR = new Float32Array(duration);
|
|
465
|
+
const noiseL = this.getNoise(duration);
|
|
466
|
+
const noiseR = this.getNoise(duration);
|
|
467
|
+
for (let i = 0; i < duration; i++) {
|
|
468
|
+
let n = 0;
|
|
469
|
+
if (i < delayDuration) {
|
|
470
|
+
impulseL[i] = 0;
|
|
471
|
+
impulseR[i] = 0;
|
|
472
|
+
n = this.options.reverse ? duration - (i - delayDuration) : i - delayDuration;
|
|
473
|
+
} else {
|
|
474
|
+
n = this.options.reverse ? duration - i : i;
|
|
475
|
+
}
|
|
476
|
+
impulseL[i] = noiseL[i] * (1 - n / duration) ** this.options.decay;
|
|
477
|
+
impulseR[i] = noiseR[i] * (1 - n / duration) ** this.options.decay;
|
|
478
|
+
}
|
|
479
|
+
impulse.getChannelData(0).set(impulseL);
|
|
480
|
+
impulse.getChannelData(1).set(impulseR);
|
|
481
|
+
this.convolverNode.buffer = impulse;
|
|
482
|
+
}
|
|
483
|
+
getNoise(duration) {
|
|
484
|
+
return [
|
|
485
|
+
...take(
|
|
486
|
+
duration,
|
|
487
|
+
this.noise === white ? white(this.options.scale, this.options.randomAlgorithm) : this.noise(
|
|
488
|
+
this.options.peaks,
|
|
489
|
+
this.options.scale,
|
|
490
|
+
this.options.randomAlgorithm
|
|
491
|
+
)
|
|
492
|
+
)
|
|
493
|
+
];
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
Reverb.version = meta.version;
|
|
497
|
+
Reverb.build = meta.date;
|
|
498
|
+
if (!window.Reverb) {
|
|
499
|
+
window.Reverb = Reverb;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
exports.default = Reverb;
|
|
503
|
+
|
|
504
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
505
|
+
|
|
506
|
+
return exports;
|
|
507
|
+
|
|
508
|
+
})({});
|