(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o` OriginalAudioContext.prototype.decodeAudioData = function (audioData, successCallback, errorCallback) { var _this5 = this; var promise = new Promise(function (resolve, reject) { return decodeAudioData.call(_this5, audioData, resolve, reject); }); promise.then(successCallback, errorCallback); return promise; }; OriginalAudioContext.prototype.decodeAudioData.original = decodeAudioData; } function installClose() { if (OriginalAudioContext.prototype.hasOwnProperty("close")) { return; } //// ### AudioContext.prototype.close //// Closes the audio context, releasing any system audio resources used by the **`AudioContext`**. //// //// #### Parameters //// - _none_ //// //// #### Return //// - `Promise` replaceAudioContext(); } function installResume() { if (OriginalAudioContext.prototype.hasOwnProperty("resume")) { return; } //// ### AudioContext.prototype.suspend //// Resumes the progression of time in an audio context that has been suspended, which may involve re-priming the frame buffer contents. //// //// #### Parameters //// - _none_ //// //// #### Return //// - `Promise` replaceAudioContext(); } function installSuspend() { if (OriginalAudioContext.prototype.hasOwnProperty("suspend")) { return; } //// ### AudioContext.prototype.suspend //// 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. //// //// #### Parameters //// - _none_ //// //// #### Return //// - `Promise` replaceAudioContext(); } function installStartRendering() { var audioContext = new OriginalOfflineAudioContext(1, 1, 44100); var isPromiseBased = false; try { isPromiseBased = !!audioContext.startRendering(); } catch (e) { nop(e); } if (isPromiseBased) { return; } var startRendering = OriginalOfflineAudioContext.prototype.startRendering; //// ### OfflineAudioContext.prototype.startRendering //// Given the current connections and scheduled changes, starts rendering audio. //// //// #### Parameters //// - _none_ //// //// #### Return //// - `Promise` OriginalOfflineAudioContext.prototype.startRendering = function () { var _this6 = this; return new Promise(function (resolve) { var oncomplete = _this6.oncomplete; _this6.oncomplete = function (e) { resolve(e.renderedBuffer); if (typeof oncomplete === "function") { oncomplete.call(_this6, e); } }; startRendering.call(_this6); }); }; OriginalOfflineAudioContext.prototype.startRendering.original = startRendering; } function install(stage) { installCreateAudioWorker(); installCreateStereoPanner(); installDecodeAudioData(); installStartRendering(); if (stage !== 0) { installClose(); installResume(); installSuspend(); } } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"stereo-panner-node":9}],5:[function(require,module,exports){ (function (global){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.install = install; var OfflineAudioContext = global.OfflineAudioContext; var AudioNode = global.AudioNode; var connect = AudioNode.prototype.connect; var disconnect = AudioNode.prototype.disconnect; function match(args, connection) { for (var i = 0, imax = args.length; i < imax; i++) { if (args[i] !== connection[i]) { return false; } } return true; } function disconnectAll(node) { for (var ch = 0, chmax = node.numberOfOutputs; ch < chmax; ch++) { disconnect.call(node, ch); } node._shim$connections = []; } function disconnectChannel(node, channel) { disconnect.call(node, channel); node._shim$connections = node._shim$connections.filter(function (connection) { return connection[1] !== channel; }); } function disconnectSelect(node, args) { var remain = []; var hasDestination = false; node._shim$connections.forEach(function (connection) { hasDestination = hasDestination || args[0] === connection[0]; if (!match(args, connection)) { remain.push(connection); } }); if (!hasDestination) { throw new Error("Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected."); } disconnectAll(node); remain.forEach(function (connection) { connect.call(node, connection[0], connection[1], connection[2]); }); node._shim$connections = remain; } function installDisconnect() { var audioContext = new OfflineAudioContext(1, 1, 44100); var isSelectiveDisconnection = false; try { audioContext.createGain().disconnect(audioContext.destination); } catch (e) { isSelectiveDisconnection = true; } if (isSelectiveDisconnection) { return; } //// ### AudioNode.prototype.disconnect //// Disconnects all outgoing connections from **`AudioNode`**. //// //// #### Parameters //// - _none_ //// //// #### Return //// - `void` //// //// ### AudioNode.prototype.disconnect //// #### Parameters //// - `output: number` //// - This parameter is an index describing which output of the AudioNode to disconnect. //// //// #### Return //// - `void` //// //// ### AudioNode.prototype.disconnect //// #### Parameters //// - `destination: AudioNode|AudioParam` //// - The destination parameter is the AudioNode/AudioParam to disconnect. //// //// #### Return //// - `void` //// //// ### AudioNode.prototype.disconnect //// #### Parameters //// - `destination: AudioNode|AudioParam` //// - The destination parameter is the AudioNode/AudioParam to disconnect. //// - `output: number` //// - The output parameter is an index describing which output of the AudioNode from which to disconnect. //// //// #### Return //// - `void` //// //// ### AudioNode.prototype.disconnect //// #### Parameters //// - `destination: AudioNode` //// - The destination parameter is the AudioNode to disconnect. //// - `output: number` //// - The output parameter is an index describing which output of the AudioNode from which to disconnect. //// - `input: number` //// - The input parameter is an index describing which input of the destination AudioNode to disconnect. //// //// #### Return //// - `void` //// AudioNode.prototype.disconnect = function () { this._shim$connections = this._shim$connections || []; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (args.length === 0) { disconnectAll(this); } else if (args.length === 1 && typeof args[0] === "number") { disconnectChannel(this, args[0]); } else { disconnectSelect(this, args); } }; AudioNode.prototype.disconnect.original = disconnect; AudioNode.prototype.connect = function (destination) { var output = arguments[1] === undefined ? 0 : arguments[1]; var input = arguments[2] === undefined ? 0 : arguments[2]; var _input = undefined; this._shim$connections = this._shim$connections || []; if (destination instanceof AudioNode) { connect.call(this, destination, output, input); _input = input; } else { connect.call(this, destination, output); _input = 0; } this._shim$connections.push([destination, output, _input]); }; AudioNode.prototype.connect.original = connect; } function install(stage) { if (stage !== 0) { installDisconnect(); } } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],6:[function(require,module,exports){ (function (global){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = install; function install() { var stage = arguments[0] === undefined ? Infinity : arguments[0]; if (!global.hasOwnProperty("AudioContext") && global.hasOwnProperty("webkitAudioContext")) { global.AudioContext = global.webkitAudioContext; } if (!global.hasOwnProperty("OfflineAudioContext") && global.hasOwnProperty("webkitOfflineAudioContext")) { global.OfflineAudioContext = global.webkitOfflineAudioContext; } if (!global.AudioContext) { return; } require("./AnalyserNode").install(stage); require("./AudioBuffer").install(stage); require("./AudioNode").install(stage); require("./AudioContext").install(stage); } module.exports = exports["default"]; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./AnalyserNode":2,"./AudioBuffer":3,"./AudioContext":4,"./AudioNode":5}],7:[function(require,module,exports){ var WS_CURVE_SIZE = 4096; var curveL = new Float32Array(WS_CURVE_SIZE); var curveR = new Float32Array(WS_CURVE_SIZE); (function() { var i; for (i = 0; i < WS_CURVE_SIZE; i++) { curveL[i] = Math.cos((i / WS_CURVE_SIZE) * Math.PI * 0.5); curveR[i] = Math.sin((i / WS_CURVE_SIZE) * Math.PI * 0.5); } })(); module.exports = { L: curveL, R: curveR, }; },{}],8:[function(require,module,exports){ (function (global){ var curve = require("./curve"); /** * StereoPannerImpl * +--------------------------------+ +------------------------+ * | ChannelSplitter(inlet) | | BufferSourceNode(_dc1) | * +--------------------------------+ | buffer: [ 1, 1 ] | * | | | loop: true | * | | +------------------------+ * | | | * | | +----------------+ * | | | GainNode(_pan) | * | | | gain: 0(pan) | * | | +----------------+ * | | | * | +-----------------------|----+ * | | | | * | +----------------------+ | +----------------------+ * | | WaveShaperNode(_wsL) | | | WaveShaperNode(_wsR) | * | | curve: curveL | | | curve: curveR | * | +----------------------+ | +----------------------+ * | | | | * | | | | * | | | | * +--------------+ | +--------------+ | * | GainNode(_L) | | | GainNode(_R) | | * | gain: 0 <----+ | gain: 0 <----+ * +--------------+ +--------------+ * | | * +--------------------------------+ * | ChannelMergerNode(outlet) | * +--------------------------------+ */ function StereoPannerImpl(audioContext) { this.audioContext = audioContext; this.inlet = audioContext.createChannelSplitter(2); this._pan = audioContext.createGain(); this.pan = this._pan.gain; this._wsL = audioContext.createWaveShaper(); this._wsR = audioContext.createWaveShaper(); this._L = audioContext.createGain(); this._R = audioContext.createGain(); this.outlet = audioContext.createChannelMerger(2); this.inlet.channelCount = 2; this.inlet.channelCountMode = "explicit"; this._pan.gain.value = 0; this._wsL.curve = curve.L; this._wsR.curve = curve.R; this._L.gain.value = 0; this._R.gain.value = 0; this.inlet.connect(this._L, 0); this.inlet.connect(this._R, 1); this._L.connect(this.outlet, 0, 0); this._R.connect(this.outlet, 0, 1); this._pan.connect(this._wsL); this._pan.connect(this._wsR); this._wsL.connect(this._L.gain); this._wsR.connect(this._R.gain); this._isConnected = false; this._dc1buffer = null; this._dc1 = null; } StereoPannerImpl.prototype.connect = function(destination) { var audioContext = this.audioContext; if (!this._isConnected) { this._isConnected = true; this._dc1buffer = audioContext.createBuffer(1, 2, audioContext.sampleRate); this._dc1buffer.getChannelData(0).set([ 1, 1 ]); this._dc1 = audioContext.createBufferSource(); this._dc1.buffer = this._dc1buffer; this._dc1.loop = true; this._dc1.start(audioContext.currentTime); this._dc1.connect(this._pan); } global.AudioNode.prototype.connect.call(this.outlet, destination); }; StereoPannerImpl.prototype.disconnect = function() { var audioContext = this.audioContext; if (this._isConnected) { this._isConnected = false; this._dc1.stop(audioContext.currentTime); this._dc1.disconnect(); this._dc1 = null; this._dc1buffer = null; } global.AudioNode.prototype.disconnect.call(this.outlet); }; module.exports = StereoPannerImpl; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./curve":7}],9:[function(require,module,exports){ (function (global){ var StereoPannerImpl = require("./stereo-panner-impl"); var AudioContext = global.AudioContext || global.webkitAudioContext; function StereoPanner(audioContext) { var impl = new StereoPannerImpl(audioContext); Object.defineProperties(impl.inlet, { pan: { value: impl.pan, enumerable: true, }, connect: { value: function(node) { return impl.connect(node); }, }, disconnect: { value: function() { return impl.disconnect(); }, }, }); return impl.inlet; } StereoPanner.polyfill = function() { if (!AudioContext || AudioContext.prototype.hasOwnProperty("createStereoPanner")) { return; } AudioContext.prototype.createStereoPanner = function() { return new StereoPanner(this); }; }; module.exports = StereoPanner; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./stereo-panner-impl":8}]},{},[1]);