@logue/reverb 0.4.2 → 0.5.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.
@@ -0,0 +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"}
package/.eslintignore DELETED
@@ -1,4 +0,0 @@
1
- node_modules/*
2
- build/*
3
- docs/*
4
- bin/*
package/.eslintrc.js DELETED
@@ -1,21 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- env: {
4
- browser: true,
5
- es6: true,
6
- node: true,
7
- },
8
- extends: ['./node_modules/gts/'],
9
- parserOptions: {
10
- ecmaVersion: 2020,
11
- },
12
- overrides: [
13
- {
14
- files: ['webpack.config.ts'],
15
- rules: {
16
- 'node/no-unpublished-import': 'off',
17
- },
18
- },
19
- ],
20
- rules: {},
21
- };
package/.gitattributes DELETED
@@ -1 +0,0 @@
1
- * text=auto eol=lf encoding=utf-8
package/.prettierrc.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- ...require('gts/.prettierrc.json')
3
- }
package/bin/reverb.js DELETED
@@ -1,424 +0,0 @@
1
- /*! @logue/reverb v0.4.2 | Logue | license: MIT | build: 2021-07-04T08:12:21.950Z */
2
- (function webpackUniversalModuleDefinition(root, factory) {
3
- if(typeof exports === 'object' && typeof module === 'object')
4
- module.exports = factory();
5
- else if(typeof define === 'function' && define.amd)
6
- define("Reverb", [], factory);
7
- else if(typeof exports === 'object')
8
- exports["Reverb"] = factory();
9
- else
10
- root["Reverb"] = factory();
11
- })((typeof self !== 'undefined' ? self : this), function() {
12
- return /******/ (() => { // webpackBootstrap
13
- /******/ "use strict";
14
- /******/ var __webpack_modules__ = ({
15
-
16
- /***/ "./src/Meta.ts":
17
- /*!*********************!*\
18
- !*** ./src/Meta.ts ***!
19
- \*********************/
20
- /***/ ((__unused_webpack_module, exports) => {
21
-
22
-
23
- Object.defineProperty(exports, "__esModule", ({ value: true }));
24
- // This file is auto-generated by the build system.
25
- const meta = {
26
- version: '0.4.2',
27
- date: '2021-07-04T08:12:21.950Z',
28
- };
29
- exports.default = meta;
30
-
31
-
32
- /***/ }),
33
-
34
- /***/ "./src/NoiseType.ts":
35
- /*!**************************!*\
36
- !*** ./src/NoiseType.ts ***!
37
- \**************************/
38
- /***/ ((__unused_webpack_module, exports) => {
39
-
40
-
41
- Object.defineProperty(exports, "__esModule", ({ value: true }));
42
- exports.NoiseType = void 0;
43
- var NoiseType;
44
- (function (NoiseType) {
45
- NoiseType[NoiseType["WHITE"] = 0] = "WHITE";
46
- NoiseType[NoiseType["PINK"] = 1] = "PINK";
47
- NoiseType[NoiseType["BROWN"] = 2] = "BROWN";
48
- })(NoiseType = exports.NoiseType || (exports.NoiseType = {}));
49
-
50
-
51
- /***/ }),
52
-
53
- /***/ "./src/Reverb.ts":
54
- /*!***********************!*\
55
- !*** ./src/Reverb.ts ***!
56
- \***********************/
57
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
58
-
59
-
60
- var __importDefault = (this && this.__importDefault) || function (mod) {
61
- return (mod && mod.__esModule) ? mod : { "default": mod };
62
- };
63
- Object.defineProperty(exports, "__esModule", ({ value: true }));
64
- const Meta_1 = __importDefault(__webpack_require__(/*! ./Meta */ "./src/Meta.ts"));
65
- const NoiseType_1 = __webpack_require__(/*! ./NoiseType */ "./src/NoiseType.ts");
66
- /**
67
- * JS reverb effect class
68
- *
69
- * @author Logue <logue@hotmail.co.jp>
70
- * @copyright 2019-2021 Masashi Yoshikawa <https://logue.dev/> All rights reserved.
71
- * @license MIT
72
- * @see {@link https://github.com/logue/Reverb.js}
73
- * {@link https://github.com/web-audio-components/simple-reverb}
74
- */
75
- class Reverb {
76
- /** バージョン */
77
- version;
78
- /** ビルド日時 */
79
- build;
80
- /** AudioContext */
81
- ctx;
82
- /** ウェットレベル(エフェクターをかけたレベル) */
83
- wetGainNode;
84
- /** ドライレベル(原音レベル) */
85
- dryGainNode;
86
- /** インパルス応答用フィルタ */
87
- filterNode;
88
- /** 畳み込みノード */
89
- convolverNode;
90
- /** 出力ノード */
91
- outputNode;
92
- /** 変数 */
93
- _options;
94
- /** 接続済みフラグ */
95
- isConnected;
96
- /**
97
- * constructor
98
- * @param ctx Root AudioContext
99
- * @param options Configure
100
- */
101
- constructor(ctx, options) {
102
- // バージョン情報など
103
- this.version = Meta_1.default.version;
104
- this.build = Meta_1.default.date;
105
- // マスターのAudioContextを取得
106
- this.ctx = ctx;
107
- // デフォルト値をマージ
108
- this._options = { ...optionDefaults, ...options };
109
- // 初期化
110
- this.wetGainNode = this.ctx.createGain();
111
- this.dryGainNode = this.ctx.createGain();
112
- this.filterNode = this.ctx.createBiquadFilter();
113
- this.convolverNode = this.ctx.createConvolver();
114
- this.outputNode = this.ctx.createGain();
115
- // 接続済みフラグを落とす
116
- this.isConnected = false;
117
- // インパルス応答を生成
118
- this.buildImpulse();
119
- }
120
- /**
121
- * connect
122
- * @param sourceNode 原音ノード
123
- */
124
- connect(sourceNode) {
125
- // 畳み込みノードをウェットレベルに接続
126
- this.convolverNode.connect(this.filterNode);
127
- // フィルタノードをウェットレベルに接続
128
- this.filterNode.connect(this.wetGainNode);
129
- // 入力ノードを畳み込みノードに接続
130
- sourceNode.connect(this.convolverNode);
131
- // ドライレベルを出力ノードに接続
132
- sourceNode.connect(this.dryGainNode).connect(this.outputNode);
133
- // ウェットレベルを出力ノードに接続
134
- sourceNode.connect(this.wetGainNode).connect(this.outputNode);
135
- // 接続済みフラグを立てる
136
- this.isConnected = true;
137
- return this.outputNode;
138
- }
139
- /**
140
- * disconnect
141
- * @param sourceNode 原音のノード
142
- */
143
- disconnect(sourceNode) {
144
- // 初期状態ではノードがつながっていないためエラーになる
145
- if (this.isConnected) {
146
- // 畳み込みノードをウェットレベルから切断
147
- this.convolverNode.disconnect(this.filterNode);
148
- // フィルタノードをウェットレベルから切断
149
- this.filterNode.disconnect(this.wetGainNode);
150
- }
151
- // 接続済みフラグを解除
152
- this.isConnected = false;
153
- // そのままノードを返す(他のAPIに似せるため)
154
- return sourceNode;
155
- }
156
- /**
157
- * Dry/Wet ratio
158
- * @param mix
159
- */
160
- mix(mix) {
161
- if (!this.inRange(mix, 0, 1)) {
162
- throw new RangeError('Reverb.js: Dry/Wet ratio must be between 0 to 1.');
163
- }
164
- this._options.mix = mix;
165
- this.dryGainNode.gain.value = 1 - this._options.mix;
166
- this.wetGainNode.gain.value = this._options.mix;
167
- console.debug(`Reverb.js: Set dry/wet ratio to ${mix * 100}%`);
168
- }
169
- /**
170
- * Set Impulse Response time length (second)
171
- * @param value
172
- */
173
- time(value) {
174
- if (!this.inRange(value, 1, 50)) {
175
- throw new RangeError('Reverb.js: Time length of inpulse response must be less than 50sec.');
176
- }
177
- this._options.time = value;
178
- this.buildImpulse();
179
- console.info(`Reverb.js: Set inpulse response time length to ${value}sec.`);
180
- }
181
- /**
182
- * Impulse response decay rate.
183
- * @param value
184
- */
185
- decay(value) {
186
- if (!this.inRange(value, 0, 100)) {
187
- throw new RangeError('Reverb.js: Inpulse Response decay level must be less than 100.');
188
- }
189
- this._options.decay = value;
190
- this.buildImpulse();
191
- console.debug(`Reverb.js: Set inpulse response decay level to ${value}.`);
192
- }
193
- /**
194
- * Impulse response delay time. (NOT deley effect)
195
- * @param value
196
- */
197
- delay(value) {
198
- if (!this.inRange(value, 0, 100)) {
199
- throw new RangeError('Reverb.js: Inpulse Response delay time must be less than 100.');
200
- }
201
- this._options.delay = value;
202
- this.buildImpulse();
203
- console.debug(`Reverb.js: Set inpulse response delay time to ${value}sec.`);
204
- }
205
- /**
206
- * Reverse the impulse response.
207
- * @param reverse
208
- */
209
- reverse(reverse) {
210
- this._options.reverse = reverse;
211
- this.buildImpulse();
212
- console.debug(`Reverb.js: Inpulse response is ${reverse ? '' : 'not '}reversed.`);
213
- }
214
- /**
215
- * Filter type.
216
- * @param type
217
- */
218
- filterType(type) {
219
- this.filterNode.type = this._options.filterType = type;
220
- console.debug(`Set filter type to ${type}`);
221
- }
222
- /**
223
- * Filter frequency.
224
- * @param freq
225
- */
226
- filterFreq(freq) {
227
- if (!this.inRange(freq, 20, 5000)) {
228
- throw new RangeError('Reverb.js: Filter frequrncy must be between 20 and 5000.');
229
- }
230
- this._options.filterFreq = freq;
231
- this.filterNode.frequency.value = this._options.filterFreq;
232
- console.debug(`Set filter frequency to ${freq}Hz.`);
233
- }
234
- /**
235
- * Filter quality.
236
- * @param q
237
- */
238
- filterQ(q) {
239
- if (!this.inRange(q, 0, 10)) {
240
- throw new RangeError('Reverb.js: Filter quality value must be between 0 and 10.');
241
- }
242
- this._options.filterQ = q;
243
- this.filterNode.Q.value = this._options.filterQ;
244
- console.debug(`Set filter quality to ${q}.`);
245
- }
246
- /**
247
- * Inpulse Response Noise algorithm.
248
- * @param type
249
- */
250
- setNoise(type) {
251
- this._options.noise = type;
252
- this.buildImpulse();
253
- console.debug(`Set Noise type to ${type}.`);
254
- }
255
- /**
256
- * return true if in range, otherwise false
257
- * @private
258
- * @param x Target value
259
- * @param min Minimum value
260
- * @param max Maximum value
261
- * @return
262
- */
263
- inRange(x, min, max) {
264
- return (x - min) * (x - max) <= 0;
265
- }
266
- /**
267
- * Utility function for building an impulse response
268
- * from the module parameters.
269
- * @private
270
- */
271
- buildImpulse() {
272
- // インパルス応答生成ロジック
273
- /** サンプリングレート */
274
- const rate = this.ctx.sampleRate;
275
- /** インパルス応答の演奏時間 */
276
- const duration = Math.max(rate * this._options.time, 1);
277
- /** インパルス応答が始まるまでの遅延時間 */
278
- const delayDuration = rate * this._options.delay;
279
- /** インパルス応答バッファ(今の所ステレオのみ) */
280
- const impulse = this.ctx.createBuffer(2, duration, rate);
281
- /** 左チャンネル */
282
- const impulseL = new Float32Array(duration);
283
- /** 右チャンネル*/
284
- const impulseR = new Float32Array(duration);
285
- /** 一時計算用 */
286
- const b = [0, 0, 0, 0, 0, 0, 0];
287
- for (let i = 0; i < duration; i++) {
288
- /** @type {number} 減衰率 */
289
- let n = 0;
290
- if (i < delayDuration) {
291
- // Delay Effect
292
- impulseL[i] = 0;
293
- impulseR[i] = 0;
294
- n = this._options.reverse
295
- ? duration - (i - delayDuration)
296
- : i - delayDuration;
297
- }
298
- else {
299
- n = this._options.reverse ? duration - i : i;
300
- }
301
- switch (this._options.noise) {
302
- default:
303
- case NoiseType_1.NoiseType.WHITE:
304
- // White Noise
305
- impulseL[i] = Reverb.whiteNoise();
306
- impulseR[i] = Reverb.whiteNoise();
307
- break;
308
- case NoiseType_1.NoiseType.PINK:
309
- // ピンクノイズ生成処理
310
- // http://noisehack.com/generate-noise-web-audio-api/
311
- b[0] = 0.99886 * b[0] + Reverb.whiteNoise() * 0.0555179;
312
- b[1] = 0.99332 * b[1] + Reverb.whiteNoise() * 0.0750759;
313
- b[2] = 0.969 * b[2] + Reverb.whiteNoise() * 0.153852;
314
- b[3] = 0.8665 * b[3] + Reverb.whiteNoise() * 0.3104856;
315
- b[4] = 0.55 * b[4] + Reverb.whiteNoise() * 0.5329522;
316
- b[5] = -0.7616 * b[5] - Reverb.whiteNoise() * 0.016898;
317
- impulseL[i] =
318
- b[0] +
319
- b[1] +
320
- b[2] +
321
- b[3] +
322
- b[4] +
323
- b[5] +
324
- b[6] +
325
- Reverb.whiteNoise() * 0.5362;
326
- impulseR[i] =
327
- b[0] +
328
- b[1] +
329
- b[2] +
330
- b[3] +
331
- b[4] +
332
- b[5] +
333
- b[6] +
334
- Reverb.whiteNoise() * 0.5362;
335
- // ゲイン補償処理
336
- impulseL[i] *= 0.11;
337
- impulseR[i] *= 0.11;
338
- b[6] = Reverb.whiteNoise() * 0.115926;
339
- break;
340
- case NoiseType_1.NoiseType.BROWN:
341
- // ブラウンノイズ生成処理
342
- impulseL[i] = (b[0] + 0.02 * Reverb.whiteNoise()) / 1.02;
343
- b[0] = impulseL[i];
344
- impulseR[i] = (b[1] + 0.02 * Reverb.whiteNoise()) / 1.02;
345
- b[1] = impulseR[i];
346
- // ゲイン補償処理
347
- impulseL[i] *= 3.5;
348
- impulseR[i] *= 3.5;
349
- break;
350
- }
351
- // 音を減衰させる
352
- impulseL[i] *= (1 - n / duration) ** this._options.decay;
353
- impulseR[i] *= (1 - n / duration) ** this._options.decay;
354
- }
355
- // インパルス応答のバッファに生成したWaveTableを代入
356
- impulse.getChannelData(0).set(impulseL);
357
- impulse.getChannelData(1).set(impulseR);
358
- this.convolverNode.buffer = impulse;
359
- }
360
- /**
361
- * Generate white noise
362
- */
363
- static whiteNoise() {
364
- // TODO: この乱数は本当に偏り無いのだろうか?
365
- return Math.random() * 2 - 1;
366
- }
367
- }
368
- exports.default = Reverb;
369
- /**
370
- * デフォルト値
371
- */
372
- const optionDefaults = {
373
- noise: 1,
374
- decay: 5,
375
- delay: 0,
376
- reverse: false,
377
- time: 3,
378
- filterType: 'lowpass',
379
- filterFreq: 2200,
380
- filterQ: 1,
381
- mix: 0.5,
382
- };
383
-
384
-
385
- /***/ })
386
-
387
- /******/ });
388
- /************************************************************************/
389
- /******/ // The module cache
390
- /******/ var __webpack_module_cache__ = {};
391
- /******/
392
- /******/ // The require function
393
- /******/ function __webpack_require__(moduleId) {
394
- /******/ // Check if module is in cache
395
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
396
- /******/ if (cachedModule !== undefined) {
397
- /******/ return cachedModule.exports;
398
- /******/ }
399
- /******/ // Create a new module (and put it into the cache)
400
- /******/ var module = __webpack_module_cache__[moduleId] = {
401
- /******/ // no module.id needed
402
- /******/ // no module.loaded needed
403
- /******/ exports: {}
404
- /******/ };
405
- /******/
406
- /******/ // Execute the module function
407
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
408
- /******/
409
- /******/ // Return the exports of the module
410
- /******/ return module.exports;
411
- /******/ }
412
- /******/
413
- /************************************************************************/
414
- /******/
415
- /******/ // startup
416
- /******/ // Load entry module and return exports
417
- /******/ // This entry module is referenced by other modules so it can't be inlined
418
- /******/ var __webpack_exports__ = __webpack_require__("./src/Reverb.ts");
419
- /******/
420
- /******/ return __webpack_exports__;
421
- /******/ })()
422
- ;
423
- });
424
- //# sourceMappingURL=reverb.js.map
package/bin/reverb.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["webpack://Reverb/webpack/universalModuleDefinition","webpack://Reverb/./src/Meta.ts","webpack://Reverb/./src/NoiseType.ts","webpack://Reverb/./src/Reverb.ts","webpack://Reverb/webpack/bootstrap","webpack://Reverb/webpack/startup"],"names":[],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;;;;;;;;;;;ACRA,mDAAmD;AACnD,MAAM,IAAI,GAAkB;IAC1B,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,0BAA0B;CACjC,CAAC;AACF,kBAAe,IAAI,CAAC;;;;;;;;;;;;;;ACPpB,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,2CAAK;IACL,yCAAI;IACJ,2CAAK;AACP,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB;;;;;;;;;;;;;;;;ACJD,mFAA0B;AAE1B,i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AAE,CAAC;IACR,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,CAAC;IACP,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,GAAG;CACT,CAAC;;;;;;;UCvWF;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"reverb.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Reverb\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Reverb\"] = factory();\n\telse\n\t\troot[\"Reverb\"] = factory();\n})((typeof self !== 'undefined' ? self : this), function() {\nreturn ","import MetaInterface from './interfaces/MetaInterface';\n\n// This file is auto-generated by the build system.\nconst meta: MetaInterface = {\n version: '0.4.2',\n date: '2021-07-04T08:12:21.950Z',\n};\nexport default meta;\n","export enum NoiseType {\n WHITE,\n PINK,\n BROWN,\n}\n","import Meta from './Meta';\nimport OptionInterface from './interfaces/OptionInterface';\nimport {NoiseType} from './NoiseType';\n\n/**\n * JS reverb effect class\n *\n * @author Logue <logue@hotmail.co.jp>\n * @copyright 2019-2021 Masashi Yoshikawa <https://logue.dev/> All rights reserved.\n * @license MIT\n * @see {@link https://github.com/logue/Reverb.js}\n * {@link https://github.com/web-audio-components/simple-reverb}\n */\nexport default class Reverb {\n /** バージョン */\n public readonly version: string;\n /** ビルド日時 */\n public readonly build: string;\n /** AudioContext */\n private readonly ctx: AudioContext;\n /** ウェットレベル(エフェクターをかけたレベル) */\n private readonly wetGainNode: GainNode;\n /** ドライレベル(原音レベル) */\n private readonly dryGainNode: GainNode;\n /** インパルス応答用フィルタ */\n private readonly filterNode: BiquadFilterNode;\n /** 畳み込みノード */\n private readonly convolverNode: ConvolverNode;\n /** 出力ノード */\n private readonly outputNode: GainNode;\n /** 変数 */\n private readonly _options: OptionInterface;\n /** 接続済みフラグ */\n private isConnected: boolean;\n\n /**\n * constructor\n * @param ctx Root AudioContext\n * @param options Configure\n */\n constructor(ctx: AudioContext, options: OptionInterface | undefined) {\n // バージョン情報など\n this.version = Meta.version;\n this.build = Meta.date;\n // マスターのAudioContextを取得\n this.ctx = ctx;\n // デフォルト値をマージ\n this._options = {...optionDefaults, ...options} as const;\n // 初期化\n this.wetGainNode = this.ctx.createGain();\n this.dryGainNode = this.ctx.createGain();\n this.filterNode = this.ctx.createBiquadFilter();\n this.convolverNode = this.ctx.createConvolver();\n this.outputNode = this.ctx.createGain();\n // 接続済みフラグを落とす\n this.isConnected = false;\n // インパルス応答を生成\n this.buildImpulse();\n }\n\n /**\n * connect\n * @param sourceNode 原音ノード\n */\n public connect(sourceNode: AudioNode): AudioNode {\n // 畳み込みノードをウェットレベルに接続\n this.convolverNode.connect(this.filterNode);\n // フィルタノードをウェットレベルに接続\n this.filterNode.connect(this.wetGainNode);\n // 入力ノードを畳み込みノードに接続\n sourceNode.connect(this.convolverNode);\n // ドライレベルを出力ノードに接続\n sourceNode.connect(this.dryGainNode).connect(this.outputNode);\n // ウェットレベルを出力ノードに接続\n sourceNode.connect(this.wetGainNode).connect(this.outputNode);\n // 接続済みフラグを立てる\n this.isConnected = true;\n\n return this.outputNode;\n }\n\n /**\n * disconnect\n * @param sourceNode 原音のノード\n */\n public disconnect(sourceNode: AudioNode | undefined): AudioNode | undefined {\n // 初期状態ではノードがつながっていないためエラーになる\n if (this.isConnected) {\n // 畳み込みノードをウェットレベルから切断\n this.convolverNode.disconnect(this.filterNode);\n // フィルタノードをウェットレベルから切断\n this.filterNode.disconnect(this.wetGainNode);\n }\n // 接続済みフラグを解除\n this.isConnected = false;\n\n // そのままノードを返す(他のAPIに似せるため)\n return sourceNode;\n }\n\n /**\n * Dry/Wet ratio\n * @param mix\n */\n public mix(mix: number): void {\n if (!this.inRange(mix, 0, 1)) {\n throw new RangeError('Reverb.js: Dry/Wet ratio must be between 0 to 1.');\n }\n this._options.mix = mix;\n this.dryGainNode.gain.value = 1 - this._options.mix;\n this.wetGainNode.gain.value = this._options.mix;\n console.debug(`Reverb.js: Set dry/wet ratio to ${mix * 100}%`);\n }\n\n /**\n * Set Impulse Response time length (second)\n * @param value\n */\n public time(value: number): void {\n if (!this.inRange(value, 1, 50)) {\n throw new RangeError(\n 'Reverb.js: Time length of inpulse response must be less than 50sec.'\n );\n }\n this._options.time = value;\n this.buildImpulse();\n console.info(`Reverb.js: Set inpulse response time length to ${value}sec.`);\n }\n\n /**\n * Impulse response decay rate.\n * @param value\n */\n public decay(value: number): void {\n if (!this.inRange(value, 0, 100)) {\n throw new RangeError(\n 'Reverb.js: Inpulse Response decay level must be less than 100.'\n );\n }\n this._options.decay = value;\n this.buildImpulse();\n console.debug(`Reverb.js: Set inpulse response decay level to ${value}.`);\n }\n\n /**\n * Impulse response delay time. (NOT deley effect)\n * @param value\n */\n public delay(value: number): void {\n if (!this.inRange(value, 0, 100)) {\n throw new RangeError(\n 'Reverb.js: Inpulse Response delay time must be less than 100.'\n );\n }\n this._options.delay = value;\n this.buildImpulse();\n console.debug(`Reverb.js: Set inpulse response delay time to ${value}sec.`);\n }\n\n /**\n * Reverse the impulse response.\n * @param reverse\n */\n public reverse(reverse: boolean): void {\n this._options.reverse = reverse;\n this.buildImpulse();\n console.debug(\n `Reverb.js: Inpulse response is ${reverse ? '' : 'not '}reversed.`\n );\n }\n\n /**\n * Filter type.\n * @param type\n */\n public filterType(type: BiquadFilterType): void {\n this.filterNode.type = this._options.filterType = type;\n console.debug(`Set filter type to ${type}`);\n }\n\n /**\n * Filter frequency.\n * @param freq\n */\n public filterFreq(freq: number): void {\n if (!this.inRange(freq, 20, 5000)) {\n throw new RangeError(\n 'Reverb.js: Filter frequrncy must be between 20 and 5000.'\n );\n }\n this._options.filterFreq = freq;\n this.filterNode.frequency.value = this._options.filterFreq;\n console.debug(`Set filter frequency to ${freq}Hz.`);\n }\n\n /**\n * Filter quality.\n * @param q\n */\n public filterQ(q: number): void {\n if (!this.inRange(q, 0, 10)) {\n throw new RangeError(\n 'Reverb.js: Filter quality value must be between 0 and 10.'\n );\n }\n this._options.filterQ = q;\n this.filterNode.Q.value = this._options.filterQ;\n console.debug(`Set filter quality to ${q}.`);\n }\n\n /**\n * Inpulse Response Noise algorithm.\n * @param type\n */\n public setNoise(type: NoiseType) {\n this._options.noise = type;\n this.buildImpulse();\n console.debug(`Set Noise type to ${type}.`);\n }\n\n /**\n * return true if in range, otherwise false\n * @private\n * @param x Target value\n * @param min Minimum value\n * @param max Maximum value\n * @return\n */\n private inRange(x: number, min: number, max: number): boolean {\n return (x - min) * (x - max) <= 0;\n }\n\n /**\n * Utility function for building an impulse response\n * from the module parameters.\n * @private\n */\n private buildImpulse(): void {\n // インパルス応答生成ロジック\n\n /** サンプリングレート */\n const rate: number = this.ctx.sampleRate;\n /** インパルス応答の演奏時間 */\n const duration: number = Math.max(rate * this._options.time, 1);\n /** インパルス応答が始まるまでの遅延時間 */\n const delayDuration: number = rate * this._options.delay;\n /** インパルス応答バッファ(今の所ステレオのみ) */\n const impulse: AudioBuffer = this.ctx.createBuffer(2, duration, rate);\n /** 左チャンネル */\n const impulseL: Float32Array = new Float32Array(duration);\n /** 右チャンネル*/\n const impulseR: Float32Array = new Float32Array(duration);\n\n /** 一時計算用 */\n const b = [0, 0, 0, 0, 0, 0, 0];\n\n for (let i = 0; i < duration; i++) {\n /** @type {number} 減衰率 */\n let n = 0;\n\n if (i < delayDuration) {\n // Delay Effect\n impulseL[i] = 0;\n impulseR[i] = 0;\n n = this._options.reverse\n ? duration - (i - delayDuration)\n : i - delayDuration;\n } else {\n n = this._options.reverse ? duration - i : i;\n }\n\n switch (this._options.noise) {\n default:\n case NoiseType.WHITE:\n // White Noise\n impulseL[i] = Reverb.whiteNoise();\n impulseR[i] = Reverb.whiteNoise();\n break;\n case NoiseType.PINK:\n // ピンクノイズ生成処理\n // http://noisehack.com/generate-noise-web-audio-api/\n b[0] = 0.99886 * b[0] + Reverb.whiteNoise() * 0.0555179;\n b[1] = 0.99332 * b[1] + Reverb.whiteNoise() * 0.0750759;\n b[2] = 0.969 * b[2] + Reverb.whiteNoise() * 0.153852;\n b[3] = 0.8665 * b[3] + Reverb.whiteNoise() * 0.3104856;\n b[4] = 0.55 * b[4] + Reverb.whiteNoise() * 0.5329522;\n b[5] = -0.7616 * b[5] - Reverb.whiteNoise() * 0.016898;\n\n impulseL[i] =\n b[0] +\n b[1] +\n b[2] +\n b[3] +\n b[4] +\n b[5] +\n b[6] +\n Reverb.whiteNoise() * 0.5362;\n\n impulseR[i] =\n b[0] +\n b[1] +\n b[2] +\n b[3] +\n b[4] +\n b[5] +\n b[6] +\n Reverb.whiteNoise() * 0.5362;\n\n // ゲイン補償処理\n impulseL[i] *= 0.11;\n impulseR[i] *= 0.11;\n\n b[6] = Reverb.whiteNoise() * 0.115926;\n break;\n case NoiseType.BROWN:\n // ブラウンノイズ生成処理\n impulseL[i] = (b[0] + 0.02 * Reverb.whiteNoise()) / 1.02;\n b[0] = impulseL[i];\n impulseR[i] = (b[1] + 0.02 * Reverb.whiteNoise()) / 1.02;\n b[1] = impulseR[i];\n\n // ゲイン補償処理\n impulseL[i] *= 3.5;\n impulseR[i] *= 3.5;\n break;\n }\n // 音を減衰させる\n impulseL[i] *= (1 - n / duration) ** this._options.decay;\n impulseR[i] *= (1 - n / duration) ** this._options.decay;\n }\n\n // インパルス応答のバッファに生成したWaveTableを代入\n impulse.getChannelData(0).set(impulseL);\n impulse.getChannelData(1).set(impulseR);\n\n this.convolverNode.buffer = impulse;\n }\n /**\n * Generate white noise\n */\n private static whiteNoise(): number {\n // TODO: この乱数は本当に偏り無いのだろうか?\n return Math.random() * 2 - 1;\n }\n}\n\n/**\n * デフォルト値\n */\nconst optionDefaults: OptionInterface = {\n noise: 1,\n decay: 5,\n delay: 0,\n reverse: false,\n time: 3,\n filterType: 'lowpass',\n filterFreq: 2200,\n filterQ: 1,\n mix: 0.5,\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/Reverb.ts\");\n"],"sourceRoot":""}
package/bin/reverb.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see reverb.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Reverb",[],t):"object"==typeof exports?exports.Reverb=t():e.Reverb=t()}("undefined"!=typeof self?self:this,(function(){return(()=>{"use strict";var e={35:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.default={version:"0.4.2",date:"2021-07-04T08:13:17.775Z"}},804:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoiseType=void 0,function(e){e[e.WHITE=0]="WHITE",e[e.PINK=1]="PINK",e[e.BROWN=2]="BROWN"}(t.NoiseType||(t.NoiseType={}))},850:function(e,t,i){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(i(35)),n=i(804);class r{version;build;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;_options;isConnected;constructor(e,t){this.version=o.default.version,this.build=o.default.date,this.ctx=e,this._options={...h,...t},this.wetGainNode=this.ctx.createGain(),this.dryGainNode=this.ctx.createGain(),this.filterNode=this.ctx.createBiquadFilter(),this.convolverNode=this.ctx.createConvolver(),this.outputNode=this.ctx.createGain(),this.isConnected=!1,this.buildImpulse()}connect(e){return 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,t,i){return(e-t)*(e-i)<=0}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this._options.time,1),i=e*this._options.delay,s=this.ctx.createBuffer(2,t,e),o=new Float32Array(t),h=new Float32Array(t),a=[0,0,0,0,0,0,0];for(let e=0;e<t;e++){let s=0;switch(e<i?(o[e]=0,h[e]=0,s=this._options.reverse?t-(e-i):e-i):s=this._options.reverse?t-e:e,this._options.noise){default:case n.NoiseType.WHITE:o[e]=r.whiteNoise(),h[e]=r.whiteNoise();break;case n.NoiseType.PINK:a[0]=.99886*a[0]+.0555179*r.whiteNoise(),a[1]=.99332*a[1]+.0750759*r.whiteNoise(),a[2]=.969*a[2]+.153852*r.whiteNoise(),a[3]=.8665*a[3]+.3104856*r.whiteNoise(),a[4]=.55*a[4]+.5329522*r.whiteNoise(),a[5]=-.7616*a[5]-.016898*r.whiteNoise(),o[e]=a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+.5362*r.whiteNoise(),h[e]=a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+.5362*r.whiteNoise(),o[e]*=.11,h[e]*=.11,a[6]=.115926*r.whiteNoise();break;case n.NoiseType.BROWN:o[e]=(a[0]+.02*r.whiteNoise())/1.02,a[0]=o[e],h[e]=(a[1]+.02*r.whiteNoise())/1.02,a[1]=h[e],o[e]*=3.5,h[e]*=3.5}o[e]*=(1-s/t)**this._options.decay,h[e]*=(1-s/t)**this._options.decay}s.getChannelData(0).set(o),s.getChannelData(1).set(h),this.convolverNode.buffer=s}static whiteNoise(){return 2*Math.random()-1}}t.default=r;const h={noise:1,decay:5,delay:0,reverse:!1,time:3,filterType:"lowpass",filterFreq:2200,filterQ:1,mix:.5}}},t={};return function i(s){var o=t[s];if(void 0!==o)return o.exports;var n=t[s]={exports:{}};return e[s].call(n.exports,n,n.exports,i),n.exports}(850)})()}));
@@ -1,11 +0,0 @@
1
- /*! @logue/reverb v0.4.2 | Logue | license: MIT | build: 2021-07-04T08:13:17.775Z */
2
-
3
- /**
4
- * JS reverb effect class
5
- *
6
- * @author Logue <logue@hotmail.co.jp>
7
- * @copyright 2019-2021 Masashi Yoshikawa <https://logue.dev/> All rights reserved.
8
- * @license MIT
9
- * @see {@link https://github.com/logue/Reverb.js}
10
- * {@link https://github.com/web-audio-components/simple-reverb}
11
- */
package/docs/demo.wav DELETED
Binary file