@ylink-sdk/mobile-web 0.1.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/dist/adapter-latest.js +4198 -0
- package/dist/protobuf.min.js +3979 -0
- package/dist/style.css +1 -0
- package/dist/web-audio-api-shim-light.js +1253 -0
- package/dist/ylink-sdk-mobile.umd.js +79 -0
- package/index.d.ts +92 -0
- package/index.js +3 -0
- package/package.json +56 -0
|
@@ -0,0 +1,1253 @@
|
|
|
1
|
+
(function e(t, n, r) {
|
|
2
|
+
function s(o, u) {
|
|
3
|
+
if (!n[o]) {
|
|
4
|
+
if (!t[o]) {
|
|
5
|
+
var a = typeof require == 'function' && require;
|
|
6
|
+
if (!u && a) return a(o, !0);
|
|
7
|
+
if (i) return i(o, !0);
|
|
8
|
+
var f = new Error("Cannot find module '" + o + "'");
|
|
9
|
+
throw ((f.code = 'MODULE_NOT_FOUND'), f);
|
|
10
|
+
}
|
|
11
|
+
var l = (n[o] = { exports: {} });
|
|
12
|
+
t[o][0].call(
|
|
13
|
+
l.exports,
|
|
14
|
+
function (e) {
|
|
15
|
+
var n = t[o][1][e];
|
|
16
|
+
return s(n ? n : e);
|
|
17
|
+
},
|
|
18
|
+
l,
|
|
19
|
+
l.exports,
|
|
20
|
+
e,
|
|
21
|
+
t,
|
|
22
|
+
n,
|
|
23
|
+
r
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return n[o].exports;
|
|
27
|
+
}
|
|
28
|
+
var i = typeof require == 'function' && require;
|
|
29
|
+
for (var o = 0; o < r.length; o++) s(r[o]);
|
|
30
|
+
return s;
|
|
31
|
+
})(
|
|
32
|
+
{
|
|
33
|
+
1: [
|
|
34
|
+
function (require, module, exports) {
|
|
35
|
+
(function (global) {
|
|
36
|
+
'use strict';
|
|
37
|
+
|
|
38
|
+
Object.defineProperty(exports, '__esModule', {
|
|
39
|
+
value: true
|
|
40
|
+
});
|
|
41
|
+
exports.install = install;
|
|
42
|
+
var AnalyserNode = global.AnalyserNode;
|
|
43
|
+
|
|
44
|
+
function installGetFloatTimeDomainData() {
|
|
45
|
+
if (AnalyserNode.prototype.hasOwnProperty('getFloatTimeDomainData')) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var uint8 = new Uint8Array(2048);
|
|
50
|
+
|
|
51
|
+
//// ### AnalyserNode.prototype.getFloatTimeDomainData
|
|
52
|
+
//// Copies the current time-domain (waveform) data into the passed floating-point array.
|
|
53
|
+
////
|
|
54
|
+
//// #### Parameters
|
|
55
|
+
//// - `array: Float32Array`
|
|
56
|
+
//// - This parameter is where the time-domain sample data will be copied.
|
|
57
|
+
////
|
|
58
|
+
//// #### Return
|
|
59
|
+
//// - `void`
|
|
60
|
+
AnalyserNode.prototype.getFloatTimeDomainData = function (array) {
|
|
61
|
+
this.getByteTimeDomainData(uint8);
|
|
62
|
+
for (var i = 0, imax = array.length; i < imax; i++) {
|
|
63
|
+
array[i] = (uint8[i] - 128) * 0.0078125;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function install() {
|
|
69
|
+
installGetFloatTimeDomainData();
|
|
70
|
+
}
|
|
71
|
+
}.call(
|
|
72
|
+
this,
|
|
73
|
+
typeof global !== 'undefined'
|
|
74
|
+
? global
|
|
75
|
+
: typeof self !== 'undefined'
|
|
76
|
+
? self
|
|
77
|
+
: typeof window !== 'undefined'
|
|
78
|
+
? window
|
|
79
|
+
: {}
|
|
80
|
+
));
|
|
81
|
+
},
|
|
82
|
+
{}
|
|
83
|
+
],
|
|
84
|
+
2: [
|
|
85
|
+
function (require, module, exports) {
|
|
86
|
+
(function (global) {
|
|
87
|
+
'use strict';
|
|
88
|
+
|
|
89
|
+
Object.defineProperty(exports, '__esModule', {
|
|
90
|
+
value: true
|
|
91
|
+
});
|
|
92
|
+
exports.install = install;
|
|
93
|
+
var AudioBuffer = global.AudioBuffer;
|
|
94
|
+
|
|
95
|
+
function installCopyFromChannel() {
|
|
96
|
+
if (AudioBuffer.prototype.hasOwnProperty('copyFromChannel')) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//// ### AudioBuffer.prototype.copyFromChannel
|
|
101
|
+
//// The `copyFromChannel` method copies the samples from the specified channel of the **`AudioBuffer`** to the `destination` array.
|
|
102
|
+
////
|
|
103
|
+
//// #### Parameters
|
|
104
|
+
//// - `destination: Float32Array`
|
|
105
|
+
//// - The array the channel data will be copied to.
|
|
106
|
+
//// - `channelNumber: number`
|
|
107
|
+
//// - The index of the channel to copy the data from.
|
|
108
|
+
//// - `startInChannel: number = 0`
|
|
109
|
+
//// - An optional offset to copy the data from.
|
|
110
|
+
////
|
|
111
|
+
//// #### Return
|
|
112
|
+
//// - `void`
|
|
113
|
+
AudioBuffer.prototype.copyFromChannel = function (
|
|
114
|
+
destination,
|
|
115
|
+
channelNumber,
|
|
116
|
+
startInChannel
|
|
117
|
+
) {
|
|
118
|
+
var source = this.getChannelData(channelNumber | 0).subarray(startInChannel | 0);
|
|
119
|
+
|
|
120
|
+
destination.set(source.subarray(0, Math.min(source.length, destination.length)));
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function installCopyToChannel() {
|
|
125
|
+
if (AudioBuffer.prototype.hasOwnProperty('copyToChannel')) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//// ### AudioBuffer.prototype.copyToChannel
|
|
130
|
+
//// The `copyToChannel` method copies the samples to the specified channel of the **`AudioBuffer`**, from the `source` array.
|
|
131
|
+
////
|
|
132
|
+
//// #### Parameters
|
|
133
|
+
//// - `source: Float32Array`
|
|
134
|
+
//// - The array the channel data will be copied from.
|
|
135
|
+
//// - `channelNumber: number`
|
|
136
|
+
//// - The index of the channel to copy the data to.
|
|
137
|
+
//// - `startInChannel: number = 0`
|
|
138
|
+
//// - An optional offset to copy the data to.
|
|
139
|
+
////
|
|
140
|
+
//// #### Return
|
|
141
|
+
//// - `void`
|
|
142
|
+
AudioBuffer.prototype.copyToChannel = function (source, channelNumber, startInChannel) {
|
|
143
|
+
var clipped = source.subarray(
|
|
144
|
+
0,
|
|
145
|
+
Math.min(source.length, this.length - (startInChannel | 0))
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
this.getChannelData(channelNumber | 0).set(clipped, startInChannel | 0);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function install() {
|
|
153
|
+
installCopyFromChannel();
|
|
154
|
+
installCopyToChannel();
|
|
155
|
+
}
|
|
156
|
+
}.call(
|
|
157
|
+
this,
|
|
158
|
+
typeof global !== 'undefined'
|
|
159
|
+
? global
|
|
160
|
+
: typeof self !== 'undefined'
|
|
161
|
+
? self
|
|
162
|
+
: typeof window !== 'undefined'
|
|
163
|
+
? window
|
|
164
|
+
: {}
|
|
165
|
+
));
|
|
166
|
+
},
|
|
167
|
+
{}
|
|
168
|
+
],
|
|
169
|
+
3: [
|
|
170
|
+
function (require, module, exports) {
|
|
171
|
+
(function (global) {
|
|
172
|
+
'use strict';
|
|
173
|
+
|
|
174
|
+
Object.defineProperty(exports, '__esModule', {
|
|
175
|
+
value: true
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
var _createClass = (function () {
|
|
179
|
+
function defineProperties(target, props) {
|
|
180
|
+
for (var i = 0; i < props.length; i++) {
|
|
181
|
+
var descriptor = props[i];
|
|
182
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
183
|
+
descriptor.configurable = true;
|
|
184
|
+
if ('value' in descriptor) descriptor.writable = true;
|
|
185
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return function (Constructor, protoProps, staticProps) {
|
|
189
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
190
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
191
|
+
return Constructor;
|
|
192
|
+
};
|
|
193
|
+
})();
|
|
194
|
+
|
|
195
|
+
var _get = function get(_x, _x2, _x3) {
|
|
196
|
+
var _again = true;
|
|
197
|
+
_function: while (_again) {
|
|
198
|
+
var object = _x,
|
|
199
|
+
property = _x2,
|
|
200
|
+
receiver = _x3;
|
|
201
|
+
desc = parent = getter = undefined;
|
|
202
|
+
_again = false;
|
|
203
|
+
if (object === null) object = Function.prototype;
|
|
204
|
+
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
205
|
+
if (desc === undefined) {
|
|
206
|
+
var parent = Object.getPrototypeOf(object);
|
|
207
|
+
if (parent === null) {
|
|
208
|
+
return undefined;
|
|
209
|
+
} else {
|
|
210
|
+
_x = parent;
|
|
211
|
+
_x2 = property;
|
|
212
|
+
_x3 = receiver;
|
|
213
|
+
_again = true;
|
|
214
|
+
continue _function;
|
|
215
|
+
}
|
|
216
|
+
} else if ('value' in desc) {
|
|
217
|
+
return desc.value;
|
|
218
|
+
} else {
|
|
219
|
+
var getter = desc.get;
|
|
220
|
+
if (getter === undefined) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
return getter.call(receiver);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
exports.install = install;
|
|
229
|
+
|
|
230
|
+
function _classCallCheck(instance, Constructor) {
|
|
231
|
+
if (!(instance instanceof Constructor)) {
|
|
232
|
+
throw new TypeError('Cannot call a class as a function');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function _inherits(subClass, superClass) {
|
|
237
|
+
if (typeof superClass !== 'function' && superClass !== null) {
|
|
238
|
+
throw new TypeError(
|
|
239
|
+
'Super expression must either be null or a function, not ' + typeof superClass
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
243
|
+
constructor: {
|
|
244
|
+
value: subClass,
|
|
245
|
+
enumerable: false,
|
|
246
|
+
writable: true,
|
|
247
|
+
configurable: true
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
if (superClass) subClass.__proto__ = superClass;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
var OriginalAudioContext = global.AudioContext;
|
|
254
|
+
var OriginalOfflineAudioContext = global.OfflineAudioContext;
|
|
255
|
+
var AudioNode = global.AudioNode;
|
|
256
|
+
var EventTarget = global.EventTarget || global.Object.constructor;
|
|
257
|
+
|
|
258
|
+
function nop() {}
|
|
259
|
+
|
|
260
|
+
function inherits(ctor, superCtor) {
|
|
261
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
262
|
+
constructor: { value: ctor, enumerable: false, writable: true, configurable: true }
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function replaceAudioContext() {
|
|
267
|
+
if (global.AudioContext !== OriginalAudioContext) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function BaseAudioContext(audioContext) {
|
|
272
|
+
this._ = {};
|
|
273
|
+
this._.audioContext = audioContext;
|
|
274
|
+
this._.destination = audioContext.destination;
|
|
275
|
+
this._.state = '';
|
|
276
|
+
this._.currentTime = 0;
|
|
277
|
+
this._.sampleRate = audioContext.sampleRate;
|
|
278
|
+
this._.onstatechange = null;
|
|
279
|
+
}
|
|
280
|
+
inherits(BaseAudioContext, EventTarget);
|
|
281
|
+
|
|
282
|
+
Object.defineProperties(BaseAudioContext.prototype, {
|
|
283
|
+
destination: {
|
|
284
|
+
get: function get() {
|
|
285
|
+
return this._.destination;
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
sampleRate: {
|
|
289
|
+
get: function get() {
|
|
290
|
+
return this._.sampleRate;
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
currentTime: {
|
|
294
|
+
get: function get() {
|
|
295
|
+
return this._.currentTime || this._.audioContext.currentTime;
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
listener: {
|
|
299
|
+
get: function get() {
|
|
300
|
+
return this._.audioContext.listener;
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
state: {
|
|
304
|
+
get: function get() {
|
|
305
|
+
return this._.state;
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
onstatechange: {
|
|
309
|
+
set: function set(fn) {
|
|
310
|
+
if (typeof fn === 'function') {
|
|
311
|
+
this._.onstatechange = fn;
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
get: function get() {
|
|
315
|
+
return this._.onstatechange;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
var AudioContext = (function (_BaseAudioContext) {
|
|
321
|
+
function AudioContext() {
|
|
322
|
+
_classCallCheck(this, AudioContext);
|
|
323
|
+
|
|
324
|
+
_get(Object.getPrototypeOf(AudioContext.prototype), 'constructor', this).call(
|
|
325
|
+
this,
|
|
326
|
+
new OriginalAudioContext()
|
|
327
|
+
);
|
|
328
|
+
this._.state = 'running';
|
|
329
|
+
|
|
330
|
+
if (!OriginalAudioContext.prototype.hasOwnProperty('suspend')) {
|
|
331
|
+
this._.destination = this._.audioContext.createGain();
|
|
332
|
+
this._.destination.connect(this._.audioContext.destination);
|
|
333
|
+
this._.destination.connect = function () {
|
|
334
|
+
this._.audioContext.destination.connect.apply(
|
|
335
|
+
this._.audioContext.destination,
|
|
336
|
+
arguments
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
this._.destination.disconnect = function () {
|
|
340
|
+
this._.audioContext.destination.connect.apply(
|
|
341
|
+
this._.audioContext.destination,
|
|
342
|
+
arguments
|
|
343
|
+
);
|
|
344
|
+
};
|
|
345
|
+
this._.destination.channelCountMode = 'explicit';
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
_inherits(AudioContext, _BaseAudioContext);
|
|
350
|
+
|
|
351
|
+
return AudioContext;
|
|
352
|
+
})(BaseAudioContext);
|
|
353
|
+
|
|
354
|
+
AudioContext.prototype.suspend = function () {
|
|
355
|
+
var _this = this;
|
|
356
|
+
|
|
357
|
+
if (this._.state === 'closed') {
|
|
358
|
+
return Promise.reject(new Error('cannot suspend a closed AudioContext'));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function changeState() {
|
|
362
|
+
this._.state = 'suspended';
|
|
363
|
+
this._.currentTime = this._.audioContext.currentTime;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
var promise = undefined;
|
|
367
|
+
|
|
368
|
+
if (typeof this._.audioContext === 'function') {
|
|
369
|
+
promise = this._.audioContext.suspend();
|
|
370
|
+
promise.then(function () {
|
|
371
|
+
changeState.call(_this);
|
|
372
|
+
});
|
|
373
|
+
} else {
|
|
374
|
+
AudioNode.prototype.disconnect.call(this._.destination);
|
|
375
|
+
|
|
376
|
+
promise = Promise.resolve();
|
|
377
|
+
promise.then(function () {
|
|
378
|
+
changeState.call(_this);
|
|
379
|
+
|
|
380
|
+
var e = new global.Event('statechange');
|
|
381
|
+
|
|
382
|
+
if (typeof _this._.onstatechange === 'function') {
|
|
383
|
+
_this._.onstatechange(e);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
_this.dispatchEvent(e);
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return promise;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
AudioContext.prototype.resume = function () {
|
|
394
|
+
var _this2 = this;
|
|
395
|
+
|
|
396
|
+
if (this._.state === 'closed') {
|
|
397
|
+
return Promise.reject(new Error('cannot resume a closed AudioContext'));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function changeState() {
|
|
401
|
+
this._.state = 'running';
|
|
402
|
+
this._.currentTime = 0;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
var promise = undefined;
|
|
406
|
+
|
|
407
|
+
if (typeof this._.audioContext.resume === 'function') {
|
|
408
|
+
promise = this._.audioContext.resume();
|
|
409
|
+
promise.then(function () {
|
|
410
|
+
changeState.call(_this2);
|
|
411
|
+
});
|
|
412
|
+
} else {
|
|
413
|
+
AudioNode.prototype.connect.call(
|
|
414
|
+
this._.destination,
|
|
415
|
+
this._.audioContext.destination
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
promise = Promise.resolve();
|
|
419
|
+
promise.then(function () {
|
|
420
|
+
changeState.call(_this2);
|
|
421
|
+
|
|
422
|
+
var e = new global.Event('statechange');
|
|
423
|
+
|
|
424
|
+
if (typeof _this2._.onstatechange === 'function') {
|
|
425
|
+
_this2._.onstatechange(e);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
_this2.dispatchEvent(e);
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return promise;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
AudioContext.prototype.close = function () {
|
|
436
|
+
var _this3 = this;
|
|
437
|
+
|
|
438
|
+
if (this._.state === 'closed') {
|
|
439
|
+
return Promise.reject(
|
|
440
|
+
new Error(
|
|
441
|
+
'Cannot close a context that is being closed or has already been closed.'
|
|
442
|
+
)
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function changeState() {
|
|
447
|
+
this._.state = 'closed';
|
|
448
|
+
this._.currentTime = Infinity;
|
|
449
|
+
this._.sampleRate = 0;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
var promise = undefined;
|
|
453
|
+
|
|
454
|
+
if (typeof this._.audioContext.close === 'function') {
|
|
455
|
+
promise = this._.audioContext.close();
|
|
456
|
+
promise.then(function () {
|
|
457
|
+
changeState.call(_this3);
|
|
458
|
+
});
|
|
459
|
+
} else {
|
|
460
|
+
if (typeof this._.audioContext.suspend === 'function') {
|
|
461
|
+
this._.audioContext.suspend();
|
|
462
|
+
} else {
|
|
463
|
+
AudioNode.prototype.disconnect.call(this._.destination);
|
|
464
|
+
}
|
|
465
|
+
promise = Promise.resolve();
|
|
466
|
+
|
|
467
|
+
promise.then(function () {
|
|
468
|
+
changeState.call(_this3);
|
|
469
|
+
|
|
470
|
+
var e = new global.Event('statechange');
|
|
471
|
+
|
|
472
|
+
if (typeof _this3._.onstatechange === 'function') {
|
|
473
|
+
_this3._.onstatechange(e);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
_this3.dispatchEvent(e);
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return promise;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
['addEventListener', 'removeEventListener', 'dispatchEvent', 'createBuffer'].forEach(
|
|
484
|
+
function (methodName) {
|
|
485
|
+
AudioContext.prototype[methodName] = function () {
|
|
486
|
+
return this._.audioContext[methodName].apply(this._.audioContext, arguments);
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
[
|
|
492
|
+
'decodeAudioData',
|
|
493
|
+
'createBufferSource',
|
|
494
|
+
'createMediaElementSource',
|
|
495
|
+
'createMediaStreamSource',
|
|
496
|
+
'createMediaStreamDestination',
|
|
497
|
+
'createAudioWorker',
|
|
498
|
+
'createScriptProcessor',
|
|
499
|
+
'createAnalyser',
|
|
500
|
+
'createGain',
|
|
501
|
+
'createDelay',
|
|
502
|
+
'createBiquadFilter',
|
|
503
|
+
'createWaveShaper',
|
|
504
|
+
'createPanner',
|
|
505
|
+
'createStereoPanner',
|
|
506
|
+
'createConvolver',
|
|
507
|
+
'createChannelSplitter',
|
|
508
|
+
'createChannelMerger',
|
|
509
|
+
'createDynamicsCompressor',
|
|
510
|
+
'createOscillator',
|
|
511
|
+
'createPeriodicWave'
|
|
512
|
+
].forEach(function (methodName) {
|
|
513
|
+
AudioContext.prototype[methodName] = function () {
|
|
514
|
+
if (this._.state === 'closed') {
|
|
515
|
+
throw new Error(
|
|
516
|
+
"Failed to execute '" +
|
|
517
|
+
methodName +
|
|
518
|
+
"' on 'AudioContext': AudioContext has been closed"
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
return this._.audioContext[methodName].apply(this._.audioContext, arguments);
|
|
522
|
+
};
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
var OfflineAudioContext = (function (_BaseAudioContext2) {
|
|
526
|
+
function OfflineAudioContext(numberOfChannels, length, sampleRate) {
|
|
527
|
+
_classCallCheck(this, OfflineAudioContext);
|
|
528
|
+
|
|
529
|
+
_get(
|
|
530
|
+
Object.getPrototypeOf(OfflineAudioContext.prototype),
|
|
531
|
+
'constructor',
|
|
532
|
+
this
|
|
533
|
+
).call(this, new OriginalOfflineAudioContext(numberOfChannels, length, sampleRate));
|
|
534
|
+
this._.state = 'suspended';
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
_inherits(OfflineAudioContext, _BaseAudioContext2);
|
|
538
|
+
|
|
539
|
+
_createClass(OfflineAudioContext, [
|
|
540
|
+
{
|
|
541
|
+
key: 'oncomplete',
|
|
542
|
+
set: function set(fn) {
|
|
543
|
+
this._.audioContext.oncomplete = fn;
|
|
544
|
+
},
|
|
545
|
+
get: function get() {
|
|
546
|
+
return this._.audioContext.oncomplete;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
]);
|
|
550
|
+
|
|
551
|
+
return OfflineAudioContext;
|
|
552
|
+
})(BaseAudioContext);
|
|
553
|
+
|
|
554
|
+
[
|
|
555
|
+
'addEventListener',
|
|
556
|
+
'removeEventListener',
|
|
557
|
+
'dispatchEvent',
|
|
558
|
+
'createBuffer',
|
|
559
|
+
'decodeAudioData',
|
|
560
|
+
'createBufferSource',
|
|
561
|
+
'createMediaElementSource',
|
|
562
|
+
'createMediaStreamSource',
|
|
563
|
+
'createMediaStreamDestination',
|
|
564
|
+
'createAudioWorker',
|
|
565
|
+
'createScriptProcessor',
|
|
566
|
+
'createAnalyser',
|
|
567
|
+
'createGain',
|
|
568
|
+
'createDelay',
|
|
569
|
+
'createBiquadFilter',
|
|
570
|
+
'createWaveShaper',
|
|
571
|
+
'createPanner',
|
|
572
|
+
'createStereoPanner',
|
|
573
|
+
'createConvolver',
|
|
574
|
+
'createChannelSplitter',
|
|
575
|
+
'createChannelMerger',
|
|
576
|
+
'createDynamicsCompressor',
|
|
577
|
+
'createOscillator',
|
|
578
|
+
'createPeriodicWave'
|
|
579
|
+
].forEach(function (methodName) {
|
|
580
|
+
OfflineAudioContext.prototype[methodName] = function () {
|
|
581
|
+
return this._.audioContext[methodName].apply(this._.audioContext, arguments);
|
|
582
|
+
};
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
OfflineAudioContext.prototype.startRendering = function () {
|
|
586
|
+
var _this4 = this;
|
|
587
|
+
|
|
588
|
+
if (this._.state !== 'suspended') {
|
|
589
|
+
return Promise.reject(new Error('cannot call startRendering more than once'));
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
this._.state = 'running';
|
|
593
|
+
|
|
594
|
+
var promise = this._.audioContext.startRendering();
|
|
595
|
+
|
|
596
|
+
promise.then(function () {
|
|
597
|
+
_this4._.state = 'closed';
|
|
598
|
+
|
|
599
|
+
var e = new global.Event('statechange');
|
|
600
|
+
|
|
601
|
+
if (typeof _this4._.onstatechange === 'function') {
|
|
602
|
+
_this4._.onstatechange(e);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
_this4.dispatchEvent(e);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
return promise;
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
OfflineAudioContext.prototype.suspend = function () {
|
|
612
|
+
if (typeof this._.audioContext.suspend === 'function') {
|
|
613
|
+
return this._.audioContext.suspend();
|
|
614
|
+
}
|
|
615
|
+
return Promise.reject(new Error('cannot suspend an OfflineAudioContext'));
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
OfflineAudioContext.prototype.resume = function () {
|
|
619
|
+
if (typeof this._.audioContext.resume === 'function') {
|
|
620
|
+
return this._.audioContext.resume();
|
|
621
|
+
}
|
|
622
|
+
return Promise.reject(new Error('cannot resume an OfflineAudioContext'));
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
OfflineAudioContext.prototype.close = function () {
|
|
626
|
+
if (typeof this._.audioContext.close === 'function') {
|
|
627
|
+
return this._.audioContext.close();
|
|
628
|
+
}
|
|
629
|
+
return Promise.reject(new Error('cannot close an OfflineAudioContext'));
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
global.AudioContext = AudioContext;
|
|
633
|
+
global.OfflineAudioContext = OfflineAudioContext;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function installCreateAudioWorker() {}
|
|
637
|
+
|
|
638
|
+
function installCreateStereoPanner() {
|
|
639
|
+
if (OriginalAudioContext.prototype.hasOwnProperty('createStereoPanner')) {
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
var StereoPannerNode = require('stereo-panner-node');
|
|
644
|
+
|
|
645
|
+
//// ### AudioContext.prototype.createStereoPanner
|
|
646
|
+
//// Creates a StereoPannerNode.
|
|
647
|
+
////
|
|
648
|
+
//// #### Parameters
|
|
649
|
+
//// - _none_
|
|
650
|
+
////
|
|
651
|
+
//// #### Return
|
|
652
|
+
//// - `AudioNode as StereoPannerNode`
|
|
653
|
+
OriginalAudioContext.prototype.createStereoPanner = function () {
|
|
654
|
+
return new StereoPannerNode(this);
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function installDecodeAudioData() {
|
|
659
|
+
var audioContext = new OriginalOfflineAudioContext(1, 1, 44100);
|
|
660
|
+
var isPromiseBased = false;
|
|
661
|
+
|
|
662
|
+
try {
|
|
663
|
+
var audioData = new Uint32Array([
|
|
664
|
+
1179011410, 48, 1163280727, 544501094, 16, 131073, 44100, 176400, 1048580,
|
|
665
|
+
1635017060, 8, 0, 0, 0, 0
|
|
666
|
+
]).buffer;
|
|
667
|
+
|
|
668
|
+
isPromiseBased = !!audioContext.decodeAudioData(audioData, nop);
|
|
669
|
+
} catch (e) {
|
|
670
|
+
nop(e);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if (isPromiseBased) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
var decodeAudioData = OriginalAudioContext.prototype.decodeAudioData;
|
|
678
|
+
|
|
679
|
+
//// ### AudioContext.prototype.decodeAudioData
|
|
680
|
+
//// Asynchronously decodes the audio file data contained in the ArrayBuffer.
|
|
681
|
+
////
|
|
682
|
+
//// #### Parameters
|
|
683
|
+
//// - `audioData: ArrayBuffer`
|
|
684
|
+
//// - An ArrayBuffer containing compressed audio data
|
|
685
|
+
//// - `successCallback: function = null`
|
|
686
|
+
//// - A callback function which will be invoked when the decoding is finished.
|
|
687
|
+
//// - `errorCallback: function = null`
|
|
688
|
+
//// - A callback function which will be invoked if there is an error decoding the audio file.
|
|
689
|
+
////
|
|
690
|
+
//// #### Return
|
|
691
|
+
//// - `Promise<AudioBuffer>`
|
|
692
|
+
OriginalAudioContext.prototype.decodeAudioData = function (
|
|
693
|
+
audioData,
|
|
694
|
+
successCallback,
|
|
695
|
+
errorCallback
|
|
696
|
+
) {
|
|
697
|
+
var _this5 = this;
|
|
698
|
+
|
|
699
|
+
var promise = new Promise(function (resolve, reject) {
|
|
700
|
+
return decodeAudioData.call(_this5, audioData, resolve, reject);
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
promise.then(successCallback, errorCallback);
|
|
704
|
+
|
|
705
|
+
return promise;
|
|
706
|
+
};
|
|
707
|
+
OriginalAudioContext.prototype.decodeAudioData.original = decodeAudioData;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function installClose() {
|
|
711
|
+
if (OriginalAudioContext.prototype.hasOwnProperty('close')) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
//// ### AudioContext.prototype.close
|
|
716
|
+
//// Closes the audio context, releasing any system audio resources used by the **`AudioContext`**.
|
|
717
|
+
////
|
|
718
|
+
//// #### Parameters
|
|
719
|
+
//// - _none_
|
|
720
|
+
////
|
|
721
|
+
//// #### Return
|
|
722
|
+
//// - `Promise<void>`
|
|
723
|
+
replaceAudioContext();
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function installResume() {
|
|
727
|
+
if (OriginalAudioContext.prototype.hasOwnProperty('resume')) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
//// ### AudioContext.prototype.suspend
|
|
732
|
+
//// Resumes the progression of time in an audio context that has been suspended, which may involve re-priming the frame buffer contents.
|
|
733
|
+
////
|
|
734
|
+
//// #### Parameters
|
|
735
|
+
//// - _none_
|
|
736
|
+
////
|
|
737
|
+
//// #### Return
|
|
738
|
+
//// - `Promise<void>`
|
|
739
|
+
replaceAudioContext();
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function installSuspend() {
|
|
743
|
+
if (OriginalAudioContext.prototype.hasOwnProperty('suspend')) {
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
//// ### AudioContext.prototype.suspend
|
|
748
|
+
//// Suspends the progression of time in the audio context, allows any current context processing blocks that are already processed to be played to the destination, and then allows the system to release its claim on audio hardware.
|
|
749
|
+
////
|
|
750
|
+
//// #### Parameters
|
|
751
|
+
//// - _none_
|
|
752
|
+
////
|
|
753
|
+
//// #### Return
|
|
754
|
+
//// - `Promise<void>`
|
|
755
|
+
replaceAudioContext();
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
function installStartRendering() {
|
|
759
|
+
var audioContext = new OriginalOfflineAudioContext(1, 1, 44100);
|
|
760
|
+
var isPromiseBased = false;
|
|
761
|
+
|
|
762
|
+
try {
|
|
763
|
+
isPromiseBased = !!audioContext.startRendering();
|
|
764
|
+
} catch (e) {
|
|
765
|
+
nop(e);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
if (isPromiseBased) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
var startRendering = OriginalOfflineAudioContext.prototype.startRendering;
|
|
773
|
+
|
|
774
|
+
//// ### OfflineAudioContext.prototype.startRendering
|
|
775
|
+
//// Given the current connections and scheduled changes, starts rendering audio.
|
|
776
|
+
////
|
|
777
|
+
//// #### Parameters
|
|
778
|
+
//// - _none_
|
|
779
|
+
////
|
|
780
|
+
//// #### Return
|
|
781
|
+
//// - `Promise<AudioBuffer>`
|
|
782
|
+
OriginalOfflineAudioContext.prototype.startRendering = function () {
|
|
783
|
+
var _this6 = this;
|
|
784
|
+
|
|
785
|
+
return new Promise(function (resolve) {
|
|
786
|
+
var oncomplete = _this6.oncomplete;
|
|
787
|
+
|
|
788
|
+
_this6.oncomplete = function (e) {
|
|
789
|
+
resolve(e.renderedBuffer);
|
|
790
|
+
if (typeof oncomplete === 'function') {
|
|
791
|
+
oncomplete.call(_this6, e);
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
startRendering.call(_this6);
|
|
795
|
+
});
|
|
796
|
+
};
|
|
797
|
+
OriginalOfflineAudioContext.prototype.startRendering.original = startRendering;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function install(stage) {
|
|
801
|
+
installCreateAudioWorker();
|
|
802
|
+
installCreateStereoPanner();
|
|
803
|
+
installDecodeAudioData();
|
|
804
|
+
installStartRendering();
|
|
805
|
+
|
|
806
|
+
if (stage !== 0) {
|
|
807
|
+
installClose();
|
|
808
|
+
installResume();
|
|
809
|
+
installSuspend();
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}.call(
|
|
813
|
+
this,
|
|
814
|
+
typeof global !== 'undefined'
|
|
815
|
+
? global
|
|
816
|
+
: typeof self !== 'undefined'
|
|
817
|
+
? self
|
|
818
|
+
: typeof window !== 'undefined'
|
|
819
|
+
? window
|
|
820
|
+
: {}
|
|
821
|
+
));
|
|
822
|
+
},
|
|
823
|
+
{ 'stereo-panner-node': 9 }
|
|
824
|
+
],
|
|
825
|
+
4: [
|
|
826
|
+
function (require, module, exports) {
|
|
827
|
+
(function (global) {
|
|
828
|
+
'use strict';
|
|
829
|
+
|
|
830
|
+
Object.defineProperty(exports, '__esModule', {
|
|
831
|
+
value: true
|
|
832
|
+
});
|
|
833
|
+
exports.install = install;
|
|
834
|
+
var OfflineAudioContext = global.OfflineAudioContext;
|
|
835
|
+
var AudioNode = global.AudioNode;
|
|
836
|
+
var connect = AudioNode.prototype.connect;
|
|
837
|
+
var disconnect = AudioNode.prototype.disconnect;
|
|
838
|
+
|
|
839
|
+
function match(args, connection) {
|
|
840
|
+
for (var i = 0, imax = args.length; i < imax; i++) {
|
|
841
|
+
if (args[i] !== connection[i]) {
|
|
842
|
+
return false;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return true;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function disconnectAll(node) {
|
|
849
|
+
for (var ch = 0, chmax = node.numberOfOutputs; ch < chmax; ch++) {
|
|
850
|
+
disconnect.call(node, ch);
|
|
851
|
+
}
|
|
852
|
+
node._shim$connections = [];
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
function disconnectChannel(node, channel) {
|
|
856
|
+
disconnect.call(node, channel);
|
|
857
|
+
node._shim$connections = node._shim$connections.filter(function (connection) {
|
|
858
|
+
return connection[1] !== channel;
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
function disconnectSelect(node, args) {
|
|
863
|
+
var remain = [];
|
|
864
|
+
var hasDestination = false;
|
|
865
|
+
|
|
866
|
+
node._shim$connections.forEach(function (connection) {
|
|
867
|
+
hasDestination = hasDestination || args[0] === connection[0];
|
|
868
|
+
if (!match(args, connection)) {
|
|
869
|
+
remain.push(connection);
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
if (!hasDestination) {
|
|
874
|
+
throw new Error(
|
|
875
|
+
"Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected."
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
disconnectAll(node);
|
|
880
|
+
|
|
881
|
+
remain.forEach(function (connection) {
|
|
882
|
+
connect.call(node, connection[0], connection[1], connection[2]);
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
node._shim$connections = remain;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
function installDisconnect() {
|
|
889
|
+
var audioContext = new OfflineAudioContext(1, 1, 44100);
|
|
890
|
+
var isSelectiveDisconnection = false;
|
|
891
|
+
|
|
892
|
+
try {
|
|
893
|
+
audioContext.createGain().disconnect(audioContext.destination);
|
|
894
|
+
} catch (e) {
|
|
895
|
+
isSelectiveDisconnection = true;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
if (isSelectiveDisconnection) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
//// ### AudioNode.prototype.disconnect
|
|
903
|
+
//// Disconnects all outgoing connections from **`AudioNode`**.
|
|
904
|
+
////
|
|
905
|
+
//// #### Parameters
|
|
906
|
+
//// - _none_
|
|
907
|
+
////
|
|
908
|
+
//// #### Return
|
|
909
|
+
//// - `void`
|
|
910
|
+
////
|
|
911
|
+
//// ### AudioNode.prototype.disconnect
|
|
912
|
+
//// #### Parameters
|
|
913
|
+
//// - `output: number`
|
|
914
|
+
//// - This parameter is an index describing which output of the AudioNode to disconnect.
|
|
915
|
+
////
|
|
916
|
+
//// #### Return
|
|
917
|
+
//// - `void`
|
|
918
|
+
////
|
|
919
|
+
//// ### AudioNode.prototype.disconnect
|
|
920
|
+
//// #### Parameters
|
|
921
|
+
//// - `destination: AudioNode|AudioParam`
|
|
922
|
+
//// - The destination parameter is the AudioNode/AudioParam to disconnect.
|
|
923
|
+
////
|
|
924
|
+
//// #### Return
|
|
925
|
+
//// - `void`
|
|
926
|
+
////
|
|
927
|
+
//// ### AudioNode.prototype.disconnect
|
|
928
|
+
//// #### Parameters
|
|
929
|
+
//// - `destination: AudioNode|AudioParam`
|
|
930
|
+
//// - The destination parameter is the AudioNode/AudioParam to disconnect.
|
|
931
|
+
//// - `output: number`
|
|
932
|
+
//// - The output parameter is an index describing which output of the AudioNode from which to disconnect.
|
|
933
|
+
////
|
|
934
|
+
//// #### Return
|
|
935
|
+
//// - `void`
|
|
936
|
+
////
|
|
937
|
+
//// ### AudioNode.prototype.disconnect
|
|
938
|
+
//// #### Parameters
|
|
939
|
+
//// - `destination: AudioNode`
|
|
940
|
+
//// - The destination parameter is the AudioNode to disconnect.
|
|
941
|
+
//// - `output: number`
|
|
942
|
+
//// - The output parameter is an index describing which output of the AudioNode from which to disconnect.
|
|
943
|
+
//// - `input: number`
|
|
944
|
+
//// - The input parameter is an index describing which input of the destination AudioNode to disconnect.
|
|
945
|
+
////
|
|
946
|
+
//// #### Return
|
|
947
|
+
//// - `void`
|
|
948
|
+
////
|
|
949
|
+
AudioNode.prototype.disconnect = function () {
|
|
950
|
+
this._shim$connections = this._shim$connections || [];
|
|
951
|
+
|
|
952
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
953
|
+
args[_key] = arguments[_key];
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
if (args.length === 0) {
|
|
957
|
+
disconnectAll(this);
|
|
958
|
+
} else if (args.length === 1 && typeof args[0] === 'number') {
|
|
959
|
+
disconnectChannel(this, args[0]);
|
|
960
|
+
} else {
|
|
961
|
+
disconnectSelect(this, args);
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
AudioNode.prototype.disconnect.original = disconnect;
|
|
965
|
+
|
|
966
|
+
AudioNode.prototype.connect = function (destination) {
|
|
967
|
+
var output = arguments[1] === undefined ? 0 : arguments[1];
|
|
968
|
+
var input = arguments[2] === undefined ? 0 : arguments[2];
|
|
969
|
+
|
|
970
|
+
var _input = undefined;
|
|
971
|
+
|
|
972
|
+
this._shim$connections = this._shim$connections || [];
|
|
973
|
+
|
|
974
|
+
if (destination instanceof AudioNode) {
|
|
975
|
+
connect.call(this, destination, output, input);
|
|
976
|
+
_input = input;
|
|
977
|
+
} else {
|
|
978
|
+
connect.call(this, destination, output);
|
|
979
|
+
_input = 0;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
this._shim$connections.push([destination, output, _input]);
|
|
983
|
+
};
|
|
984
|
+
AudioNode.prototype.connect.original = connect;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
function install(stage) {
|
|
988
|
+
if (stage !== 0) {
|
|
989
|
+
installDisconnect();
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}.call(
|
|
993
|
+
this,
|
|
994
|
+
typeof global !== 'undefined'
|
|
995
|
+
? global
|
|
996
|
+
: typeof self !== 'undefined'
|
|
997
|
+
? self
|
|
998
|
+
: typeof window !== 'undefined'
|
|
999
|
+
? window
|
|
1000
|
+
: {}
|
|
1001
|
+
));
|
|
1002
|
+
},
|
|
1003
|
+
{}
|
|
1004
|
+
],
|
|
1005
|
+
5: [
|
|
1006
|
+
function (require, module, exports) {
|
|
1007
|
+
(function (global) {
|
|
1008
|
+
'use strict';
|
|
1009
|
+
|
|
1010
|
+
Object.defineProperty(exports, '__esModule', {
|
|
1011
|
+
value: true
|
|
1012
|
+
});
|
|
1013
|
+
exports['default'] = install;
|
|
1014
|
+
|
|
1015
|
+
function install() {
|
|
1016
|
+
var stage = arguments[0] === undefined ? Infinity : arguments[0];
|
|
1017
|
+
|
|
1018
|
+
if (
|
|
1019
|
+
!global.hasOwnProperty('AudioContext') &&
|
|
1020
|
+
global.hasOwnProperty('webkitAudioContext')
|
|
1021
|
+
) {
|
|
1022
|
+
global.AudioContext = global.webkitAudioContext;
|
|
1023
|
+
}
|
|
1024
|
+
if (
|
|
1025
|
+
!global.hasOwnProperty('OfflineAudioContext') &&
|
|
1026
|
+
global.hasOwnProperty('webkitOfflineAudioContext')
|
|
1027
|
+
) {
|
|
1028
|
+
global.OfflineAudioContext = global.webkitOfflineAudioContext;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
if (!global.AudioContext) {
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
require('./AnalyserNode').install(stage);
|
|
1036
|
+
require('./AudioBuffer').install(stage);
|
|
1037
|
+
require('./AudioNode').install(stage);
|
|
1038
|
+
require('./AudioContext').install(stage);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
module.exports = exports['default'];
|
|
1042
|
+
}.call(
|
|
1043
|
+
this,
|
|
1044
|
+
typeof global !== 'undefined'
|
|
1045
|
+
? global
|
|
1046
|
+
: typeof self !== 'undefined'
|
|
1047
|
+
? self
|
|
1048
|
+
: typeof window !== 'undefined'
|
|
1049
|
+
? window
|
|
1050
|
+
: {}
|
|
1051
|
+
));
|
|
1052
|
+
},
|
|
1053
|
+
{ './AnalyserNode': 1, './AudioBuffer': 2, './AudioContext': 3, './AudioNode': 4 }
|
|
1054
|
+
],
|
|
1055
|
+
6: [
|
|
1056
|
+
function (require, module, exports) {
|
|
1057
|
+
module.exports = require('./lib/install')(0);
|
|
1058
|
+
},
|
|
1059
|
+
{ './lib/install': 5 }
|
|
1060
|
+
],
|
|
1061
|
+
7: [
|
|
1062
|
+
function (require, module, exports) {
|
|
1063
|
+
var WS_CURVE_SIZE = 4096;
|
|
1064
|
+
var curveL = new Float32Array(WS_CURVE_SIZE);
|
|
1065
|
+
var curveR = new Float32Array(WS_CURVE_SIZE);
|
|
1066
|
+
|
|
1067
|
+
(function () {
|
|
1068
|
+
var i;
|
|
1069
|
+
|
|
1070
|
+
for (i = 0; i < WS_CURVE_SIZE; i++) {
|
|
1071
|
+
curveL[i] = Math.cos((i / WS_CURVE_SIZE) * Math.PI * 0.5);
|
|
1072
|
+
curveR[i] = Math.sin((i / WS_CURVE_SIZE) * Math.PI * 0.5);
|
|
1073
|
+
}
|
|
1074
|
+
})();
|
|
1075
|
+
|
|
1076
|
+
module.exports = {
|
|
1077
|
+
L: curveL,
|
|
1078
|
+
R: curveR
|
|
1079
|
+
};
|
|
1080
|
+
},
|
|
1081
|
+
{}
|
|
1082
|
+
],
|
|
1083
|
+
8: [
|
|
1084
|
+
function (require, module, exports) {
|
|
1085
|
+
(function (global) {
|
|
1086
|
+
var curve = require('./curve');
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* StereoPannerImpl
|
|
1090
|
+
* +--------------------------------+ +------------------------+
|
|
1091
|
+
* | ChannelSplitter(inlet) | | BufferSourceNode(_dc1) |
|
|
1092
|
+
* +--------------------------------+ | buffer: [ 1, 1 ] |
|
|
1093
|
+
* | | | loop: true |
|
|
1094
|
+
* | | +------------------------+
|
|
1095
|
+
* | | |
|
|
1096
|
+
* | | +----------------+
|
|
1097
|
+
* | | | GainNode(_pan) |
|
|
1098
|
+
* | | | gain: 0(pan) |
|
|
1099
|
+
* | | +----------------+
|
|
1100
|
+
* | | |
|
|
1101
|
+
* | +-----------------------|----+
|
|
1102
|
+
* | | | |
|
|
1103
|
+
* | +----------------------+ | +----------------------+
|
|
1104
|
+
* | | WaveShaperNode(_wsL) | | | WaveShaperNode(_wsR) |
|
|
1105
|
+
* | | curve: curveL | | | curve: curveR |
|
|
1106
|
+
* | +----------------------+ | +----------------------+
|
|
1107
|
+
* | | | |
|
|
1108
|
+
* | | | |
|
|
1109
|
+
* | | | |
|
|
1110
|
+
* +--------------+ | +--------------+ |
|
|
1111
|
+
* | GainNode(_L) | | | GainNode(_R) | |
|
|
1112
|
+
* | gain: 0 <----+ | gain: 0 <----+
|
|
1113
|
+
* +--------------+ +--------------+
|
|
1114
|
+
* | |
|
|
1115
|
+
* +--------------------------------+
|
|
1116
|
+
* | ChannelMergerNode(outlet) |
|
|
1117
|
+
* +--------------------------------+
|
|
1118
|
+
*/
|
|
1119
|
+
function StereoPannerImpl(audioContext) {
|
|
1120
|
+
this.audioContext = audioContext;
|
|
1121
|
+
this.inlet = audioContext.createChannelSplitter(2);
|
|
1122
|
+
this._pan = audioContext.createGain();
|
|
1123
|
+
this.pan = this._pan.gain;
|
|
1124
|
+
this._wsL = audioContext.createWaveShaper();
|
|
1125
|
+
this._wsR = audioContext.createWaveShaper();
|
|
1126
|
+
this._L = audioContext.createGain();
|
|
1127
|
+
this._R = audioContext.createGain();
|
|
1128
|
+
this.outlet = audioContext.createChannelMerger(2);
|
|
1129
|
+
|
|
1130
|
+
this.inlet.channelCount = 2;
|
|
1131
|
+
this.inlet.channelCountMode = 'explicit';
|
|
1132
|
+
this._pan.gain.value = 0;
|
|
1133
|
+
this._wsL.curve = curve.L;
|
|
1134
|
+
this._wsR.curve = curve.R;
|
|
1135
|
+
this._L.gain.value = 0;
|
|
1136
|
+
this._R.gain.value = 0;
|
|
1137
|
+
|
|
1138
|
+
this.inlet.connect(this._L, 0);
|
|
1139
|
+
this.inlet.connect(this._R, 1);
|
|
1140
|
+
this._L.connect(this.outlet, 0, 0);
|
|
1141
|
+
this._R.connect(this.outlet, 0, 1);
|
|
1142
|
+
this._pan.connect(this._wsL);
|
|
1143
|
+
this._pan.connect(this._wsR);
|
|
1144
|
+
this._wsL.connect(this._L.gain);
|
|
1145
|
+
this._wsR.connect(this._R.gain);
|
|
1146
|
+
|
|
1147
|
+
this._isConnected = false;
|
|
1148
|
+
this._dc1buffer = null;
|
|
1149
|
+
this._dc1 = null;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
StereoPannerImpl.prototype.connect = function (destination) {
|
|
1153
|
+
var audioContext = this.audioContext;
|
|
1154
|
+
|
|
1155
|
+
if (!this._isConnected) {
|
|
1156
|
+
this._isConnected = true;
|
|
1157
|
+
this._dc1buffer = audioContext.createBuffer(1, 2, audioContext.sampleRate);
|
|
1158
|
+
this._dc1buffer.getChannelData(0).set([1, 1]);
|
|
1159
|
+
|
|
1160
|
+
this._dc1 = audioContext.createBufferSource();
|
|
1161
|
+
this._dc1.buffer = this._dc1buffer;
|
|
1162
|
+
this._dc1.loop = true;
|
|
1163
|
+
this._dc1.start(audioContext.currentTime);
|
|
1164
|
+
this._dc1.connect(this._pan);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
global.AudioNode.prototype.connect.call(this.outlet, destination);
|
|
1168
|
+
};
|
|
1169
|
+
|
|
1170
|
+
StereoPannerImpl.prototype.disconnect = function () {
|
|
1171
|
+
var audioContext = this.audioContext;
|
|
1172
|
+
|
|
1173
|
+
if (this._isConnected) {
|
|
1174
|
+
this._isConnected = false;
|
|
1175
|
+
this._dc1.stop(audioContext.currentTime);
|
|
1176
|
+
this._dc1.disconnect();
|
|
1177
|
+
this._dc1 = null;
|
|
1178
|
+
this._dc1buffer = null;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
global.AudioNode.prototype.disconnect.call(this.outlet);
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
module.exports = StereoPannerImpl;
|
|
1185
|
+
}.call(
|
|
1186
|
+
this,
|
|
1187
|
+
typeof global !== 'undefined'
|
|
1188
|
+
? global
|
|
1189
|
+
: typeof self !== 'undefined'
|
|
1190
|
+
? self
|
|
1191
|
+
: typeof window !== 'undefined'
|
|
1192
|
+
? window
|
|
1193
|
+
: {}
|
|
1194
|
+
));
|
|
1195
|
+
},
|
|
1196
|
+
{ './curve': 7 }
|
|
1197
|
+
],
|
|
1198
|
+
9: [
|
|
1199
|
+
function (require, module, exports) {
|
|
1200
|
+
(function (global) {
|
|
1201
|
+
var StereoPannerImpl = require('./stereo-panner-impl');
|
|
1202
|
+
var AudioContext = global.AudioContext || global.webkitAudioContext;
|
|
1203
|
+
|
|
1204
|
+
function StereoPanner(audioContext) {
|
|
1205
|
+
var impl = new StereoPannerImpl(audioContext);
|
|
1206
|
+
|
|
1207
|
+
Object.defineProperties(impl.inlet, {
|
|
1208
|
+
pan: {
|
|
1209
|
+
value: impl.pan,
|
|
1210
|
+
enumerable: true
|
|
1211
|
+
},
|
|
1212
|
+
connect: {
|
|
1213
|
+
value: function (node) {
|
|
1214
|
+
return impl.connect(node);
|
|
1215
|
+
}
|
|
1216
|
+
},
|
|
1217
|
+
disconnect: {
|
|
1218
|
+
value: function () {
|
|
1219
|
+
return impl.disconnect();
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
|
|
1224
|
+
return impl.inlet;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
StereoPanner.polyfill = function () {
|
|
1228
|
+
if (!AudioContext || AudioContext.prototype.hasOwnProperty('createStereoPanner')) {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
AudioContext.prototype.createStereoPanner = function () {
|
|
1232
|
+
return new StereoPanner(this);
|
|
1233
|
+
};
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
module.exports = StereoPanner;
|
|
1237
|
+
}.call(
|
|
1238
|
+
this,
|
|
1239
|
+
typeof global !== 'undefined'
|
|
1240
|
+
? global
|
|
1241
|
+
: typeof self !== 'undefined'
|
|
1242
|
+
? self
|
|
1243
|
+
: typeof window !== 'undefined'
|
|
1244
|
+
? window
|
|
1245
|
+
: {}
|
|
1246
|
+
));
|
|
1247
|
+
},
|
|
1248
|
+
{ './stereo-panner-impl': 8 }
|
|
1249
|
+
]
|
|
1250
|
+
},
|
|
1251
|
+
{},
|
|
1252
|
+
[6]
|
|
1253
|
+
);
|