@logue/reverb 0.4.4 → 0.5.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.
- package/README.md +8 -10
- package/dist/reverb.es.js +188 -0
- package/dist/reverb.umd.js +10 -0
- package/package.json +59 -44
- package/types/Meta.d.ts +4 -0
- package/types/Meta.d.ts.map +1 -0
- package/types/NoiseType.d.ts +14 -0
- package/types/NoiseType.d.ts.map +1 -0
- package/types/Reverb.d.ts +118 -0
- package/types/Reverb.d.ts.map +1 -0
- package/{src/interfaces/MetaInterface.ts → types/interfaces/MetaInterface.d.ts} +2 -3
- package/{dist → types}/interfaces/MetaInterface.d.ts.map +1 -1
- package/{src/interfaces/OptionInterface.ts → types/interfaces/OptionInterface.d.ts} +5 -5
- package/types/interfaces/OptionInterface.d.ts.map +1 -0
- package/.eslintignore +0 -4
- package/.eslintrc.js +0 -21
- package/.gitattributes +0 -1
- package/.prettierrc.js +0 -3
- package/bin/reverb.js +0 -432
- package/bin/reverb.js.map +0 -1
- package/bin/reverb.min.js +0 -2
- package/bin/reverb.min.js.LICENSE.txt +0 -11
- package/dist/Meta.d.ts +0 -4
- package/dist/Meta.d.ts.map +0 -1
- package/dist/Meta.js +0 -9
- package/dist/Meta.js.map +0 -1
- package/dist/NoiseType.d.ts +0 -7
- package/dist/NoiseType.d.ts.map +0 -1
- package/dist/NoiseType.js +0 -12
- package/dist/NoiseType.js.map +0 -1
- package/dist/Reverb.d.ts +0 -114
- package/dist/Reverb.d.ts.map +0 -1
- package/dist/Reverb.js +0 -331
- package/dist/Reverb.js.map +0 -1
- package/dist/interfaces/MetaInterface.d.ts +0 -10
- package/dist/interfaces/MetaInterface.js +0 -3
- package/dist/interfaces/MetaInterface.js.map +0 -1
- package/dist/interfaces/OptionInterface.d.ts +0 -25
- package/dist/interfaces/OptionInterface.d.ts.map +0 -1
- package/dist/interfaces/OptionInterface.js +0 -3
- package/dist/interfaces/OptionInterface.js.map +0 -1
- package/docs/demo.wav +0 -0
- package/docs/index.html +0 -365
- package/docs/localaudio.html +0 -718
- package/docs/reverb.js +0 -432
- package/docs/reverb.js.map +0 -1
- package/src/Meta.ts +0 -8
- package/src/NoiseType.ts +0 -7
- package/src/Reverb.ts +0 -366
- package/tsconfig.json +0 -32
- package/webpack.config.ts +0 -102
package/docs/reverb.js
DELETED
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
/*! @logue/reverb v0.4.4 | Logue | license: MIT | build: 2021-09-14T00:43:02.792Z */
|
|
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.4',
|
|
27
|
-
date: '2021-09-14T00:42:46.926Z',
|
|
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
|
-
/** Impulse response noise generation algorithm */
|
|
44
|
-
var NoiseType;
|
|
45
|
-
(function (NoiseType) {
|
|
46
|
-
NoiseType[NoiseType["WHITE"] = 0] = "WHITE";
|
|
47
|
-
NoiseType[NoiseType["PINK"] = 1] = "PINK";
|
|
48
|
-
NoiseType[NoiseType["BROWN"] = 2] = "BROWN";
|
|
49
|
-
// BLUE,
|
|
50
|
-
})(NoiseType = exports.NoiseType || (exports.NoiseType = {}));
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/***/ }),
|
|
54
|
-
|
|
55
|
-
/***/ "./src/Reverb.ts":
|
|
56
|
-
/*!***********************!*\
|
|
57
|
-
!*** ./src/Reverb.ts ***!
|
|
58
|
-
\***********************/
|
|
59
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
63
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
64
|
-
};
|
|
65
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
66
|
-
const Meta_1 = __importDefault(__webpack_require__(/*! ./Meta */ "./src/Meta.ts"));
|
|
67
|
-
const NoiseType_1 = __webpack_require__(/*! ./NoiseType */ "./src/NoiseType.ts");
|
|
68
|
-
/**
|
|
69
|
-
* JS reverb effect class
|
|
70
|
-
*
|
|
71
|
-
* @author Logue <logue@hotmail.co.jp>
|
|
72
|
-
* @copyright 2019-2021 Masashi Yoshikawa <https://logue.dev/> All rights reserved.
|
|
73
|
-
* @license MIT
|
|
74
|
-
* @see {@link https://github.com/logue/Reverb.js}
|
|
75
|
-
* {@link https://github.com/web-audio-components/simple-reverb}
|
|
76
|
-
*/
|
|
77
|
-
class Reverb {
|
|
78
|
-
/** Version strings */
|
|
79
|
-
version;
|
|
80
|
-
/** Build date */
|
|
81
|
-
build;
|
|
82
|
-
/** AudioContext */
|
|
83
|
-
ctx;
|
|
84
|
-
/** Wet Level (Reverberated node) */
|
|
85
|
-
wetGainNode;
|
|
86
|
-
/** Dry Level (Original sound node) */
|
|
87
|
-
dryGainNode;
|
|
88
|
-
/** Impulse response filter */
|
|
89
|
-
filterNode;
|
|
90
|
-
/** Convolution node for applying impulse response */
|
|
91
|
-
convolverNode;
|
|
92
|
-
/** Output nodse */
|
|
93
|
-
outputNode;
|
|
94
|
-
/** Option */
|
|
95
|
-
_options;
|
|
96
|
-
/** Connected flag */
|
|
97
|
-
isConnected;
|
|
98
|
-
/**
|
|
99
|
-
* constructor
|
|
100
|
-
* @param ctx Root AudioContext
|
|
101
|
-
* @param options Configure
|
|
102
|
-
*/
|
|
103
|
-
constructor(ctx, options) {
|
|
104
|
-
// バージョン情報など
|
|
105
|
-
this.version = Meta_1.default.version;
|
|
106
|
-
this.build = Meta_1.default.date;
|
|
107
|
-
// マスターのAudioContextを取得
|
|
108
|
-
this.ctx = ctx;
|
|
109
|
-
// デフォルト値をマージ
|
|
110
|
-
this._options = { ...optionDefaults, ...options };
|
|
111
|
-
// 初期化
|
|
112
|
-
this.wetGainNode = this.ctx.createGain();
|
|
113
|
-
this.dryGainNode = this.ctx.createGain();
|
|
114
|
-
this.filterNode = this.ctx.createBiquadFilter();
|
|
115
|
-
this.convolverNode = this.ctx.createConvolver();
|
|
116
|
-
this.outputNode = this.ctx.createGain();
|
|
117
|
-
// 接続済みフラグを落とす
|
|
118
|
-
this.isConnected = false;
|
|
119
|
-
// インパルス応答を生成
|
|
120
|
-
this.buildImpulse();
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Connect the node for the reverb effect to the original sound node.
|
|
124
|
-
* @param sourceNode Input source node
|
|
125
|
-
*/
|
|
126
|
-
connect(sourceNode) {
|
|
127
|
-
if (this.isConnected) {
|
|
128
|
-
// 接続済みだった場合そのまま出力ノードを返す
|
|
129
|
-
return this.outputNode;
|
|
130
|
-
}
|
|
131
|
-
// 畳み込みノードをウェットレベルに接続
|
|
132
|
-
this.convolverNode.connect(this.filterNode);
|
|
133
|
-
// フィルタノードをウェットレベルに接続
|
|
134
|
-
this.filterNode.connect(this.wetGainNode);
|
|
135
|
-
// 入力ノードを畳み込みノードに接続
|
|
136
|
-
sourceNode.connect(this.convolverNode);
|
|
137
|
-
// ドライレベルを出力ノードに接続
|
|
138
|
-
sourceNode.connect(this.dryGainNode).connect(this.outputNode);
|
|
139
|
-
// ウェットレベルを出力ノードに接続
|
|
140
|
-
sourceNode.connect(this.wetGainNode).connect(this.outputNode);
|
|
141
|
-
// トライ/ウェットノードの量を調整
|
|
142
|
-
this.mix(this._options.mix);
|
|
143
|
-
// 接続済みフラグを立てる
|
|
144
|
-
this.isConnected = true;
|
|
145
|
-
return this.outputNode;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Disconnect the reverb node
|
|
149
|
-
* @param sourceNode Input source node
|
|
150
|
-
*/
|
|
151
|
-
disconnect(sourceNode) {
|
|
152
|
-
// 初期状態ではノードがつながっていないためエラーになる
|
|
153
|
-
if (this.isConnected) {
|
|
154
|
-
// 畳み込みノードをウェットレベルから切断
|
|
155
|
-
this.convolverNode.disconnect(this.filterNode);
|
|
156
|
-
// フィルタノードをウェットレベルから切断
|
|
157
|
-
this.filterNode.disconnect(this.wetGainNode);
|
|
158
|
-
}
|
|
159
|
-
// 接続済みフラグを解除
|
|
160
|
-
this.isConnected = false;
|
|
161
|
-
// そのままノードを返す(他のAPIに似せるため)
|
|
162
|
-
return sourceNode;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Dry/Wet ratio
|
|
166
|
-
* @param mix
|
|
167
|
-
*/
|
|
168
|
-
mix(mix) {
|
|
169
|
-
if (!this.inRange(mix, 0, 1)) {
|
|
170
|
-
throw new RangeError('Reverb.js: Dry/Wet ratio must be between 0 to 1.');
|
|
171
|
-
}
|
|
172
|
-
this._options.mix = mix;
|
|
173
|
-
this.dryGainNode.gain.value = 1 - this._options.mix;
|
|
174
|
-
this.wetGainNode.gain.value = this._options.mix;
|
|
175
|
-
console.debug(`Reverb.js: Set dry/wet ratio to ${mix * 100}%`);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Set Impulse Response time length (second)
|
|
179
|
-
* @param value
|
|
180
|
-
*/
|
|
181
|
-
time(value) {
|
|
182
|
-
if (!this.inRange(value, 1, 50)) {
|
|
183
|
-
throw new RangeError('Reverb.js: Time length of inpulse response must be less than 50sec.');
|
|
184
|
-
}
|
|
185
|
-
this._options.time = value;
|
|
186
|
-
this.buildImpulse();
|
|
187
|
-
console.info(`Reverb.js: Set inpulse response time length to ${value}sec.`);
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Impulse response decay rate.
|
|
191
|
-
* @param value
|
|
192
|
-
*/
|
|
193
|
-
decay(value) {
|
|
194
|
-
if (!this.inRange(value, 0, 100)) {
|
|
195
|
-
throw new RangeError('Reverb.js: Inpulse Response decay level must be less than 100.');
|
|
196
|
-
}
|
|
197
|
-
this._options.decay = value;
|
|
198
|
-
this.buildImpulse();
|
|
199
|
-
console.debug(`Reverb.js: Set inpulse response decay level to ${value}.`);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Delay before reverberation starts
|
|
203
|
-
* @param value time[ms]
|
|
204
|
-
*/
|
|
205
|
-
delay(value) {
|
|
206
|
-
if (!this.inRange(value, 0, 100)) {
|
|
207
|
-
throw new RangeError('Reverb.js: Inpulse Response delay time must be less than 100.');
|
|
208
|
-
}
|
|
209
|
-
this._options.delay = value;
|
|
210
|
-
this.buildImpulse();
|
|
211
|
-
console.debug(`Reverb.js: Set inpulse response delay time to ${value}sec.`);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Reverse the impulse response.
|
|
215
|
-
* @param reverse
|
|
216
|
-
*/
|
|
217
|
-
reverse(reverse) {
|
|
218
|
-
this._options.reverse = reverse;
|
|
219
|
-
this.buildImpulse();
|
|
220
|
-
console.debug(`Reverb.js: Inpulse response is ${reverse ? '' : 'not '}reversed.`);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Filter for impulse response
|
|
224
|
-
* @param type
|
|
225
|
-
*/
|
|
226
|
-
filterType(type) {
|
|
227
|
-
this.filterNode.type = this._options.filterType = type;
|
|
228
|
-
console.debug(`Set filter type to ${type}`);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Filter frequency applied to impulse response
|
|
232
|
-
* @param freq
|
|
233
|
-
*/
|
|
234
|
-
filterFreq(freq) {
|
|
235
|
-
if (!this.inRange(freq, 20, 5000)) {
|
|
236
|
-
throw new RangeError('Reverb.js: Filter frequrncy must be between 20 and 5000.');
|
|
237
|
-
}
|
|
238
|
-
this._options.filterFreq = freq;
|
|
239
|
-
this.filterNode.frequency.value = this._options.filterFreq;
|
|
240
|
-
console.debug(`Set filter frequency to ${freq}Hz.`);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Filter quality.
|
|
244
|
-
* @param q
|
|
245
|
-
*/
|
|
246
|
-
filterQ(q) {
|
|
247
|
-
if (!this.inRange(q, 0, 10)) {
|
|
248
|
-
throw new RangeError('Reverb.js: Filter quality value must be between 0 and 10.');
|
|
249
|
-
}
|
|
250
|
-
this._options.filterQ = q;
|
|
251
|
-
this.filterNode.Q.value = this._options.filterQ;
|
|
252
|
-
console.debug(`Set filter quality to ${q}.`);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Inpulse Response Noise algorithm.
|
|
256
|
-
* @param type
|
|
257
|
-
*/
|
|
258
|
-
setNoise(type) {
|
|
259
|
-
this._options.noise = type;
|
|
260
|
-
this.buildImpulse();
|
|
261
|
-
console.debug(`Set Noise type to ${type}.`);
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* return true if in range, otherwise false
|
|
265
|
-
* @private
|
|
266
|
-
* @param x Target value
|
|
267
|
-
* @param min Minimum value
|
|
268
|
-
* @param max Maximum value
|
|
269
|
-
* @return
|
|
270
|
-
*/
|
|
271
|
-
inRange(x, min, max) {
|
|
272
|
-
return (x - min) * (x - max) <= 0;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Utility function for building an impulse response
|
|
276
|
-
* from the module parameters.
|
|
277
|
-
* @private
|
|
278
|
-
*/
|
|
279
|
-
buildImpulse() {
|
|
280
|
-
// インパルス応答生成ロジック
|
|
281
|
-
/** サンプリングレート */
|
|
282
|
-
const rate = this.ctx.sampleRate;
|
|
283
|
-
/** インパルス応答の演奏時間 */
|
|
284
|
-
const duration = Math.max(rate * this._options.time, 1);
|
|
285
|
-
/** インパルス応答が始まるまでの遅延時間 */
|
|
286
|
-
const delayDuration = rate * this._options.delay;
|
|
287
|
-
/** インパルス応答バッファ(今の所ステレオのみ) */
|
|
288
|
-
const impulse = this.ctx.createBuffer(2, duration, rate);
|
|
289
|
-
/** 左チャンネル */
|
|
290
|
-
const impulseL = new Float32Array(duration);
|
|
291
|
-
/** 右チャンネル*/
|
|
292
|
-
const impulseR = new Float32Array(duration);
|
|
293
|
-
/** 一時計算用 */
|
|
294
|
-
const b = [0, 0, 0, 0, 0, 0, 0];
|
|
295
|
-
for (let i = 0; i < duration; i++) {
|
|
296
|
-
/** @type {number} 減衰率 */
|
|
297
|
-
let n = 0;
|
|
298
|
-
if (i < delayDuration) {
|
|
299
|
-
// Delay Effect
|
|
300
|
-
impulseL[i] = 0;
|
|
301
|
-
impulseR[i] = 0;
|
|
302
|
-
n = this._options.reverse
|
|
303
|
-
? duration - (i - delayDuration)
|
|
304
|
-
: i - delayDuration;
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
n = this._options.reverse ? duration - i : i;
|
|
308
|
-
}
|
|
309
|
-
switch (this._options.noise) {
|
|
310
|
-
default:
|
|
311
|
-
case NoiseType_1.NoiseType.WHITE:
|
|
312
|
-
// White Noise
|
|
313
|
-
impulseL[i] = Reverb.whiteNoise();
|
|
314
|
-
impulseR[i] = Reverb.whiteNoise();
|
|
315
|
-
break;
|
|
316
|
-
case NoiseType_1.NoiseType.PINK:
|
|
317
|
-
// ピンクノイズ生成処理
|
|
318
|
-
// http://noisehack.com/generate-noise-web-audio-api/
|
|
319
|
-
b[0] = 0.99886 * b[0] + Reverb.whiteNoise() * 0.0555179;
|
|
320
|
-
b[1] = 0.99332 * b[1] + Reverb.whiteNoise() * 0.0750759;
|
|
321
|
-
b[2] = 0.969 * b[2] + Reverb.whiteNoise() * 0.153852;
|
|
322
|
-
b[3] = 0.8665 * b[3] + Reverb.whiteNoise() * 0.3104856;
|
|
323
|
-
b[4] = 0.55 * b[4] + Reverb.whiteNoise() * 0.5329522;
|
|
324
|
-
b[5] = -0.7616 * b[5] - Reverb.whiteNoise() * 0.016898;
|
|
325
|
-
impulseL[i] =
|
|
326
|
-
b[0] +
|
|
327
|
-
b[1] +
|
|
328
|
-
b[2] +
|
|
329
|
-
b[3] +
|
|
330
|
-
b[4] +
|
|
331
|
-
b[5] +
|
|
332
|
-
b[6] +
|
|
333
|
-
Reverb.whiteNoise() * 0.5362;
|
|
334
|
-
impulseR[i] =
|
|
335
|
-
b[0] +
|
|
336
|
-
b[1] +
|
|
337
|
-
b[2] +
|
|
338
|
-
b[3] +
|
|
339
|
-
b[4] +
|
|
340
|
-
b[5] +
|
|
341
|
-
b[6] +
|
|
342
|
-
Reverb.whiteNoise() * 0.5362;
|
|
343
|
-
// ゲイン補償処理
|
|
344
|
-
impulseL[i] *= 0.11;
|
|
345
|
-
impulseR[i] *= 0.11;
|
|
346
|
-
b[6] = Reverb.whiteNoise() * 0.115926;
|
|
347
|
-
break;
|
|
348
|
-
case NoiseType_1.NoiseType.BROWN:
|
|
349
|
-
// ブラウンノイズ生成処理
|
|
350
|
-
impulseL[i] = (b[0] + 0.02 * Reverb.whiteNoise()) / 1.02;
|
|
351
|
-
b[0] = impulseL[i];
|
|
352
|
-
impulseR[i] = (b[1] + 0.02 * Reverb.whiteNoise()) / 1.02;
|
|
353
|
-
b[1] = impulseR[i];
|
|
354
|
-
// ゲイン補償処理
|
|
355
|
-
impulseL[i] *= 3.5;
|
|
356
|
-
impulseR[i] *= 3.5;
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
// 音を減衰させる
|
|
360
|
-
impulseL[i] *= (1 - n / duration) ** this._options.decay;
|
|
361
|
-
impulseR[i] *= (1 - n / duration) ** this._options.decay;
|
|
362
|
-
}
|
|
363
|
-
// インパルス応答のバッファに生成したWaveTableを代入
|
|
364
|
-
impulse.getChannelData(0).set(impulseL);
|
|
365
|
-
impulse.getChannelData(1).set(impulseR);
|
|
366
|
-
this.convolverNode.buffer = impulse;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Generate white noise
|
|
370
|
-
*/
|
|
371
|
-
static whiteNoise() {
|
|
372
|
-
// TODO: この乱数は本当に偏り無いのだろうか?
|
|
373
|
-
return Math.random() * 2 - 1;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
exports["default"] = Reverb;
|
|
377
|
-
/**
|
|
378
|
-
* デフォルト値
|
|
379
|
-
*/
|
|
380
|
-
const optionDefaults = {
|
|
381
|
-
noise: NoiseType_1.NoiseType.WHITE,
|
|
382
|
-
decay: 2,
|
|
383
|
-
delay: 0,
|
|
384
|
-
reverse: false,
|
|
385
|
-
time: 1.1,
|
|
386
|
-
filterType: 'lowpass',
|
|
387
|
-
filterFreq: 2200,
|
|
388
|
-
filterQ: 1,
|
|
389
|
-
mix: 0.5,
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
/***/ })
|
|
394
|
-
|
|
395
|
-
/******/ });
|
|
396
|
-
/************************************************************************/
|
|
397
|
-
/******/ // The module cache
|
|
398
|
-
/******/ var __webpack_module_cache__ = {};
|
|
399
|
-
/******/
|
|
400
|
-
/******/ // The require function
|
|
401
|
-
/******/ function __webpack_require__(moduleId) {
|
|
402
|
-
/******/ // Check if module is in cache
|
|
403
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
404
|
-
/******/ if (cachedModule !== undefined) {
|
|
405
|
-
/******/ return cachedModule.exports;
|
|
406
|
-
/******/ }
|
|
407
|
-
/******/ // Create a new module (and put it into the cache)
|
|
408
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
409
|
-
/******/ // no module.id needed
|
|
410
|
-
/******/ // no module.loaded needed
|
|
411
|
-
/******/ exports: {}
|
|
412
|
-
/******/ };
|
|
413
|
-
/******/
|
|
414
|
-
/******/ // Execute the module function
|
|
415
|
-
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
416
|
-
/******/
|
|
417
|
-
/******/ // Return the exports of the module
|
|
418
|
-
/******/ return module.exports;
|
|
419
|
-
/******/ }
|
|
420
|
-
/******/
|
|
421
|
-
/************************************************************************/
|
|
422
|
-
/******/
|
|
423
|
-
/******/ // startup
|
|
424
|
-
/******/ // Load entry module and return exports
|
|
425
|
-
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
426
|
-
/******/ var __webpack_exports__ = __webpack_require__("./src/Reverb.ts");
|
|
427
|
-
/******/
|
|
428
|
-
/******/ return __webpack_exports__;
|
|
429
|
-
/******/ })()
|
|
430
|
-
;
|
|
431
|
-
});
|
|
432
|
-
//# sourceMappingURL=reverb.js.map
|
package/docs/reverb.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://Reverb/webpack/universalModuleDefinition","webpack://Reverb/./src/Meta.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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C;YAClC,MAAM,GAAG,GAAW,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC9D,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC;YACpC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC;SACrC;QAED,gCAAgC;QAChC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAExC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,OAAO,CAAC;IACtC,CAAC;IACD;;;;;OAKG;IACK,QAAQ;QACd,2BAA2B;QAC3B,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF;AA7QD,yBA6QC;AAED;;GAEG;AACH,MAAM,cAAc,GAAoB;IACtC,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,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;;;;;;;UCvSF;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;UCrBA;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.3.1',\n date: '2020-12-23T05:51:29.106Z',\n};\nexport default meta;\n","import Meta from './Meta';\nimport OptionInterface from './interfaces/OptionInterface';\n\n/**\n * JS reverb effect class\n *\n * @author Logue <logue@hotmail.co.jp>\n * @copyright 2019-2020 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 /** @type {string} バージョン */\n public readonly version: string;\n /** @type {string} ビルド日時 */\n public readonly build: string;\n /** @type {AudioContext} AudioContext */\n private readonly ctx: AudioContext;\n /** @type {GainNode} ウェットレベル(エフェクターをかけたレベル) */\n private readonly wetGainNode: GainNode;\n /** @type {GainNode} ドライレベル(原音レベル) */\n private readonly dryGainNode: GainNode;\n /** @type {BiquadFilterNode} インパルス応答用フィルタ */\n private readonly filterNode: BiquadFilterNode;\n /** @type {ConvolverNode} 畳み込みノード */\n private readonly convolverNode: ConvolverNode;\n /** @type {GainNode} 出力ノード */\n private readonly outputNode: GainNode;\n /** @type {Option} 変数 */\n private readonly _options: OptionInterface;\n /** @type {boolean} 接続済みフラグ */\n private isConnected: boolean;\n\n /**\n * constructor\n * @param {AudioContext} ctx Root AudioContext\n * @param {OptionInterface} 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 {AudioNode} sourceNode 原音ノード\n * @return {AudioNode}\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 {AudioNode} sourceNode 原音のノード\n * @return {AudioNode}\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 {number} 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 {number} 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 {number} 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 {number} 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 {boolean} 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 {BiquadFilterType} 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 {number} 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 {number} 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 * return true if in range, otherwise false\n * @private\n * @param {number} x Target value\n * @param {number} min Minimum value\n * @param {number} max Maximum value\n * @return {bool}\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 /** @type {number} サンプリングレート */\n const rate: number = this.ctx.sampleRate;\n /** @type {number} インパルス応答の演奏時間 */\n const duration: number = Math.max(rate * this._options.time, 1);\n /** @type {number} インパルス応答が始まるまでの遅延時間 */\n const delayDuration: number = rate * this._options.delay;\n /** @type {AudioBuffer} インパルス応答バッファ(今の所ステレオのみ) */\n const impulse: AudioBuffer = this.ctx.createBuffer(2, duration, rate);\n /** @type {Array<number>|ArrayBufferView} 左チャンネル */\n const impulseL: Float32Array = new Float32Array(duration);\n /** @type {Array<number>|ArrayBufferView} 右チャンネル*/\n const impulseR: Float32Array = new Float32Array(duration);\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 /** @type {number} 平方根を利用した減衰曲線 */\n const pow: number = (1 - n / duration) ** this._options.decay;\n impulseL[i] = this.getNoise() * pow;\n impulseR[i] = this.getNoise() * pow;\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 * @param {number} rate Attenuation rate\n * @return {number}\n * @private\n */\n private getNoise(): number {\n // TODO: 他のカラードノイズを指定できるように\n return Math.random() * 2 - 1;\n }\n}\n\n/**\n * デフォルト値\n */\nconst optionDefaults: OptionInterface = {\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\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].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](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(\"./src/Reverb.ts\");\n"],"sourceRoot":""}
|
package/src/Meta.ts
DELETED