From d3f9e2ce46c2f1558addb6df2a1d5aad3dbe6134 Mon Sep 17 00:00:00 2001 From: Jason Sigal Date: Tue, 25 May 2021 23:00:21 -0400 Subject: [PATCH] bump library version building on https://github.com/processing/p5.js-sound/pull/583 with some additional updates - fix drywet function but https://github.com/processing/p5.js-sound/pull/606 - fix function name in documentation https://github.com/processing/p5.js-sound/pull/603 - fix repeat initialization of audioWorklet https://github.com/processing/p5.js-sound/pull/593 - fix issue with p5.Score that prevented parts from being passed as argument https://github.com/processing/p5.js-sound/pull/543 --- lib/p5.sound.js | 405 ++++++++++++++++++++-------------------- lib/p5.sound.js.map | 2 +- lib/p5.sound.min.js | 4 +- lib/p5.sound.min.js.map | 2 +- package.json | 2 +- 5 files changed, 207 insertions(+), 208 deletions(-) diff --git a/lib/p5.sound.js b/lib/p5.sound.js index eb941df6..a67ad215 100644 --- a/lib/p5.sound.js +++ b/lib/p5.sound.js @@ -1,4 +1,4 @@ -/** [p5.sound] Version: 1.0.0 - 2021-04-19 */ +/** [p5.sound] Version: 1.0.1 - 2021-05-25 */ /** *

p5.sound extends p5 with Web Audio functionality including audio input, @@ -690,8 +690,8 @@ var audiocontext = __webpack_require__(3); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var master_Master = function Master() { - _classCallCheck(this, Master); +var main_Main = function Main() { + _classCallCheck(this, Main); this.input = audiocontext["a" ].createGain(); this.output = audiocontext["a" ].createGain(); @@ -722,17 +722,17 @@ var master_Master = function Master() { }; -var p5sound = new master_Master(); +var p5sound = new main_Main(); /** - * Returns a number representing the master amplitude (volume) for sound + * Returns a number representing the output volume for sound * in this sketch. * - * @method getMasterVolume - * @return {Number} Master amplitude (volume) for sound in this sketch. + * @method getOutputVolume + * @return {Number} Output volume for sound in this sketch. * Should be between 0.0 (silence) and 1.0. */ -p5.prototype.getMasterVolume = function () { +p5.prototype.getOutputVolume = function () { return p5sound.output.gain.value; }; /** @@ -754,7 +754,7 @@ p5.prototype.getMasterVolume = function () { * *

If no value is provided, returns a Web Audio API Gain Node

* - * @method masterVolume + * @method outputVolume * @param {Number|Object} volume Volume (amplitude) between 0.0 * and 1.0 or modulating signal/oscillator * @param {Number} [rampTime] Fade for t seconds @@ -763,7 +763,7 @@ p5.prototype.getMasterVolume = function () { */ -p5.prototype.masterVolume = function (vol) { +p5.prototype.outputVolume = function (vol) { var rampTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var tFromNow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; @@ -780,7 +780,7 @@ p5.prototype.masterVolume = function (vol) { } }; /** - * `p5.soundOut` is the p5.sound master output. It sends output to + * `p5.soundOut` is the p5.sound final output bus. It sends output to * the destination of this window's web audio context. It contains * Web Audio API nodes including a dyanmicsCompressor (.limiter), * and Gain Nodes for .input and .output. @@ -796,7 +796,7 @@ p5.soundOut._silentNode.gain.value = 0; p5.soundOut._silentNode.connect(p5sound.audiocontext.destination); - var master = (p5sound); + var main = (p5sound); var processorNames = __webpack_require__(5); var processorNames_default = __webpack_require__.n(processorNames); @@ -820,7 +820,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat */ function sampleRate() { - return master.audiocontext.sampleRate; + return main.audiocontext.sampleRate; } /** * Returns the closest MIDI note value for @@ -954,13 +954,13 @@ function noteToFreq(note) { function soundFormats() { - master.extensions = []; + main.extensions = []; for (var i = 0; i < arguments.length; i++) { arguments[i] = arguments[i].toLowerCase(); if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(arguments[i]) > -1) { - master.extensions.push(arguments[i]); + main.extensions.push(arguments[i]); } else { throw arguments[i] + ' is not a valid sound format!'; } @@ -968,8 +968,8 @@ function soundFormats() { } function disposeSound() { - for (var i = 0; i < master.soundArray.length; i++) { - master.soundArray[i].dispose(); + for (var i = 0; i < main.soundArray.length; i++) { + main.soundArray[i].dispose(); } } @@ -986,8 +986,8 @@ function _checkFileFormats(paths) { var pathSplit = path.split('.'); var pathCore = pathSplit[pathSplit.length - 1]; - for (var _i = 0; _i < master.extensions.length; _i++) { - var _extension = master.extensions[_i]; + for (var _i = 0; _i < main.extensions.length; _i++) { + var _extension = main.extensions[_i]; var _supported = p5.prototype.isFileSupported(_extension); @@ -1011,8 +1011,8 @@ function _checkFileFormats(paths) { } } else { - for (var _i3 = 0; _i3 < master.extensions.length; _i3++) { - var _extension2 = master.extensions[_i3]; + for (var _i3 = 0; _i3 < main.extensions.length; _i3++) { + var _extension2 = main.extensions[_i3]; var _supported2 = p5.prototype.isFileSupported(_extension2); @@ -1086,8 +1086,8 @@ function convertToWav(audioBuffer) { view.setUint16(20, 1, true); view.setUint16(22, 2, true); - view.setUint32(24, master.audiocontext.sampleRate, true); - view.setUint32(28, master.audiocontext.sampleRate * 4, true); + view.setUint32(24, main.audiocontext.sampleRate, true); + view.setUint32(28, main.audiocontext.sampleRate * 4, true); view.setUint16(32, 4, true); view.setUint16(34, 16, true); @@ -1132,7 +1132,7 @@ function writeUTFBytes(view, offset, string) { function safeBufferSize(idealBufferSize) { var bufferSize = idealBufferSize; - var tempAudioWorkletNode = new AudioWorkletNode(master.audiocontext, processorNames_default.a.soundFileProcessor); + var tempAudioWorkletNode = new AudioWorkletNode(main.audiocontext, processorNames_default.a.soundFileProcessor); if (tempAudioWorkletNode instanceof ScriptProcessorNode) { bufferSize = tempAudioWorkletNode.bufferSize; @@ -1179,7 +1179,7 @@ var CustomError = function CustomError(name, errorTrace, failedPath) { var errorHandler = (CustomError); var moduleSources = [__webpack_require__(27)["default"], __webpack_require__(28)["default"], __webpack_require__(29)["default"]]; -var audioWorklet_ac = master.audiocontext; +var audioWorklet_ac = main.audiocontext; var initializedAudioWorklets = false; function loadAudioWorkletModules() { @@ -1217,7 +1217,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } -var panner_ac = master.audiocontext; +var panner_ac = main.audiocontext; var panner; if (typeof panner_ac.createStereoPanner !== 'undefined') { @@ -1353,7 +1353,7 @@ function soundfile_classCallCheck(instance, Constructor) { if (!(instance instan -var soundfile_ac = master.audiocontext; +var soundfile_ac = main.audiocontext; var _createCounterBuffer = function _createCounterBuffer(buffer) { var len = buffer.length; @@ -1505,8 +1505,8 @@ function () { this.bufferSourceNode = null; this.buffer = null; this.playbackRate = 1; - this.input = master.audiocontext.createGain(); - this.output = master.audiocontext.createGain(); + this.input = main.audiocontext.createGain(); + this.output = main.audiocontext.createGain(); this.reversed = false; this.startTime = 0; @@ -1518,14 +1518,14 @@ function () { this.startMillis = null; this.panPosition = 0.0; - this.panner = new panner_0(this.output, master.input, 2); + this.panner = new panner_0(this.output, main.input, 2); if (this.url || this.file) { this.load(onload, onerror); } - master.soundArray.push(this); + main.soundArray.push(this); if (typeof whileLoading === 'function') { this._whileLoading = whileLoading; @@ -1697,7 +1697,7 @@ function () { return; } - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var cueStart, cueEnd; var time = startTime || 0; @@ -1832,7 +1832,7 @@ function () { if (s === 'restart' && this.buffer && this.bufferSourceNode) { for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.bufferSourceNodes[i].stop(now); } } @@ -1885,7 +1885,7 @@ function () { }, { key: "pause", value: function pause(startTime) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var time = startTime || 0; var pTime = time + now; @@ -2042,7 +2042,7 @@ function () { this.pauseTime = 0; this._paused = false; } else if (this.buffer && this.bufferSourceNode) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var t = time || 0; this.pauseTime = 0; this.bufferSourceNode.stop(now + t); @@ -2061,7 +2061,7 @@ function () { }, { key: "stopAll", value: function stopAll(_time) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var time = _time || 0; if (this.buffer && this.bufferSourceNode) { @@ -2209,7 +2209,7 @@ function () { } if (this.bufferSourceNode) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.bufferSourceNode.playbackRate.cancelScheduledValues(now); this.bufferSourceNode.playbackRate.linearRampToValueAtTime(Math.abs(playbackRate), now); @@ -2262,7 +2262,7 @@ function () { if (typeof vol === 'number') { var rampTime = _rampTime || 0; var tFromNow = _tFromNow || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var currentVol = this.output.gain.value; this.output.gain.cancelScheduledValues(now + tFromNow); this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow); @@ -2520,10 +2520,10 @@ function () { }, { key: "dispose", value: function dispose() { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); this.stop(now); if (this.buffer && this.bufferSourceNode) { @@ -2566,7 +2566,7 @@ function () { * Connects the output of a p5sound object to input of another * p5.sound object. For example, you may connect a p5.SoundFile to an * FFT or an Effect. If no parameter is given, it will connect to - * the master output. Most p5sound objects connect to the master + * the main output. Most p5sound objects connect to the master * output when they are created. * * @method connect @@ -2578,7 +2578,7 @@ function () { key: "connect", value: function connect(unit) { if (!unit) { - this.panner.connect(master.input); + this.panner.connect(main.input); } else { if (unit.hasOwnProperty('input')) { this.panner.connect(unit.input); @@ -3038,7 +3038,7 @@ function amplitude_createClass(Constructor, protoProps, staticProps) { if (proto * } * function setup() { * let cnv = createCanvas(100,100); - * cnv.mouseClicked(toggleSound); + * cnv.mouseClicked(togglePlay); * amplitude = new p5.Amplitude(); * } * @@ -3071,7 +3071,7 @@ function () { this.bufferSize = safeBufferSize(2048); - this.audiocontext = master.audiocontext; + this.audiocontext = main.audiocontext; this._workletNode = new AudioWorkletNode(this.audiocontext, processorNames_default.a.amplitudeProcessor, { outputChannelCount: [1], parameterData: { @@ -3110,19 +3110,19 @@ function () { this.output.connect(this.audiocontext.destination); - master.meter.connect(this._workletNode); + main.meter.connect(this._workletNode); - master.soundArray.push(this); + main.soundArray.push(this); } /** - * Connects to the p5sound instance (master output) by default. + * Connects to the p5sound instance (main output) by default. * Optionally, you can pass in a specific source (i.e. a soundfile). * * @method setInput * @for p5.Amplitude * @param {soundObject|undefined} [snd] set the sound source * (optional, defaults to - * master output) + * main output) * @param {Number|undefined} [smoothing] a range between 0.0 and 1.0 * to smooth amplitude readings * @example @@ -3164,7 +3164,7 @@ function () { amplitude_createClass(Amplitude, [{ key: "setInput", value: function setInput(source, smoothing) { - master.meter.disconnect(); + main.meter.disconnect(); if (smoothing) { this._workletNode.parameters.get('smoothing').value = smoothing; @@ -3172,8 +3172,8 @@ function () { if (source == null) { - console.log('Amplitude input source is not ready! Connecting to master output instead'); - master.meter.connect(this._workletNode); + console.log('Amplitude input source is not ready! Connecting to main output instead'); + main.meter.connect(this._workletNode); } else if (source) { source.connect(this._workletNode); @@ -3183,7 +3183,7 @@ function () { this._workletNode.connect(this.output); } else { - master.meter.connect(this._workletNode); + main.meter.connect(this._workletNode); } } }, { @@ -3196,7 +3196,7 @@ function () { this.output.connect(unit); } } else { - this.output.connect(this.panner.connect(master.input)); + this.output.connect(this.panner.connect(main.input)); } } }, { @@ -3314,8 +3314,8 @@ function () { }, { key: "dispose", value: function dispose() { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); if (this.input) { this.input.disconnect(); @@ -3434,7 +3434,7 @@ function () { function FFT(smoothing, bins) { fft_classCallCheck(this, FFT); - this.input = this.analyser = master.audiocontext.createAnalyser(); + this.input = this.analyser = main.audiocontext.createAnalyser(); Object.defineProperties(this, { bins: { get: function get() { @@ -3461,7 +3461,7 @@ function () { this.smooth(smoothing); this.bins = bins || 1024; - master.fftMeter.connect(this.analyser); + main.fftMeter.connect(this.analyser); this.freqDomain = new Uint8Array(this.analyser.frequencyBinCount); this.timeDomain = new Uint8Array(this.analyser.frequencyBinCount); @@ -3471,7 +3471,7 @@ function () { this.highMid = [2600, 5200]; this.treble = [5200, 14000]; - master.soundArray.push(this); + main.soundArray.push(this); } /** * Set the input source for the FFT analysis. If no source is @@ -3487,7 +3487,7 @@ function () { key: "setInput", value: function setInput(source) { if (!source) { - master.fftMeter.connect(this.analyser); + main.fftMeter.connect(this.analyser); } else { if (source.output) { source.output.connect(this.analyser); @@ -3495,7 +3495,7 @@ function () { source.connect(this.analyser); } - master.fftMeter.disconnect(); + main.fftMeter.disconnect(); } } /** @@ -3680,7 +3680,7 @@ function () { }, { key: "getEnergy", value: function getEnergy(frequency1, frequency2) { - var nyquist = master.audiocontext.sampleRate / 2; + var nyquist = main.audiocontext.sampleRate / 2; if (frequency1 === 'bass') { frequency1 = this.bass[0]; @@ -3805,7 +3805,7 @@ function () { }, { key: "getCentroid", value: function getCentroid() { - var nyquist = master.audiocontext.sampleRate / 2; + var nyquist = main.audiocontext.sampleRate / 2; var cumulative_sum = 0; var centroid_normalization = 0; @@ -3843,8 +3843,8 @@ function () { }, { key: "dispose", value: function dispose() { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); if (this.analyser) { this.analyser.disconnect(); @@ -3903,7 +3903,7 @@ function () { }, { key: "logAverages", value: function logAverages(octaveBands) { - var nyquist = master.audiocontext.sampleRate / 2; + var nyquist = main.audiocontext.sampleRate / 2; var spectrum = this.freqDomain; var spectrumLength = spectrum.length; var logAverages = new Array(octaveBands.length); @@ -3951,7 +3951,7 @@ function () { hi: fCtr0 * Math.pow(2, 1 / (2 * N)) }; octaveBands.push(lastFrequencyBand); - var nyquist = master.audiocontext.sampleRate / 2; + var nyquist = main.audiocontext.sampleRate / 2; while (lastFrequencyBand.hi < nyquist) { var newFrequencyBand = {}; @@ -4141,27 +4141,27 @@ function () { this.started = false; this.phaseAmount = undefined; - this.oscillator = master.audiocontext.createOscillator(); + this.oscillator = main.audiocontext.createOscillator(); this.f = freq || 440.0; this.oscillator.type = type || 'sine'; - this.oscillator.frequency.setValueAtTime(this.f, master.audiocontext.currentTime); + this.oscillator.frequency.setValueAtTime(this.f, main.audiocontext.currentTime); - this.output = master.audiocontext.createGain(); + this.output = main.audiocontext.createGain(); this._freqMods = []; this.output.gain.value = 0.5; - this.output.gain.setValueAtTime(0.5, master.audiocontext.currentTime); + this.output.gain.setValueAtTime(0.5, main.audiocontext.currentTime); this.oscillator.connect(this.output); this.panPosition = 0.0; - this.connection = master.input; + this.connection = main.input; this.panner = new panner_0(this.output, this.connection, 1); this.mathOps = [this.output]; - master.soundArray.push(this); + main.soundArray.push(this); this.fade = this.amp; } @@ -4183,7 +4183,7 @@ function () { key: "start", value: function start(time, f) { if (this.started) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.stop(now); } @@ -4197,13 +4197,13 @@ function () { } - this.oscillator = master.audiocontext.createOscillator(); + this.oscillator = main.audiocontext.createOscillator(); this.oscillator.frequency.value = Math.abs(freq); this.oscillator.type = type; this.oscillator.connect(this.output); time = time || 0; - this.oscillator.start(time + master.audiocontext.currentTime); + this.oscillator.start(time + main.audiocontext.currentTime); this.freqNode = this.oscillator.frequency; for (var i in this._freqMods) { @@ -4230,7 +4230,7 @@ function () { value: function stop(time) { if (this.started) { var t = time || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.oscillator.stop(t + now); this.started = false; } @@ -4260,7 +4260,7 @@ function () { var tFromNow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; if (typeof vol === 'number') { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime); } else if (vol) { vol.connect(this.output.gain); @@ -4329,7 +4329,7 @@ function () { if (typeof val === 'number' && !isNaN(val)) { this.f = val; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; if (rampTime === 0) { this.oscillator.frequency.setValueAtTime(val, tFromNow + now); @@ -4408,7 +4408,7 @@ function () { key: "connect", value: function connect(unit) { if (!unit) { - this.panner.connect(master.input); + this.panner.connect(main.input); } else if (unit.hasOwnProperty('input')) { this.panner.connect(unit.input); this.connection = unit.input; @@ -4475,11 +4475,11 @@ function () { }, { key: "dispose", value: function dispose() { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); if (this.oscillator) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.stop(now); this.disconnect(); this.panner = null; @@ -4505,11 +4505,11 @@ function () { key: "phase", value: function phase(p) { var delayAmt = p5.prototype.map(p, 0, 1.0, 0, 1 / this.f); - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.phaseAmount = p; if (!this.dNode) { - this.dNode = master.audiocontext.createDelay(); + this.dNode = main.audiocontext.createDelay(); this.oscillator.disconnect(); this.oscillator.connect(this.dNode); @@ -4801,7 +4801,7 @@ p5.Envelope = function (t1, l1, t2, l2, t3, l3) { this.rLevel = l3 || 0; this._rampHighPercentage = 0.98; this._rampLowPercentage = 0.02; - this.output = master.audiocontext.createGain(); + this.output = main.audiocontext.createGain(); this.control = new TimelineSignal_default.a(); this._init(); @@ -4819,12 +4819,12 @@ p5.Envelope = function (t1, l1, t2, l2, t3, l3) { this.wasTriggered = false; - master.soundArray.push(this); + main.soundArray.push(this); }; p5.Envelope.prototype._init = function () { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var t = now; this.control.setTargetAtTime(0.00001, t, 0.001); @@ -5202,7 +5202,7 @@ p5.Envelope.prototype.play = function (unit, secondsFromNow, susTime) { p5.Envelope.prototype.triggerAttack = function (unit, secondsFromNow) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var tFromNow = secondsFromNow || 0; var t = now + tFromNow; this.lastAttack = t; @@ -5311,7 +5311,7 @@ p5.Envelope.prototype.triggerRelease = function (unit, secondsFromNow) { return; } - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var tFromNow = secondsFromNow || 0; var t = now + tFromNow; @@ -5402,7 +5402,7 @@ p5.Envelope.prototype.triggerRelease = function (unit, secondsFromNow) { p5.Envelope.prototype.ramp = function (unit, secondsFromNow, v1, v2) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var tFromNow = secondsFromNow || 0; var t = now + tFromNow; var destination1 = this.checkExpInput(v1); @@ -5445,7 +5445,7 @@ p5.Envelope.prototype.connect = function (unit) { } if (unit instanceof AudioParam) { - unit.setValueAtTime(0, master.audiocontext.currentTime); + unit.setValueAtTime(0, main.audiocontext.currentTime); } this.output.connect(unit); @@ -5520,8 +5520,8 @@ p5.Envelope.prototype.scale = function (inMin, inMax, outMin, outMax) { p5.Envelope.prototype.dispose = function () { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); this.disconnect(); if (this.control) { @@ -5564,8 +5564,8 @@ function noise_setPrototypeOf(o, p) { noise_setPrototypeOf = Object.setPrototype var _whiteNoiseBuffer = function () { - var bufferSize = 2 * master.audiocontext.sampleRate; - var whiteBuffer = master.audiocontext.createBuffer(1, bufferSize, master.audiocontext.sampleRate); + var bufferSize = 2 * main.audiocontext.sampleRate; + var whiteBuffer = main.audiocontext.createBuffer(1, bufferSize, main.audiocontext.sampleRate); var noiseData = whiteBuffer.getChannelData(0); for (var i = 0; i < bufferSize; i++) { @@ -5577,8 +5577,8 @@ var _whiteNoiseBuffer = function () { }(); var _pinkNoiseBuffer = function () { - var bufferSize = 2 * master.audiocontext.sampleRate; - var pinkBuffer = master.audiocontext.createBuffer(1, bufferSize, master.audiocontext.sampleRate); + var bufferSize = 2 * main.audiocontext.sampleRate; + var pinkBuffer = main.audiocontext.createBuffer(1, bufferSize, main.audiocontext.sampleRate); var noiseData = pinkBuffer.getChannelData(0); var b0, b1, b2, b3, b4, b5, b6; b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0.0; @@ -5602,8 +5602,8 @@ var _pinkNoiseBuffer = function () { }(); var _brownNoiseBuffer = function () { - var bufferSize = 2 * master.audiocontext.sampleRate; - var brownBuffer = master.audiocontext.createBuffer(1, bufferSize, master.audiocontext.sampleRate); + var bufferSize = 2 * main.audiocontext.sampleRate; + var brownBuffer = main.audiocontext.createBuffer(1, bufferSize, main.audiocontext.sampleRate); var noiseData = brownBuffer.getChannelData(0); var lastOut = 0.0; @@ -5684,7 +5684,7 @@ function (_Oscillator) { } if (this.started) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.stop(now); this.start(now + 0.01); } @@ -5701,18 +5701,18 @@ function (_Oscillator) { this.stop(); } - this.noise = master.audiocontext.createBufferSource(); + this.noise = main.audiocontext.createBufferSource(); this.noise.buffer = this.buffer; this.noise.loop = true; this.noise.connect(this.output); - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.noise.start(now); this.started = true; } }, { key: "stop", value: function stop() { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; if (this.noise) { this.noise.stop(now); @@ -5722,10 +5722,10 @@ function (_Oscillator) { }, { key: "dispose", value: function dispose() { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); if (this.noise) { this.noise.disconnect(); @@ -5836,10 +5836,10 @@ function (_Oscillator) { _this.osc2 = new SawOsc(freq); - _this.dNode = master.audiocontext.createDelay(); + _this.dNode = main.audiocontext.createDelay(); _this.dcOffset = createDCOffset(); - _this.dcGain = master.audiocontext.createGain(); + _this.dcGain = main.audiocontext.createGain(); _this.dcOffset.connect(_this.dcGain); @@ -5904,19 +5904,19 @@ function (_Oscillator) { }, { key: "start", value: function start(f, time) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var t = time || 0; if (!this.started) { var freq = f || this.f; var type = this.oscillator.type; - this.oscillator = master.audiocontext.createOscillator(); + this.oscillator = main.audiocontext.createOscillator(); this.oscillator.frequency.setValueAtTime(freq, now); this.oscillator.type = type; this.oscillator.connect(this.output); this.oscillator.start(t + now); - this.osc2.oscillator = master.audiocontext.createOscillator(); + this.osc2.oscillator = main.audiocontext.createOscillator(); this.osc2.oscillator.frequency.setValueAtTime(freq, t + now); this.osc2.oscillator.type = type; this.osc2.oscillator.connect(this.osc2.output); @@ -5941,7 +5941,7 @@ function (_Oscillator) { value: function stop(time) { if (this.started) { var t = time || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.oscillator.stop(t + now); if (this.osc2.oscillator) { @@ -5961,7 +5961,7 @@ function (_Oscillator) { if (typeof val === 'number') { this.f = val; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var currentFreq = this.oscillator.frequency.value; this.oscillator.frequency.cancelScheduledValues(now); this.oscillator.frequency.setValueAtTime(currentFreq, now + tFromNow); @@ -5988,7 +5988,7 @@ function (_Oscillator) { function createDCOffset() { - var ac = master.audiocontext; + var ac = main.audiocontext; var buffer = ac.createBuffer(1, 2048, ac.sampleRate); var data = buffer.getChannelData(0); @@ -6011,7 +6011,7 @@ function audioin_createClass(Constructor, protoProps, staticProps) { if (protoPr -master.inputSources = []; +main.inputSources = []; /** *

Get audio from an input, i.e. your computer's microphone.

* @@ -6039,7 +6039,7 @@ master.inputSources = []; * * function setup(){ * let cnv = createCanvas(100, 100); - * cnv.mousePressed(useraudiocontextStartAudio); + * cnv.mousePressed(userStartAudio); * textAlign(CENTER); * mic = new p5.AudioIn(); * mic.start(); @@ -6066,12 +6066,12 @@ function () { /** * @property {GainNode} input */ - this.input = master.audiocontext.createGain(); + this.input = main.audiocontext.createGain(); /** * @property {GainNode} output */ - this.output = master.audiocontext.createGain(); + this.output = main.audiocontext.createGain(); /** * @property {MediaStream|null} stream */ @@ -6109,7 +6109,7 @@ function () { } - master.soundArray.push(this); + main.soundArray.push(this); } /** * Start processing audio input. This enables the use of other @@ -6143,15 +6143,15 @@ function () { } - var audioSource = master.inputSources[self.currentSource]; + var audioSource = main.inputSources[self.currentSource]; var constraints = { audio: { - sampleRate: master.audiocontext.sampleRate, + sampleRate: main.audiocontext.sampleRate, echoCancellation: false } }; - if (master.inputSources[this.currentSource]) { + if (main.inputSources[this.currentSource]) { constraints.audio.deviceId = audioSource.deviceId; } @@ -6159,7 +6159,7 @@ function () { self.stream = stream; self.enabled = true; - self.mediaStream = master.audiocontext.createMediaStreamSource(stream); + self.mediaStream = main.audiocontext.createMediaStreamSource(stream); self.mediaStream.connect(self.output); self.amplitude.setInput(self.output); @@ -6190,7 +6190,7 @@ function () { } /** * Connect to an audio unit. If no parameter is provided, will - * connect to the master output (i.e. your speakers).
+ * connect to the main output (i.e. your speakers).
* * @method connect * @for p5.AudioIn @@ -6210,7 +6210,7 @@ function () { this.output.connect(unit); } } else { - this.output.connect(master.input); + this.output.connect(main.input); } } /** @@ -6269,12 +6269,12 @@ function () { if (t) { var rampTime = t || 0; var currentVol = this.output.gain.value; - this.output.gain.cancelScheduledValues(master.audiocontext.currentTime); - this.output.gain.setValueAtTime(currentVol, master.audiocontext.currentTime); - this.output.gain.linearRampToValueAtTime(vol, rampTime + master.audiocontext.currentTime); + this.output.gain.cancelScheduledValues(main.audiocontext.currentTime); + this.output.gain.setValueAtTime(currentVol, main.audiocontext.currentTime); + this.output.gain.linearRampToValueAtTime(vol, rampTime + main.audiocontext.currentTime); } else { - this.output.gain.cancelScheduledValues(master.audiocontext.currentTime); - this.output.gain.setValueAtTime(vol, master.audiocontext.currentTime); + this.output.gain.cancelScheduledValues(main.audiocontext.currentTime); + this.output.gain.setValueAtTime(vol, main.audiocontext.currentTime); } } /** @@ -6318,13 +6318,13 @@ function () { value: function getSources(onSuccess, onError) { return new Promise(function (resolve, reject) { window.navigator.mediaDevices.enumerateDevices().then(function (devices) { - master.inputSources = devices.filter(function (device) { + main.inputSources = devices.filter(function (device) { return device.kind === 'audioinput'; }); - resolve(master.inputSources); + resolve(main.inputSources); if (onSuccess) { - onSuccess(master.inputSources); + onSuccess(main.inputSources); } })["catch"](function (error) { reject(error); @@ -6372,9 +6372,9 @@ function () { }, { key: "setSource", value: function setSource(num) { - if (master.inputSources.length > 0 && num < master.inputSources.length) { + if (main.inputSources.length > 0 && num < main.inputSources.length) { this.currentSource = num; - console.log('set source to ', master.inputSources[this.currentSource]); + console.log('set source to ', main.inputSources[this.currentSource]); } else { console.log('unable to set input source'); } @@ -6388,8 +6388,8 @@ function () { }, { key: "dispose", value: function dispose() { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); this.stop(); if (this.output) { @@ -6449,7 +6449,7 @@ function () { function Effect() { effect_classCallCheck(this, Effect); - this.ac = master.audiocontext; + this.ac = main.audiocontext; this.input = this.ac.createGain(); this.output = this.ac.createGain(); /** @@ -6473,7 +6473,7 @@ function () { this.connect(); - master.soundArray.push(this); + main.soundArray.push(this); } /** * Set the output volume of the filter. @@ -6491,7 +6491,7 @@ function () { value: function amp(vol) { var rampTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var tFromNow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var startTime = now + tFromNow; var endTime = startTime + rampTime + 0.001; var currentVol = this.output.gain.value; @@ -6570,8 +6570,8 @@ function () { }, { key: "dispose", value: function dispose() { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); if (this.input) { this.input.disconnect(); @@ -7067,8 +7067,8 @@ function (_Filter) { }, { key: "dispose", value: function dispose() { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); this.disconnect(); delete this.biquad; } @@ -7354,7 +7354,7 @@ function () { function Listener3D(type) { listener3d_classCallCheck(this, Listener3D); - this.ac = master.audiocontext; + this.ac = main.audiocontext; this.listener = this.ac.listener; } // * Connect an audio sorce @@ -8593,7 +8593,7 @@ function (_Effect) { * background(220); * text('tap to play', 20, 20); * - * // disconnect from master output... + * // disconnect from main output... * sound.disconnect(); * * // ...and process with cVerb @@ -8763,7 +8763,7 @@ function (_Reverb) { * background(220); * text('tap to play', 20, 20); * - * // disconnect from master output... + * // disconnect from main output... * sound.disconnect(); * * // ...and process with cVerb @@ -8918,7 +8918,7 @@ function (_Reverb) { * background(220); * text('tap to play', 20, 20); * - * // disconnect from master output... + * // disconnect from main output... * sound.disconnect(); * * // ...and process with cVerb @@ -8988,7 +8988,7 @@ function () { key: "ontick", value: function ontick(tickTime) { var elapsedTime = tickTime - this.prevTick; - var secondsFromNow = tickTime - master.audiocontext.currentTime; + var secondsFromNow = tickTime - main.audiocontext.currentTime; if (elapsedTime - this.tatumTime <= -0.02) { return; @@ -9018,7 +9018,7 @@ function () { value: function setBPM(bpm) { var rampTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var beatTime = 60 / (bpm * this.tatums); - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.tatumTime = beatTime; this.clock.frequency.setValueAtTime(this.clock.frequency.value, now); this.clock.frequency.linearRampToValueAtTime(bpm, now + rampTime); @@ -9050,7 +9050,7 @@ function () { key: "start", value: function start(timeFromNow) { var t = timeFromNow || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.clock.start(now + t); this.setBPM(this.bpm); } @@ -9058,7 +9058,7 @@ function () { key: "stop", value: function stop(timeFromNow) { var t = timeFromNow || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; this.clock.stop(now + t); } }, { @@ -9094,9 +9094,9 @@ var BPM = 120; p5.prototype.setBPM = function (bpm, rampTime) { BPM = bpm; - for (var i in master.parts) { - if (master.parts[i]) { - master.parts[i].setBPM(bpm, rampTime); + for (var i in main.parts) { + if (main.parts[i]) { + main.parts[i].setBPM(bpm, rampTime); } } }; @@ -9256,7 +9256,7 @@ function () { this.metro.beatLength(this.tatums); this.metro.setBPM(BPM); - master.parts.push(this); + main.parts.push(this); this.callback = function () {}; } @@ -9508,19 +9508,18 @@ function () { looper_classCallCheck(this, Score); this.parts = []; - this.currentPart = 0; + this.currentPart = new Array(arguments.length); + ; var thisScore = this; for (var i in arguments) { - if (arguments[i] && this.parts[i]) { - this.parts[i] = arguments[i]; - this.parts[i].nextPart = this.parts[i + 1]; + this.parts[i] = arguments[i]; + this.parts[i].nextPart = this.parts[i + 1]; - this.parts[i].onended = function () { - thisScore.resetPart(i); - playNextPart(thisScore); - }; - } + this.parts[i].onended = function () { + thisScore.resetPart(i); + playNextPart(thisScore); + }; } this.looping = false; @@ -9823,7 +9822,7 @@ function () { var self = this; this.clock = new Clock_default.a({ callback: function callback(time) { - var timeFromNow = time - master.audiocontext.currentTime; + var timeFromNow = time - main.audiocontext.currentTime; /** * Do not initiate the callback if timeFromNow is < 0 * This ususually occurs for a few milliseconds when the page @@ -9851,7 +9850,7 @@ function () { key: "start", value: function start(timeFromNow) { var t = timeFromNow || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; if (!this.isPlaying) { this.clock.start(now + t); @@ -9869,7 +9868,7 @@ function () { key: "stop", value: function stop(timeFromNow) { var t = timeFromNow || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; if (this.isPlaying) { this.clock.stop(now + t); @@ -9887,7 +9886,7 @@ function () { key: "pause", value: function pause(timeFromNow) { var t = timeFromNow || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; if (this.isPlaying) { this.clock.pause(now + t); @@ -9910,7 +9909,7 @@ function () { key: "syncedStart", value: function syncedStart(otherLoop, timeFromNow) { var t = timeFromNow || 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; if (!otherLoop.isPlaying) { otherLoop.clock.start(now + t); @@ -9918,7 +9917,7 @@ function () { this.clock.start(now + t); this.isPlaying = true; } else if (otherLoop.isPlaying) { - var time = otherLoop.clock._nextTick - master.audiocontext.currentTime; + var time = otherLoop.clock._nextTick - main.audiocontext.currentTime; this.clock.start(now + time); this.isPlaying = true; } @@ -10042,7 +10041,7 @@ function compressor_setPrototypeOf(o, p) { compressor_setPrototypeOf = Object.se * Compression can be used to avoid clipping (sound distortion due to * peaks in volume) and is especially useful when many sounds are played * at once. Compression can be used on indivudal sound sources in addition - * to the master output. + * to the main output. * * This class extends p5.Effect. * Methods amp(), chain(), @@ -10556,7 +10555,7 @@ function soundRecorder_createClass(Constructor, protoProps, staticProps) { if (p -var soundRecorder_ac = master.audiocontext; +var soundRecorder_ac = main.audiocontext; /** *

Record sounds for playback and/or to save as a .wav file. * The p5.SoundRecorder records all sound output from your sketch, @@ -10672,7 +10671,7 @@ function () { this.setInput(); - master.soundArray.push(this); + main.soundArray.push(this); } /** * Connect a specific device to the p5.SoundRecorder. @@ -10757,8 +10756,8 @@ function () { }, { key: "dispose", value: function dispose() { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); this._callback = function () {}; @@ -10982,7 +10981,7 @@ function gain_createClass(Constructor, protoProps, staticProps) { if (protoProps * * // load two soundfile and crossfade beetween them * let sound1,sound2; - * let sound1Gain, sound2Gain, masterGain; + * let sound1Gain, sound2Gain, mixGain; * function preload(){ * soundFormats('ogg', 'mp3'); * sound1 = loadSound('assets/Damscray_-_Dancing_Tiger_01'); @@ -10991,17 +10990,17 @@ function gain_createClass(Constructor, protoProps, staticProps) { if (protoProps * function setup() { * let cnv = createCanvas(100, 100); * cnv.mousePressed(startSound); - * // create a 'master' gain to which we will connect both soundfiles - * masterGain = new p5.Gain(); - * masterGain.connect(); + * // create a 'mix' gain bus to which we will connect both soundfiles + * mixGain = new p5.Gain(); + * mixGain.connect(); * sound1.disconnect(); // diconnect from p5 output * sound1Gain = new p5.Gain(); // setup a gain node * sound1Gain.setInput(sound1); // connect the first sound to its input - * sound1Gain.connect(masterGain); // connect its output to the 'master' + * sound1Gain.connect(mixGain); // connect its output to the final mix bus * sound2.disconnect(); * sound2Gain = new p5.Gain(); * sound2Gain.setInput(sound2); - * sound2Gain.connect(masterGain); + * sound2Gain.connect(mixGain); * } * function startSound() { * sound1.loop(); @@ -11026,10 +11025,10 @@ function gain_createClass(Constructor, protoProps, staticProps) { if (protoProps * var sound2Volume = 1-sound1Volume; * sound1Gain.amp(sound1Volume); * sound2Gain.amp(sound2Volume); - * // map the vertical position of the mouse to values useable for 'master * volume control' - * var masterVolume = constrain(map(mouseY,height,0,0,1), 0, 1); - * masterGain.amp(masterVolume); - * text('master', width/2, height - masterVolume * height * 0.9) + * // map the vertical position of the mouse to values useable for 'output * volume control' + * var outputVolume = constrain(map(mouseY,height,0,0,1), 0, 1); + * mixGain.amp(outputVolume); + * text('output', width/2, height - outputVolume * height * 0.9) * fill(255, 0, 255); * textAlign(LEFT); * text('sound1', 5, height - sound1Volume * height * 0.9); @@ -11044,14 +11043,14 @@ function () { function Gain() { gain_classCallCheck(this, Gain); - this.ac = master.audiocontext; + this.ac = main.audiocontext; this.input = this.ac.createGain(); this.output = this.ac.createGain(); this.input.gain.value = 0.5; this.input.connect(this.output); - master.soundArray.push(this); + main.soundArray.push(this); } /** * Connect a source to the gain node. @@ -11112,7 +11111,7 @@ function () { value: function amp(vol) { var rampTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var tFromNow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var currentVol = this.output.gain.value; this.output.gain.cancelScheduledValues(now); this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow); @@ -11121,8 +11120,8 @@ function () { }, { key: "dispose", value: function dispose() { - var index = master.soundArray.indexOf(this); - master.soundArray.splice(index, 1); + var index = main.soundArray.indexOf(this); + main.soundArray.splice(index, 1); if (this.output) { this.output.disconnect(); @@ -11161,10 +11160,10 @@ function () { function AudioVoice() { audioVoice_classCallCheck(this, AudioVoice); - this.ac = master.audiocontext; + this.ac = main.audiocontext; this.output = this.ac.createGain(); this.connect(); - master.soundArray.push(this); + main.soundArray.push(this); } audioVoice_createClass(AudioVoice, [{ @@ -11189,7 +11188,7 @@ function () { }, { key: "connect", value: function connect(unit) { - var u = unit || master.input; + var u = unit || main.input; this.output.connect(u.input ? u.input : u); } /** @@ -11319,7 +11318,7 @@ function (_AudioVoice) { _this.connect(); - master.soundArray.push(monosynth_assertThisInitialized(_this)); + main.soundArray.push(monosynth_assertThisInitialized(_this)); /** * Getters and Setters * @property {Number} attack @@ -11573,7 +11572,7 @@ function (_AudioVoice) { }, { key: "connect", value: function connect(unit) { - var u = unit || master.input; + var u = unit || main.input; this.output.connect(u.input ? u.input : u); } /** @@ -11774,12 +11773,12 @@ function () { */ this._voicesInUse = new TimelineSignal_default.a(0); - this.output = master.audiocontext.createGain(); + this.output = main.audiocontext.createGain(); this.connect(); this._allocateVoices(); - master.soundArray.push(this); + main.soundArray.push(this); } /** * Construct the appropriate number of audiovoices @@ -11875,7 +11874,7 @@ function () { key: "noteADSR", value: function noteADSR(note, a, d, s, r) { var timeFromNow = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var t = now + timeFromNow; this.audiovoices[this.notes[note].getValueAtTime(t)].setADSR(a, d, s, r); } @@ -11951,7 +11950,7 @@ function () { key: "noteAttack", value: function noteAttack(_note, _velocity) { var secondsFromNow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var acTime = master.audiocontext.currentTime + secondsFromNow; + var acTime = main.audiocontext.currentTime + secondsFromNow; var note = noteToFreq(_note); var velocity = _velocity || 0.1; @@ -12063,7 +12062,7 @@ function () { }, { key: "noteRelease", value: function noteRelease(_note, secondsFromNow) { - var now = master.audiocontext.currentTime; + var now = main.audiocontext.currentTime; var tFromNow = secondsFromNow || 0; var t = now + tFromNow; @@ -12114,7 +12113,7 @@ function () { }, { key: "connect", value: function connect(unit) { - var u = unit || master.input; + var u = unit || main.input; this.output.connect(u.input ? u.input : u); } /** diff --git a/lib/p5.sound.js.map b/lib/p5.sound.js.map index d9ee463f..d8163d63 100644 --- a/lib/p5.sound.js.map +++ b/lib/p5.sound.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../node_modules/tone/Tone/core/Tone.js","webpack:///../node_modules/tone/Tone/signal/Multiply.js","webpack:///../node_modules/tone/Tone/signal/Signal.js","webpack:///./audiocontext.js","webpack:///../node_modules/tone/Tone/signal/Add.js","webpack:///./audioWorklet/processorNames.js","webpack:///../node_modules/tone/Tone/signal/WaveShaper.js","webpack:///../node_modules/tone/Tone/signal/TimelineSignal.js","webpack:///../node_modules/tone/Tone/signal/Scale.js","webpack:///../node_modules/tone/Tone/type/Type.js","webpack:///../node_modules/tone/Tone/core/Gain.js","webpack:///../node_modules/tone/Tone/core/Clock.js","webpack:///../node_modules/tone/Tone/core/Context.js","webpack:///../node_modules/tone/Tone/signal/Subtract.js","webpack:///../node_modules/tone/Tone/core/Emitter.js","webpack:///../node_modules/tone/Tone/signal/SignalBase.js","webpack:///../node_modules/tone/Tone/type/Time.js","webpack:///../node_modules/tone/Tone/type/TimeBase.js","webpack:///../node_modules/tone/Tone/core/Param.js","webpack:///../node_modules/tone/Tone/core/Timeline.js","webpack:///../node_modules/tone/Tone/signal/Negate.js","webpack:///../node_modules/tone/Tone/signal/GreaterThanZero.js","webpack:///../node_modules/startaudiocontext/StartAudioContext.js","webpack:///../node_modules/tone/Tone/component/CrossFade.js","webpack:///../node_modules/audioworklet-polyfill/dist/audioworklet-polyfill.js","webpack:///./shims.js","webpack:///../node_modules/webpack/buildin/global.js","webpack:///./audioWorklet/recorderProcessor.js","webpack:///./audioWorklet/soundFileProcessor.js","webpack:///./audioWorklet/amplitudeProcessor.js","webpack:///../node_modules/tone/Tone/type/Frequency.js","webpack:///../node_modules/tone/Tone/type/TransportTime.js","webpack:///../node_modules/tone/Tone/signal/Expr.js","webpack:///../node_modules/tone/Tone/signal/GreaterThan.js","webpack:///../node_modules/tone/Tone/signal/Abs.js","webpack:///../node_modules/tone/Tone/signal/Modulo.js","webpack:///../node_modules/tone/Tone/signal/Pow.js","webpack:///../node_modules/tone/Tone/signal/AudioToGain.js","webpack:///../node_modules/tone/Tone/signal/EqualPowerGain.js","webpack:///../node_modules/tone/Tone/core/TimelineState.js","webpack:///./master.js","webpack:///./helpers.js","webpack:///./errorHandler.js","webpack:///./audioWorklet/index.js","webpack:///./panner.js","webpack:///./soundfile.js","webpack:///./amplitude.js","webpack:///./fft.js","webpack:///./oscillator.js","webpack:///./envelope.js","webpack:///./noise.js","webpack:///./pulse.js","webpack:///./audioin.js","webpack:///./effect.js","webpack:///./filter.js","webpack:///./eqFilter.js","webpack:///./eq.js","webpack:///./listener3d.js","webpack:///./panner3d.js","webpack:///./delay.js","webpack:///./reverb.js","webpack:///./metro.js","webpack:///./looper.js","webpack:///./soundLoop.js","webpack:///./compressor.js","webpack:///./peakDetect.js","webpack:///./soundRecorder.js","webpack:///./distortion.js","webpack:///./gain.js","webpack:///./audioVoice.js","webpack:///./monosynth.js","webpack:///./onsetDetect.js","webpack:///./polysynth.js","webpack:///./deprecations/Signal.js","webpack:///./app.js"],"names":["define","Tone","inputs","outputs","this","isUndef","input","context","createGain","Array","output","audioContext","prototype","set","params","value","rampTime","isObject","isString","tmpObj","paramLoop","attr","parent","indexOf","attrSplit","split","i","length","splice","innerParam","join","param","Signal","Param","rampTo","AudioParam","get","_collectDefaults","constructor","ret","subRet","j","subAttr","isFunction","constr","defaults","Object","keys","_super","superDefs","push","toString","className","isLetter","match","sameConstructor","defineProperty","isArray","dispose","AudioNode","disconnect","connect","unit","outputNum","inputNum","defaultArg","destination","isNumber","apply","arguments","connectSeries","currentUnit","toUnit","chain","fan","given","fallback","givenProp","fallbackProp","optionsObject","values","options","val","arg","call","isBoolean","noOp","_readOnly","property","writable","enumerable","_writable","State","Started","Stopped","Paused","equalPowerScale","percent","piFactor","Math","PI","sin","dbToGain","db","pow","gainToDb","gain","log","LN10","intervalToFrequencyRatio","interval","now","extend","child","TempConstructor","Context","emit","setContext","ctx","sampleRate","hasAudioContext","window","hasOwnProperty","hasPromises","hasWorkers","version","TONE_SILENCE_VERSION_LOGGING","console","Multiply","createInsOuts","_mult","Gain","_param","_gain","getConstant","units","Type","Default","convert","SignalBase","global","audiocontext","AudioContext","getAudioContext","userStartAudio","elements","callback","elt","p5","Element","map","e","StartAudioContext","Add","_sum","module","exports","recorderProcessor","soundFileProcessor","amplitudeProcessor","WaveShaper","mapping","bufferLen","_shaper","createWaveShaper","_curve","curve","isFinite","Float32Array","setMap","len","normalized","oversample","oversampling","RangeError","TimelineSignal","_events","Timeline","_initial","_fromUnits","Linear","Exponential","Target","Curve","Set","getValueAtTime","_toUnits","convertedVal","cancelScheduledValues","setValueAtTime","startTime","toSeconds","add","type","time","linearRampToValueAtTime","endTime","exponentialRampToValueAtTime","beforeEvent","_searchBefore","_minOutput","setValue","max","sampleTime","setTargetAtTime","timeConstant","constant","setValueCurveAtTime","duration","scaling","floats","segmentTime","after","cancel","setRampPoint","before","_searchAfter","linearRampToValueBetween","start","finish","exponentialRampToValueBetween","getAfter","previouVal","previous","getBefore","_exponentialApproach","_curveInterpolate","_linearInterpolate","_exponentialInterpolate","t0","v0","v1","t","exp","t1","progress","lowerIndex","floor","upperIndex","ceil","lowerVal","upperVal","Scale","outputMin","outputMax","_outputMin","_outputMax","_scale","_add","_setRange","min","Time","Frequency","TransportTime","Ticks","NormalRange","AudioRange","Decibels","Interval","BPM","Positive","Cents","Degrees","MIDI","BarsBeatsSixteenths","Samples","Hertz","Note","Milliseconds","Seconds","Notation","TimeBase","toFrequency","freq","valueOf","toTicks","Transport","ticks","GainNode","createGainNode","_gainNode","Clock","Emitter","_nextTick","_lastState","frequency","_state","TimelineState","_boundLoop","_loop","bind","on","lookAhead","offset","state","stop","setStateAtTime","pause","loopInterval","updateInterval","lag","currentState","event","tickTime","getStateAtTime","off","Infinity","toneConnect","B","outNum","inNum","nativeConnect","Error","nativeDisconnect","webkitAudioContext","prop","_context","_defineProperty","_latencyHint","_lookAhead","_updateInterval","_computedUpdateInterval","_worker","_createWorker","_constants","mixin","currentTime","URL","webkitURL","blob","Blob","toFixed","blobUrl","createObjectURL","worker","Worker","addEventListener","_lastUpdate","diff","buffer","createBuffer","arr","getChannelData","createBufferSource","channelCount","channelCountMode","loop","lA","blockTime","postMessage","hint","latencyHint","supported","warn","Subtract","_neg","Negate","events","eventName","ev","eventList","args","slice","object","functions","func","emitterFunc","node","outputNumber","inputNumber","overridden","_plusNow","_unaryExpressions","create","quantize","regexp","method","rh","nextSubdivision","lh","subdiv","_expr","expr","subdivision","round","addNow","_defaultExpr","_noOp","copy","toNotation","retNotation","_toNotationHelper","retTripletNotation","testNotations","threshold","_notationToUnits","notationTime","multiple","notation","primaryExprs","_primaryExpressions","notationExprs","n","m","toBarsBeatsSixteenths","quarterTime","_beatsToUnits","quarters","measures","_timeSignature","sixteenths","parseFloat","PPQ","toSamples","toMilliseconds","_defaultUnits","exprString","_parseExprString","clone","instance","parseInt","_ticksToUnits","hz","_frequencyToUnits","tr","q","s","total","_secondsToUnits","samples","default","_binaryExpressions","+","precedence","-","*","/","neg","_syntaxGlue","(",")","_tokenize","position","tokens","token","getNextToken","trim","substr","expressions","group","opName","op","reg","SyntaxError","next","peek","_matchGroup","prec","test","_parseBinary","lexer","_parseUnary","_parsePrimary","matching","beats","bpm","seconds","timeSignature","_pushExpr","name","sub","mult","div","_lfo","lfo","undefined","LFO","currentVal","exponentialRampToValue","linearRampToValue","_timeline","_toRemove","_iterating","memory","index","_search","remove","shift","cancelBefore","beginning","end","midPoint","nextEvent","_iterate","lowerBound","upperBound","forEach","forEachBefore","forEachAfter","forEachFrom","forEachAtTime","_multiply","GreaterThanZero","_thresh","root","factory","amd","TapListener","element","_dragged","_element","_bindedMove","_moved","_bindedEnd","_ended","isStarted","source","resume","startContext","removeEventListener","promise","Promise","success","checkLoop","requestAnimationFrame","onStarted","tapListeners","bindTapListener","NodeList","document","querySelectorAll","jquery","toArray","tap","body","then","CrossFade","initialFade","a","b","fade","_equalPowerA","EqualPowerGain","_equalPowerB","_invert","Expr","r","parameters","o","bufferSize","fill","processor","realm","exec","inputBuffer","outputBuffer","process","numberOfChannels","$$processors","$$context","AudioWorkletNode","self","createScriptProcessor","outputChannelCount","Map","properties","u","c","l","defaultValue","p","MessageChannel","port2","f","Processor","port","port1","onaudioprocess","$$audioWorklet","AudioWorklet","addModule","fetch","ok","status","text","AudioWorkletProcessor","registerProcessor","parameterDescriptors","createElement","style","cssText","appendChild","contentWindow","createTextNode","$hook","documentElement","transpile","String","fixSetTarget","setTargetValueAtTime","createDelay","createDelayNode","createJavaScriptNode","createPeriodicWave","createWaveTable","internal_createGain","internal_createDelay","maxDelayTime","delayTime","internal_createBufferSource","when","noteGrainOn","noteOn","internal_start","noteOff","internal_stop","playbackRate","internal_createDynamicsCompressor","createDynamicsCompressor","knee","ratio","reduction","attack","release","internal_createBiquadFilter","createBiquadFilter","detune","Q","createOscillator","internal_createOscillator","setPeriodicWave","setWaveTable","OfflineAudioContext","webkitOfflineAudioContext","navigator","getUserMedia","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","el","isSupported","canPlayType","isOGGSupported","isMP3Supported","isWAVSupported","isAACSupported","isAIFSupported","isFileSupported","extension","toLowerCase","g","Function","midi","midiToFrequency","note","pitch","octave","noteNumber","noteToScaleIndex","transpose","harmonize","intervals","toMidi","frequencyToMidi","toNote","A4","LN2","scaleIndexToNote","cbb","cb","c#","cx","dbb","d","d#","dx","ebb","eb","e#","ex","fbb","fb","f#","fx","gbb","gb","g#","gx","abb","ab","a#","ax","bbb","bb","b#","bx","_secondsToTicks","applyBinary","Constructor","_eval","applyUnary","getNumber","literalNumber","_replacements","inputCount","_parseInputs","_nodes","result","tree","_parseTree","_disposeNodes","_Expressions","signal","glue",",","abs","Abs","mod","modulus","Modulo","Pow","a2g","AudioToGain","binary","unary","!","NOT","inputArray","inputMax","replace","matchSyntax","syn","matchGroup","groupName","parseExpression","parseUnary","operator","parsePrimary","parseArgumentList","parseFunctionCall","GreaterThan","_gtz","_abs","_subtract","_modSignal","_setWaveShaper","_exp","_expScaler","_expFunc","_norm","x","_eqPower","initial","Master","limiter","meter","fftMeter","soundArray","parts","extensions","p5sound","getMasterVolume","masterVolume","vol","tFromNow","currentVol","soundOut","_silentNode","freqToMidi","mathlog2","midiToFreq","noteToFreq","wholeNotes","A","C","D","E","F","G","toUpperCase","soundFormats","disposeSound","_checkFileFormats","paths","path","extTest","pop","pathSplit","pathCore","_mathChain","math","thisChain","nextChain","mathOps","convertToWav","audioBuffer","leftChannel","rightChannel","interleaved","interleave","ArrayBuffer","view","DataView","writeUTFBytes","setUint32","setUint16","lng","volume","setInt16","inputIndex","string","setUint8","charCodeAt","safeBufferSize","idealBufferSize","tempAudioWorkletNode","processorNames","ScriptProcessorNode","saveSound","soundFile","fileName","dataView","writeFile","CustomError","errorTrace","failedPath","err","tempStack","splitStack","originalStack","stack","filter","ln","moduleSources","require","ac","initializedAudioWorklets","loadAudioWorkletModules","all","moduleSrc","objectURL","audioWorklet","registerMethod","preload","_incrementPreload","onWorkletModulesLoad","_decrementPreload","panner","createStereoPanner","Panner","stereoPanner","pan","obj","numInputChannels","left","right","channelInterpretation","splitter","createChannelSplitter","createChannelMerger","v","rightVal","cos","leftVal","numChannels","_createCounterBuffer","audioBuf","arrayBuffer","Cue","id","_clearOnEnd","thisBufferSourceNode","target","_playing","_onended","bufferSourceNodes","_","reverse","SoundFile","onload","onerror","whileLoading","url","File","FileReader","FileList","file","_looping","_paused","_pauseTime","_cues","_cueIDCounter","_lastPos","_counterNode","_workletNode","bufferSourceNode","reversed","pauseTime","mode","startMillis","panPosition","load","_whileLoading","amp","setVolume","errorCallback","request","XMLHttpRequest","evt","_updateProgress","open","responseType","decodeAudioData","response","buff","inputChannels","msg","error","statusText","message","send","reader","readAsArrayBuffer","lengthComputable","percentComplete","loaded","rate","_cueStart","cueStart","cueEnd","isPlaying","_initSourceNode","_initCounterNode","_arrayIndex","loopStart","loopEnd","str","pTime","play","bool","timeFromNow","stopAll","_time","pval","reverseBuffer","num","newPlaybackRate","_rampTime","_tFromNow","cueTime","cTime","dur","width","sampleSize","sampleStep","channels","peaks","chan","currentPos","curVol","getVolume","jump","buf","size","newBuffer","channelNum","channel","cNode","workletBufferSize","processorOptions","onmessage","data","_onTimeUpdate","_initThreshold","_minThreshold","_minPeaks","cue","cueLength","playbackTime","callbackTime","leftLimit","_prevUpdateTime","rightLimit","loadSound","location","origin","cordova","alert","Amplitude","smoothing","parameterData","normalize","volNorm","stereoVol","stereoVolNorm","FFT","bins","analyser","createAnalyser","defineProperties","fftSize","configurable","smoothingTimeConstant","smooth","freqDomain","Uint8Array","frequencyBinCount","timeDomain","bass","lowMid","mid","highMid","treble","normalArray","_isSafari","timeToFloat","getFloatTimeDomainData","timeToInt","getByteTimeDomainData","scaled","freqToFloat","getFloatFrequencyData","freqToInt","getByteFrequencyData","frequency1","frequency2","nyquist","swap","lowIndex","highIndex","numFrequencies","toReturn","freq1","freq2","getEnergy","cumulative_sum","centroid_normalization","mean_freq_index","spec_centroid_freq","_N","N","spectrum","spectrumLength","spectrumStep","linearAverages","groupIndex","specIndex","octaveBands","logAverages","octaveIndex","specIndexFrequency","hi","_fCtr0","fCtr0","lastFrequencyBand","lo","ctr","newFrequencyBand","fft","sigChain","mathObj","chainSource","oscillator","Oscillator","started","phaseAmount","_freqMods","connection","freqNode","isNaN","phase","oscMods","osc2","delayAmt","dNode","Mult","inMin","inMax","outMin","outMax","mapOutMin","mapOutMax","scale","SinOsc","TriOsc","SawOsc","SqrOsc","Envelope","l1","t2","l2","t3","l3","aTime","aLevel","dTime","dLevel","rTime","rLevel","_rampHighPercentage","_rampLowPercentage","control","_init","isExponential","sourceToClear","wasTriggered","_setRampAD","setADSR","sPercent","setRange","_rampAttackTime","checkExpInput","_rampDecayTime","TCDenominator","_rampAttackTC","_rampDecayTC","setRampPercentages","p1","p2","setInput","setExp","isExp","secondsFromNow","susTime","triggerAttack","triggerRelease","lastAttack","valToSet","ramp","v2","destination1","destination2","AudioIn","Reverb","Noise","Filter","Delay","Env","_whiteNoiseBuffer","whiteBuffer","noiseData","random","_pinkNoiseBuffer","pinkBuffer","b0","b1","b2","b3","b4","b5","b6","white","_brownNoiseBuffer","brownBuffer","lastOut","assignType","noise","Pulse","w","dcOffset","createDCOffset","dcGain","mW","sig","mult1","mult2","mods","currentFreq","freqMod","bufferSource","inputSources","stream","mediaStream","currentSource","enabled","amplitude","MediaStreamTrack","mediaDevices","successCallback","audioSource","constraints","audio","echoCancellation","deviceId","createMediaStreamSource","getTracks","track","getLevel","onSuccess","onError","resolve","reject","enumerateDevices","devices","device","kind","active","Effect","_drywet","wet","biquad","setType","_on","_untoggledType","src","res","LowPass","HighPass","BandPass","EQFilter","EQ","_eqsize","factor","bands","_newBand","Listener3D","listener","xVal","yVal","zVal","positionX","positionY","positionZ","xValF","yValF","zValF","xValU","yValU","zValU","orientForward","orientUp","forwardX","forwardY","forwardZ","upX","upY","upZ","Panner3D","createPanner","panningModel","distanceModel","orientX","orientY","orientZ","orientationX","orientationY","orientationZ","maxDistance","rolloffFactor","maxDist","rolloff","_split","_merge","_leftGain","_rightGain","leftDelay","rightDelay","_leftFilter","_rightFilter","_maxDelay","maxValue","feedback","_delayTime","_feedback","_filter","_initConvolverNode","_seconds","_decay","_reverse","_buildImpulse","convolverNode","createConvolver","_teardownConvolverNode","decayRate","rebuild","decay","impulse","impulseL","impulseR","_setBuffer","Convolver","impulses","_loadBuffer","_path","chunks","cReverb","Metro","clock","ontick","syncedParts","prevTick","tatumTime","tickCallback","elapsedTime","thisPart","incrementStep","phrases","thisPhrase","phraseArray","sequence","bNum","metroTicks","looping","beatTime","tatums","getRate","part","setBPM","Phrase","phraseStep","Part","steps","bLength","partStep","noLoop","metro","beatLength","tempo","getBPM","resetSync","onended","array","Score","currentPart","thisScore","nextPart","resetPart","playNextPart","resetParts","scoreStep","aScore","SoundLoop","_bpm","musicalTimeMode","_update","timeSig","_interval","maxIterations","iterations","_calcFreq","otherLoop","_convertNotation","Number","_measure","_note","Compressor","compressor","number","PeakDetect","_framesPerPeak","framesPerPeak","framesSinceLastPeak","cutoff","cutoffMult","energy","penergy","currentValue","isDetected","f1","f2","_onPeak","fftObject","nrg","SoundRecorder","_inputChannels","_outputChannels","buffers","leftBuffer","rightBuffer","_callback","sFile","setBuffer","makeDistortionCurve","amount","k","numSamples","deg","Distortion","curveAmount","waveShaperNode","AudioVoice","velocity","sustime","DEFAULT_SUSTAIN","MonoSynth","env","sustain","vel","OnsetDetect","freqLow","freqHigh","treshold","sensitivity","setTimeout","PolySynth","audioVoice","maxVoices","audiovoices","notes","_newest","_oldest","_voicesInUse","_allocateVoices","noteAttack","noteRelease","voice","_velocity","acTime","currentVoice","oldestNote","previousVal","_updateAfter","maxRange","nextTime","registerPreloadMethod","listener3D","peakDetect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,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AH,GAAgBA,UAAhB;AAEA;AACA7qC,EAAE,CAACovC,UAAH,GAAgBA,UAAhB;AAEA;AACApvC,EAAE,CAAC+rC,aAAH,GAAmBA,aAAnB;AAEA;AACA/rC,EAAE,CAAC6sC,UAAH,GAAgBA,UAAhB;AAEA;AACA7sC,EAAE,CAACjB,IAAH,GAAUA,IAAV;AAEA;AACAiB,EAAE,CAACgtC,UAAH,GAAgBA,YAAhB;AAEA;AACAhtC,EAAE,CAACotC,SAAH,GAAeA,SAAf;AAEA;AACAptC,EAAE,CAACwtC,WAAH,GAAiBA,WAAjB;AAEA;AACAxtC,EAAE,CAAC8tC,SAAH,GAAeA,SAAf,C,CAEA;;AACA;AACA9tC,EAAE,CAACpH,MAAH,GAAYA,mBAAZ,C","file":"p5.sound.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 40);\n","/**\n * Tone.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2014-2017 Yotam Mann\n */\ndefine(function(){\n\n\t\"use strict\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTONE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * @class Tone is the base class of all other classes. It provides \n\t * a lot of methods and functionality to all classes that extend\n\t * it. \n\t * \n\t * @constructor\n\t * @alias Tone\n\t * @param {number} [inputs=1] the number of input nodes\n\t * @param {number} [outputs=1] the number of output nodes\n\t */\n\tvar Tone = function(inputs, outputs){\n\n\t\t/**\n\t\t * the input node(s)\n\t\t * @type {GainNode|Array}\n\t\t */\n\t\tif (this.isUndef(inputs) || inputs === 1){\n\t\t\tthis.input = this.context.createGain();\n\t\t} else if (inputs > 1){\n\t\t\tthis.input = new Array(inputs);\n\t\t}\n\n\t\t/**\n\t\t * the output node(s)\n\t\t * @type {GainNode|Array}\n\t\t */\n\t\tif (this.isUndef(outputs) || outputs === 1){\n\t\t\tthis.output = this.context.createGain();\n\t\t} else if (outputs > 1){\n\t\t\tthis.output = new Array(inputs);\n\t\t}\n\t};\n\n\t/**\n\t * Set the parameters at once. Either pass in an\n\t * object mapping parameters to values, or to set a\n\t * single parameter, by passing in a string and value.\n\t * The last argument is an optional ramp time which \n\t * will ramp any signal values to their destination value\n\t * over the duration of the rampTime.\n\t * @param {Object|string} params\n\t * @param {number=} value\n\t * @param {Time=} rampTime\n\t * @returns {Tone} this\n\t * @example\n\t * //set values using an object\n\t * filter.set({\n\t * \t\"frequency\" : 300,\n\t * \t\"type\" : highpass\n\t * });\n\t * @example\n\t * filter.set(\"type\", \"highpass\");\n\t * @example\n\t * //ramp to the value 220 over 3 seconds. \n\t * oscillator.set({\n\t * \t\"frequency\" : 220\n\t * }, 3);\n\t */\n\tTone.prototype.set = function(params, value, rampTime){\n\t\tif (this.isObject(params)){\n\t\t\trampTime = value;\n\t\t} else if (this.isString(params)){\n\t\t\tvar tmpObj = {};\n\t\t\ttmpObj[params] = value;\n\t\t\tparams = tmpObj;\n\t\t}\n\n\t\tparamLoop:\n\t\tfor (var attr in params){\n\t\t\tvalue = params[attr];\n\t\t\tvar parent = this;\n\t\t\tif (attr.indexOf(\".\") !== -1){\n\t\t\t\tvar attrSplit = attr.split(\".\");\n\t\t\t\tfor (var i = 0; i < attrSplit.length - 1; i++){\n\t\t\t\t\tparent = parent[attrSplit[i]];\n\t\t\t\t\tif (parent instanceof Tone) {\n\t\t\t\t\t\tattrSplit.splice(0,i+1);\n\t\t\t\t\t\tvar innerParam = attrSplit.join(\".\");\n\t\t\t\t\t\tparent.set(innerParam, value);\n\t\t\t\t\t\tcontinue paramLoop;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tattr = attrSplit[attrSplit.length - 1];\n\t\t\t}\n\t\t\tvar param = parent[attr];\n\t\t\tif (this.isUndef(param)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((Tone.Signal && param instanceof Tone.Signal) || \n\t\t\t\t\t(Tone.Param && param instanceof Tone.Param)){\n\t\t\t\tif (param.value !== value){\n\t\t\t\t\tif (this.isUndef(rampTime)){\n\t\t\t\t\t\tparam.value = value;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparam.rampTo(value, rampTime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (param instanceof AudioParam){\n\t\t\t\tif (param.value !== value){\n\t\t\t\t\tparam.value = value;\n\t\t\t\t}\t\t\t\t\n\t\t\t} else if (param instanceof Tone){\n\t\t\t\tparam.set(value);\n\t\t\t} else if (param !== value){\n\t\t\t\tparent[attr] = value;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Get the object's attributes. Given no arguments get\n\t * will return all available object properties and their corresponding\n\t * values. Pass in a single attribute to retrieve or an array\n\t * of attributes. The attribute strings can also include a \".\"\n\t * to access deeper properties.\n\t * @example\n\t * osc.get();\n\t * //returns {\"type\" : \"sine\", \"frequency\" : 440, ...etc}\n\t * @example\n\t * osc.get(\"type\");\n\t * //returns { \"type\" : \"sine\"}\n\t * @example\n\t * //use dot notation to access deep properties\n\t * synth.get([\"envelope.attack\", \"envelope.release\"]);\n\t * //returns {\"envelope\" : {\"attack\" : 0.2, \"release\" : 0.4}}\n\t * @param {Array=|string|undefined} params the parameters to get, otherwise will return \n\t * \t\t\t\t\t all available.\n\t * @returns {Object}\n\t */\n\tTone.prototype.get = function(params){\n\t\tif (this.isUndef(params)){\n\t\t\tparams = this._collectDefaults(this.constructor);\n\t\t} else if (this.isString(params)){\n\t\t\tparams = [params];\n\t\t} \n\t\tvar ret = {};\n\t\tfor (var i = 0; i < params.length; i++){\n\t\t\tvar attr = params[i];\n\t\t\tvar parent = this;\n\t\t\tvar subRet = ret;\n\t\t\tif (attr.indexOf(\".\") !== -1){\n\t\t\t\tvar attrSplit = attr.split(\".\");\n\t\t\t\tfor (var j = 0; j < attrSplit.length - 1; j++){\n\t\t\t\t\tvar subAttr = attrSplit[j];\n\t\t\t\t\tsubRet[subAttr] = subRet[subAttr] || {};\n\t\t\t\t\tsubRet = subRet[subAttr];\n\t\t\t\t\tparent = parent[subAttr];\n\t\t\t\t}\n\t\t\t\tattr = attrSplit[attrSplit.length - 1];\n\t\t\t}\n\t\t\tvar param = parent[attr];\n\t\t\tif (this.isObject(params[attr])){\n\t\t\t\tsubRet[attr] = param.get();\n\t\t\t} else if (Tone.Signal && param instanceof Tone.Signal){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (Tone.Param && param instanceof Tone.Param){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (param instanceof AudioParam){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (param instanceof Tone){\n\t\t\t\tsubRet[attr] = param.get();\n\t\t\t} else if (!this.isFunction(param) && !this.isUndef(param)){\n\t\t\t\tsubRet[attr] = param;\n\t\t\t} \n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * collect all of the default attributes in one\n\t * @private\n\t * @param {function} constr the constructor to find the defaults from\n\t * @return {Array} all of the attributes which belong to the class\n\t */\n\tTone.prototype._collectDefaults = function(constr){\n\t\tvar ret = [];\n\t\tif (!this.isUndef(constr.defaults)){\n\t\t\tret = Object.keys(constr.defaults);\n\t\t}\n\t\tif (!this.isUndef(constr._super)){\n\t\t\tvar superDefs = this._collectDefaults(constr._super);\n\t\t\t//filter out repeats\n\t\t\tfor (var i = 0; i < superDefs.length; i++){\n\t\t\t\tif (ret.indexOf(superDefs[i]) === -1){\n\t\t\t\t\tret.push(superDefs[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * @returns {string} returns the name of the class as a string\n\t */\n\tTone.prototype.toString = function(){\n\t\tfor (var className in Tone){\n\t\t\tvar isLetter = className[0].match(/^[A-Z]$/);\n\t\t\tvar sameConstructor = Tone[className] === this.constructor;\n\t\t\tif (this.isFunction(Tone[className]) && isLetter && sameConstructor){\n\t\t\t\treturn className;\n\t\t\t}\n\t\t}\n\t\treturn \"Tone\";\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCLASS VARS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The number of inputs feeding into the AudioNode. \n\t * For source nodes, this will be 0.\n\t * @memberOf Tone#\n\t * @name numberOfInputs\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"numberOfInputs\", {\n\t\tget : function(){\n\t\t\tif (this.input){\n\t\t\t\tif (this.isArray(this.input)){\n\t\t\t\t\treturn this.input.length;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * The number of outputs coming out of the AudioNode. \n\t * For source nodes, this will be 0.\n\t * @memberOf Tone#\n\t * @name numberOfInputs\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"numberOfOutputs\", {\n\t\tget : function(){\n\t\t\tif (this.output){\n\t\t\t\tif (this.isArray(this.output)){\n\t\t\t\t\treturn this.output.length;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\t\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCONNECTIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * disconnect and dispose\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.dispose = function(){\n\t\tif (!this.isUndef(this.input)){\n\t\t\tif (this.input instanceof AudioNode){\n\t\t\t\tthis.input.disconnect();\n\t\t\t} \n\t\t\tthis.input = null;\n\t\t}\n\t\tif (!this.isUndef(this.output)){\n\t\t\tif (this.output instanceof AudioNode){\n\t\t\t\tthis.output.disconnect();\n\t\t\t} \n\t\t\tthis.output = null;\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode\n\t * @param {Tone | AudioParam | AudioNode} unit \n\t * @param {number} [outputNum=0] optionally which output to connect from\n\t * @param {number} [inputNum=0] optionally which input to connect to\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.connect = function(unit, outputNum, inputNum){\n\t\tif (Array.isArray(this.output)){\n\t\t\toutputNum = this.defaultArg(outputNum, 0);\n\t\t\tthis.output[outputNum].connect(unit, 0, inputNum);\n\t\t} else {\n\t\t\tthis.output.connect(unit, outputNum, inputNum);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * disconnect the output\n\t * @param {Number|AudioNode} output Either the output index to disconnect\n\t * if the output is an array, or the\n\t * node to disconnect from.\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.disconnect = function(destination, outputNum, inputNum){\n\t\tif (this.isArray(this.output)){\n\t\t\tif (this.isNumber(destination)){\n\t\t\t\tthis.output[destination].disconnect();\n\t\t\t} else {\n\t\t\t\toutputNum = this.defaultArg(outputNum, 0);\n\t\t\t\tthis.output[outputNum].disconnect(destination, 0, inputNum);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.output.disconnect.apply(this.output, arguments);\n\t\t}\n\t};\n\n\t/**\n\t * connect together all of the arguments in series\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.connectSeries = function(){\n\t\tif (arguments.length > 1){\n\t\t\tvar currentUnit = arguments[0];\n\t\t\tfor (var i = 1; i < arguments.length; i++){\n\t\t\t\tvar toUnit = arguments[i];\n\t\t\t\tcurrentUnit.connect(toUnit);\n\t\t\t\tcurrentUnit = toUnit;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Connect the output of this node to the rest of the nodes in series.\n\t * @example\n\t * //connect a node to an effect, panVol and then to the master output\n\t * node.chain(effect, panVol, Tone.Master);\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.chain = function(){\n\t\tif (arguments.length > 0){\n\t\t\tvar currentUnit = this;\n\t\t\tfor (var i = 0; i < arguments.length; i++){\n\t\t\t\tvar toUnit = arguments[i];\n\t\t\t\tcurrentUnit.connect(toUnit);\n\t\t\t\tcurrentUnit = toUnit;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * connect the output of this node to the rest of the nodes in parallel.\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.fan = function(){\n\t\tif (arguments.length > 0){\n\t\t\tfor (var i = 0; i < arguments.length; i++){\n\t\t\t\tthis.connect(arguments[i]);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t//give native nodes chain and fan methods\n\tAudioNode.prototype.chain = Tone.prototype.chain;\n\tAudioNode.prototype.fan = Tone.prototype.fan;\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUTILITIES / HELPERS / MATHS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * If the `given` parameter is undefined, use the `fallback`. \n\t * If both `given` and `fallback` are object literals, it will\n\t * return a deep copy which includes all of the parameters from both \n\t * objects. If a parameter is undefined in given, it will return\n\t * the fallback property. \n\t *

\n\t * WARNING: if object is self referential, it will go into an an \n\t * infinite recursive loop.\n\t * \n\t * @param {*} given \n\t * @param {*} fallback \n\t * @return {*} \n\t */\n\tTone.prototype.defaultArg = function(given, fallback){\n\t\tif (this.isObject(given) && this.isObject(fallback)){\n\t\t\tvar ret = {};\n\t\t\t//make a deep copy of the given object\n\t\t\tfor (var givenProp in given) {\n\t\t\t\tret[givenProp] = this.defaultArg(fallback[givenProp], given[givenProp]);\n\t\t\t}\n\t\t\tfor (var fallbackProp in fallback) {\n\t\t\t\tret[fallbackProp] = this.defaultArg(given[fallbackProp], fallback[fallbackProp]);\n\t\t\t}\n\t\t\treturn ret;\n\t\t} else {\n\t\t\treturn this.isUndef(given) ? fallback : given;\n\t\t}\n\t};\n\n\t/**\n\t * returns the args as an options object with given arguments\n\t * mapped to the names provided. \n\t *\n\t * if the args given is an array containing only one object, it is assumed\n\t * that that's already the options object and will just return it. \n\t * \n\t * @param {Array} values the 'arguments' object of the function\n\t * @param {Array} keys the names of the arguments as they\n\t * should appear in the options object\n\t * @param {Object=} defaults optional defaults to mixin to the returned \n\t * options object \n\t * @return {Object} the options object with the names mapped to the arguments\n\t */\n\tTone.prototype.optionsObject = function(values, keys, defaults){\n\t\tvar options = {};\n\t\tif (values.length === 1 && this.isObject(values[0])){\n\t\t\toptions = values[0];\n\t\t} else {\n\t\t\tfor (var i = 0; i < keys.length; i++){\n\t\t\t\toptions[keys[i]] = values[i];\n\t\t\t}\n\t\t}\n\t\tif (!this.isUndef(defaults)){\n\t\t\treturn this.defaultArg(options, defaults);\n\t\t} else {\n\t\t\treturn options;\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// TYPE CHECKING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * test if the arg is undefined\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is undefined\n\t * @function\n\t */\n\tTone.prototype.isUndef = function(val){\n\t\treturn typeof val === \"undefined\";\n\t};\n\n\t/**\n\t * test if the arg is a function\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a function\n\t * @function\n\t */\n\tTone.prototype.isFunction = function(val){\n\t\treturn typeof val === \"function\";\n\t};\n\n\t/**\n\t * Test if the argument is a number.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a number\n\t */\n\tTone.prototype.isNumber = function(arg){\n\t\treturn (typeof arg === \"number\");\n\t};\n\n\t/**\n\t * Test if the given argument is an object literal (i.e. `{}`);\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is an object literal.\n\t */\n\tTone.prototype.isObject = function(arg){\n\t\treturn (Object.prototype.toString.call(arg) === \"[object Object]\" && arg.constructor === Object);\n\t};\n\n\t/**\n\t * Test if the argument is a boolean.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a boolean\n\t */\n\tTone.prototype.isBoolean = function(arg){\n\t\treturn (typeof arg === \"boolean\");\n\t};\n\n\t/**\n\t * Test if the argument is an Array\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is an array\n\t */\n\tTone.prototype.isArray = function(arg){\n\t\treturn (Array.isArray(arg));\n\t};\n\n\t/**\n\t * Test if the argument is a string.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a string\n\t */\n\tTone.prototype.isString = function(arg){\n\t\treturn (typeof arg === \"string\");\n\t};\n\n \t/**\n\t * An empty function.\n\t * @static\n\t */\n\tTone.noOp = function(){};\n\n\t/**\n\t * Make the property not writable. Internal use only. \n\t * @private\n\t * @param {string} property the property to make not writable\n\t */\n\tTone.prototype._readOnly = function(property){\n\t\tif (Array.isArray(property)){\n\t\t\tfor (var i = 0; i < property.length; i++){\n\t\t\t\tthis._readOnly(property[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tObject.defineProperty(this, property, { \n\t\t\t\twritable: false,\n\t\t\t\tenumerable : true,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Make an attribute writeable. Interal use only. \n\t * @private\n\t * @param {string} property the property to make writable\n\t */\n\tTone.prototype._writable = function(property){\n\t\tif (Array.isArray(property)){\n\t\t\tfor (var i = 0; i < property.length; i++){\n\t\t\t\tthis._writable(property[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tObject.defineProperty(this, property, { \n\t\t\t\twritable: true,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Possible play states. \n\t * @enum {string}\n\t */\n\tTone.State = {\n\t\tStarted : \"started\",\n\t\tStopped : \"stopped\",\n\t\tPaused : \"paused\",\n \t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Equal power gain scale. Good for cross-fading.\n\t * @param {NormalRange} percent (0-1)\n\t * @return {Number} output gain (0-1)\n\t */\n\tTone.prototype.equalPowerScale = function(percent){\n\t\tvar piFactor = 0.5 * Math.PI;\n\t\treturn Math.sin(percent * piFactor);\n\t};\n\n\t/**\n\t * Convert decibels into gain.\n\t * @param {Decibels} db\n\t * @return {Number} \n\t */\n\tTone.prototype.dbToGain = function(db) {\n\t\treturn Math.pow(2, db / 6);\n\t};\n\n\t/**\n\t * Convert gain to decibels.\n\t * @param {Number} gain (0-1)\n\t * @return {Decibels} \n\t */\n\tTone.prototype.gainToDb = function(gain) {\n\t\treturn 20 * (Math.log(gain) / Math.LN10);\n\t};\n\n\t/**\n\t * Convert an interval (in semitones) to a frequency ratio.\n\t * @param {Interval} interval the number of semitones above the base note\n\t * @return {number} the frequency ratio\n\t * @example\n\t * tone.intervalToFrequencyRatio(0); // 1\n\t * tone.intervalToFrequencyRatio(12); // 2\n\t * tone.intervalToFrequencyRatio(-12); // 0.5\n\t */\n\tTone.prototype.intervalToFrequencyRatio = function(interval){\n\t\treturn Math.pow(2,(interval/12));\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTIMING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Return the current time of the AudioContext clock.\n\t * @return {Number} the currentTime from the AudioContext\n\t */\n\tTone.prototype.now = function(){\n\t\treturn Tone.context.now();\n\t};\n\n\t/**\n\t * Return the current time of the AudioContext clock.\n\t * @return {Number} the currentTime from the AudioContext\n\t * @static\n\t */\n\tTone.now = function(){\n\t\treturn Tone.context.now();\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tINHERITANCE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * have a child inherit all of Tone's (or a parent's) prototype\n\t * to inherit the parent's properties, make sure to call \n\t * Parent.call(this) in the child's constructor\n\t *\n\t * based on closure library's inherit function\n\t *\n\t * @static\n\t * @param {function} \tchild \n\t * @param {function=} parent (optional) parent to inherit from\n\t * if no parent is supplied, the child\n\t * will inherit from Tone\n\t */\n\tTone.extend = function(child, parent){\n\t\tif (Tone.prototype.isUndef(parent)){\n\t\t\tparent = Tone;\n\t\t}\n\t\tfunction TempConstructor(){}\n\t\tTempConstructor.prototype = parent.prototype;\n\t\tchild.prototype = new TempConstructor();\n\t\t/** @override */\n\t\tchild.prototype.constructor = child;\n\t\tchild._super = parent;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCONTEXT\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The private audio context shared by all Tone Nodes. \n\t * @private\n\t * @type {Tone.Context|undefined}\n\t */\n\tvar audioContext;\n\n\t/**\n\t * A static pointer to the audio context accessible as Tone.context. \n\t * @type {Tone.Context}\n\t * @name context\n\t * @memberOf Tone\n\t */\n\tObject.defineProperty(Tone, \"context\", {\n\t\tget : function(){\n\t\t\treturn audioContext;\n\t\t},\n\t\tset : function(context){\n\t\t\tif (Tone.Context && context instanceof Tone.Context){\n\t\t\t\taudioContext = context;\n\t\t\t} else {\n\t\t\t\taudioContext = new Tone.Context(context);\n\t\t\t}\n\t\t\t//initialize the new audio context\n\t\t\tif (Tone.Context){\n\t\t\t\tTone.Context.emit(\"init\", audioContext);\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * The AudioContext\n\t * @type {Tone.Context}\n\t * @name context\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"context\", {\n\t\tget : function(){\n\t\t\treturn Tone.context;\n\t\t}\n\t});\n\n\t/**\n\t * Tone automatically creates a context on init, but if you are working\n\t * with other libraries which also create an AudioContext, it can be\n\t * useful to set your own. If you are going to set your own context, \n\t * be sure to do it at the start of your code, before creating any objects.\n\t * @static\n\t * @param {AudioContext} ctx The new audio context to set\n\t */\n\tTone.setContext = function(ctx){\n\t\tTone.context = ctx;\n\t};\n\n\t/**\n\t * The number of seconds of 1 processing block (128 samples)\n\t * @type {Number}\n\t * @name blockTime\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"blockTime\", {\n\t\tget : function(){\n\t\t\treturn 128 / this.context.sampleRate;\n\t\t}\n\t});\n\n\t/**\n\t * The duration in seconds of one sample.\n\t * @type {Number}\n\t * @name sampleTime\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"sampleTime\", {\n\t\tget : function(){\n\t\t\treturn 1 / this.context.sampleRate;\n\t\t}\n\t});\n\n\t/**\n\t * Whether or not all the technologies that Tone.js relies on are supported by the current browser. \n\t * @type {Boolean}\n\t * @name supported\n\t * @memberOf Tone\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone, \"supported\", {\n\t\tget : function(){\n\t\t\tvar hasAudioContext = window.hasOwnProperty(\"AudioContext\") || window.hasOwnProperty(\"webkitAudioContext\");\n\t\t\tvar hasPromises = window.hasOwnProperty(\"Promise\");\n\t\t\tvar hasWorkers = window.hasOwnProperty(\"Worker\");\n\t\t\treturn hasAudioContext && hasPromises && hasWorkers;\n\t\t}\n\t});\n\n\tTone.version = \"r10\";\n\n\t// allow optional silencing of this log\n\tif (!window.TONE_SILENCE_VERSION_LOGGING) {\n\t\tconsole.log(\"%c * Tone.js \" + Tone.version + \" * \", \"background: #000; color: #fff\");\n\t}\n\n\treturn Tone;\n});\n","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Multiply two incoming signals. Or, if a number is given in the constructor, \n\t * multiplies the incoming signal by that value. \n\t *\n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number=} value Constant value to multiple. If no value is provided,\n\t * it will return the product of the first and second inputs\n\t * @example\n\t * var mult = new Tone.Multiply();\n\t * var sigA = new Tone.Signal(3);\n\t * var sigB = new Tone.Signal(4);\n\t * sigA.connect(mult, 0, 0);\n\t * sigB.connect(mult, 0, 1);\n\t * //output of mult is 12.\n\t * @example\n\t * var mult = new Tone.Multiply(10);\n\t * var sig = new Tone.Signal(2).connect(mult);\n\t * //the output of mult is 20. \n\t */\n\tTone.Multiply = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the input node is the same as the output node\n\t\t * it is also the GainNode which handles the scaling of incoming signal\n\t\t * \n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._mult = this.input[0] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * the scaling parameter\n\t\t * @type {AudioParam}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input[1] = this.output.gain;\n\t\t\n\t\tthis._param.value = this.defaultArg(value, 0);\n\t};\n\n\tTone.extend(Tone.Multiply, Tone.Signal);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Multiply} this\n\t */\n\tTone.Multiply.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._mult.dispose();\n\t\tthis._mult = null;\n\t\tthis._param = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Multiply;\n});\n","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/type/Type\", \"Tone/core/Param\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class A signal is an audio-rate value. Tone.Signal is a core component of the library.\n\t * Unlike a number, Signals can be scheduled with sample-level accuracy. Tone.Signal\n\t * has all of the methods available to native Web Audio \n\t * [AudioParam](http://webaudio.github.io/web-audio-api/#the-audioparam-interface)\n\t * as well as additional conveniences. Read more about working with signals \n\t * [here](https://github.com/Tonejs/Tone.js/wiki/Signals).\n\t *\n\t * @constructor\n\t * @extends {Tone.Param}\n\t * @param {Number|AudioParam} [value] Initial value of the signal. If an AudioParam\n\t * is passed in, that parameter will be wrapped\n\t * and controlled by the Signal. \n\t * @param {string} [units=Number] unit The units the signal is in. \n\t * @example\n\t * var signal = new Tone.Signal(10);\n\t */\n\tTone.Signal = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"value\", \"units\"], Tone.Signal.defaults);\n\n\t\t/**\n\t\t * The node where the constant signal value is scaled.\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis.output = this._gain = this.context.createGain();\n\n\t\toptions.param = this._gain.gain;\n\t\tTone.Param.call(this, options);\n\n\t\t/**\n\t\t * The node where the value is set.\n\t\t * @type {Tone.Param}\n\t\t * @private\n\t\t */\n\t\tthis.input = this._param = this._gain.gain;\n\n\t\t//connect the const output to the node output\n\t\tthis.context.getConstant(1).chain(this._gain);\n\t};\n\n\tTone.extend(Tone.Signal, Tone.Param);\n\n\t/**\n\t * The default values\n\t * @type {Object}\n\t * @static\n\t * @const\n\t */\n\tTone.Signal.defaults = {\n\t\t\"value\" : 0,\n\t\t\"units\" : Tone.Type.Default,\n\t\t\"convert\" : true,\n\t};\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.SignalBase} this\n\t * @method\n\t */\n\tTone.Signal.prototype.connect = Tone.SignalBase.prototype.connect;\n\n\t/**\n\t * dispose and disconnect\n\t * @returns {Tone.Signal} this\n\t */\n\tTone.Signal.prototype.dispose = function(){\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._param = null;\n\t\tthis._gain.disconnect();\n\t\tthis._gain = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Signal;\n});","global.TONE_SILENCE_VERSION_LOGGING = true;\n\nimport StartAudioContext from 'startaudiocontext';\nimport Tone from 'Tone/core/Tone';\nimport 'Tone/core/Context';\n\n// Create the Audio Context\nconst audiocontext = new window.AudioContext();\n\n// Tone and p5.sound share the same audio context\nTone.setContext(audiocontext);\n\n/**\n *

Returns the Audio Context for this sketch. Useful for users\n * who would like to dig deeper into the Web Audio API\n * .

\n *\n *

Some browsers require users to startAudioContext\n * with a user gesture, such as touchStarted in the example below.

\n *\n * @for p5\n * @method getAudioContext\n * @return {Object} AudioContext for this sketch\n * @example\n *
\n * function draw() {\n * background(255);\n * textAlign(CENTER);\n *\n * if (getAudioContext().state !== 'running') {\n * text('click to start audio', width/2, height/2);\n * } else {\n * text('audio is enabled', width/2, height/2);\n * }\n * }\n *\n * function touchStarted() {\n * if (getAudioContext().state !== 'running') {\n * getAudioContext().resume();\n * }\n * var synth = new p5.MonoSynth();\n * synth.play('A4', 0.5, 0, 0.2);\n * }\n *\n *
\n */\nexport function getAudioContext() {\n return audiocontext;\n}\n\n/**\n *

It is not only a good practice to give users control over starting\n * audio. This policy is enforced by many web browsers, including iOS and\n * Google Chrome, which create the Web Audio API's\n * Audio Context\n * in a suspended state.

\n *\n *

In these browser-specific policies, sound will not play until a user\n * interaction event (i.e. mousePressed()) explicitly resumes\n * the AudioContext, or starts an audio node. This can be accomplished by\n * calling start() on a p5.Oscillator,\n * play() on a p5.SoundFile, or simply\n * userStartAudio().

\n *\n *

userStartAudio() starts the AudioContext on a user\n * gesture. The default behavior will enable audio on any\n * mouseUp or touchEnd event. It can also be placed in a specific\n * interaction function, such as mousePressed() as in the\n * example below. This method utilizes\n * StartAudioContext\n * , a library by Yotam Mann (MIT Licence, 2016).

\n * @param {Element|Array} [element(s)] This argument can be an Element,\n * Selector String, NodeList, p5.Element,\n * jQuery Element, or an Array of any of those.\n * @param {Function} [callback] Callback to invoke when the AudioContext\n * has started\n * @return {Promise} Returns a Promise that resolves when\n * the AudioContext state is 'running'\n * @method userStartAudio\n * @for p5\n * @example\n *
\n * function setup() {\n * // mimics the autoplay policy\n * getAudioContext().suspend();\n *\n * let mySynth = new p5.MonoSynth();\n *\n * // This won't play until the context has resumed\n * mySynth.play('A6');\n * }\n * function draw() {\n * background(220);\n * textAlign(CENTER, CENTER);\n * text(getAudioContext().state, width/2, height/2);\n * }\n * function mousePressed() {\n * userStartAudio();\n * }\n *
\n */\nexport function userStartAudio(elements, callback) {\n var elt = elements;\n if (elements instanceof p5.Element) {\n elt = elements.elt;\n } else if (elements instanceof Array && elements[0] instanceof p5.Element) {\n elt = elements.map(function (e) {\n return e.elt;\n });\n }\n return StartAudioContext(audiocontext, elt, callback);\n}\n\nexport default audiocontext;\n","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Add a signal and a number or two signals. When no value is\n\t * passed into the constructor, Tone.Add will sum input[0]\n\t * and input[1]. If a value is passed into the constructor, \n\t * the it will be added to the input.\n\t * \n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number=} value If no value is provided, Tone.Add will sum the first\n\t * and second inputs. \n\t * @example\n\t * var signal = new Tone.Signal(2);\n\t * var add = new Tone.Add(2);\n\t * signal.connect(add);\n\t * //the output of add equals 4\n\t * @example\n\t * //if constructed with no arguments\n\t * //it will add the first and second inputs\n\t * var add = new Tone.Add();\n\t * var sig0 = new Tone.Signal(3).connect(add, 0, 0);\n\t * var sig1 = new Tone.Signal(4).connect(add, 0, 1);\n\t * //the output of add equals 7. \n\t */\n\tTone.Add = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the summing node\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._sum = this.input[0] = this.input[1] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * @private\n\t\t * @type {Tone.Signal}\n\t\t */\n\t\tthis._param = this.input[1] = new Tone.Signal(value);\n\n\t\tthis._param.connect(this._sum);\n\t};\n\n\tTone.extend(Tone.Add, Tone.Signal);\n\t\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Add} this\n\t */\n\tTone.Add.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._sum.dispose();\n\t\tthis._sum = null;\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Add;\n});","module.exports = {\n recorderProcessor: 'recorder-processor',\n soundFileProcessor: 'sound-file-processor',\n amplitudeProcessor: 'amplitude-processor',\n};\n","define([\"Tone/core/Tone\", \"Tone/signal/SignalBase\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Wraps the native Web Audio API \n\t * [WaveShaperNode](http://webaudio.github.io/web-audio-api/#the-waveshapernode-interface).\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {function|Array|Number} mapping The function used to define the values. \n\t * The mapping function should take two arguments: \n\t * the first is the value at the current position \n\t * and the second is the array position. \n\t * If the argument is an array, that array will be\n\t * set as the wave shaping function. The input\n\t * signal is an AudioRange [-1, 1] value and the output\n\t * signal can take on any numerical values. \n\t * \n\t * @param {Number} [bufferLen=1024] The length of the WaveShaperNode buffer.\n\t * @example\n\t * var timesTwo = new Tone.WaveShaper(function(val){\n\t * \treturn val * 2;\n\t * }, 2048);\n\t * @example\n\t * //a waveshaper can also be constructed with an array of values\n\t * var invert = new Tone.WaveShaper([1, -1]);\n\t */\n\tTone.WaveShaper = function(mapping, bufferLen){\n\n\t\t/**\n\t\t * the waveshaper\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._shaper = this.input = this.output = this.context.createWaveShaper();\n\n\t\t/**\n\t\t * the waveshapers curve\n\t\t * @type {Float32Array}\n\t\t * @private\n\t\t */\n\t\tthis._curve = null;\n\n\t\tif (Array.isArray(mapping)){\n\t\t\tthis.curve = mapping;\n\t\t} else if (isFinite(mapping) || this.isUndef(mapping)){\n\t\t\tthis._curve = new Float32Array(this.defaultArg(mapping, 1024));\n\t\t} else if (this.isFunction(mapping)){\n\t\t\tthis._curve = new Float32Array(this.defaultArg(bufferLen, 1024));\n\t\t\tthis.setMap(mapping);\n\t\t} \n\t};\n\n\tTone.extend(Tone.WaveShaper, Tone.SignalBase);\n\n\t/**\n\t * Uses a mapping function to set the value of the curve. \n\t * @param {function} mapping The function used to define the values. \n\t * The mapping function take two arguments: \n\t * the first is the value at the current position \n\t * which goes from -1 to 1 over the number of elements\n\t * in the curve array. The second argument is the array position. \n\t * @returns {Tone.WaveShaper} this\n\t * @example\n\t * //map the input signal from [-1, 1] to [0, 10]\n\t * shaper.setMap(function(val, index){\n\t * \treturn (val + 1) * 5;\n\t * })\n\t */\n\tTone.WaveShaper.prototype.setMap = function(mapping){\n\t\tfor (var i = 0, len = this._curve.length; i < len; i++){\n\t\t\tvar normalized = (i / (len - 1)) * 2 - 1;\n\t\t\tthis._curve[i] = mapping(normalized, i);\n\t\t}\n\t\tthis._shaper.curve = this._curve;\n\t\treturn this;\n\t};\n\n\t/**\n\t * The array to set as the waveshaper curve. For linear curves\n\t * array length does not make much difference, but for complex curves\n\t * longer arrays will provide smoother interpolation. \n\t * @memberOf Tone.WaveShaper#\n\t * @type {Array}\n\t * @name curve\n\t */\n\tObject.defineProperty(Tone.WaveShaper.prototype, \"curve\", {\n\t\tget : function(){\n\t\t\treturn this._shaper.curve;\n\t\t},\n\t\tset : function(mapping){\n\t\t\tthis._curve = new Float32Array(mapping);\n\t\t\tthis._shaper.curve = this._curve;\n\t\t}\n\t});\n\n\t/**\n\t * Specifies what type of oversampling (if any) should be used when \n\t * applying the shaping curve. Can either be \"none\", \"2x\" or \"4x\". \n\t * @memberOf Tone.WaveShaper#\n\t * @type {string}\n\t * @name oversample\n\t */\n\tObject.defineProperty(Tone.WaveShaper.prototype, \"oversample\", {\n\t\tget : function(){\n\t\t\treturn this._shaper.oversample;\n\t\t},\n\t\tset : function(oversampling){\n\t\t\tif ([\"none\", \"2x\", \"4x\"].indexOf(oversampling) !== -1){\n\t\t\t\tthis._shaper.oversample = oversampling;\n\t\t\t} else {\n\t\t\t\tthrow new RangeError(\"Tone.WaveShaper: oversampling must be either 'none', '2x', or '4x'\");\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.WaveShaper} this\n\t */\n\tTone.WaveShaper.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._shaper.disconnect();\n\t\tthis._shaper = null;\n\t\tthis._curve = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.WaveShaper;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Timeline\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A signal which adds the method getValueAtTime. \n\t * Code and inspiration from https://github.com/jsantell/web-audio-automation-timeline\n\t * @extends {Tone.Param}\n\t * @param {Number=} value The initial value of the signal\n\t * @param {String=} units The conversion units of the signal.\n\t */\n\tTone.TimelineSignal = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"value\", \"units\"], Tone.Signal.defaults);\n\t\t\n\t\t/**\n\t\t * The scheduled events\n\t\t * @type {Tone.Timeline}\n\t\t * @private\n\t\t */\n\t\tthis._events = new Tone.Timeline(10);\n\n\t\t//constructors\n\t\tTone.Signal.apply(this, options);\n\t\toptions.param = this._param;\n\t\tTone.Param.call(this, options);\n\n\t\t/**\n\t\t * The initial scheduled value\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._initial = this._fromUnits(this._param.value);\n\t};\n\n\tTone.extend(Tone.TimelineSignal, Tone.Param);\n\n\t/**\n\t * The event types of a schedulable signal.\n\t * @enum {String}\n\t * @private\n\t */\n\tTone.TimelineSignal.Type = {\n\t\tLinear : \"linear\",\n\t\tExponential : \"exponential\",\n\t\tTarget : \"target\",\n\t\tCurve : \"curve\",\n\t\tSet : \"set\"\n\t};\n\n\t/**\n\t * The current value of the signal. \n\t * @memberOf Tone.TimelineSignal#\n\t * @type {Number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.TimelineSignal.prototype, \"value\", {\n\t\tget : function(){\n\t\t\tvar now = this.now();\n\t\t\tvar val = this.getValueAtTime(now);\n\t\t\treturn this._toUnits(val);\n\t\t},\n\t\tset : function(value){\n\t\t\tvar convertedVal = this._fromUnits(value);\n\t\t\tthis._initial = convertedVal;\n\t\t\tthis.cancelScheduledValues();\n\t\t\tthis._param.value = convertedVal;\n\t\t}\n\t});\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tSCHEDULING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Schedules a parameter value change at the given time.\n\t * @param {*}\tvalue The value to set the signal.\n\t * @param {Time} time The time when the change should occur.\n\t * @returns {Tone.TimelineSignal} this\n\t * @example\n\t * //set the frequency to \"G4\" in exactly 1 second from now. \n\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t */\n\tTone.TimelineSignal.prototype.setValueAtTime = function (value, startTime) {\n\t\tvalue = this._fromUnits(value);\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Set,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : startTime\n\t\t});\n\t\t//invoke the original event\n\t\tthis._param.setValueAtTime(value, startTime);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules a linear continuous change in parameter value from the \n\t * previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.linearRampToValueAtTime = function (value, endTime) {\n\t\tvalue = this._fromUnits(value);\n\t\tendTime = this.toSeconds(endTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Linear,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : endTime\n\t\t});\n\t\tthis._param.linearRampToValueAtTime(value, endTime);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.exponentialRampToValueAtTime = function (value, endTime) {\n\t\t//get the previous event and make sure it's not starting from 0\n\t\tendTime = this.toSeconds(endTime);\n\t\tvar beforeEvent = this._searchBefore(endTime);\n\t\tif (beforeEvent && beforeEvent.value === 0){\n\t\t\t//reschedule that event\n\t\t\tthis.setValueAtTime(this._minOutput, beforeEvent.time);\n\t\t}\n\t\tvalue = this._fromUnits(value);\n\t\tvar setValue = Math.max(value, this._minOutput);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Exponential,\n\t\t\t\"value\" : setValue,\n\t\t\t\"time\" : endTime\n\t\t});\n\t\t//if the ramped to value is 0, make it go to the min output, and then set to 0.\n\t\tif (value < this._minOutput){\n\t\t\tthis._param.exponentialRampToValueAtTime(this._minOutput, endTime - this.sampleTime);\n\t\t\tthis.setValueAtTime(0, endTime);\n\t\t} else {\n\t\t\tthis._param.exponentialRampToValueAtTime(value, endTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Start exponentially approaching the target value at the given time with\n\t * a rate having the given time constant.\n\t * @param {number} value \n\t * @param {Time} startTime \n\t * @param {number} timeConstant \n\t * @returns {Tone.TimelineSignal} this \n\t */\n\tTone.TimelineSignal.prototype.setTargetAtTime = function (value, startTime, timeConstant) {\n\t\tvalue = this._fromUnits(value);\n\t\tvalue = Math.max(this._minOutput, value);\n\t\ttimeConstant = Math.max(this._minOutput, timeConstant);\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Target,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : startTime,\n\t\t\t\"constant\" : timeConstant\n\t\t});\n\t\tthis._param.setTargetAtTime(value, startTime, timeConstant);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Set an array of arbitrary values starting at the given time for the given duration.\n\t * @param {Float32Array} values \n\t * @param {Time} startTime \n\t * @param {Time} duration\n\t * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value\n\t * @returns {Tone.TimelineSignal} this \n\t */\n\tTone.TimelineSignal.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) {\n\t\tscaling = this.defaultArg(scaling, 1);\n\t\t//copy the array\n\t\tvar floats = new Array(values.length);\n\t\tfor (var i = 0; i < floats.length; i++){\n\t\t\tfloats[i] = this._fromUnits(values[i]) * scaling;\n\t\t}\n\t\tstartTime = this.toSeconds(startTime);\n\t\tduration = this.toSeconds(duration);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Curve,\n\t\t\t\"value\" : floats,\n\t\t\t\"time\" : startTime,\n\t\t\t\"duration\" : duration\n\t\t});\n\t\t//set the first value\n\t\tthis._param.setValueAtTime(floats[0], startTime);\n\t\t//schedule a lienar ramp for each of the segments\n\t\tfor (var j = 1; j < floats.length; j++){\n\t\t\tvar segmentTime = startTime + (j / (floats.length - 1) * duration);\n\t\t\tthis._param.linearRampToValueAtTime(floats[j], segmentTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancels all scheduled parameter changes with times greater than or \n\t * equal to startTime.\n\t * \n\t * @param {Time} startTime\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.cancelScheduledValues = function (after) {\n\t\tafter = this.toSeconds(after);\n\t\tthis._events.cancel(after);\n\t\tthis._param.cancelScheduledValues(after);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Sets the computed value at the given time. This provides\n\t * a point from which a linear or exponential curve\n\t * can be scheduled after. Will cancel events after \n\t * the given time and shorten the currently scheduled\n\t * linear or exponential ramp so that it ends at `time` .\n\t * This is to avoid discontinuities and clicks in envelopes. \n\t * @param {Time} time When to set the ramp point\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.setRampPoint = function (time) {\n\t\ttime = this.toSeconds(time);\n\t\t//get the value at the given time\n\t\tvar val = this._toUnits(this.getValueAtTime(time));\n\t\t//if there is an event at the given time\n\t\t//and that even is not a \"set\"\n\t\tvar before = this._searchBefore(time);\n\t\tif (before && before.time === time){\n\t\t\t//remove everything after\n\t\t\tthis.cancelScheduledValues(time + this.sampleTime);\n\t\t} else if (before && \n\t\t\t\t before.type === Tone.TimelineSignal.Type.Curve &&\n\t\t\t\t before.time + before.duration > time){\n\t\t\t//if the curve is still playing\n\t\t\t//cancel the curve\n\t\t\tthis.cancelScheduledValues(time);\n\t\t\tthis.linearRampToValueAtTime(val, time);\n\t\t} else {\n\t\t\t//reschedule the next event to end at the given time\n\t\t\tvar after = this._searchAfter(time);\n\t\t\tif (after){\n\t\t\t\t//cancel the next event(s)\n\t\t\t\tthis.cancelScheduledValues(time);\n\t\t\t\tif (after.type === Tone.TimelineSignal.Type.Linear){\n\t\t\t\t\tthis.linearRampToValueAtTime(val, time);\n\t\t\t\t} else if (after.type === Tone.TimelineSignal.Type.Exponential){\n\t\t\t\t\tthis.exponentialRampToValueAtTime(val, time);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setValueAtTime(val, time);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Do a linear ramp to the given value between the start and finish times.\n\t * @param {Number} value The value to ramp to.\n\t * @param {Time} start The beginning anchor point to do the linear ramp\n\t * @param {Time} finish The ending anchor point by which the value of\n\t * the signal will equal the given value.\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.linearRampToValueBetween = function (value, start, finish) {\n\t\tthis.setRampPoint(start);\n\t\tthis.linearRampToValueAtTime(value, finish);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Do a exponential ramp to the given value between the start and finish times.\n\t * @param {Number} value The value to ramp to.\n\t * @param {Time} start The beginning anchor point to do the exponential ramp\n\t * @param {Time} finish The ending anchor point by which the value of\n\t * the signal will equal the given value.\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.exponentialRampToValueBetween = function (value, start, finish) {\n\t\tthis.setRampPoint(start);\n\t\tthis.exponentialRampToValueAtTime(value, finish);\n\t\treturn this;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tGETTING SCHEDULED VALUES\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value before or equal to the given time\n\t * @param {Number} time The time to query\n\t * @return {Object} The event at or before the given time.\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._searchBefore = function(time){\n\t\treturn this._events.get(time);\n\t};\n\n\t/**\n\t * The event after the given time\n\t * @param {Number} time The time to query.\n\t * @return {Object} The next event after the given time\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._searchAfter = function(time){\n\t\treturn this._events.getAfter(time);\n\t};\n\n\t/**\n\t * Get the scheduled value at the given time. This will\n\t * return the unconverted (raw) value.\n\t * @param {Number} time The time in seconds.\n\t * @return {Number} The scheduled value at the given time.\n\t */\n\tTone.TimelineSignal.prototype.getValueAtTime = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tvar after = this._searchAfter(time);\n\t\tvar before = this._searchBefore(time);\n\t\tvar value = this._initial;\n\t\t//if it was set by\n\t\tif (before === null){\n\t\t\tvalue = this._initial;\n\t\t} else if (before.type === Tone.TimelineSignal.Type.Target){\n\t\t\tvar previous = this._events.getBefore(before.time);\n\t\t\tvar previouVal;\n\t\t\tif (previous === null){\n\t\t\t\tpreviouVal = this._initial;\n\t\t\t} else {\n\t\t\t\tpreviouVal = previous.value;\n\t\t\t}\n\t\t\tvalue = this._exponentialApproach(before.time, previouVal, before.value, before.constant, time);\n\t\t} else if (before.type === Tone.TimelineSignal.Type.Curve){\n\t\t\tvalue = this._curveInterpolate(before.time, before.value, before.duration, time);\n\t\t} else if (after === null){\n\t\t\tvalue = before.value;\n\t\t} else if (after.type === Tone.TimelineSignal.Type.Linear){\n\t\t\tvalue = this._linearInterpolate(before.time, before.value, after.time, after.value, time);\n\t\t} else if (after.type === Tone.TimelineSignal.Type.Exponential){\n\t\t\tvalue = this._exponentialInterpolate(before.time, before.value, after.time, after.value, time);\n\t\t} else {\n\t\t\tvalue = before.value;\n\t\t}\n\t\treturn value;\n\t};\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.TimelineSignal} this\n\t * @method\n\t */\n\tTone.TimelineSignal.prototype.connect = Tone.SignalBase.prototype.connect;\n\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tAUTOMATION CURVE CALCULATIONS\n\t//\tMIT License, copyright (c) 2014 Jordan Santell\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Calculates the the value along the curve produced by setTargetAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._exponentialApproach = function (t0, v0, v1, timeConstant, t) {\n\t\treturn v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant);\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by linearRampToValueAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._linearInterpolate = function (t0, v0, t1, v1, t) {\n\t\treturn v0 + (v1 - v0) * ((t - t0) / (t1 - t0));\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by exponentialRampToValueAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._exponentialInterpolate = function (t0, v0, t1, v1, t) {\n\t\tv0 = Math.max(this._minOutput, v0);\n\t\treturn v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0));\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by setValueCurveAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._curveInterpolate = function (start, curve, duration, time) {\n\t\tvar len = curve.length;\n\t\t// If time is after duration, return the last curve value\n\t\tif (time >= start + duration) {\n\t\t\treturn curve[len - 1];\n\t\t} else if (time <= start){\n\t\t\treturn curve[0];\n\t\t} else {\n\t\t\tvar progress = (time - start) / duration;\n\t\t\tvar lowerIndex = Math.floor((len - 1) * progress);\n\t\t\tvar upperIndex = Math.ceil((len - 1) * progress);\n\t\t\tvar lowerVal = curve[lowerIndex];\n\t\t\tvar upperVal = curve[upperIndex];\n\t\t\tif (upperIndex === lowerIndex){\n\t\t\t\treturn lowerVal;\n\t\t\t} else {\n\t\t\t\treturn this._linearInterpolate(lowerIndex, lowerVal, upperIndex, upperVal, progress * (len - 1));\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.dispose = function(){\n\t\tTone.Signal.prototype.dispose.call(this);\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._events.dispose();\n\t\tthis._events = null;\n\t};\n\n\treturn Tone.TimelineSignal;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Multiply\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\t\n\t/**\n\t * @class Performs a linear scaling on an input signal.\n\t * Scales a NormalRange input to between\n\t * outputMin and outputMax.\n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @param {number} [outputMin=0] The output value when the input is 0. \n\t * @param {number} [outputMax=1]\tThe output value when the input is 1. \n\t * @example\n\t * var scale = new Tone.Scale(50, 100);\n\t * var signal = new Tone.Signal(0.5).connect(scale);\n\t * //the output of scale equals 75\n\t */\n\tTone.Scale = function(outputMin, outputMax){\n\n\t\t/** \n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._outputMin = this.defaultArg(outputMin, 0);\n\n\t\t/** \n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._outputMax = this.defaultArg(outputMax, 1);\n\n\n\t\t/** \n\t\t * @private\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._scale = this.input = new Tone.Multiply(1);\n\t\t\n\t\t/** \n\t\t * @private\n\t\t * @type {Tone.Add}\n\t\t * @private\n\t\t */\n\t\tthis._add = this.output = new Tone.Add(0);\n\n\t\tthis._scale.connect(this._add);\n\t\tthis._setRange();\n\t};\n\n\tTone.extend(Tone.Scale, Tone.SignalBase);\n\n\t/**\n\t * The minimum output value. This number is output when \n\t * the value input value is 0. \n\t * @memberOf Tone.Scale#\n\t * @type {number}\n\t * @name min\n\t */\n\tObject.defineProperty(Tone.Scale.prototype, \"min\", {\n\t\tget : function(){\n\t\t\treturn this._outputMin;\n\t\t},\n\t\tset : function(min){\n\t\t\tthis._outputMin = min;\n\t\t\tthis._setRange();\n\t\t}\n\t});\n\n\t/**\n\t * The maximum output value. This number is output when \n\t * the value input value is 1. \n\t * @memberOf Tone.Scale#\n\t * @type {number}\n\t * @name max\n\t */\n\tObject.defineProperty(Tone.Scale.prototype, \"max\", {\n\t\tget : function(){\n\t\t\treturn this._outputMax;\n\t\t},\n\t\tset : function(max){\n\t\t\tthis._outputMax = max;\n\t\t\tthis._setRange();\n\t\t}\n\t});\n\n\t/**\n\t * set the values\n\t * @private\n\t */\n\tTone.Scale.prototype._setRange = function() {\n\t\tthis._add.value = this._outputMin;\n\t\tthis._scale.value = this._outputMax - this._outputMin;\n\t};\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Scale} this\n\t */\n\tTone.Scale.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._add.dispose();\n\t\tthis._add = null;\n\t\tthis._scale.dispose();\n\t\tthis._scale = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Scale;\n});\n","define([\"Tone/core/Tone\", \"Tone/type/Time\", \"Tone/type/Frequency\", \"Tone/type/TransportTime\", \"Tone/core/Context\"],\nfunction (Tone) {\t\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTYPES\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Units which a value can take on.\n\t * @enum {String}\n\t */\n\tTone.Type = {\n\t\t/** \n\t\t * Default units\n\t\t * @typedef {Default}\n\t\t */\n\t\tDefault : \"number\",\n\t\t/**\n\t\t * Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time).\n\t\t *\n\t\t * \n\t\t * \n\t\t * @typedef {Time}\n\t\t */\n\t\tTime : \"time\",\n\t\t/**\n\t\t * Frequency can be described similar to time, except ultimately the\n\t\t * values are converted to frequency instead of seconds. A number\n\t\t * is taken literally as the value in hertz. Additionally any of the \n\t\t * Time encodings can be used. Note names in the form\n\t\t * of NOTE OCTAVE (i.e. C4) are also accepted and converted to their\n\t\t * frequency value. \n\t\t * @typedef {Frequency}\n\t\t */\n\t\tFrequency : \"frequency\",\n\t\t/**\n\t\t * TransportTime describes a position along the Transport's timeline. It is\n\t\t * similar to Time in that it uses all the same encodings, but TransportTime specifically\n\t\t * pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable. \n\t\t * [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime)\n\t\t * @typedef {TransportTime}\n\t\t */\n\t\tTransportTime : \"transportTime\",\n\t\t/** \n\t\t * Ticks are the basic subunit of the Transport. They are\n\t\t * the smallest unit of time that the Transport supports.\n\t\t * @typedef {Ticks}\n\t\t */\n\t\tTicks : \"ticks\",\n\t\t/** \n\t\t * Normal values are within the range [0, 1].\n\t\t * @typedef {NormalRange}\n\t\t */\n\t\tNormalRange : \"normalRange\",\n\t\t/** \n\t\t * AudioRange values are between [-1, 1].\n\t\t * @typedef {AudioRange}\n\t\t */\n\t\tAudioRange : \"audioRange\",\n\t\t/** \n\t\t * Decibels are a logarithmic unit of measurement which is useful for volume\n\t\t * because of the logarithmic way that we perceive loudness. 0 decibels \n\t\t * means no change in volume. -10db is approximately half as loud and 10db \n\t\t * is twice is loud. \n\t\t * @typedef {Decibels}\n\t\t */\n\t\tDecibels : \"db\",\n\t\t/** \n\t\t * Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up.\n\t\t * @typedef {Interval}\n\t\t */\n\t\tInterval : \"interval\",\n\t\t/** \n\t\t * Beats per minute. \n\t\t * @typedef {BPM}\n\t\t */\n\t\tBPM : \"bpm\",\n\t\t/** \n\t\t * The value must be greater than or equal to 0.\n\t\t * @typedef {Positive}\n\t\t */\n\t\tPositive : \"positive\",\n\t\t/** \n\t\t * A cent is a hundredth of a semitone. \n\t\t * @typedef {Cents}\n\t\t */\n\t\tCents : \"cents\",\n\t\t/** \n\t\t * Angle between 0 and 360. \n\t\t * @typedef {Degrees}\n\t\t */\n\t\tDegrees : \"degrees\",\n\t\t/** \n\t\t * A number representing a midi note.\n\t\t * @typedef {MIDI}\n\t\t */\n\t\tMIDI : \"midi\",\n\t\t/** \n\t\t * A colon-separated representation of time in the form of\n\t\t * Bars:Beats:Sixteenths. \n\t\t * @typedef {BarsBeatsSixteenths}\n\t\t */\n\t\tBarsBeatsSixteenths : \"barsBeatsSixteenths\",\n\t\t/** \n\t\t * Sampling is the reduction of a continuous signal to a discrete signal.\n\t\t * Audio is typically sampled 44100 times per second. \n\t\t * @typedef {Samples}\n\t\t */\n\t\tSamples : \"samples\",\n\t\t/** \n\t\t * Hertz are a frequency representation defined as one cycle per second.\n\t\t * @typedef {Hertz}\n\t\t */\n\t\tHertz : \"hertz\",\n\t\t/** \n\t\t * A frequency represented by a letter name, \n\t\t * accidental and octave. This system is known as\n\t\t * [Scientific Pitch Notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation).\n\t\t * @typedef {Note}\n\t\t */\n\t\tNote : \"note\",\n\t\t/** \n\t\t * One millisecond is a thousandth of a second. \n\t\t * @typedef {Milliseconds}\n\t\t */\n\t\tMilliseconds : \"milliseconds\",\n\t\t/** \n\t\t * Seconds are the time unit of the AudioContext. In the end, \n\t\t * all values need to be evaluated to seconds. \n\t\t * @typedef {Seconds}\n\t\t */\n\t\tSeconds : \"seconds\",\n\t\t/** \n\t\t * A string representing a duration relative to a measure. \n\t\t * \n\t\t * @typedef {Notation}\n\t\t */\n\t\tNotation : \"notation\",\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// AUGMENT TONE's PROTOTYPE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Convert Time into seconds.\n\t * \n\t * Unlike the method which it overrides, this takes into account \n\t * transporttime and musical notation.\n\t *\n\t * Time : 1.40\n\t * Notation: 4n|1m|2t\n\t * Now Relative: +3n\n\t * Math: 3n+16n or even complicated expressions ((3n*2)/6 + 1)\n\t *\n\t * @param {Time} time \n\t * @return {Seconds} \n\t */\n\tTone.prototype.toSeconds = function(time){\n\t\tif (this.isNumber(time)){\n\t\t\treturn time;\n\t\t} else if (this.isUndef(time)){\n\t\t\treturn this.now();\t\t\t\n\t\t} else if (this.isString(time)){\n\t\t\treturn (new Tone.Time(time)).toSeconds();\n\t\t} else if (time instanceof Tone.TimeBase){\n\t\t\treturn time.toSeconds();\n\t\t}\n\t};\n\n\t/**\n\t * Convert a frequency representation into a number.\n\t * @param {Frequency} freq \n\t * @return {Hertz} the frequency in hertz\n\t */\n\tTone.prototype.toFrequency = function(freq){\n\t\tif (this.isNumber(freq)){\n\t\t\treturn freq;\n\t\t} else if (this.isString(freq) || this.isUndef(freq)){\n\t\t\treturn (new Tone.Frequency(freq)).valueOf();\n\t\t} else if (freq instanceof Tone.TimeBase){\n\t\t\treturn freq.toFrequency();\n\t\t}\n\t};\n\n\t/**\n\t * Convert a time representation into ticks.\n\t * @param {Time} time\n\t * @return {Ticks} the time in ticks\n\t */\n\tTone.prototype.toTicks = function(time){\n\t\tif (this.isNumber(time) || this.isString(time)){\n\t\t\treturn (new Tone.TransportTime(time)).toTicks();\n\t\t} else if (this.isUndef(time)){\n\t\t\treturn Tone.Transport.ticks;\t\t\t\n\t\t} else if (time instanceof Tone.TimeBase){\n\t\t\treturn time.toTicks();\n\t\t}\n\t};\n\n\treturn Tone;\n});","define([\"Tone/core/Tone\", \"Tone/core/Param\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * createGain shim\n\t * @private\n\t */\n\tif (window.GainNode && !AudioContext.prototype.createGain){\n\t\tAudioContext.prototype.createGain = AudioContext.prototype.createGainNode;\n\t}\n\n\t/**\n\t * @class A thin wrapper around the Native Web Audio GainNode.\n\t * The GainNode is a basic building block of the Web Audio\n\t * API and is useful for routing audio and adjusting gains. \n\t * @extends {Tone}\n\t * @param {Number=} gain The initial gain of the GainNode\n\t * @param {Tone.Type=} units The units of the gain parameter. \n\t */\n\tTone.Gain = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"gain\", \"units\"], Tone.Gain.defaults);\n\n\t\t/**\n\t\t * The GainNode\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis.input = this.output = this._gainNode = this.context.createGain();\n\n\t\t/**\n\t\t * The gain parameter of the gain node.\n\t\t * @type {Tone.Param}\n\t\t * @signal\n\t\t */\n\t\tthis.gain = new Tone.Param({\n\t\t\t\"param\" : this._gainNode.gain, \n\t\t\t\"units\" : options.units,\n\t\t\t\"value\" : options.gain,\n\t\t\t\"convert\" : options.convert\n\t\t});\n\t\tthis._readOnly(\"gain\");\n\t};\n\n\tTone.extend(Tone.Gain);\n\n\t/**\n\t * The defaults\n\t * @const\n\t * @type {Object}\n\t */\n\tTone.Gain.defaults = {\n\t\t\"gain\" : 1,\n\t\t\"convert\" : true,\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.Gain} this\n\t */\n\tTone.Gain.prototype.dispose = function(){\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._gainNode.disconnect();\n\t\tthis._gainNode = null;\n\t\tthis._writable(\"gain\");\n\t\tthis.gain.dispose();\n\t\tthis.gain = null;\n\t};\n\n\t//STATIC///////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Create input and outputs for this object.\n\t * @param {Number} input The number of inputs\n\t * @param {Number=} outputs The number of outputs\n\t * @return {Tone} this\n\t * @internal\n\t */\n\tTone.prototype.createInsOuts = function(inputs, outputs){\n\n\t\tif (inputs === 1){\n\t\t\tthis.input = new Tone.Gain();\n\t\t} else if (inputs > 1){\n\t\t\tthis.input = new Array(inputs);\n\t\t}\n\n\t\tif (outputs === 1){\n\t\t\tthis.output = new Tone.Gain();\n\t\t} else if (outputs > 1){\n\t\t\tthis.output = new Array(inputs);\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\n\treturn Tone.Gain;\n});","define([\"Tone/core/Tone\", \"Tone/signal/TimelineSignal\", \"Tone/core/TimelineState\", \n\t\"Tone/core/Emitter\", \"Tone/core/Context\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A sample accurate clock which provides a callback at the given rate. \n\t * While the callback is not sample-accurate (it is still susceptible to\n\t * loose JS timing), the time passed in as the argument to the callback\n\t * is precise. For most applications, it is better to use Tone.Transport\n\t * instead of the Clock by itself since you can synchronize multiple callbacks.\n\t *\n\t * \t@constructor\n\t * @extends {Tone.Emitter}\n\t * \t@param {function} callback The callback to be invoked with the time of the audio event\n\t * \t@param {Frequency} frequency The rate of the callback\n\t * \t@example\n\t * //the callback will be invoked approximately once a second\n\t * //and will print the time exactly once a second apart.\n\t * var clock = new Tone.Clock(function(time){\n\t * \tconsole.log(time);\n\t * }, 1);\n\t */\n\tTone.Clock = function(){\n\n\t\tTone.Emitter.call(this);\n\n\t\tvar options = this.optionsObject(arguments, [\"callback\", \"frequency\"], Tone.Clock.defaults);\n\n\t\t/**\n\t\t * The callback function to invoke at the scheduled tick.\n\t\t * @type {Function}\n\t\t */\n\t\tthis.callback = options.callback;\n\n\t\t/**\n\t\t * The next time the callback is scheduled.\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._nextTick = 0;\n\n\t\t/**\n\t\t * The last state of the clock.\n\t\t * @type {State}\n\t\t * @private\n\t\t */\n\t\tthis._lastState = Tone.State.Stopped;\n\n\t\t/**\n\t\t * The rate the callback function should be invoked. \n\t\t * @type {BPM}\n\t\t * @signal\n\t\t */\n\t\tthis.frequency = new Tone.TimelineSignal(options.frequency, Tone.Type.Frequency);\n\t\tthis._readOnly(\"frequency\");\n\n\t\t/**\n\t\t * The number of times the callback was invoked. Starts counting at 0\n\t\t * and increments after the callback was invoked. \n\t\t * @type {Ticks}\n\t\t * @readOnly\n\t\t */\n\t\tthis.ticks = 0;\n\n\t\t/**\n\t\t * The state timeline\n\t\t * @type {Tone.TimelineState}\n\t\t * @private\n\t\t */\n\t\tthis._state = new Tone.TimelineState(Tone.State.Stopped);\n\n\t\t/**\n\t\t * The loop function bound to its context. \n\t\t * This is necessary to remove the event in the end.\n\t\t * @type {Function}\n\t\t * @private\n\t\t */\n\t\tthis._boundLoop = this._loop.bind(this);\n\n\t\t//bind a callback to the worker thread\n \tthis.context.on(\"tick\", this._boundLoop);\n\t};\n\n\tTone.extend(Tone.Clock, Tone.Emitter);\n\n\t/**\n\t * The defaults\n\t * @const\n\t * @type {Object}\n\t */\n\tTone.Clock.defaults = {\n\t\t\"callback\" : Tone.noOp,\n\t\t\"frequency\" : 1,\n\t\t\"lookAhead\" : \"auto\",\n\t};\n\n\t/**\n\t * Returns the playback state of the source, either \"started\", \"stopped\" or \"paused\".\n\t * @type {Tone.State}\n\t * @readOnly\n\t * @memberOf Tone.Clock#\n\t * @name state\n\t */\n\tObject.defineProperty(Tone.Clock.prototype, \"state\", {\n\t\tget : function(){\n\t\t\treturn this._state.getValueAtTime(this.now());\n\t\t}\n\t});\n\n\t/**\n\t * Start the clock at the given time. Optionally pass in an offset\n\t * of where to start the tick counter from.\n\t * @param {Time} time The time the clock should start\n\t * @param {Ticks=} offset Where the tick counter starts counting from.\n\t * @return {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.start = function(time, offset){\n\t\ttime = this.toSeconds(time);\n\t\tif (this._state.getValueAtTime(time) !== Tone.State.Started){\n\t\t\tthis._state.add({\n\t\t\t\t\"state\" : Tone.State.Started, \n\t\t\t\t\"time\" : time,\n\t\t\t\t\"offset\" : offset\n\t\t\t});\n\t\t}\n\t\treturn this;\t\n\t};\n\n\t/**\n\t * Stop the clock. Stopping the clock resets the tick counter to 0.\n\t * @param {Time} [time=now] The time when the clock should stop.\n\t * @returns {Tone.Clock} this\n\t * @example\n\t * clock.stop();\n\t */\n\tTone.Clock.prototype.stop = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tthis._state.cancel(time);\n\t\tthis._state.setStateAtTime(Tone.State.Stopped, time);\n\t\treturn this;\t\n\t};\n\n\n\t/**\n\t * Pause the clock. Pausing does not reset the tick counter.\n\t * @param {Time} [time=now] The time when the clock should stop.\n\t * @returns {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.pause = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tif (this._state.getValueAtTime(time) === Tone.State.Started){\n\t\t\tthis._state.setStateAtTime(Tone.State.Paused, time);\n\t\t}\n\t\treturn this;\t\n\t};\n\n\t/**\n\t * The scheduling loop.\n\t * @param {Number} time The current page time starting from 0\n\t * when the page was loaded.\n\t * @private\n\t */\n\tTone.Clock.prototype._loop = function(){\n\t\t//get the frequency value to compute the value of the next loop\n\t\tvar now = this.now();\n\t\t//if it's started\n\t\tvar lookAhead = this.context.lookAhead;\n\t\tvar updateInterval = this.context.updateInterval;\n\t\tvar lagCompensation = this.context.lag * 2;\n\t\tvar loopInterval = now + lookAhead + updateInterval + lagCompensation;\n\t\twhile (loopInterval > this._nextTick && this._state){\n\t\t\tvar currentState = this._state.getValueAtTime(this._nextTick);\n\t\t\tif (currentState !== this._lastState){\n\t\t\t\tthis._lastState = currentState;\n\t\t\t\tvar event = this._state.get(this._nextTick);\n\t\t\t\t// emit an event\n\t\t\t\tif (currentState === Tone.State.Started){\n\t\t\t\t\t//correct the time\n\t\t\t\t\tthis._nextTick = event.time;\n\t\t\t\t\tif (!this.isUndef(event.offset)){\n\t\t\t\t\t\tthis.ticks = event.offset;\n\t\t\t\t\t}\n\t\t\t\t\tthis.emit(\"start\", event.time, this.ticks);\n\t\t\t\t} else if (currentState === Tone.State.Stopped){\n\t\t\t\t\tthis.ticks = 0;\n\n\t\t\t\t\tthis.emit(\"stop\", event.time);\n\t\t\t\t} else if (currentState === Tone.State.Paused){\n\t\t\t\t\tthis.emit(\"pause\", event.time);\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar tickTime = this._nextTick;\n\t\t\tif (this.frequency){\n\t\t\t\tthis._nextTick += 1 / this.frequency.getValueAtTime(this._nextTick);\n\t\t\t\tif (currentState === Tone.State.Started){\n\t\t\t\t\tthis.callback(tickTime);\n\t\t\t\t\tthis.ticks++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Returns the scheduled state at the given time.\n\t * @param {Time} time The time to query.\n\t * @return {String} The name of the state input in setStateAtTime.\n\t * @example\n\t * clock.start(\"+0.1\");\n\t * clock.getStateAtTime(\"+0.1\"); //returns \"started\"\n\t */\n\tTone.Clock.prototype.getStateAtTime = function(time){\n\t\ttime = this.toSeconds(time);\n\t\treturn this._state.getValueAtTime(time);\n\t};\n\n\t/**\n\t * Clean up\n\t * @returns {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.dispose = function(){\n\t\tTone.Emitter.prototype.dispose.call(this);\n\t\tthis.context.off(\"tick\", this._boundLoop);\n\t\tthis._writable(\"frequency\");\n\t\tthis.frequency.dispose();\n\t\tthis.frequency = null;\n\t\tthis._boundLoop = null;\n\t\tthis._nextTick = Infinity;\n\t\tthis.callback = null;\n\t\tthis._state.dispose();\n\t\tthis._state = null;\n\t};\n\n\treturn Tone.Clock;\n});","define([\"Tone/core/Tone\", \"Tone/core/Emitter\"], function (Tone) {\n\n\t/**\n\t * shim\n\t * @private\n\t */\n\tif (!window.hasOwnProperty(\"AudioContext\") && window.hasOwnProperty(\"webkitAudioContext\")){\n\t\twindow.AudioContext = window.webkitAudioContext;\n\t}\n\n\t/**\n\t * @class Wrapper around the native AudioContext.\n\t * @extends {Tone.Emitter}\n\t * @param {AudioContext=} context optionally pass in a context\n\t */\n\tTone.Context = function(context){\n\n\t\tTone.Emitter.call(this);\n\n\t\tif (!context){\n\t\t\tcontext = new window.AudioContext();\n\t\t}\n\t\tthis._context = context;\n\t\t// extend all of the methods\n\t\tfor (var prop in this._context){\n\t\t\tthis._defineProperty(this._context, prop);\n\t\t}\n\n\t\t///////////////////////////////////////////////////////////////////////\n\t\t// WORKER\n\t\t///////////////////////////////////////////////////////////////////////\n\n\t\t/**\n\t\t * The default latency hint\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t\tthis._latencyHint = \"interactive\";\n\n\t\t/**\n\t\t * The amount of time events are scheduled\n\t\t * into the future\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._lookAhead = 0.1;\n\n\t\t/**\n\t\t * How often the update look runs\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._updateInterval = this._lookAhead/3;\n\n\t\t/**\n\t\t * A reference to the actual computed update interval\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._computedUpdateInterval = 0;\n\n\t\t/**\n\t\t * The web worker which is used to update Tone.Clock\n\t\t * @private\n\t\t * @type {WebWorker}\n\t\t */\n\t\tthis._worker = this._createWorker();\n\n\t\t/**\n\t\t * An object containing all of the constants AudioBufferSourceNodes\n\t\t * @type {Object}\n\t\t * @private\n\t\t */\n\t\tthis._constants = {};\n\n\t};\n\n\tTone.extend(Tone.Context, Tone.Emitter);\n\tTone.Emitter.mixin(Tone.Context);\n\n\t/**\n\t * Define a property on this Tone.Context. \n\t * This is used to extend the native AudioContext\n\t * @param {AudioContext} context\n\t * @param {String} prop \n\t * @private\n\t */\n\tTone.Context.prototype._defineProperty = function(context, prop){\n\t\tif (this.isUndef(this[prop])){\n\t\t\tObject.defineProperty(this, prop, {\n\t\t\t\tget : function(){\n\t\t\t\t\tif (typeof context[prop] === \"function\"){\n\t\t\t\t\t\treturn context[prop].bind(context);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn context[prop];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tset : function(val){\n\t\t\t\t\tcontext[prop] = val;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * The current audio context time\n\t * @return {Number}\n\t */\n\tTone.Context.prototype.now = function(){\n\t\treturn this._context.currentTime;\n\t};\n\n\t/**\n\t * Generate a web worker\n\t * @return {WebWorker}\n\t * @private\n\t */\n\tTone.Context.prototype._createWorker = function(){\n\t\t\n\t\t//URL Shim\n\t\twindow.URL = window.URL || window.webkitURL;\n\n\t\tvar blob = new Blob([\n\t\t\t//the initial timeout time\n\t\t\t\"var timeoutTime = \"+(this._updateInterval * 1000).toFixed(1)+\";\" +\n\t\t\t//onmessage callback\n\t\t\t\"self.onmessage = function(msg){\" +\n\t\t\t\"\ttimeoutTime = parseInt(msg.data);\" + \n\t\t\t\"};\" + \n\t\t\t//the tick function which posts a message\n\t\t\t//and schedules a new tick\n\t\t\t\"function tick(){\" +\n\t\t\t\"\tsetTimeout(tick, timeoutTime);\" +\n\t\t\t\"\tself.postMessage('tick');\" +\n\t\t\t\"}\" +\n\t\t\t//call tick initially\n\t\t\t\"tick();\"\n\t\t]);\n\t\tvar blobUrl = URL.createObjectURL(blob);\n\t\tvar worker = new Worker(blobUrl);\n\n\t\tworker.addEventListener(\"message\", function(){\n\t\t\t// tick the clock\n\t\t\tthis.emit(\"tick\");\n\t\t}.bind(this));\n\n\t\t//lag compensation\n\t\tworker.addEventListener(\"message\", function(){\n\t\t\tvar now = this.now();\n\t\t\tif (this.isNumber(this._lastUpdate)){\n\t\t\t\tvar diff = now - this._lastUpdate;\n\t\t\t\tthis._computedUpdateInterval = Math.max(diff, this._computedUpdateInterval * 0.97);\n\t\t\t}\n\t\t\tthis._lastUpdate = now;\n\t\t}.bind(this));\n\n\t\treturn worker;\n\t};\n\n\t/**\n\t * Generate a looped buffer at some constant value.\n\t * @param {Number} val\n\t * @return {BufferSourceNode}\n\t */\n\tTone.Context.prototype.getConstant = function(val){\n\t\tif (this._constants[val]){\n\t\t\treturn this._constants[val];\n\t\t} else {\n\t\t\tvar buffer = this._context.createBuffer(1, 128, this._context.sampleRate);\n\t\t\tvar arr = buffer.getChannelData(0);\n\t\t\tfor (var i = 0; i < arr.length; i++){\n\t\t\t\tarr[i] = val;\n\t\t\t}\n\t\t\tvar constant = this._context.createBufferSource();\n\t\t\tconstant.channelCount = 1;\n\t\t\tconstant.channelCountMode = \"explicit\";\n\t\t\tconstant.buffer = buffer;\n\t\t\tconstant.loop = true;\n\t\t\tconstant.start(0);\n\t\t\tthis._constants[val] = constant;\n\t\t\treturn constant;\n\t\t}\n\t};\n\n\t/**\n\t * This is the time that the clock is falling behind\n\t * the scheduled update interval. The Context automatically\n\t * adjusts for the lag and schedules further in advance.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name lag\n\t * @static\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"lag\", {\n\t\tget : function(){\n\t\t\tvar diff = this._computedUpdateInterval - this._updateInterval;\n\t\t\tdiff = Math.max(diff, 0);\n\t\t\treturn diff;\n\t\t}\n\t});\n\n\t/**\n\t * The amount of time in advance that events are scheduled.\n\t * The lookAhead will adjust slightly in response to the \n\t * measured update time to try to avoid clicks.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name lookAhead\n\t * @static\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"lookAhead\", {\n\t\tget : function(){\n\t\t\treturn this._lookAhead;\n\t\t},\n\t\tset : function(lA){\n\t\t\tthis._lookAhead = lA;\n\t\t}\n\t});\n\n\t/**\n\t * How often the Web Worker callback is invoked.\n\t * This number corresponds to how responsive the scheduling\n\t * can be. Context.updateInterval + Context.lookAhead gives you the\n\t * total latency between scheduling an event and hearing it.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name updateInterval\n\t * @static\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"updateInterval\", {\n\t\tget : function(){\n\t\t\treturn this._updateInterval;\n\t\t},\n\t\tset : function(interval){\n\t\t\tthis._updateInterval = Math.max(interval, Tone.prototype.blockTime);\n\t\t\tthis._worker.postMessage(Math.max(interval * 1000, 1));\n\t\t}\n\t});\n\n\t/**\n\t * The type of playback, which affects tradeoffs between audio \n\t * output latency and responsiveness. \n\t * \n\t * In addition to setting the value in seconds, the latencyHint also\n\t * accepts the strings \"interactive\" (prioritizes low latency), \n\t * \"playback\" (prioritizes sustained playback), \"balanced\" (balances\n\t * latency and performance), and \"fastest\" (lowest latency, might glitch more often). \n\t * @type {String|Seconds}\n\t * @memberOf Tone.Context#\n\t * @name latencyHint\n\t * @static\n\t * @example\n\t * //set the lookAhead to 0.3 seconds\n\t * Tone.context.latencyHint = 0.3;\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"latencyHint\", {\n\t\tget : function(){\n\t\t\treturn this._latencyHint;\n\t\t},\n\t\tset : function(hint){\n\t\t\tvar lookAhead = hint;\n\t\t\tthis._latencyHint = hint;\n\t\t\tif (this.isString(hint)){\n\t\t\t\tswitch(hint){\n\t\t\t\t\tcase \"interactive\" :\n\t\t\t\t\t\tlookAhead = 0.1;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"playback\" :\n\t\t\t\t\t\tlookAhead = 0.8;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"balanced\" :\n\t\t\t\t\t\tlookAhead = 0.25;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fastest\" :\n\t\t\t\t\t\tlookAhead = 0.01;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.lookAhead = lookAhead;\n\t\t\tthis.updateInterval = lookAhead/3;\n\t\t}\n\t});\n\n\t/**\n\t * Shim all connect/disconnect and some deprecated methods which are still in\n\t * some older implementations.\n\t * @private\n\t */\n\tfunction shimConnect(){\n\n\t\tvar nativeConnect = AudioNode.prototype.connect;\n\t\tvar nativeDisconnect = AudioNode.prototype.disconnect;\n\n\t\t//replace the old connect method\n\t\tfunction toneConnect(B, outNum, inNum){\n\t\t\tif (B.input){\n\t\t\t\tif (Array.isArray(B.input)){\n\t\t\t\t\tif (Tone.prototype.isUndef(inNum)){\n\t\t\t\t\t\tinNum = 0;\n\t\t\t\t\t}\n\t\t\t\t\tthis.connect(B.input[inNum]);\n\t\t\t\t} else {\n\t\t\t\t\tthis.connect(B.input, outNum, inNum);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tif (B instanceof AudioNode){\n\t\t\t\t\t\tnativeConnect.call(this, B, outNum, inNum);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnativeConnect.call(this, B, outNum);\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new Error(\"error connecting to node: \"+B+\"\\n\"+e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//replace the old disconnect method\n\t\tfunction toneDisconnect(B, outNum, inNum){\n\t\t\tif (B && B.input && Array.isArray(B.input)){\n\t\t\t\tif (Tone.prototype.isUndef(inNum)){\n\t\t\t\t\tinNum = 0;\n\t\t\t\t}\n\t\t\t\tthis.disconnect(B.input[inNum], outNum, inNum);\n\t\t\t} else if (B && B.input){\n\t\t\t\tthis.disconnect(B.input, outNum, inNum);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tnativeDisconnect.apply(this, arguments);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new Error(\"error disconnecting node: \"+B+\"\\n\"+e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (AudioNode.prototype.connect !== toneConnect){\n\t\t\tAudioNode.prototype.connect = toneConnect;\n\t\t\tAudioNode.prototype.disconnect = toneDisconnect;\n\t\t}\n\t}\n\n\t// set the audio context initially\n\tif (Tone.supported){\n\t\tshimConnect();\n\t\tTone.context = new Tone.Context();\n\t} else {\n\t\tconsole.warn(\"This browser does not support Tone.js\");\n\t}\n\n\treturn Tone.Context;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Negate\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Subtract the signal connected to input[1] from the signal connected \n\t * to input[0]. If an argument is provided in the constructor, the \n\t * signals .value will be subtracted from the incoming signal.\n\t *\n\t * @extends {Tone.Signal}\n\t * @constructor\n\t * @param {number=} value The value to subtract from the incoming signal. If the value\n\t * is omitted, it will subtract the second signal from the first.\n\t * @example\n\t * var sub = new Tone.Subtract(1);\n\t * var sig = new Tone.Signal(4).connect(sub);\n\t * //the output of sub is 3. \n\t * @example\n\t * var sub = new Tone.Subtract();\n\t * var sigA = new Tone.Signal(10);\n\t * var sigB = new Tone.Signal(2.5);\n\t * sigA.connect(sub, 0, 0);\n\t * sigB.connect(sub, 0, 1);\n\t * //output of sub is 7.5\n\t */\n\tTone.Subtract = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the summing node\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._sum = this.input[0] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * negate the input of the second input before connecting it\n\t\t * to the summing node.\n\t\t * @type {Tone.Negate}\n\t\t * @private\n\t\t */\n\t\tthis._neg = new Tone.Negate();\n\n\t\t/**\n\t\t * the node where the value is set\n\t\t * @private\n\t\t * @type {Tone.Signal}\n\t\t */\n\t\tthis._param = this.input[1] = new Tone.Signal(value);\n\n\t\tthis._param.chain(this._neg, this._sum);\n\t};\n\n\tTone.extend(Tone.Subtract, Tone.Signal);\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.SignalBase} this\n\t */\n\tTone.Subtract.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._neg.dispose();\n\t\tthis._neg = null;\n\t\tthis._sum.disconnect();\n\t\tthis._sum = null;\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Subtract;\n});","define([\"Tone/core/Tone\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Emitter gives classes which extend it\n\t * the ability to listen for and emit events. \n\t * Inspiration and reference from Jerome Etienne's [MicroEvent](https://github.com/jeromeetienne/microevent.js).\n\t * MIT (c) 2011 Jerome Etienne.\n\t * \n\t * @extends {Tone}\n\t */\n\tTone.Emitter = function(){\n\t\t/**\n\t\t * Contains all of the events.\n\t\t * @private\n\t\t * @type {Object}\n\t\t */\n\t\tthis._events = {};\n\t};\n\n\tTone.extend(Tone.Emitter);\n\n\t/**\n\t * Bind a callback to a specific event.\n\t * @param {String} event The name of the event to listen for.\n\t * @param {Function} callback The callback to invoke when the\n\t * event is emitted\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.on = function(event, callback){\n\t\t//split the event\n\t\tvar events = event.split(/\\W+/);\n\t\tfor (var i = 0; i < events.length; i++){\n\t\t\tvar eventName = events[i];\n\t\t\tif (!this._events.hasOwnProperty(eventName)){\n\t\t\t\tthis._events[eventName] = [];\n\t\t\t}\n\t\t\tthis._events[eventName].push(callback);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Remove the event listener.\n\t * @param {String} event The event to stop listening to.\n\t * @param {Function=} callback The callback which was bound to \n\t * the event with Tone.Emitter.on.\n\t * If no callback is given, all callbacks\n\t * events are removed.\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.off = function(event, callback){\n\t\tvar events = event.split(/\\W+/);\n\t\tfor (var ev = 0; ev < events.length; ev++){\n\t\t\tevent = events[ev];\n\t\t\tif (this._events.hasOwnProperty(event)){\n\t\t\t\tif (Tone.prototype.isUndef(callback)){\n\t\t\t\t\tthis._events[event] = [];\n\t\t\t\t} else {\n\t\t\t\t\tvar eventList = this._events[event];\n\t\t\t\t\tfor (var i = 0; i < eventList.length; i++){\n\t\t\t\t\t\tif (eventList[i] === callback){\n\t\t\t\t\t\t\teventList.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Invoke all of the callbacks bound to the event\n\t * with any arguments passed in. \n\t * @param {String} event The name of the event.\n\t * @param {*...} args The arguments to pass to the functions listening.\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.emit = function(event){\n\t\tif (this._events){\n\t\t\tvar args = Array.apply(null, arguments).slice(1);\n\t\t\tif (this._events.hasOwnProperty(event)){\n\t\t\t\tvar eventList = this._events[event];\n\t\t\t\tfor (var i = 0, len = eventList.length; i < len; i++){\n\t\t\t\t\teventList[i].apply(this, args);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Add Emitter functions (on/off/emit) to the object\n\t * @param {Object|Function} object The object or class to extend.\n\t */\n\tTone.Emitter.mixin = function(object){\n\t\tvar functions = [\"on\", \"off\", \"emit\"];\n\t\tobject._events = {};\n\t\tfor (var i = 0; i < functions.length; i++){\n\t\t\tvar func = functions[i];\n\t\t\tvar emitterFunc = Tone.Emitter.prototype[func];\n\t\t\tobject[func] = emitterFunc;\n\t\t}\n\t};\n\n\t/**\n\t * Clean up\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._events = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Emitter;\n});","define([\"Tone/core/Tone\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Base class for all Signals. Used Internally. \n\t *\n\t * @constructor\n\t * @extends {Tone}\n\t */\n\tTone.SignalBase = function(){};\n\n\tTone.extend(Tone.SignalBase);\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.SignalBase} this\n\t */\n\tTone.SignalBase.prototype.connect = function(node, outputNumber, inputNumber){\n\t\t//zero it out so that the signal can have full control\n\t\tif ((Tone.Signal && Tone.Signal === node.constructor) || \n\t\t\t\t(Tone.Param && Tone.Param === node.constructor) || \n\t\t\t\t(Tone.TimelineSignal && Tone.TimelineSignal === node.constructor)){\n\t\t\t//cancel changes\n\t\t\tnode._param.cancelScheduledValues(0);\n\t\t\t//reset the value\n\t\t\tnode._param.value = 0;\n\t\t\t//mark the value as overridden\n\t\t\tnode.overridden = true;\n\t\t} else if (node instanceof AudioParam){\n\t\t\tnode.cancelScheduledValues(0);\n\t\t\tnode.value = 0;\n\t\t} \n\t\tTone.prototype.connect.call(this, node, outputNumber, inputNumber);\n\t\treturn this;\n\t};\n\n\treturn Tone.SignalBase;\n});","define([\"Tone/core/Tone\", \"Tone/type/TimeBase\"], function (Tone) {\n\n\t/**\n\t * @class Tone.Time is a primitive type for encoding Time values. \n\t * Eventually all time values are evaluated to seconds\n\t * using the `eval` method. Tone.Time can be constructed\n\t * with or without the `new` keyword. Tone.Time can be passed\n\t * into the parameter of any method which takes time as an argument. \n\t * @constructor\n\t * @extends {Tone.TimeBase}\n\t * @param {String|Number} val The time value.\n\t * @param {String=} units The units of the value.\n\t * @example\n\t * var t = Tone.Time(\"4n\");//encodes a quarter note\n\t * t.mult(4); // multiply that value by 4\n\t * t.toNotation(); //returns \"1m\"\n\t */\n\tTone.Time = function(val, units){\n\t\tif (this instanceof Tone.Time){\n\n\t\t\t/**\n\t\t\t * If the current clock time should\n\t\t\t * be added to the output\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t\t\tthis._plusNow = false;\n\t\t\t\n\t\t\tTone.TimeBase.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.Time(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.Time, Tone.TimeBase);\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.Time.prototype._unaryExpressions = Object.create(Tone.TimeBase.prototype._unaryExpressions);\n\n\t/*\n\t * Adds an additional unary expression\n\t * which quantizes values to the next subdivision\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Time.prototype._unaryExpressions.quantize = {\n\t\tregexp : /^@/,\n\t\tmethod : function(rh){\n\t\t\treturn Tone.Transport.nextSubdivision(rh());\n\t\t}\n\t};\n\n\t/*\n\t * Adds an additional unary expression\n\t * which adds the current clock time.\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Time.prototype._unaryExpressions.now = {\n\t\tregexp : /^\\+/,\n\t\tmethod : function(lh){\n\t\t\tthis._plusNow = true;\n\t\t\treturn lh();\n\t\t}\n\t};\n\n\t/**\n\t * Quantize the time by the given subdivision. Optionally add a\n\t * percentage which will move the time value towards the ideal\n\t * quantized value by that percentage. \n\t * @param {Number|Time} val The subdivision to quantize to\n\t * @param {NormalRange} [percent=1] Move the time value\n\t * towards the quantized value by\n\t * a percentage.\n\t * @return {Tone.Time} this\n\t * @example\n\t * Tone.Time(21).quantize(2) //returns 22\n\t * Tone.Time(0.6).quantize(\"4n\", 0.5) //returns 0.55\n\t */\n\tTone.Time.prototype.quantize = function(subdiv, percent){\n\t\tpercent = this.defaultArg(percent, 1);\n\t\tthis._expr = function(expr, subdivision, percent){\n\t\t\texpr = expr();\n\t\t\tsubdivision = subdivision.toSeconds();\n\t\t\tvar multiple = Math.round(expr / subdivision);\n\t\t\tvar ideal = multiple * subdivision;\n\t\t\tvar diff = ideal - expr;\n\t\t\treturn expr + diff * percent;\n\t\t}.bind(this, this._expr, new this.constructor(subdiv), percent);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Adds the clock time to the time expression at the \n\t * moment of evaluation. \n\t * @return {Tone.Time} this\n\t */\n\tTone.Time.prototype.addNow = function(){\n\t\tthis._plusNow = true;\n\t\treturn this;\n\t};\n\n\t/**\n\t * @override\n\t * Override the default value return when no arguments are passed in.\n\t * The default value is 'now'\n\t * @private\n\t */\n\tTone.Time.prototype._defaultExpr = function(){\n\t\tthis._plusNow = true;\n\t\treturn this._noOp;\n\t};\n\n\t/**\n\t * Copies the value of time to this Time\n\t * @param {Tone.Time} time\n\t * @return {Time}\n\t */\n\tTone.Time.prototype.copy = function(time){\n\t\tTone.TimeBase.prototype.copy.call(this, time);\n\t\tthis._plusNow = time._plusNow;\n\t\treturn this;\n\t};\n\n\t//CONVERSIONS//////////////////////////////////////////////////////////////\n\n\t/**\n\t * Convert a Time to Notation. Values will be thresholded to the nearest 128th note. \n\t * @return {Notation} \n\t * @example\n\t * //if the Transport is at 120bpm:\n\t * Tone.Time(2).toNotation();//returns \"1m\"\n\t */\n\tTone.Time.prototype.toNotation = function(){\n\t\tvar time = this.toSeconds();\n\t\tvar testNotations = [\"1m\", \"2n\", \"4n\", \"8n\", \"16n\", \"32n\", \"64n\", \"128n\"];\n\t\tvar retNotation = this._toNotationHelper(time, testNotations);\n\t\t//try the same thing but with tripelets\n\t\tvar testTripletNotations = [\"1m\", \"2n\", \"2t\", \"4n\", \"4t\", \"8n\", \"8t\", \"16n\", \"16t\", \"32n\", \"32t\", \"64n\", \"64t\", \"128n\"];\n\t\tvar retTripletNotation = this._toNotationHelper(time, testTripletNotations);\n\t\t//choose the simpler expression of the two\n\t\tif (retTripletNotation.split(\"+\").length < retNotation.split(\"+\").length){\n\t\t\treturn retTripletNotation;\n\t\t} else {\n\t\t\treturn retNotation;\n\t\t}\n\t};\n\n\t/**\n\t * Helper method for Tone.toNotation\n\t * @param {Number} units \n\t * @param {Array} testNotations\n\t * @return {String}\n\t * @private\n\t */\n\tTone.Time.prototype._toNotationHelper = function(units, testNotations){\n\t\t//the threshold is the last value in the array\n\t\tvar threshold = this._notationToUnits(testNotations[testNotations.length - 1]);\n\t\tvar retNotation = \"\";\n\t\tfor (var i = 0; i < testNotations.length; i++){\n\t\t\tvar notationTime = this._notationToUnits(testNotations[i]);\n\t\t\t//account for floating point errors (i.e. round up if the value is 0.999999)\n\t\t\tvar multiple = units / notationTime;\n\t\t\tvar floatingPointError = 0.000001;\n\t\t\tif (1 - multiple % 1 < floatingPointError){\n\t\t\t\tmultiple += floatingPointError;\n\t\t\t}\n\t\t\tmultiple = Math.floor(multiple);\n\t\t\tif (multiple > 0){\n\t\t\t\tif (multiple === 1){\n\t\t\t\t\tretNotation += testNotations[i];\n\t\t\t\t} else {\n\t\t\t\t\tretNotation += multiple.toString() + \"*\" + testNotations[i];\n\t\t\t\t}\n\t\t\t\tunits -= multiple * notationTime;\n\t\t\t\tif (units < threshold){\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tretNotation += \" + \";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (retNotation === \"\"){\n\t\t\tretNotation = \"0\";\n\t\t}\n\t\treturn retNotation;\n\t};\n\n\t/**\n\t * Convert a notation value to the current units\n\t * @param {Notation} notation \n\t * @return {Number} \n\t * @private\n\t */\n\tTone.Time.prototype._notationToUnits = function(notation){\n\t\tvar primaryExprs = this._primaryExpressions;\n\t\tvar notationExprs = [primaryExprs.n, primaryExprs.t, primaryExprs.m];\n\t\tfor (var i = 0; i < notationExprs.length; i++){\n\t\t\tvar expr = notationExprs[i];\n\t\t\tvar match = notation.match(expr.regexp);\n\t\t\tif (match){\n\t\t\t\treturn expr.method.call(this, match[1]);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Return the time encoded as Bars:Beats:Sixteenths.\n\t * @return {BarsBeatsSixteenths}\n\t */\n\tTone.Time.prototype.toBarsBeatsSixteenths = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.toSeconds() / quarterTime;\n\t\tvar measures = Math.floor(quarters / this._timeSignature());\n\t\tvar sixteenths = (quarters % 1) * 4;\n\t\tquarters = Math.floor(quarters) % this._timeSignature();\n\t\tsixteenths = sixteenths.toString();\n\t\tif (sixteenths.length > 3){\n\t\t\tsixteenths = parseFloat(sixteenths).toFixed(3);\n\t\t}\n\t\tvar progress = [measures, quarters, sixteenths];\n\t\treturn progress.join(\":\");\n\t};\n\n\t/**\n\t * Return the time in ticks.\n\t * @return {Ticks}\n\t */\n\tTone.Time.prototype.toTicks = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.valueOf() / quarterTime;\n\t\treturn Math.floor(quarters * Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Return the time in samples\n\t * @return {Samples} \n\t */\n\tTone.Time.prototype.toSamples = function(){\n\t\treturn this.toSeconds() * this.context.sampleRate;\n\t};\n\n\t/**\n\t * Return the time as a frequency value\n\t * @return {Frequency} \n\t * @example\n\t * Tone.Time(2).toFrequency(); //0.5\n\t */\n\tTone.Time.prototype.toFrequency = function(){\n\t\treturn 1/this.toSeconds();\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.Time.prototype.toSeconds = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the time in milliseconds.\n\t * @return {Milliseconds} \n\t */\n\tTone.Time.prototype.toMilliseconds = function(){\n\t\treturn this.toSeconds() * 1000;\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.Time.prototype.valueOf = function(){\n\t\tvar val = this._expr();\n\t\treturn val + (this._plusNow?this.now():0);\n\t};\n\n\treturn Tone.Time;\n});","define([\"Tone/core/Tone\"], function (Tone) {\n\n\t/**\n\t * @class Tone.TimeBase is a flexible encoding of time\n\t * which can be evaluated to and from a string.\n\t * Parsing code modified from https://code.google.com/p/tapdigit/\n\t * Copyright 2011 2012 Ariya Hidayat, New BSD License\n\t * @extends {Tone}\n\t * @param {Time} val The time value as a number or string\n\t * @param {String=} units Unit values\n\t * @example\n\t * Tone.TimeBase(4, \"n\")\n\t * Tone.TimeBase(2, \"t\")\n\t * Tone.TimeBase(\"2t\").add(\"1m\")\n\t * Tone.TimeBase(\"2t + 1m\");\n\t */\n\tTone.TimeBase = function(val, units){\n\n\t\t//allows it to be constructed with or without 'new'\n\t\tif (this instanceof Tone.TimeBase) {\n\n\t\t\t/**\n\t\t\t * Any expressions parsed from the Time\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t\t\tthis._expr = this._noOp;\n\n\t\t\tif (val instanceof Tone.TimeBase){\n\t\t\t\tthis.copy(val);\n\t\t\t} else if (!this.isUndef(units) || this.isNumber(val)){\n\t\t\t\t//default units\n\t\t\t\tunits = this.defaultArg(units, this._defaultUnits);\n\t\t\t\tvar method = this._primaryExpressions[units].method;\n\t\t\t\tthis._expr = method.bind(this, val);\n\t\t\t} else if (this.isString(val)){\n\t\t\t\tthis.set(val);\n\t\t\t} else if (this.isUndef(val)){\n\t\t\t\t//default expression\n\t\t\t\tthis._expr = this._defaultExpr();\n\t\t\t}\n\t\t} else {\n\n\t\t\treturn new Tone.TimeBase(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.TimeBase);\n\n\t/**\n\t * Repalce the current time value with the value\n\t * given by the expression string.\n\t * @param {String} exprString\n\t * @return {Tone.TimeBase} this\n\t */\n\tTone.TimeBase.prototype.set = function(exprString){\n\t\tthis._expr = this._parseExprString(exprString);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Return a clone of the TimeBase object.\n\t * @return {Tone.TimeBase} The new cloned Tone.TimeBase\n\t */\n\tTone.TimeBase.prototype.clone = function(){\n\t\tvar instance = new this.constructor();\n\t\tinstance.copy(this);\n\t\treturn instance;\n\t};\n\n\t/**\n\t * Copies the value of time to this Time\n\t * @param {Tone.TimeBase} time\n\t * @return {TimeBase}\n\t */\n\tTone.TimeBase.prototype.copy = function(time){\n\t\tvar val = time._expr();\n\t\treturn this.set(val);\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tABSTRACT SYNTAX TREE PARSER\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * All the primary expressions.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._primaryExpressions = {\n\t\t\"n\" : {\n\t\t\tregexp : /^(\\d+)n/i,\n\t\t\tmethod : function(value){\n\t\t\t\tvalue = parseInt(value);\n\t\t\t\tif (value === 1){\n\t\t\t\t\treturn this._beatsToUnits(this._timeSignature());\n\t\t\t\t} else {\n\t\t\t\t\treturn this._beatsToUnits(4 / value);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"t\" : {\n\t\t\tregexp : /^(\\d+)t/i,\n\t\t\tmethod : function(value){\n\t\t\t\tvalue = parseInt(value);\n\t\t\t\treturn this._beatsToUnits(8 / (parseInt(value) * 3));\n\t\t\t}\n\t\t},\n\t\t\"m\" : {\n\t\t\tregexp : /^(\\d+)m/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._beatsToUnits(parseInt(value) * this._timeSignature());\n\t\t\t}\n\t\t},\n\t\t\"i\" : {\n\t\t\tregexp : /^(\\d+)i/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._ticksToUnits(parseInt(value));\n\t\t\t}\n\t\t},\n\t\t\"hz\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?)hz/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._frequencyToUnits(parseFloat(value));\n\t\t\t}\n\t\t},\n\t\t\"tr\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t\t\tmethod : function(m, q, s){\n\t\t\t\tvar total = 0;\n\t\t\t\tif (m && m !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(this._timeSignature() * parseFloat(m));\n\t\t\t\t}\n\t\t\t\tif (q && q !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(parseFloat(q));\n\t\t\t\t}\n\t\t\t\tif (s && s !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(parseFloat(s) / 4);\n\t\t\t\t}\n\t\t\t\treturn total;\n\t\t\t}\n\t\t},\n\t\t\"s\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?s)/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._secondsToUnits(parseFloat(value));\n\t\t\t}\n\t\t},\n\t\t\"samples\" : {\n\t\t\tregexp : /^(\\d+)samples/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn parseInt(value) / this.context.sampleRate;\n\t\t\t}\n\t\t},\n\t\t\"default\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?)/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._primaryExpressions[this._defaultUnits].method.call(this, value);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * All the binary expressions that TimeBase can accept.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._binaryExpressions = {\n\t\t\"+\" : {\n\t\t\tregexp : /^\\+/,\n\t\t\tprecedence : 2,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() + rh();\n\t\t\t}\n\t\t},\n\t\t\"-\" : {\n\t\t\tregexp : /^\\-/,\n\t\t\tprecedence : 2,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() - rh();\n\t\t\t}\n\t\t},\n\t\t\"*\" : {\n\t\t\tregexp : /^\\*/,\n\t\t\tprecedence : 1,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() * rh();\n\t\t\t}\n\t\t},\n\t\t\"/\" : {\n\t\t\tregexp : /^\\//,\n\t\t\tprecedence : 1,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() / rh();\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * All the unary expressions.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._unaryExpressions = {\n\t\t\"neg\" : {\n\t\t\tregexp : /^\\-/,\n\t\t\tmethod : function(lh){\n\t\t\t\treturn -lh();\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Syntactic glue which holds expressions together\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._syntaxGlue = {\n\t\t\"(\" : {\n\t\t\tregexp : /^\\(/\n\t\t},\n\t\t\")\" : {\n\t\t\tregexp : /^\\)/\n\t\t}\n\t};\n\n\t/**\n\t * tokenize the expression based on the Expressions object\n\t * @param {string} expr \n\t * @return {Object} returns two methods on the tokenized list, next and peek\n\t * @private\n\t */\n\tTone.TimeBase.prototype._tokenize = function(expr){\n\t\tvar position = -1;\n\t\tvar tokens = [];\n\n\t\twhile(expr.length > 0){\n\t\t\texpr = expr.trim();\n\t\t\tvar token = getNextToken(expr, this);\n\t\t\ttokens.push(token);\n\t\t\texpr = expr.substr(token.value.length);\n\t\t}\n\n\t\tfunction getNextToken(expr, context){\n\t\t\tvar expressions = [\"_binaryExpressions\", \"_unaryExpressions\", \"_primaryExpressions\", \"_syntaxGlue\"];\n\t\t\tfor (var i = 0; i < expressions.length; i++){\n\t\t\t\tvar group = context[expressions[i]];\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tvar reg = op.regexp;\n\t\t\t\t\tvar match = expr.match(reg);\n\t\t\t\t\tif (match !== null){\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tmethod : op.method,\n\t\t\t\t\t\t\tprecedence : op.precedence,\n\t\t\t\t\t\t\tregexp : op.regexp,\n\t\t\t\t\t\t\tvalue : match[0],\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.TimeBase: Unexpected token \"+expr);\n\t\t}\n\n\t\treturn {\n\t\t\tnext : function(){\n\t\t\t\treturn tokens[++position];\n\t\t\t},\n\t\t\tpeek : function(){\n\t\t\t\treturn tokens[position + 1];\n\t\t\t}\n\t\t};\n\t};\n\n\t/**\n\t * Given a token, find the value within the groupName\n\t * @param {Object} token\n\t * @param {String} groupName\n\t * @param {Number} precedence\n\t * @private\n\t */\n\tTone.TimeBase.prototype._matchGroup = function(token, group, prec) {\n\t\tvar ret = false;\n\t\tif (!this.isUndef(token)){\n\t\t\tfor (var opName in group){\n\t\t\t\tvar op = group[opName];\n\t\t\t\tif (op.regexp.test(token.value)){\n\t\t\t\t\tif (!this.isUndef(prec)){\n\t\t\t\t\t\tif(op.precedence === prec){\t\n\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn op;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * Match a binary expression given the token and the precedence\n\t * @param {Lexer} lexer\n\t * @param {Number} precedence\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseBinary = function(lexer, precedence){\n\t\tif (this.isUndef(precedence)){\n\t\t\tprecedence = 2;\n\t\t}\n\t\tvar expr;\n\t\tif (precedence < 0){\n\t\t\texpr = this._parseUnary(lexer);\n\t\t} else {\n\t\t\texpr = this._parseBinary(lexer, precedence - 1);\n\t\t}\n\t\tvar token = lexer.peek();\n\t\twhile (token && this._matchGroup(token, this._binaryExpressions, precedence)){\n\t\t\ttoken = lexer.next();\n\t\t\texpr = token.method.bind(this, expr, this._parseBinary(lexer, precedence - 1));\n\t\t\ttoken = lexer.peek();\n\t\t}\n\t\treturn expr;\n\t};\n\n\t/**\n\t * Match a unary expression.\n\t * @param {Lexer} lexer\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseUnary = function(lexer){\n\t\tvar token, expr;\n\t\ttoken = lexer.peek();\n\t\tvar op = this._matchGroup(token, this._unaryExpressions);\n\t\tif (op) {\n\t\t\ttoken = lexer.next();\n\t\t\texpr = this._parseUnary(lexer);\n\t\t\treturn op.method.bind(this, expr);\n\t\t}\n\t\treturn this._parsePrimary(lexer);\n\t};\n\n\t/**\n\t * Match a primary expression (a value).\n\t * @param {Lexer} lexer\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parsePrimary = function(lexer){\n\t\tvar token, expr;\n\t\ttoken = lexer.peek();\n\t\tif (this.isUndef(token)) {\n\t\t\tthrow new SyntaxError(\"Tone.TimeBase: Unexpected end of expression\");\n\t\t}\n\t\tif (this._matchGroup(token, this._primaryExpressions)) {\n\t\t\ttoken = lexer.next();\n\t\t\tvar matching = token.value.match(token.regexp);\n\t\t\treturn token.method.bind(this, matching[1], matching[2], matching[3]);\n\t\t}\n\t\tif (token && token.value === \"(\"){\n\t\t\tlexer.next();\n\t\t\texpr = this._parseBinary(lexer);\n\t\t\ttoken = lexer.next();\n\t\t\tif (!(token && token.value === \")\")) {\n\t\t\t\tthrow new SyntaxError(\"Expected )\");\n\t\t\t}\n\t\t\treturn expr;\n\t\t}\n\t\tthrow new SyntaxError(\"Tone.TimeBase: Cannot process token \" + token.value);\n\t};\n\n\t/**\n\t * Recursively parse the string expression into a syntax tree.\n\t * @param {string} expr \n\t * @return {Function} the bound method to be evaluated later\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseExprString = function(exprString){\n\t\tif (!this.isString(exprString)){\n\t\t\texprString = exprString.toString();\n\t\t}\n\t\tvar lexer = this._tokenize(exprString);\n\t\tvar tree = this._parseBinary(lexer);\n\t\treturn tree;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tDEFAULTS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The initial expression value\n\t * @return {Number} The initial value 0\n\t * @private\n\t */\n\tTone.TimeBase.prototype._noOp = function(){\n\t\treturn 0;\n\t};\n\n\t/**\n\t * The default expression value if no arguments are given\n\t * @private\n\t */\n\tTone.TimeBase.prototype._defaultExpr = function(){\n\t\treturn this._noOp;\n\t};\n\n\t/**\n\t * The default units if none are given.\n\t * @private\n\t */\n\tTone.TimeBase.prototype._defaultUnits = \"s\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value of a frequency in the current units\n\t * @param {Frequency} freq\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._frequencyToUnits = function(freq){\n\t\treturn 1/freq;\n\t};\n\n\t/**\n\t * Return the value of the beats in the current units\n\t * @param {Number} beats\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._beatsToUnits = function(beats){\n\t\treturn (60 / Tone.Transport.bpm.value) * beats;\n\t};\n\n\t/**\n\t * Returns the value of a second in the current units\n\t * @param {Seconds} seconds\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._secondsToUnits = function(seconds){\n\t\treturn seconds;\n\t};\n\n\t/**\n\t * Returns the value of a tick in the current time units\n\t * @param {Ticks} ticks\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._ticksToUnits = function(ticks){\n\t\treturn ticks * (this._beatsToUnits(1) / Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Return the time signature.\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._timeSignature = function(){\n\t\treturn Tone.Transport.timeSignature;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tEXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Push an expression onto the expression list\n\t * @param {Time} val\n\t * @param {String} type\n\t * @param {String} units\n\t * @return {Tone.TimeBase} \n\t * @private\n\t */\n\tTone.TimeBase.prototype._pushExpr = function(val, name, units){\n\t\t//create the expression\n\t\tif (!(val instanceof Tone.TimeBase)){\n\t\t\tval = new this.constructor(val, units);\n\t\t}\n\t\tthis._expr = this._binaryExpressions[name].method.bind(this, this._expr, val._expr);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Add to the current value.\n\t * @param {Time} val The value to add\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").add(\"1m\"); //\"3m\"\n\t */\n\tTone.TimeBase.prototype.add = function(val, units){\n\t\treturn this._pushExpr(val, \"+\", units);\n\t};\n\n\t/**\n\t * Subtract the value from the current time.\n\t * @param {Time} val The value to subtract\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").sub(\"1m\"); //\"1m\"\n\t */\n\tTone.TimeBase.prototype.sub = function(val, units){\n\t\treturn this._pushExpr(val, \"-\", units);\n\t};\n\n\t/**\n\t * Multiply the current value by the given time.\n\t * @param {Time} val The value to multiply\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").mult(\"2\"); //\"4m\"\n\t */\n\tTone.TimeBase.prototype.mult = function(val, units){\n\t\treturn this._pushExpr(val, \"*\", units);\n\t};\n\n\t/**\n\t * Divide the current value by the given time.\n\t * @param {Time} val The value to divide by\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").div(2); //\"1m\"\n\t */\n\tTone.TimeBase.prototype.div = function(val, units){\n\t\treturn this._pushExpr(val, \"/\", units);\n\t};\n\n\t/**\n\t * Evaluate the time value. Returns the time\n\t * in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.TimeBase.prototype.valueOf = function(){\n\t\treturn this._expr();\n\t};\n\n\t/**\n\t * Clean up\n\t * @return {Tone.TimeBase} this\n\t */\n\tTone.TimeBase.prototype.dispose = function(){\n\t\tthis._expr = null;\n\t};\n\n\treturn Tone.TimeBase;\n});","define([\"Tone/core/Tone\", \"Tone/type/Type\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Param wraps the native Web Audio's AudioParam to provide\n\t * additional unit conversion functionality. It also\n\t * serves as a base-class for classes which have a single,\n\t * automatable parameter. \n\t * @extends {Tone}\n\t * @param {AudioParam} param The parameter to wrap.\n\t * @param {Tone.Type} units The units of the audio param.\n\t * @param {Boolean} convert If the param should be converted.\n\t */\n\tTone.Param = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"param\", \"units\", \"convert\"], Tone.Param.defaults);\n\n\t\t/**\n\t\t * The native parameter to control\n\t\t * @type {AudioParam}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input = options.param;\n\n\t\t/**\n\t\t * The units of the parameter\n\t\t * @type {Tone.Type}\n\t\t */\n\t\tthis.units = options.units;\n\n\t\t/**\n\t\t * If the value should be converted or not\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.convert = options.convert;\n\n\t\t/**\n\t\t * True if the signal value is being overridden by \n\t\t * a connected signal.\n\t\t * @readOnly\n\t\t * @type {boolean}\n\t\t * @private\n\t\t */\n\t\tthis.overridden = false;\n\n\t\t/**\n\t\t * If there is an LFO, this is where it is held.\n\t\t * @type {Tone.LFO}\n\t\t * @private\n\t\t */\n\t\tthis._lfo = null;\n\n\t\tif (this.isObject(options.lfo)){\n\t\t\tthis.value = options.lfo;\n\t\t} else if (!this.isUndef(options.value)){\n\t\t\tthis.value = options.value;\n\t\t}\n\t};\n\n\tTone.extend(Tone.Param);\n\t\n\t/**\n\t * Defaults\n\t * @type {Object}\n\t * @const\n\t */\n\tTone.Param.defaults = {\n\t\t\"units\" : Tone.Type.Default,\n\t\t\"convert\" : true,\n\t\t\"param\" : undefined\n\t};\n\n\t/**\n\t * The current value of the parameter. \n\t * @memberOf Tone.Param#\n\t * @type {Number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Param.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._toUnits(this._param.value);\n\t\t},\n\t\tset : function(value){\n\t\t\tif (this.isObject(value)){\n\t\t\t\t//throw an error if the LFO needs to be included\n\t\t\t\tif (this.isUndef(Tone.LFO)){\n\t\t\t\t\tthrow new Error(\"Include 'Tone.LFO' to use an LFO as a Param value.\");\n\t\t\t\t}\n\t\t\t\t//remove the old one\n\t\t\t\tif (this._lfo){\n\t\t\t\t\tthis._lfo.dispose();\n\t\t\t\t}\n\t\t\t\tthis._lfo = new Tone.LFO(value).start();\n\t\t\t\tthis._lfo.connect(this.input);\n\t\t\t} else {\n\t\t\t\tvar convertedVal = this._fromUnits(value);\n\t\t\t\tthis._param.cancelScheduledValues(0);\n\t\t\t\tthis._param.value = convertedVal;\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Convert the given value from the type specified by Tone.Param.units\n\t * into the destination value (such as Gain or Frequency).\n\t * @private\n\t * @param {*} val the value to convert\n\t * @return {number} the number which the value should be set to\n\t */\n\tTone.Param.prototype._fromUnits = function(val){\n\t\tif (this.convert || this.isUndef(this.convert)){\n\t\t\tswitch(this.units){\n\t\t\t\tcase Tone.Type.Time: \n\t\t\t\t\treturn this.toSeconds(val);\n\t\t\t\tcase Tone.Type.Frequency: \n\t\t\t\t\treturn this.toFrequency(val);\n\t\t\t\tcase Tone.Type.Decibels: \n\t\t\t\t\treturn this.dbToGain(val);\n\t\t\t\tcase Tone.Type.NormalRange: \n\t\t\t\t\treturn Math.min(Math.max(val, 0), 1);\n\t\t\t\tcase Tone.Type.AudioRange: \n\t\t\t\t\treturn Math.min(Math.max(val, -1), 1);\n\t\t\t\tcase Tone.Type.Positive: \n\t\t\t\t\treturn Math.max(val, 0);\n\t\t\t\tdefault:\n\t\t\t\t\treturn val;\n\t\t\t}\n\t\t} else {\n\t\t\treturn val;\n\t\t}\n\t};\n\n\t/**\n\t * Convert the parameters value into the units specified by Tone.Param.units.\n\t * @private\n\t * @param {number} val the value to convert\n\t * @return {number}\n\t */\n\tTone.Param.prototype._toUnits = function(val){\n\t\tif (this.convert || this.isUndef(this.convert)){\n\t\t\tswitch(this.units){\n\t\t\t\tcase Tone.Type.Decibels: \n\t\t\t\t\treturn this.gainToDb(val);\n\t\t\t\tdefault:\n\t\t\t\t\treturn val;\n\t\t\t}\n\t\t} else {\n\t\t\treturn val;\n\t\t}\n\t};\n\n\t/**\n\t * the minimum output value\n\t * @type {Number}\n\t * @private\n\t */\n\tTone.Param.prototype._minOutput = 0.00001;\n\n\t/**\n\t * Schedules a parameter value change at the given time.\n\t * @param {*}\tvalue The value to set the signal.\n\t * @param {Time} time The time when the change should occur.\n\t * @returns {Tone.Param} this\n\t * @example\n\t * //set the frequency to \"G4\" in exactly 1 second from now. \n\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t */\n\tTone.Param.prototype.setValueAtTime = function(value, time){\n\t\tvalue = this._fromUnits(value);\n\t\ttime = this.toSeconds(time);\n\t\tif (time <= this.now() + this.blockTime){\n\t\t\tthis._param.value = value;\n\t\t} else {\n\t\t\tthis._param.setValueAtTime(value, time);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Creates a schedule point with the current value at the current time.\n\t * This is useful for creating an automation anchor point in order to \n\t * schedule changes from the current value. \n\t *\n\t * @param {number=} now (Optionally) pass the now value in. \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.setRampPoint = function(now){\n\t\tnow = this.defaultArg(now, this.now());\n\t\tvar currentVal = this._param.value;\n\t\t// exponentialRampToValueAt cannot ever ramp from or to 0\n\t\t// More info: https://bugzilla.mozilla.org/show_bug.cgi?id=1125600#c2\n\t\tif (currentVal === 0){\n\t\t\tcurrentVal = this._minOutput;\n\t\t}\n\t\tthis._param.setValueAtTime(currentVal, now);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules a linear continuous change in parameter value from the \n\t * previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.linearRampToValueAtTime = function(value, endTime){\n\t\tvalue = this._fromUnits(value);\n\t\tthis._param.linearRampToValueAtTime(value, this.toSeconds(endTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.exponentialRampToValueAtTime = function(value, endTime){\n\t\tvalue = this._fromUnits(value);\n\t\tvalue = Math.max(this._minOutput, value);\n\t\tthis._param.exponentialRampToValueAtTime(value, this.toSeconds(endTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the current time and current value to the given value over the \n\t * duration of the rampTime.\n\t * \n\t * @param {number} value The value to ramp to.\n\t * @param {Time} rampTime the time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //exponentially ramp to the value 2 over 4 seconds. \n\t * signal.exponentialRampToValue(2, 4);\n\t */\n\tTone.Param.prototype.exponentialRampToValue = function(value, rampTime, startTime){\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis.setRampPoint(startTime);\n\t\tthis.exponentialRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an linear continuous change in parameter value from \n\t * the current time and current value to the given value over the \n\t * duration of the rampTime.\n\t * \n\t * @param {number} value The value to ramp to.\n\t * @param {Time} rampTime the time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //linearly ramp to the value 4 over 3 seconds. \n\t * signal.linearRampToValue(4, 3);\n\t */\n\tTone.Param.prototype.linearRampToValue = function(value, rampTime, startTime){\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis.setRampPoint(startTime);\n\t\tthis.linearRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Start exponentially approaching the target value at the given time with\n\t * a rate having the given time constant.\n\t * @param {number} value \n\t * @param {Time} startTime \n\t * @param {number} timeConstant \n\t * @returns {Tone.Param} this \n\t */\n\tTone.Param.prototype.setTargetAtTime = function(value, startTime, timeConstant){\n\t\tvalue = this._fromUnits(value);\n\t\t// The value will never be able to approach without timeConstant > 0.\n\t\t// http://www.w3.org/TR/webaudio/#dfn-setTargetAtTime, where the equation\n\t\t// is described. 0 results in a division by 0.\n\t\tvalue = Math.max(this._minOutput, value);\n\t\ttimeConstant = Math.max(this._minOutput, timeConstant);\n\t\tthis._param.setTargetAtTime(value, this.toSeconds(startTime), timeConstant);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Sets an array of arbitrary parameter values starting at the given time\n\t * for the given duration.\n\t * \t\n\t * @param {Array} values \n\t * @param {Time} startTime \n\t * @param {Time} duration \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.setValueCurveAtTime = function(values, startTime, duration){\n\t\tfor (var i = 0; i < values.length; i++){\n\t\t\tvalues[i] = this._fromUnits(values[i]);\n\t\t}\n\t\tthis._param.setValueCurveAtTime(values, this.toSeconds(startTime), this.toSeconds(duration));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancels all scheduled parameter changes with times greater than or \n\t * equal to startTime.\n\t * \n\t * @param {Time} startTime\n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.cancelScheduledValues = function(startTime){\n\t\tthis._param.cancelScheduledValues(this.toSeconds(startTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Ramps to the given value over the duration of the rampTime. \n\t * Automatically selects the best ramp type (exponential or linear)\n\t * depending on the `units` of the signal\n\t * \n\t * @param {number} value \n\t * @param {Time} rampTime \tThe time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //ramp to the value either linearly or exponentially \n\t * //depending on the \"units\" value of the signal\n\t * signal.rampTo(0, 10);\n\t * @example\n\t * //schedule it to ramp starting at a specific time\n\t * signal.rampTo(0, 10, 5)\n\t */\n\tTone.Param.prototype.rampTo = function(value, rampTime, startTime){\n\t\trampTime = this.defaultArg(rampTime, 0);\n\t\tif (this.units === Tone.Type.Frequency || this.units === Tone.Type.BPM || this.units === Tone.Type.Decibels){\n\t\t\tthis.exponentialRampToValue(value, rampTime, startTime);\n\t\t} else {\n\t\t\tthis.linearRampToValue(value, rampTime, startTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * The LFO created by the signal instance. If none\n\t * was created, this is null.\n\t * @type {Tone.LFO}\n\t * @readOnly\n\t * @memberOf Tone.Param#\n\t * @name lfo\n\t */\n\tObject.defineProperty(Tone.Param.prototype, \"lfo\", {\n\t\tget : function(){\n\t\t\treturn this._lfo;\n\t\t}\n\t});\n\n\t/**\n\t * Clean up\n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._param = null;\n\t\tif (this._lfo){\n\t\t\tthis._lfo.dispose();\n\t\t\tthis._lfo = null;\n\t\t}\n\t\treturn this;\n\t};\n\n\treturn Tone.Param;\n});","define([\"Tone/core/Tone\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A Timeline class for scheduling and maintaining state\n\t * along a timeline. All events must have a \"time\" property. \n\t * Internally, events are stored in time order for fast \n\t * retrieval.\n\t * @extends {Tone}\n\t * @param {Positive} [memory=Infinity] The number of previous events that are retained.\n\t */\n\tTone.Timeline = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"memory\"], Tone.Timeline.defaults);\n\n\t\t/**\n\t\t * The array of scheduled timeline events\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._timeline = [];\n\n\t\t/**\n\t\t * An array of items to remove from the list. \n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._toRemove = [];\n\n\t\t/**\n\t\t * Flag if the tieline is mid iteration\n\t\t * @private\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis._iterating = false;\n\n\t\t/**\n\t\t * The memory of the timeline, i.e.\n\t\t * how many events in the past it will retain\n\t\t * @type {Positive}\n\t\t */\n\t\tthis.memory = options.memory;\n\t};\n\n\tTone.extend(Tone.Timeline);\n\n\t/**\n\t * the default parameters\n\t * @static\n\t * @const\n\t */\n\tTone.Timeline.defaults = {\n\t\t\"memory\" : Infinity\n\t};\n\n\t/**\n\t * The number of items in the timeline.\n\t * @type {Number}\n\t * @memberOf Tone.Timeline#\n\t * @name length\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.Timeline.prototype, \"length\", {\n\t\tget : function(){\n\t\t\treturn this._timeline.length;\n\t\t}\n\t});\n\n\t/**\n\t * Insert an event object onto the timeline. Events must have a \"time\" attribute.\n\t * @param {Object} event The event object to insert into the \n\t * timeline. \n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.add = function(event){\n\t\t//the event needs to have a time attribute\n\t\tif (this.isUndef(event.time)){\n\t\t\tthrow new Error(\"Tone.Timeline: events must have a time attribute\");\n\t\t}\n\t\tif (this._timeline.length){\n\t\t\tvar index = this._search(event.time);\n\t\t\tthis._timeline.splice(index + 1, 0, event);\n\t\t} else {\n\t\t\tthis._timeline.push(event);\t\t\t\n\t\t}\n\t\t//if the length is more than the memory, remove the previous ones\n\t\tif (this.length > this.memory){\n\t\t\tvar diff = this.length - this.memory;\n\t\t\tthis._timeline.splice(0, diff);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Remove an event from the timeline.\n\t * @param {Object} event The event object to remove from the list.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.remove = function(event){\n\t\tif (this._iterating){\n\t\t\tthis._toRemove.push(event);\n\t\t} else {\n\t\t\tvar index = this._timeline.indexOf(event);\n\t\t\tif (index !== -1){\n\t\t\t\tthis._timeline.splice(index, 1);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Get the nearest event whose time is less than or equal to the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object set after that time.\n\t */\n\tTone.Timeline.prototype.get = function(time){\n\t\tvar index = this._search(time);\n\t\tif (index !== -1){\n\t\t\treturn this._timeline[index];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Return the first event in the timeline without removing it\n\t * @returns {Object} The first event object\n\t */\n\tTone.Timeline.prototype.peek = function(){\n\t\treturn this._timeline[0];\n\t};\n\n\t/**\n\t * Return the first event in the timeline and remove it\n\t * @returns {Object} The first event object\n\t */\n\tTone.Timeline.prototype.shift = function(){\n\t\treturn this._timeline.shift();\n\t};\n\n\t/**\n\t * Get the event which is scheduled after the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object after the given time\n\t */\n\tTone.Timeline.prototype.getAfter = function(time){\n\t\tvar index = this._search(time);\n\t\tif (index + 1 < this._timeline.length){\n\t\t\treturn this._timeline[index + 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Get the event before the event at the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object before the given time\n\t */\n\tTone.Timeline.prototype.getBefore = function(time){\n\t\tvar len = this._timeline.length;\n\t\t//if it's after the last item, return the last item\n\t\tif (len > 0 && this._timeline[len - 1].time < time){\n\t\t\treturn this._timeline[len - 1];\n\t\t}\n\t\tvar index = this._search(time);\n\t\tif (index - 1 >= 0){\n\t\t\treturn this._timeline[index - 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Cancel events after the given time\n\t * @param {Number} time The time to query.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.cancel = function(after){\n\t\tif (this._timeline.length > 1){\n\t\t\tvar index = this._search(after);\n\t\t\tif (index >= 0){\n\t\t\t\tif (this._timeline[index].time === after){\n\t\t\t\t\t//get the first item with that time\n\t\t\t\t\tfor (var i = index; i >= 0; i--){\n\t\t\t\t\t\tif (this._timeline[i].time === after){\n\t\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis._timeline = this._timeline.slice(0, index);\n\t\t\t\t} else {\n\t\t\t\t\tthis._timeline = this._timeline.slice(0, index + 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis._timeline = [];\n\t\t\t}\n\t\t} else if (this._timeline.length === 1){\n\t\t\t//the first item's time\n\t\t\tif (this._timeline[0].time >= after){\n\t\t\t\tthis._timeline = [];\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancel events before or equal to the given time.\n\t * @param {Number} time The time to cancel before.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.cancelBefore = function(time){\n\t\tif (this._timeline.length){\n\t\t\tvar index = this._search(time);\n\t\t\tif (index >= 0){\n\t\t\t\tthis._timeline = this._timeline.slice(index + 1);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Does a binary serach on the timeline array and returns the \n\t * nearest event index whose time is after or equal to the given time.\n\t * If a time is searched before the first index in the timeline, -1 is returned.\n\t * If the time is after the end, the index of the last item is returned.\n\t * @param {Number} time \n\t * @return {Number} the index in the timeline array \n\t * @private\n\t */\n\tTone.Timeline.prototype._search = function(time){\n\t\tvar beginning = 0;\n\t\tvar len = this._timeline.length;\n\t\tvar end = len;\n\t\tif (len > 0 && this._timeline[len - 1].time <= time){\n\t\t\treturn len - 1;\n\t\t}\n\t\twhile (beginning < end){\n\t\t\t// calculate the midpoint for roughly equal partition\n\t\t\tvar midPoint = Math.floor(beginning + (end - beginning) / 2);\n\t\t\tvar event = this._timeline[midPoint];\n\t\t\tvar nextEvent = this._timeline[midPoint + 1];\n\t\t\tif (event.time === time){\n\t\t\t\t//choose the last one that has the same time\n\t\t\t\tfor (var i = midPoint; i < this._timeline.length; i++){\n\t\t\t\t\tvar testEvent = this._timeline[i];\n\t\t\t\t\tif (testEvent.time === time){\n\t\t\t\t\t\tmidPoint = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn midPoint;\n\t\t\t} else if (event.time < time && nextEvent.time > time){\n\t\t\t\treturn midPoint;\n\t\t\t} else if (event.time > time){\n\t\t\t\t//search lower\n\t\t\t\tend = midPoint;\n\t\t\t} else if (event.time < time){\n\t\t\t\t//search upper\n\t\t\t\tbeginning = midPoint + 1;\n\t\t\t} \n\t\t}\n\t\treturn -1;\n\t};\n\n\t/**\n\t * Internal iterator. Applies extra safety checks for \n\t * removing items from the array. \n\t * @param {Function} callback \n\t * @param {Number=} lowerBound \n\t * @param {Number=} upperBound \n\t * @private\n\t */\n\tTone.Timeline.prototype._iterate = function(callback, lowerBound, upperBound){\n\t\tthis._iterating = true;\n\t\tlowerBound = this.defaultArg(lowerBound, 0);\n\t\tupperBound = this.defaultArg(upperBound, this._timeline.length - 1);\n\t\tfor (var i = lowerBound; i <= upperBound; i++){\n\t\t\tcallback(this._timeline[i]);\n\t\t}\n\t\tthis._iterating = false;\n\t\tif (this._toRemove.length > 0){\n\t\t\tfor (var j = 0; j < this._toRemove.length; j++){\n\t\t\t\tvar index = this._timeline.indexOf(this._toRemove[j]);\n\t\t\t\tif (index !== -1){\n\t\t\t\t\tthis._timeline.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._toRemove = [];\n\t\t}\n\t};\n\n\t/**\n\t * Iterate over everything in the array\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEach = function(callback){\n\t\tthis._iterate(callback);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at or before the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachBefore = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar upperBound = this._search(time);\n\t\tif (upperBound !== -1){\n\t\t\tthis._iterate(callback, 0, upperBound);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array after the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachAfter = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar lowerBound = this._search(time);\n\t\tthis._iterate(callback, lowerBound + 1);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at or after the given time. Similar to \n\t * forEachAfter, but includes the item(s) at the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachFrom = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar lowerBound = this._search(time);\n\t\t//work backwards until the event time is less than time\n\t\twhile (lowerBound >= 0 && this._timeline[lowerBound].time >= time){\n\t\t\tlowerBound--;\n\t\t}\n\t\tthis._iterate(callback, lowerBound + 1);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at the given time\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachAtTime = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar upperBound = this._search(time);\n\t\tif (upperBound !== -1){\n\t\t\tthis._iterate(function(event){\n\t\t\t\tif (event.time === time){\n\t\t\t\t\tcallback(event);\n\t\t\t\t} \n\t\t\t}, 0, upperBound);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._timeline = null;\n\t\tthis._toRemove = null;\n\t};\n\n\treturn Tone.Timeline;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Multiply\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Negate the incoming signal. i.e. an input signal of 10 will output -10\n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var neg = new Tone.Negate();\n\t * var sig = new Tone.Signal(-2).connect(neg);\n\t * //output of neg is positive 2. \n\t */\n\tTone.Negate = function(){\n\t\t/**\n\t\t * negation is done by multiplying by -1\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._multiply = this.input = this.output = new Tone.Multiply(-1);\n\t};\n\n\tTone.extend(Tone.Negate, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Negate} this\n\t */\n\tTone.Negate.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._multiply.dispose();\n\t\tthis._multiply = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Negate;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/signal/Multiply\", \"Tone/signal/WaveShaper\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class GreaterThanZero outputs 1 when the input is strictly greater than zero\n\t * \n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var gt0 = new Tone.GreaterThanZero();\n\t * var sig = new Tone.Signal(0.01).connect(gt0);\n\t * //the output of gt0 is 1. \n\t * sig.value = 0;\n\t * //the output of gt0 is 0. \n\t */\n\tTone.GreaterThanZero = function(){\n\t\t\n\t\t/**\n\t\t * @type {Tone.WaveShaper}\n\t\t * @private\n\t\t */\n\t\tthis._thresh = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (val <= 0){\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}, 127);\n\n\t\t/**\n\t\t * scale the first thresholded signal by a large value.\n\t\t * this will help with values which are very close to 0\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._scale = this.input = new Tone.Multiply(10000);\n\n\t\t//connections\n\t\tthis._scale.connect(this._thresh);\n\t};\n\n\tTone.extend(Tone.GreaterThanZero, Tone.SignalBase);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.GreaterThanZero} this\n\t */\n\tTone.GreaterThanZero.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._scale.dispose();\n\t\tthis._scale = null;\n\t\tthis._thresh.dispose();\n\t\tthis._thresh = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.GreaterThanZero;\n});","/**\n * StartAudioContext.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2016 Yotam Mann\n */\n(function (root, factory) {\n\tif (typeof define === \"function\" && define.amd) {\n\t\tdefine([], factory)\n\t } else if (typeof module === \"object\" && module.exports) {\n module.exports = factory()\n\t} else {\n\t\troot.StartAudioContext = factory()\n }\n}(this, function () {\n\n\t//TAP LISTENER/////////////////////////////////////////////////////////////\n\n\t/**\n\t * @class Listens for non-dragging tap ends on the given element\n\t * @param {Element} element\n\t * @internal\n\t */\n\tvar TapListener = function(element, context){\n\n\t\tthis._dragged = false\n\n\t\tthis._element = element\n\n\t\tthis._bindedMove = this._moved.bind(this)\n\t\tthis._bindedEnd = this._ended.bind(this, context)\n\n\t\telement.addEventListener(\"touchstart\", this._bindedEnd)\n\t\telement.addEventListener(\"touchmove\", this._bindedMove)\n\t\telement.addEventListener(\"touchend\", this._bindedEnd)\n\t\telement.addEventListener(\"mouseup\", this._bindedEnd)\n\t}\n\n\t/**\n\t * drag move event\n\t */\n\tTapListener.prototype._moved = function(e){\n\t\tthis._dragged = true\n\t};\n\n\t/**\n\t * tap ended listener\n\t */\n\tTapListener.prototype._ended = function(context){\n\t\tif (!this._dragged){\n\t\t\tstartContext(context)\n\t\t}\n\t\tthis._dragged = false\n\t};\n\n\t/**\n\t * remove all the bound events\n\t */\n\tTapListener.prototype.dispose = function(){\n\t\tthis._element.removeEventListener(\"touchstart\", this._bindedEnd)\n\t\tthis._element.removeEventListener(\"touchmove\", this._bindedMove)\n\t\tthis._element.removeEventListener(\"touchend\", this._bindedEnd)\n\t\tthis._element.removeEventListener(\"mouseup\", this._bindedEnd)\n\t\tthis._bindedMove = null\n\t\tthis._bindedEnd = null\n\t\tthis._element = null\n\t};\n\n\t//END TAP LISTENER/////////////////////////////////////////////////////////\n\n\t/**\n\t * Plays a silent sound and also invoke the \"resume\" method\n\t * @param {AudioContext} context\n\t * @private\n\t */\n\tfunction startContext(context){\n\t\t// this accomplishes the iOS specific requirement\n\t\tvar buffer = context.createBuffer(1, 1, context.sampleRate)\n\t\tvar source = context.createBufferSource()\n\t\tsource.buffer = buffer\n\t\tsource.connect(context.destination)\n\t\tsource.start(0)\n\n\t\t// resume the audio context\n\t\tif (context.resume){\n\t\t\tcontext.resume()\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if the audio context is started\n\t * @param {AudioContext} context\n\t * @return {Boolean}\n\t * @private\n\t */\n\tfunction isStarted(context){\n\t\t return context.state === \"running\"\n\t}\n\n\t/**\n\t * Invokes the callback as soon as the AudioContext\n\t * is started\n\t * @param {AudioContext} context\n\t * @param {Function} callback\n\t */\n\tfunction onStarted(context, callback){\n\n\t\tfunction checkLoop(){\n\t\t\tif (isStarted(context)){\n\t\t\t\tcallback()\n\t\t\t} else {\n\t\t\t\trequestAnimationFrame(checkLoop)\n\t\t\t\tif (context.resume){\n\t\t\t\t\tcontext.resume()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isStarted(context)){\n\t\t\tcallback()\n\t\t} else {\n\t\t\tcheckLoop()\n\t\t}\n\t}\n\n\t/**\n\t * Add a tap listener to the audio context\n\t * @param {Array|Element|String|jQuery} element\n\t * @param {Array} tapListeners\n\t */\n\tfunction bindTapListener(element, tapListeners, context){\n\t\tif (Array.isArray(element) || (NodeList && element instanceof NodeList)){\n\t\t\tfor (var i = 0; i < element.length; i++){\n\t\t\t\tbindTapListener(element[i], tapListeners, context)\n\t\t\t}\n\t\t} else if (typeof element === \"string\"){\n\t\t\tbindTapListener(document.querySelectorAll(element), tapListeners, context)\n\t\t} else if (element.jquery && typeof element.toArray === \"function\"){\n\t\t\tbindTapListener(element.toArray(), tapListeners, context)\n\t\t} else if (Element && element instanceof Element){\n\t\t\t//if it's an element, create a TapListener\n\t\t\tvar tap = new TapListener(element, context)\n\t\t\ttapListeners.push(tap)\n\t\t} \n\t}\n\n\t/**\n\t * @param {AudioContext} context The AudioContext to start.\n\t * @param {Array|String|Element|jQuery=} elements For iOS, the list of elements\n\t * to bind tap event listeners\n\t * which will start the AudioContext. If\n\t * no elements are given, it will bind\n\t * to the document.body.\n\t * @param {Function=} callback The callback to invoke when the AudioContext is started.\n\t * @return {Promise} The promise is invoked when the AudioContext\n\t * is started.\n\t */\n\tfunction StartAudioContext(context, elements, callback){\n\n\t\t//the promise is invoked when the AudioContext is started\n\t\tvar promise = new Promise(function(success) {\n\t\t\tonStarted(context, success)\n\t\t})\n\n\t\t// The TapListeners bound to the elements\n\t\tvar tapListeners = []\n\n\t\t// add all the tap listeners\n\t\tif (!elements){\n\t\t\telements = document.body\n\t\t}\n\t\tbindTapListener(elements, tapListeners, context)\n\n\t\t//dispose all these tap listeners when the context is started\n\t\tpromise.then(function(){\n\t\t\tfor (var i = 0; i < tapListeners.length; i++){\n\t\t\t\ttapListeners[i].dispose()\n\t\t\t}\n\t\t\ttapListeners = null\n\n\t\t\tif (callback){\n\t\t\t\tcallback()\n\t\t\t}\n\t\t})\n\n\t\treturn promise\n\t}\n\n\treturn StartAudioContext\n}))","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/signal/Expr\", \n\t\"Tone/signal/EqualPowerGain\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Crossfade provides equal power fading between two inputs. \n\t * More on crossfading technique [here](https://en.wikipedia.org/wiki/Fade_(audio_engineering)#Crossfading).\n\t *\n\t * @constructor\n\t * @extends {Tone}\n\t * @param {NormalRange} [initialFade=0.5]\n\t * @example\n\t * var crossFade = new Tone.CrossFade(0.5);\n\t * //connect effect A to crossfade from\n\t * //effect output 0 to crossfade input 0\n\t * effectA.connect(crossFade, 0, 0);\n\t * //connect effect B to crossfade from\n\t * //effect output 0 to crossfade input 1\n\t * effectB.connect(crossFade, 0, 1);\n\t * crossFade.fade.value = 0;\n\t * // ^ only effectA is output\n\t * crossFade.fade.value = 1;\n\t * // ^ only effectB is output\n\t * crossFade.fade.value = 0.5;\n\t * // ^ the two signals are mixed equally. \n\t */\t\t\n\tTone.CrossFade = function(initialFade){\n\n\t\tthis.createInsOuts(2, 1);\n\n\t\t/**\n\t\t * Alias for input[0]. \n\t\t * @type {Tone.Gain}\n\t\t */\n\t\tthis.a = this.input[0] = new Tone.Gain();\n\n\t\t/**\n\t\t * Alias for input[1]. \n\t\t * @type {Tone.Gain}\n\t\t */\n\t\tthis.b = this.input[1] = new Tone.Gain();\n\n\t\t/**\n\t\t * \tThe mix between the two inputs. A fade value of 0\n\t\t * \twill output 100% input[0] and \n\t\t * \ta value of 1 will output 100% input[1]. \n\t\t * @type {NormalRange}\n\t\t * @signal\n\t\t */\n\t\tthis.fade = new Tone.Signal(this.defaultArg(initialFade, 0.5), Tone.Type.NormalRange);\n\n\t\t/**\n\t\t * equal power gain cross fade\n\t\t * @private\n\t\t * @type {Tone.EqualPowerGain}\n\t\t */\n\t\tthis._equalPowerA = new Tone.EqualPowerGain();\n\n\t\t/**\n\t\t * equal power gain cross fade\n\t\t * @private\n\t\t * @type {Tone.EqualPowerGain}\n\t\t */\n\t\tthis._equalPowerB = new Tone.EqualPowerGain();\n\t\t\n\t\t/**\n\t\t * invert the incoming signal\n\t\t * @private\n\t\t * @type {Tone}\n\t\t */\n\t\tthis._invert = new Tone.Expr(\"1 - $0\");\n\n\t\t//connections\n\t\tthis.a.connect(this.output);\n\t\tthis.b.connect(this.output);\n\t\tthis.fade.chain(this._equalPowerB, this.b.gain);\n\t\tthis.fade.chain(this._invert, this._equalPowerA, this.a.gain);\n\t\tthis._readOnly(\"fade\");\n\t};\n\n\tTone.extend(Tone.CrossFade);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.CrossFade} this\n\t */\n\tTone.CrossFade.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._writable(\"fade\");\n\t\tthis._equalPowerA.dispose();\n\t\tthis._equalPowerA = null;\n\t\tthis._equalPowerB.dispose();\n\t\tthis._equalPowerB = null;\n\t\tthis.fade.dispose();\n\t\tthis.fade = null;\n\t\tthis._invert.dispose();\n\t\tthis._invert = null;\n\t\tthis.a.dispose();\n\t\tthis.a = null;\n\t\tthis.b.dispose();\n\t\tthis.b = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.CrossFade;\n});\n","!function(){var e,t=[];function r(e){var r=this,n={},i=-1;this.parameters.forEach(function(e,o){var s=t[++i]||(t[i]=new Float32Array(r.bufferSize));s.fill(e.value),n[o]=s}),this.processor.realm.exec(\"self.sampleRate=sampleRate=\"+this.context.sampleRate+\";self.currentTime=currentTime=\"+this.context.currentTime);var s=o(e.inputBuffer),a=o(e.outputBuffer);this.instance.process([s],[a],n)}function o(e){for(var t=[],r=0;r= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar RecorderProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(RecorderProcessor, _AudioWorkletProcesso);\\n\\n function RecorderProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, RecorderProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(RecorderProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.numOutputChannels = options.outputChannelCount || 2;\\n _this.numInputChannels = processorOptions.numInputChannels || 2;\\n _this.bufferSize = processorOptions.bufferSize || 1024;\\n _this.recording = false;\\n\\n _this.clear();\\n\\n _this.port.onmessage = function (event) {\\n var data = event.data;\\n\\n if (data.name === 'start') {\\n _this.record(data.duration);\\n } else if (data.name === 'stop') {\\n _this.stop();\\n }\\n };\\n\\n return _this;\\n }\\n\\n _createClass(RecorderProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs) {\\n if (!this.recording) {\\n return true;\\n } else if (this.sampleLimit && this.recordedSamples >= this.sampleLimit) {\\n this.stop();\\n return true;\\n }\\n\\n var input = inputs[0];\\n this.inputRingBuffer.push(input);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n\\n for (var channel = 0; channel < this.numOutputChannels; ++channel) {\\n var inputChannelCopy = this.inputRingBufferArraySequence[channel].slice();\\n\\n if (channel === 0) {\\n this.leftBuffers.push(inputChannelCopy);\\n\\n if (this.numInputChannels === 1) {\\n this.rightBuffers.push(inputChannelCopy);\\n }\\n } else if (channel === 1 && this.numInputChannels > 1) {\\n this.rightBuffers.push(inputChannelCopy);\\n }\\n }\\n\\n this.recordedSamples += this.bufferSize;\\n }\\n\\n return true;\\n }\\n }, {\\n key: \\\"record\\\",\\n value: function record(duration) {\\n if (duration) {\\n this.sampleLimit = Math.round(duration * sampleRate);\\n }\\n\\n this.recording = true;\\n }\\n }, {\\n key: \\\"stop\\\",\\n value: function stop() {\\n this.recording = false;\\n var buffers = this.getBuffers();\\n var leftBuffer = buffers[0].buffer;\\n var rightBuffer = buffers[1].buffer;\\n this.port.postMessage({\\n name: 'buffers',\\n leftBuffer: leftBuffer,\\n rightBuffer: rightBuffer\\n }, [leftBuffer, rightBuffer]);\\n this.clear();\\n }\\n }, {\\n key: \\\"getBuffers\\\",\\n value: function getBuffers() {\\n var buffers = [];\\n buffers.push(this.mergeBuffers(this.leftBuffers));\\n buffers.push(this.mergeBuffers(this.rightBuffers));\\n return buffers;\\n }\\n }, {\\n key: \\\"mergeBuffers\\\",\\n value: function mergeBuffers(channelBuffer) {\\n var result = new Float32Array(this.recordedSamples);\\n var offset = 0;\\n var lng = channelBuffer.length;\\n\\n for (var i = 0; i < lng; i++) {\\n var buffer = channelBuffer[i];\\n result.set(buffer, offset);\\n offset += buffer.length;\\n }\\n\\n return result;\\n }\\n }, {\\n key: \\\"clear\\\",\\n value: function clear() {\\n var _this2 = this;\\n\\n this.leftBuffers = [];\\n this.rightBuffers = [];\\n this.inputRingBuffer = new RingBuffer(this.bufferSize, this.numInputChannels);\\n this.inputRingBufferArraySequence = new Array(this.numInputChannels).fill(null).map(function () {\\n return new Float32Array(_this2.bufferSize);\\n });\\n this.recordedSamples = 0;\\n this.sampleLimit = null;\\n }\\n }]);\\n\\n return RecorderProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.recorderProcessor, RecorderProcessor);\"","export default \"function _typeof(obj) { if (typeof Symbol === \\\"function\\\" && typeof Symbol.iterator === \\\"symbol\\\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \\\"function\\\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \\\"symbol\\\" : typeof obj; }; } return _typeof(obj); }\\n\\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \\\"object\\\" || typeof call === \\\"function\\\")) { return call; } return _assertThisInitialized(self); }\\n\\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\"); } return self; }\\n\\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \\\"function\\\" && superClass !== null) { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\\n\\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \\\"function\\\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \\\"function\\\") { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } if (typeof _cache !== \\\"undefined\\\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\\n\\nfunction isNativeReflectConstruct() { if (typeof Reflect === \\\"undefined\\\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \\\"function\\\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\\n\\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\\n\\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\\\"[native code]\\\") !== -1; }\\n\\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\\n\\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\\n\\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\\"Cannot call a class as a function\\\"); } }\\n\\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\\\"value\\\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\\n\\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\\n\\n// import dependencies via preval.require so that they're available as values at compile time\\nvar processorNames = {\\n \\\"recorderProcessor\\\": \\\"recorder-processor\\\",\\n \\\"soundFileProcessor\\\": \\\"sound-file-processor\\\",\\n \\\"amplitudeProcessor\\\": \\\"amplitude-processor\\\"\\n};\\nvar RingBuffer = {\\n \\\"default\\\":\\n /*#__PURE__*/\\n function () {\\n /**\\n * @constructor\\n * @param {number} length Buffer length in frames.\\n * @param {number} channelCount Buffer channel count.\\n */\\n function RingBuffer(length, channelCount) {\\n _classCallCheck(this, RingBuffer);\\n\\n this._readIndex = 0;\\n this._writeIndex = 0;\\n this._framesAvailable = 0;\\n this._channelCount = channelCount;\\n this._length = length;\\n this._channelData = [];\\n\\n for (var i = 0; i < this._channelCount; ++i) {\\n this._channelData[i] = new Float32Array(length);\\n }\\n }\\n /**\\n * Getter for Available frames in buffer.\\n *\\n * @return {number} Available frames in buffer.\\n */\\n\\n\\n _createClass(RingBuffer, [{\\n key: \\\"push\\\",\\n\\n /**\\n * Push a sequence of Float32Arrays to buffer.\\n *\\n * @param {array} arraySequence A sequence of Float32Arrays.\\n */\\n value: function push(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // Transfer data from the |arraySequence| storage to the internal buffer.\\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\\n\\n for (var i = 0; i < sourceLength; ++i) {\\n var writeIndex = (this._writeIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\\n }\\n }\\n\\n this._writeIndex += sourceLength;\\n\\n if (this._writeIndex >= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar SoundFileProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(SoundFileProcessor, _AudioWorkletProcesso);\\n\\n function SoundFileProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, SoundFileProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SoundFileProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.bufferSize = processorOptions.bufferSize || 256;\\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, 1);\\n _this.inputRingBufferArraySequence = [new Float32Array(_this.bufferSize)];\\n return _this;\\n }\\n\\n _createClass(SoundFileProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs) {\\n var input = inputs[0]; // we only care about the first input channel, because that contains the position data\\n\\n this.inputRingBuffer.push([input[0]]);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n var inputChannel = this.inputRingBufferArraySequence[0];\\n var position = inputChannel[inputChannel.length - 1] || 0;\\n this.port.postMessage({\\n name: 'position',\\n position: position\\n });\\n }\\n\\n return true;\\n }\\n }]);\\n\\n return SoundFileProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.soundFileProcessor, SoundFileProcessor);\"","export default \"function _typeof(obj) { if (typeof Symbol === \\\"function\\\" && typeof Symbol.iterator === \\\"symbol\\\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \\\"function\\\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \\\"symbol\\\" : typeof obj; }; } return _typeof(obj); }\\n\\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \\\"object\\\" || typeof call === \\\"function\\\")) { return call; } return _assertThisInitialized(self); }\\n\\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\"); } return self; }\\n\\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \\\"function\\\" && superClass !== null) { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\\n\\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \\\"function\\\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \\\"function\\\") { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } if (typeof _cache !== \\\"undefined\\\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\\n\\nfunction isNativeReflectConstruct() { if (typeof Reflect === \\\"undefined\\\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \\\"function\\\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\\n\\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\\n\\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\\\"[native code]\\\") !== -1; }\\n\\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\\n\\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\\n\\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\\"Cannot call a class as a function\\\"); } }\\n\\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\\\"value\\\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\\n\\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\\n\\n// import dependencies via preval.require so that they're available as values at compile time\\nvar processorNames = {\\n \\\"recorderProcessor\\\": \\\"recorder-processor\\\",\\n \\\"soundFileProcessor\\\": \\\"sound-file-processor\\\",\\n \\\"amplitudeProcessor\\\": \\\"amplitude-processor\\\"\\n};\\nvar RingBuffer = {\\n \\\"default\\\":\\n /*#__PURE__*/\\n function () {\\n /**\\n * @constructor\\n * @param {number} length Buffer length in frames.\\n * @param {number} channelCount Buffer channel count.\\n */\\n function RingBuffer(length, channelCount) {\\n _classCallCheck(this, RingBuffer);\\n\\n this._readIndex = 0;\\n this._writeIndex = 0;\\n this._framesAvailable = 0;\\n this._channelCount = channelCount;\\n this._length = length;\\n this._channelData = [];\\n\\n for (var i = 0; i < this._channelCount; ++i) {\\n this._channelData[i] = new Float32Array(length);\\n }\\n }\\n /**\\n * Getter for Available frames in buffer.\\n *\\n * @return {number} Available frames in buffer.\\n */\\n\\n\\n _createClass(RingBuffer, [{\\n key: \\\"push\\\",\\n\\n /**\\n * Push a sequence of Float32Arrays to buffer.\\n *\\n * @param {array} arraySequence A sequence of Float32Arrays.\\n */\\n value: function push(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // Transfer data from the |arraySequence| storage to the internal buffer.\\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\\n\\n for (var i = 0; i < sourceLength; ++i) {\\n var writeIndex = (this._writeIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\\n }\\n }\\n\\n this._writeIndex += sourceLength;\\n\\n if (this._writeIndex >= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar AmplitudeProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(AmplitudeProcessor, _AudioWorkletProcesso);\\n\\n function AmplitudeProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, AmplitudeProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(AmplitudeProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.numOutputChannels = options.outputChannelCount || 1;\\n _this.numInputChannels = processorOptions.numInputChannels || 2;\\n _this.normalize = processorOptions.normalize || false;\\n _this.smoothing = processorOptions.smoothing || 0;\\n _this.bufferSize = processorOptions.bufferSize || 2048;\\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, _this.numInputChannels);\\n _this.outputRingBuffer = new RingBuffer(_this.bufferSize, _this.numOutputChannels);\\n _this.inputRingBufferArraySequence = new Array(_this.numInputChannels).fill(null).map(function () {\\n return new Float32Array(_this.bufferSize);\\n });\\n _this.stereoVol = [0, 0];\\n _this.stereoVolNorm = [0, 0];\\n _this.volMax = 0.001;\\n\\n _this.port.onmessage = function (event) {\\n var data = event.data;\\n\\n if (data.name === 'toggleNormalize') {\\n _this.normalize = data.normalize;\\n } else if (data.name === 'smoothing') {\\n _this.smoothing = Math.max(0, Math.min(1, data.smoothing));\\n }\\n };\\n\\n return _this;\\n } // TO DO make this stereo / dependent on # of audio channels\\n\\n\\n _createClass(AmplitudeProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs, outputs) {\\n var input = inputs[0];\\n var output = outputs[0];\\n var smoothing = this.smoothing;\\n this.inputRingBuffer.push(input);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n\\n for (var channel = 0; channel < this.numInputChannels; ++channel) {\\n var inputBuffer = this.inputRingBufferArraySequence[channel];\\n var bufLength = inputBuffer.length;\\n var sum = 0;\\n\\n for (var i = 0; i < bufLength; i++) {\\n var x = inputBuffer[i];\\n\\n if (this.normalize) {\\n sum += Math.max(Math.min(x / this.volMax, 1), -1) * Math.max(Math.min(x / this.volMax, 1), -1);\\n } else {\\n sum += x * x;\\n }\\n } // ... then take the square root of the sum.\\n\\n\\n var rms = Math.sqrt(sum / bufLength);\\n this.stereoVol[channel] = Math.max(rms, this.stereoVol[channel] * smoothing);\\n this.volMax = Math.max(this.stereoVol[channel], this.volMax);\\n } // calculate stero normalized volume and add volume from all channels together\\n\\n\\n var volSum = 0;\\n\\n for (var index = 0; index < this.stereoVol.length; index++) {\\n this.stereoVolNorm[index] = Math.max(Math.min(this.stereoVol[index] / this.volMax, 1), 0);\\n volSum += this.stereoVol[index];\\n } // volume is average of channels\\n\\n\\n var volume = volSum / this.stereoVol.length; // normalized value\\n\\n var volNorm = Math.max(Math.min(volume / this.volMax, 1), 0);\\n this.port.postMessage({\\n name: 'amplitude',\\n volume: volume,\\n volNorm: volNorm,\\n stereoVol: this.stereoVol,\\n stereoVolNorm: this.stereoVolNorm\\n }); // pass input through to output\\n\\n this.outputRingBuffer.push(this.inputRingBufferArraySequence);\\n } // pull 128 frames out of the ring buffer\\n // if the ring buffer does not have enough frames, the output will be silent\\n\\n\\n this.outputRingBuffer.pull(output);\\n return true;\\n }\\n }]);\\n\\n return AmplitudeProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.amplitudeProcessor, AmplitudeProcessor);\"","define([\"Tone/core/Tone\", \"Tone/type/TimeBase\"], function (Tone) {\n\n\t/**\n\t * @class Tone.Frequency is a primitive type for encoding Frequency values. \n\t * Eventually all time values are evaluated to hertz\n\t * using the `eval` method. \n\t * @constructor\n\t * @extends {Tone.TimeBase}\n\t * @param {String|Number} val The time value.\n\t * @param {String=} units The units of the value.\n\t * @example\n\t * Tone.Frequency(\"C3\") // 261\n\t * Tone.Frequency(38, \"midi\") //\n\t * Tone.Frequency(\"C3\").transpose(4);\n\t */\n\tTone.Frequency = function(val, units){\n\t\tif (this instanceof Tone.Frequency){\n\t\t\t\n\t\t\tTone.TimeBase.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.Frequency(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.Frequency, Tone.TimeBase);\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tAUGMENT BASE EXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.Frequency.prototype._primaryExpressions = Object.create(Tone.TimeBase.prototype._primaryExpressions);\n\n\t/*\n\t * midi type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.midi = {\n\t\tregexp : /^(\\d+(?:\\.\\d+)?midi)/,\n\t\tmethod : function(value){\n\t\t\treturn this.midiToFrequency(value);\n\t\t}\t\n\t};\n\n\t/*\n\t * note type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.note = {\n\t\tregexp : /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,\n\t\tmethod : function(pitch, octave){\n\t\t\tvar index = noteToScaleIndex[pitch.toLowerCase()];\n\t\t\tvar noteNumber = index + (parseInt(octave) + 1) * 12;\n\t\t\treturn this.midiToFrequency(noteNumber);\n\t\t}\t\n\t};\n\n\t/*\n\t * BeatsBarsSixteenths type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.tr = {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t\t\tmethod : function(m, q, s){\n\t\t\tvar total = 1;\n\t\t\tif (m && m !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(this._timeSignature() * parseFloat(m));\n\t\t\t}\n\t\t\tif (q && q !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(parseFloat(q));\n\t\t\t}\n\t\t\tif (s && s !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(parseFloat(s) / 4);\n\t\t\t}\n\t\t\treturn total;\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tEXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Transposes the frequency by the given number of semitones.\n\t * @param {Interval} interval\n\t * @return {Tone.Frequency} this\n\t * @example\n\t * Tone.Frequency(\"A4\").transpose(3); //\"C5\"\n\t */\n\tTone.Frequency.prototype.transpose = function(interval){\n\t\tthis._expr = function(expr, interval){\n\t\t\tvar val = expr();\n\t\t\treturn val * this.intervalToFrequencyRatio(interval);\n\t\t}.bind(this, this._expr, interval);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Takes an array of semitone intervals and returns\n\t * an array of frequencies transposed by those intervals.\n\t * @param {Array} intervals\n\t * @return {Tone.Frequency} this\n\t * @example\n\t * Tone.Frequency(\"A4\").harmonize([0, 3, 7]); //[\"A4\", \"C5\", \"E5\"]\n\t */\n\tTone.Frequency.prototype.harmonize = function(intervals){\n\t\tthis._expr = function(expr, intervals){\n\t\t\tvar val = expr();\n\t\t\tvar ret = [];\n\t\t\tfor (var i = 0; i < intervals.length; i++){\n\t\t\t\tret[i] = val * this.intervalToFrequencyRatio(intervals[i]);\n\t\t\t}\n\t\t\treturn ret;\n\t\t}.bind(this, this._expr, intervals);\n\t\treturn this;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Return the value of the frequency as a MIDI note\n\t * @return {MIDI}\n\t * @example\n\t * Tone.Frequency(\"C4\").toMidi(); //60\n\t */\n\tTone.Frequency.prototype.toMidi = function(){\n\t\treturn this.frequencyToMidi(this.valueOf());\n\t};\n\n\t/**\n\t * Return the value of the frequency in Scientific Pitch Notation\n\t * @return {Note}\n\t * @example\n\t * Tone.Frequency(69, \"midi\").toNote(); //\"A4\"\n\t */\n\tTone.Frequency.prototype.toNote = function(){\n\t\tvar freq = this.valueOf();\n\t\tvar log = Math.log(freq / Tone.Frequency.A4) / Math.LN2;\n\t\tvar noteNumber = Math.round(12 * log) + 57;\n\t\tvar octave = Math.floor(noteNumber/12);\n\t\tif(octave < 0){\n\t\t\tnoteNumber += -12 * octave;\n\t\t}\n\t\tvar noteName = scaleIndexToNote[noteNumber % 12];\n\t\treturn noteName + octave.toString();\n\t};\n\n\t/**\n\t * Return the duration of one cycle in seconds.\n\t * @return {Seconds}\n\t */\n\tTone.Frequency.prototype.toSeconds = function(){\n\t\treturn 1 / this.valueOf();\n\t};\n\n\t/**\n\t * Return the value in Hertz\n\t * @return {Frequency}\n\t */\n\tTone.Frequency.prototype.toFrequency = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the duration of one cycle in ticks\n\t * @return {Ticks}\n\t */\n\tTone.Frequency.prototype.toTicks = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.valueOf() / quarterTime;\n\t\treturn Math.floor(quarters * Tone.Transport.PPQ);\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS HELPERS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value of a frequency in the current units\n\t * @param {Frequency} freq\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._frequencyToUnits = function(freq){\n\t\treturn freq;\n\t};\n\n\t/**\n\t * Returns the value of a tick in the current time units\n\t * @param {Ticks} ticks\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._ticksToUnits = function(ticks){\n\t\treturn 1 / ((ticks * 60) / (Tone.Transport.bpm.value * Tone.Transport.PPQ));\n\t};\n\n\t/**\n\t * Return the value of the beats in the current units\n\t * @param {Number} beats\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._beatsToUnits = function(beats){\n\t\treturn 1 / Tone.TimeBase.prototype._beatsToUnits.call(this, beats);\n\t};\n\n\t/**\n\t * Returns the value of a second in the current units\n\t * @param {Seconds} seconds\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._secondsToUnits = function(seconds){\n\t\treturn 1 / seconds;\n\t};\n\n\t/**\n\t * The default units if none are given.\n\t * @private\n\t */\n\tTone.Frequency.prototype._defaultUnits = \"hz\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tFREQUENCY CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Note to scale index\n\t * @type {Object}\n\t */\n\tvar noteToScaleIndex = {\n\t\t\"cbb\" : -2, \"cb\" : -1, \"c\" : 0, \"c#\" : 1, \"cx\" : 2, \n\t\t\"dbb\" : 0, \"db\" : 1, \"d\" : 2, \"d#\" : 3, \"dx\" : 4,\n\t\t\"ebb\" : 2, \"eb\" : 3, \"e\" : 4, \"e#\" : 5, \"ex\" : 6, \n\t\t\"fbb\" : 3, \"fb\" : 4, \"f\" : 5, \"f#\" : 6, \"fx\" : 7,\n\t\t\"gbb\" : 5, \"gb\" : 6, \"g\" : 7, \"g#\" : 8, \"gx\" : 9,\n\t\t\"abb\" : 7, \"ab\" : 8, \"a\" : 9, \"a#\" : 10, \"ax\" : 11,\n\t\t\"bbb\" : 9, \"bb\" : 10, \"b\" : 11, \"b#\" : 12, \"bx\" : 13,\n\t};\n\n\t/**\n\t * scale index to note (sharps)\n\t * @type {Array}\n\t */\n\tvar scaleIndexToNote = [\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"A#\", \"B\"];\n\n\t/**\n\t * The [concert pitch](https://en.wikipedia.org/wiki/Concert_pitch)\n\t * A4's values in Hertz. \n\t * @type {Frequency}\n\t * @static\n\t */\n\tTone.Frequency.A4 = 440;\n\n\t/**\n\t * Convert a MIDI note to frequency value. \n\t * @param {MIDI} midi The midi number to convert.\n\t * @return {Frequency} the corresponding frequency value\n\t * @example\n\t * tone.midiToFrequency(69); // returns 440\n\t */\n\tTone.Frequency.prototype.midiToFrequency = function(midi){\n\t\treturn Tone.Frequency.A4 * Math.pow(2, (midi - 69) / 12);\n\t};\n\n\t/**\n\t * Convert a frequency value to a MIDI note.\n\t * @param {Frequency} frequency The value to frequency value to convert.\n\t * @returns {MIDI}\n\t * @example\n\t * tone.midiToFrequency(440); // returns 69\n\t */\n\tTone.Frequency.prototype.frequencyToMidi = function(frequency){\n\t\treturn 69 + 12 * Math.log(frequency / Tone.Frequency.A4) / Math.LN2;\n\t};\n\n\treturn Tone.Frequency;\n});","define([\"Tone/core/Tone\", \"Tone/type/Time\"], function (Tone) {\n\n\t/**\n\t * @class Tone.TransportTime is a the time along the Transport's\n\t * timeline. It is similar to Tone.Time, but instead of evaluating\n\t * against the AudioContext's clock, it is evaluated against\n\t * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime).\n\t * @constructor\n\t * @param {Time} val The time value as a number or string\n\t * @param {String=} units Unit values\n\t * @extends {Tone.Time}\n\t */\n\tTone.TransportTime = function(val, units){\n\t\tif (this instanceof Tone.TransportTime){\n\t\t\t\n\t\t\tTone.Time.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.TransportTime(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.TransportTime, Tone.Time);\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.TransportTime.prototype._unaryExpressions = Object.create(Tone.Time.prototype._unaryExpressions);\n\n\t/**\n\t * Adds an additional unary expression\n\t * which quantizes values to the next subdivision\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.TransportTime.prototype._unaryExpressions.quantize = {\n\t\tregexp : /^@/,\n\t\tmethod : function(rh){\n\t\t\tvar subdivision = this._secondsToTicks(rh());\n\t\t\tvar multiple = Math.ceil(Tone.Transport.ticks / subdivision);\n\t\t\treturn this._ticksToUnits(multiple * subdivision);\n\t\t}\n\t};\n\n\t/**\n\t * Convert seconds into ticks\n\t * @param {Seconds} seconds\n\t * @return {Ticks}\n\t * @private\n\t */\n\tTone.TransportTime.prototype._secondsToTicks = function(seconds){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = seconds / quarterTime;\n\t\treturn Math.round(quarters * Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Evaluate the time expression. Returns values in ticks\n\t * @return {Ticks}\n\t */\n\tTone.TransportTime.prototype.valueOf = function(){\n\t\tvar val = this._secondsToTicks(this._expr());\n\t\treturn val + (this._plusNow ? Tone.Transport.ticks : 0);\n\t};\n\n\t/**\n\t * Return the time in ticks.\n\t * @return {Ticks}\n\t */\n\tTone.TransportTime.prototype.toTicks = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds}\n\t */\n\tTone.TransportTime.prototype.toSeconds = function(){\n\t\tvar val = this._expr();\n\t\treturn val + (this._plusNow ? Tone.Transport.seconds : 0);\n\t};\n\n\t/**\n\t * Return the time as a frequency value\n\t * @return {Frequency} \n\t */\n\tTone.TransportTime.prototype.toFrequency = function(){\n\t\treturn 1/this.toSeconds();\n\t};\n\n\treturn Tone.TransportTime;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Subtract\", \"Tone/signal/Multiply\", \n\t\"Tone/signal/GreaterThan\", \"Tone/signal/GreaterThanZero\", \"Tone/signal/Abs\", \"Tone/signal/Negate\", \n\t\"Tone/signal/Modulo\", \"Tone/signal/Pow\", \"Tone/signal/AudioToGain\"], \n\tfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Evaluate an expression at audio rate.

\n\t * Parsing code modified from https://code.google.com/p/tapdigit/\n\t * Copyright 2011 2012 Ariya Hidayat, New BSD License\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {string} expr the expression to generate\n\t * @example\n\t * //adds the signals from input[0] and input[1].\n\t * var expr = new Tone.Expr(\"$0 + $1\");\n\t */\n\tTone.Expr = function(){\n\n\t\tvar expr = this._replacements(Array.prototype.slice.call(arguments));\n\t\tvar inputCount = this._parseInputs(expr);\n\n\t\t/**\n\t\t * hold onto all of the nodes for disposal\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._nodes = [];\n\n\t\t/**\n\t\t * The inputs. The length is determined by the expression. \n\t\t * @type {Array}\n\t\t */\n\t\tthis.input = new Array(inputCount);\n\n\t\t//create a gain for each input\n\t\tfor (var i = 0; i < inputCount; i++){\n\t\t\tthis.input[i] = this.context.createGain();\n\t\t}\n\n\t\t//parse the syntax tree\n\t\tvar tree = this._parseTree(expr);\n\t\t//evaluate the results\n\t\tvar result;\n\t\ttry {\n\t\t\tresult = this._eval(tree);\n\t\t} catch (e){\n\t\t\tthis._disposeNodes();\n\t\t\tthrow new Error(\"Tone.Expr: Could evaluate expression: \"+expr);\n\t\t}\n\n\t\t/**\n\t\t * The output node is the result of the expression\n\t\t * @type {Tone}\n\t\t */\n\t\tthis.output = result;\n\t};\n\n\tTone.extend(Tone.Expr, Tone.SignalBase);\n\n\t//some helpers to cut down the amount of code\n\tfunction applyBinary(Constructor, args, self){\n\t\tvar op = new Constructor();\n\t\tself._eval(args[0]).connect(op, 0, 0);\n\t\tself._eval(args[1]).connect(op, 0, 1);\n\t\treturn op;\n\t}\n\tfunction applyUnary(Constructor, args, self){\n\t\tvar op = new Constructor();\n\t\tself._eval(args[0]).connect(op, 0, 0);\n\t\treturn op;\n\t}\n\tfunction getNumber(arg){\n\t\treturn arg ? parseFloat(arg) : undefined;\n\t}\n\tfunction literalNumber(arg){\n\t\treturn arg && arg.args ? parseFloat(arg.args) : undefined;\n\t}\n\n\t/*\n\t * the Expressions that Tone.Expr can parse.\n\t *\n\t * each expression belongs to a group and contains a regexp \n\t * for selecting the operator as well as that operators method\n\t * \n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Expr._Expressions = {\n\t\t//values\n\t\t\"value\" : {\n\t\t\t\"signal\" : {\n\t\t\t\tregexp : /^\\d+\\.\\d+|^\\d+/,\n\t\t\t\tmethod : function(arg){\n\t\t\t\t\tvar sig = new Tone.Signal(getNumber(arg));\n\t\t\t\t\treturn sig;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"input\" : {\n\t\t\t\tregexp : /^\\$\\d/,\n\t\t\t\tmethod : function(arg, self){\n\t\t\t\t\treturn self.input[getNumber(arg.substr(1))];\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t//syntactic glue\n\t\t\"glue\" : {\n\t\t\t\"(\" : {\n\t\t\t\tregexp : /^\\(/,\n\t\t\t},\n\t\t\t\")\" : {\n\t\t\t\tregexp : /^\\)/,\n\t\t\t},\n\t\t\t\",\" : {\n\t\t\t\tregexp : /^,/,\n\t\t\t}\n\t\t},\n\t\t//functions\n\t\t\"func\" : {\n\t\t\t\"abs\" : {\n\t\t\t\tregexp : /^abs/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.Abs)\n\t\t\t},\n\t\t\t\"mod\" : {\n\t\t\t\tregexp : /^mod/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar modulus = literalNumber(args[1]);\n\t\t\t\t\tvar op = new Tone.Modulo(modulus);\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"pow\" : {\n\t\t\t\tregexp : /^pow/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar exp = literalNumber(args[1]);\n\t\t\t\t\tvar op = new Tone.Pow(exp);\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"a2g\" : {\n\t\t\t\tregexp : /^a2g/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar op = new Tone.AudioToGain();\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t//binary expressions\n\t\t\"binary\" : {\n\t\t\t\"+\" : {\n\t\t\t\tregexp : /^\\+/,\n\t\t\t\tprecedence : 1,\n\t\t\t\tmethod : applyBinary.bind(this, Tone.Add)\n\t\t\t},\n\t\t\t\"-\" : {\n\t\t\t\tregexp : /^\\-/,\n\t\t\t\tprecedence : 1,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\t//both unary and binary op\n\t\t\t\t\tif (args.length === 1){\n\t\t\t\t\t\treturn applyUnary(Tone.Negate, args, self);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn applyBinary(Tone.Subtract, args, self);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"*\" : {\n\t\t\t\tregexp : /^\\*/,\n\t\t\t\tprecedence : 0,\n\t\t\t\tmethod : applyBinary.bind(this, Tone.Multiply)\n\t\t\t}\n\t\t},\n\t\t//unary expressions\n\t\t\"unary\" : {\n\t\t\t\"-\" : {\n\t\t\t\tregexp : /^\\-/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.Negate)\n\t\t\t},\n\t\t\t\"!\" : {\n\t\t\t\tregexp : /^\\!/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.NOT)\n\t\t\t},\n\t\t},\n\t};\n\t\t\n\t/**\n\t * @param {string} expr the expression string\n\t * @return {number} the input count\n\t * @private\n\t */\n\tTone.Expr.prototype._parseInputs = function(expr){\n\t\tvar inputArray = expr.match(/\\$\\d/g);\n\t\tvar inputMax = 0;\n\t\tif (inputArray !== null){\n\t\t\tfor (var i = 0; i < inputArray.length; i++){\n\t\t\t\tvar inputNum = parseInt(inputArray[i].substr(1)) + 1;\n\t\t\t\tinputMax = Math.max(inputMax, inputNum);\n\t\t\t}\n\t\t}\n\t\treturn inputMax;\n\t};\n\n\t/**\n\t * @param {Array} args \tan array of arguments\n\t * @return {string} the results of the replacements being replaced\n\t * @private\n\t */\n\tTone.Expr.prototype._replacements = function(args){\n\t\tvar expr = args.shift();\n\t\tfor (var i = 0; i < args.length; i++){\n\t\t\texpr = expr.replace(/\\%/i, args[i]);\n\t\t}\n\t\treturn expr;\n\t};\n\n\t/**\n\t * tokenize the expression based on the Expressions object\n\t * @param {string} expr \n\t * @return {Object} returns two methods on the tokenized list, next and peek\n\t * @private\n\t */\n\tTone.Expr.prototype._tokenize = function(expr){\n\t\tvar position = -1;\n\t\tvar tokens = [];\n\n\t\twhile(expr.length > 0){\n\t\t\texpr = expr.trim();\n\t\t\tvar token = getNextToken(expr);\n\t\t\ttokens.push(token);\n\t\t\texpr = expr.substr(token.value.length);\n\t\t}\n\n\t\tfunction getNextToken(expr){\n\t\t\tfor (var type in Tone.Expr._Expressions){\n\t\t\t\tvar group = Tone.Expr._Expressions[type];\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tvar reg = op.regexp;\n\t\t\t\t\tvar match = expr.match(reg);\n\t\t\t\t\tif (match !== null){\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype : type,\n\t\t\t\t\t\t\tvalue : match[0],\n\t\t\t\t\t\t\tmethod : op.method\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.Expr: Unexpected token \"+expr);\n\t\t}\n\n\t\treturn {\n\t\t\tnext : function(){\n\t\t\t\treturn tokens[++position];\n\t\t\t},\n\t\t\tpeek : function(){\n\t\t\t\treturn tokens[position + 1];\n\t\t\t}\n\t\t};\n\t};\n\n\t/**\n\t * recursively parse the string expression into a syntax tree\n\t * \n\t * @param {string} expr \n\t * @return {Object}\n\t * @private\n\t */\n\tTone.Expr.prototype._parseTree = function(expr){\n\t\tvar lexer = this._tokenize(expr);\n\t\tvar isUndef = this.isUndef.bind(this);\n\n\t\tfunction matchSyntax(token, syn) {\n\t\t\treturn !isUndef(token) && \n\t\t\t\ttoken.type === \"glue\" &&\n\t\t\t\ttoken.value === syn;\n\t\t}\n\n\t\tfunction matchGroup(token, groupName, prec) {\n\t\t\tvar ret = false;\n\t\t\tvar group = Tone.Expr._Expressions[groupName];\n\t\t\tif (!isUndef(token)){\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tif (op.regexp.test(token.value)){\n\t\t\t\t\t\tif (!isUndef(prec)){\n\t\t\t\t\t\t\tif(op.precedence === prec){\t\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tfunction parseExpression(precedence) {\n\t\t\tif (isUndef(precedence)){\n\t\t\t\tprecedence = 5;\n\t\t\t}\n\t\t\tvar expr;\n\t\t\tif (precedence < 0){\n\t\t\t\texpr = parseUnary();\n\t\t\t} else {\n\t\t\t\texpr = parseExpression(precedence-1);\n\t\t\t}\n\t\t\tvar token = lexer.peek();\n\t\t\twhile (matchGroup(token, \"binary\", precedence)) {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\texpr = {\n\t\t\t\t\toperator: token.value,\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : [\n\t\t\t\t\t\texpr,\n\t\t\t\t\t\tparseExpression(precedence-1)\n\t\t\t\t\t]\n\t\t\t\t};\n\t\t\t\ttoken = lexer.peek();\n\t\t\t}\n\t\t\treturn expr;\n\t\t}\n\n\t\tfunction parseUnary() {\n\t\t\tvar token, expr;\n\t\t\ttoken = lexer.peek();\n\t\t\tif (matchGroup(token, \"unary\")) {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\texpr = parseUnary();\n\t\t\t\treturn {\n\t\t\t\t\toperator: token.value,\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : [expr]\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn parsePrimary();\n\t\t}\n\n\t\tfunction parsePrimary() {\n\t\t\tvar token, expr;\n\t\t\ttoken = lexer.peek();\n\t\t\tif (isUndef(token)) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Unexpected termination of expression\");\n\t\t\t}\n\t\t\tif (token.type === \"func\") {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\treturn parseFunctionCall(token);\n\t\t\t}\n\t\t\tif (token.type === \"value\") {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\treturn {\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : token.value\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (matchSyntax(token, \"(\")) {\n\t\t\t\tlexer.next();\n\t\t\t\texpr = parseExpression();\n\t\t\t\ttoken = lexer.next();\n\t\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\t\tthrow new SyntaxError(\"Expected )\");\n\t\t\t\t}\n\t\t\t\treturn expr;\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.Expr: Parse error, cannot process token \" + token.value);\n\t\t}\n\n\t\tfunction parseFunctionCall(func) {\n\t\t\tvar token, args = [];\n\t\t\ttoken = lexer.next();\n\t\t\tif (!matchSyntax(token, \"(\")) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Expected ( in a function call \\\"\" + func.value + \"\\\"\");\n\t\t\t}\n\t\t\ttoken = lexer.peek();\n\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\targs = parseArgumentList();\n\t\t\t}\n\t\t\ttoken = lexer.next();\n\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Expected ) in a function call \\\"\" + func.value + \"\\\"\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tmethod : func.method,\n\t\t\t\targs : args,\n\t\t\t\tname : name\n\t\t\t};\n\t\t}\n\n\t\tfunction parseArgumentList() {\n\t\t\tvar token, expr, args = [];\n\t\t\twhile (true) {\n\t\t\t\texpr = parseExpression();\n\t\t\t\tif (isUndef(expr)) {\n\t\t\t\t\t// TODO maybe throw exception?\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\targs.push(expr);\n\t\t\t\ttoken = lexer.peek();\n\t\t\t\tif (!matchSyntax(token, \",\")) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tlexer.next();\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\n\t\treturn parseExpression();\n\t};\n\n\t/**\n\t * recursively evaluate the expression tree\n\t * @param {Object} tree \n\t * @return {AudioNode} the resulting audio node from the expression\n\t * @private\n\t */\n\tTone.Expr.prototype._eval = function(tree){\n\t\tif (!this.isUndef(tree)){\n\t\t\tvar node = tree.method(tree.args, this);\n\t\t\tthis._nodes.push(node);\n\t\t\treturn node;\n\t\t} \n\t};\n\n\t/**\n\t * dispose all the nodes\n\t * @private\n\t */\n\tTone.Expr.prototype._disposeNodes = function(){\n\t\tfor (var i = 0; i < this._nodes.length; i++){\n\t\t\tvar node = this._nodes[i];\n\t\t\tif (this.isFunction(node.dispose)) {\n\t\t\t\tnode.dispose();\n\t\t\t} else if (this.isFunction(node.disconnect)) {\n\t\t\t\tnode.disconnect();\n\t\t\t}\n\t\t\tnode = null;\n\t\t\tthis._nodes[i] = null;\n\t\t}\n\t\tthis._nodes = null;\n\t};\n\n\t/**\n\t * clean up\n\t */\n\tTone.Expr.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._disposeNodes();\n\t};\n\n\treturn Tone.Expr;\n});","define([\"Tone/core/Tone\", \"Tone/signal/GreaterThanZero\", \"Tone/signal/Subtract\", \"Tone/signal/Signal\"], \n\tfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Output 1 if the signal is greater than the value, otherwise outputs 0.\n\t * can compare two signals or a signal and a number. \n\t * \n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number} [value=0] the value to compare to the incoming signal\n\t * @example\n\t * var gt = new Tone.GreaterThan(2);\n\t * var sig = new Tone.Signal(4).connect(gt);\n\t * //output of gt is equal 1. \n\t */\n\tTone.GreaterThan = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\t\t\n\t\t/**\n\t\t * subtract the amount from the incoming signal\n\t\t * @type {Tone.Subtract}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input[0] = new Tone.Subtract(value);\n\t\tthis.input[1] = this._param.input[1];\n\n\t\t/**\n\t\t * compare that amount to zero\n\t\t * @type {Tone.GreaterThanZero}\n\t\t * @private\n\t\t */\n\t\tthis._gtz = this.output = new Tone.GreaterThanZero();\n\n\t\t//connect\n\t\tthis._param.connect(this._gtz);\n\t};\n\n\tTone.extend(Tone.GreaterThan, Tone.Signal);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.GreaterThan} this\n\t */\n\tTone.GreaterThan.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\tthis._gtz.dispose();\n\t\tthis._gtz = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.GreaterThan;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/SignalBase\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Return the absolute value of an incoming signal. \n\t * \n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var signal = new Tone.Signal(-1);\n\t * var abs = new Tone.Abs();\n\t * signal.connect(abs);\n\t * //the output of abs is 1. \n\t */\n\tTone.Abs = function(){\n\t\t/**\n\t\t * @type {Tone.LessThan}\n\t\t * @private\n\t\t */\n\t\tthis._abs = this.input = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (val === 0){\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn Math.abs(val);\n\t\t\t}\n\t\t}, 127);\n\t};\n\n\tTone.extend(Tone.Abs, Tone.SignalBase);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.Abs} this\n\t */\n\tTone.Abs.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._abs.dispose();\n\t\tthis._abs = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Abs;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/Multiply\", \"Tone/signal/Subtract\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Signal-rate modulo operator. Only works in AudioRange [-1, 1] and for modulus\n\t * values in the NormalRange. \n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @param {NormalRange} modulus The modulus to apply.\n\t * @example\n\t * var mod = new Tone.Modulo(0.2)\n\t * var sig = new Tone.Signal(0.5).connect(mod);\n\t * //mod outputs 0.1\n\t */\n\tTone.Modulo = function(modulus){\n\n\t\tthis.createInsOuts(1, 0);\n\n\t\t/**\n\t\t * A waveshaper gets the integer multiple of \n\t\t * the input signal and the modulus.\n\t\t * @private\n\t\t * @type {Tone.WaveShaper}\n\t\t */\n\t\tthis._shaper = new Tone.WaveShaper(Math.pow(2, 16));\n\n\t\t/**\n\t\t * the integer multiple is multiplied by the modulus\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._multiply = new Tone.Multiply();\n\n\t\t/**\n\t\t * and subtracted from the input signal\n\t\t * @type {Tone.Subtract}\n\t\t * @private\n\t\t */\n\t\tthis._subtract = this.output = new Tone.Subtract();\n\n\t\t/**\n\t\t * the modulus signal\n\t\t * @type {Tone.Signal}\n\t\t * @private\n\t\t */\n\t\tthis._modSignal = new Tone.Signal(modulus);\n\n\t\t//connections\n\t\tthis.input.fan(this._shaper, this._subtract);\n\t\tthis._modSignal.connect(this._multiply, 0, 0);\n\t\tthis._shaper.connect(this._multiply, 0, 1);\n\t\tthis._multiply.connect(this._subtract, 0, 1);\n\t\tthis._setWaveShaper(modulus);\n\t};\n\n\tTone.extend(Tone.Modulo, Tone.SignalBase);\n\n\t/**\n\t * @param {number} mod the modulus to apply\n\t * @private\n\t */\n\tTone.Modulo.prototype._setWaveShaper = function(mod){\n\t\tthis._shaper.setMap(function(val){\n\t\t\tvar multiple = Math.floor((val + 0.0001) / mod);\n\t\t\treturn multiple;\n\t\t});\n\t};\n\n\t/**\n\t * The modulus value.\n\t * @memberOf Tone.Modulo#\n\t * @type {NormalRange}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Modulo.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._modSignal.value;\n\t\t},\n\t\tset : function(mod){\n\t\t\tthis._modSignal.value = mod;\n\t\t\tthis._setWaveShaper(mod);\n\t\t}\n\t});\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Modulo} this\n\t */\n\tTone.Modulo.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._shaper.dispose();\n\t\tthis._shaper = null;\n\t\tthis._multiply.dispose();\n\t\tthis._multiply = null;\n\t\tthis._subtract.dispose();\n\t\tthis._subtract = null;\n\t\tthis._modSignal.dispose();\n\t\tthis._modSignal = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Modulo;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Pow applies an exponent to the incoming signal. The incoming signal\n\t * must be AudioRange.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {Positive} exp The exponent to apply to the incoming signal, must be at least 2. \n\t * @example\n\t * var pow = new Tone.Pow(2);\n\t * var sig = new Tone.Signal(0.5).connect(pow);\n\t * //output of pow is 0.25. \n\t */\n\tTone.Pow = function(exp){\n\n\t\t/**\n\t\t * the exponent\n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._exp = this.defaultArg(exp, 1);\n\n\t\t/**\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._expScaler = this.input = this.output = new Tone.WaveShaper(this._expFunc(this._exp), 8192);\n\t};\n\n\tTone.extend(Tone.Pow, Tone.SignalBase);\n\n\t/**\n\t * The value of the exponent.\n\t * @memberOf Tone.Pow#\n\t * @type {number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Pow.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._exp;\n\t\t},\n\t\tset : function(exp){\n\t\t\tthis._exp = exp;\n\t\t\tthis._expScaler.setMap(this._expFunc(this._exp));\n\t\t}\n\t});\n\n\n\t/**\n\t * the function which maps the waveshaper\n\t * @param {number} exp\n\t * @return {function}\n\t * @private\n\t */\n\tTone.Pow.prototype._expFunc = function(exp){\n\t\treturn function(val){\n\t\t\treturn Math.pow(Math.abs(val), exp);\n\t\t};\n\t};\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Pow} this\n\t */\n\tTone.Pow.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._expScaler.dispose();\n\t\tthis._expScaler = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Pow;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1]. \n\t * See Tone.GainToAudio.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @example\n\t * var a2g = new Tone.AudioToGain();\n\t */\n\tTone.AudioToGain = function(){\n\n\t\t/**\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._norm = this.input = this.output = new Tone.WaveShaper(function(x){\n\t\t\treturn (x + 1) / 2;\n\t\t});\n\t};\n\n\tTone.extend(Tone.AudioToGain, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.AudioToGain} this\n\t */\n\tTone.AudioToGain.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._norm.dispose();\n\t\tthis._norm = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.AudioToGain;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Convert an incoming signal between 0, 1 to an equal power gain scale.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @example\n\t * var eqPowGain = new Tone.EqualPowerGain();\n\t */\n\tTone.EqualPowerGain = function(){\n\n\t\t/**\n\t\t * @type {Tone.WaveShaper}\n\t\t * @private\n\t\t */\n\t\tthis._eqPower = this.input = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (Math.abs(val) < 0.001){\n\t\t\t\t//should output 0 when input is 0\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn this.equalPowerScale(val);\n\t\t\t}\n\t\t}.bind(this), 4096);\n\t};\n\n\tTone.extend(Tone.EqualPowerGain, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.EqualPowerGain} this\n\t */\n\tTone.EqualPowerGain.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._eqPower.dispose();\n\t\tthis._eqPower = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.EqualPowerGain;\n});","define([\"Tone/core/Tone\", \"Tone/core/Timeline\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A Timeline State. Provides the methods: setStateAtTime(\"state\", time)\n\t * and getValueAtTime(time).\n\t *\n\t * @extends {Tone.Timeline}\n\t * @param {String} initial The initial state of the TimelineState. \n\t * Defaults to undefined\n\t */\n\tTone.TimelineState = function(initial){\n\n\t\tTone.Timeline.call(this);\n\n\t\t/**\n\t\t * The initial state\n\t\t * @private\n\t\t * @type {String}\n\t\t */\n\t\tthis._initial = initial;\n\t};\n\n\tTone.extend(Tone.TimelineState, Tone.Timeline);\n\n\t/**\n\t * Returns the scheduled state scheduled before or at\n\t * the given time.\n\t * @param {Number} time The time to query.\n\t * @return {String} The name of the state input in setStateAtTime.\n\t */\n\tTone.TimelineState.prototype.getValueAtTime = function(time){\n\t\tvar event = this.get(time);\n\t\tif (event !== null){\n\t\t\treturn event.state;\n\t\t} else {\n\t\t\treturn this._initial;\n\t\t}\n\t};\n\n\t/**\n\t * Returns the scheduled state scheduled before or at\n\t * the given time.\n\t * @param {String} state The name of the state to set.\n\t * @param {Number} time The time to query.\n\t */\n\tTone.TimelineState.prototype.setStateAtTime = function(state, time){\n\t\tthis.add({\n\t\t\t\"state\" : state,\n\t\t\t\"time\" : time\n\t\t});\n\t};\n\n\treturn Tone.TimelineState;\n});","import audiocontext from './audiocontext.js';\n// Master contains the master sound output.\nclass Master {\n constructor() {\n this.input = audiocontext.createGain();\n this.output = audiocontext.createGain();\n\n //put a hard limiter on the output\n this.limiter = audiocontext.createDynamicsCompressor();\n this.limiter.threshold.value = -3;\n this.limiter.ratio.value = 20;\n this.limiter.knee.value = 1;\n\n this.audiocontext = audiocontext;\n\n this.output.disconnect();\n\n // connect input to limiter\n this.input.connect(this.limiter);\n\n // connect limiter to output\n this.limiter.connect(this.output);\n\n // meter is just for global Amplitude / FFT analysis\n this.meter = audiocontext.createGain();\n this.fftMeter = audiocontext.createGain();\n this.output.connect(this.meter);\n this.output.connect(this.fftMeter);\n\n // connect output to destination\n this.output.connect(this.audiocontext.destination);\n\n // an array of all sounds in the sketch\n this.soundArray = [];\n // an array of all musical parts in the sketch\n this.parts = [];\n\n // file extensions to search for\n this.extensions = [];\n }\n}\n\n// create a single instance of the p5Sound / master output for use within this sketch\nconst p5sound = new Master();\n\n/**\n * Returns a number representing the master amplitude (volume) for sound\n * in this sketch.\n *\n * @method getMasterVolume\n * @return {Number} Master amplitude (volume) for sound in this sketch.\n * Should be between 0.0 (silence) and 1.0.\n */\np5.prototype.getMasterVolume = function () {\n return p5sound.output.gain.value;\n};\n\n/**\n *

Scale the output of all sound in this sketch

\n * Scaled between 0.0 (silence) and 1.0 (full volume).\n * 1.0 is the maximum amplitude of a digital sound, so multiplying\n * by greater than 1.0 may cause digital distortion. To\n * fade, provide a rampTime parameter. For more\n * complex fades, see the Envelope class.\n *\n * Alternately, you can pass in a signal source such as an\n * oscillator to modulate the amplitude with an audio signal.\n *\n *

How This Works: When you load the p5.sound module, it\n * creates a single instance of p5sound. All sound objects in this\n * module output to p5sound before reaching your computer's output.\n * So if you change the amplitude of p5sound, it impacts all of the\n * sound in this module.

\n *\n *

If no value is provided, returns a Web Audio API Gain Node

\n *\n * @method masterVolume\n * @param {Number|Object} volume Volume (amplitude) between 0.0\n * and 1.0 or modulating signal/oscillator\n * @param {Number} [rampTime] Fade for t seconds\n * @param {Number} [timeFromNow] Schedule this event to happen at\n * t seconds in the future\n */\np5.prototype.masterVolume = function (vol, rampTime = 0, tFromNow = 0) {\n if (typeof vol === 'number') {\n var now = p5sound.audiocontext.currentTime;\n var currentVol = p5sound.output.gain.value;\n p5sound.output.gain.cancelScheduledValues(now + tFromNow);\n p5sound.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n p5sound.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(p5sound.output.gain);\n } else {\n // return the Gain Node\n return p5sound.output.gain;\n }\n};\n\n/**\n * `p5.soundOut` is the p5.sound master output. It sends output to\n * the destination of this window's web audio context. It contains\n * Web Audio API nodes including a dyanmicsCompressor (.limiter),\n * and Gain Nodes for .input and .output.\n *\n * @property {Object} soundOut\n */\np5.prototype.soundOut = p5.soundOut = p5sound;\n\n// a silent connection to the DesinationNode\n// which will ensure that anything connected to it\n// will not be garbage collected\np5.soundOut._silentNode = p5sound.audiocontext.createGain();\np5.soundOut._silentNode.gain.value = 0;\np5.soundOut._silentNode.connect(p5sound.audiocontext.destination);\n\nexport default p5sound;\n","import p5sound from './master';\nimport processorNames from './audioWorklet/processorNames';\n/**\n * @for p5\n */\n\n/**\n * Returns a number representing the sample rate, in samples per second,\n * of all sound objects in this audio context. It is determined by the\n * sampling rate of your operating system's sound card, and it is not\n * currently possile to change.\n * It is often 44100, or twice the range of human hearing.\n *\n * @method sampleRate\n * @return {Number} samplerate samples per second\n */\nfunction sampleRate() {\n return p5sound.audiocontext.sampleRate;\n}\n\n/**\n * Returns the closest MIDI note value for\n * a given frequency.\n *\n * @method freqToMidi\n * @param {Number} frequency A freqeuncy, for example, the \"A\"\n * above Middle C is 440Hz\n * @return {Number} MIDI note value\n */\nfunction freqToMidi(f) {\n var mathlog2 = Math.log(f / 440) / Math.log(2);\n var m = Math.round(12 * mathlog2) + 69;\n return m;\n}\n\n/**\n * Returns the frequency value of a MIDI note value.\n * General MIDI treats notes as integers where middle C\n * is 60, C# is 61, D is 62 etc. Useful for generating\n * musical frequencies with oscillators.\n *\n * @method midiToFreq\n * @param {Number} midiNote The number of a MIDI note\n * @return {Number} Frequency value of the given MIDI note\n * @example\n *
\n * let midiNotes = [60, 64, 67, 72];\n * let noteIndex = 0;\n * let midiVal, freq;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startSound);\n * osc = new p5.TriOsc();\n * env = new p5.Envelope();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 10, 20);\n * if (midiVal) {\n * text('MIDI: ' + midiVal, 10, 40);\n * text('Freq: ' + freq, 10, 60);\n * }\n * }\n *\n * function startSound() {\n * // see also: userStartAudio();\n * osc.start();\n *\n * midiVal = midiNotes[noteIndex % midiNotes.length];\n * freq = midiToFreq(midiVal);\n * osc.freq(freq);\n * env.ramp(osc, 0, 1.0, 0);\n *\n * noteIndex++;\n * }\n *
\n */\nfunction midiToFreq(m) {\n return 440 * Math.pow(2, (m - 69) / 12.0);\n}\n\n// This method converts ANSI notes specified as a string \"C4\", \"Eb3\" to a frequency\nfunction noteToFreq(note) {\n if (typeof note !== 'string') {\n return note;\n }\n var wholeNotes = { A: 21, B: 23, C: 24, D: 26, E: 28, F: 29, G: 31 };\n var value = wholeNotes[note[0].toUpperCase()];\n var octave = ~~note.slice(-1);\n value += 12 * (octave - 1);\n\n switch (note[1]) {\n case '#':\n value += 1;\n break;\n case 'b':\n value -= 1;\n break;\n default:\n break;\n }\n return midiToFreq(value);\n}\n\n/**\n * List the SoundFile formats that you will include. LoadSound\n * will search your directory for these extensions, and will pick\n * a format that is compatable with the client's web browser.\n * Here is a free online file\n * converter.\n *\n * @method soundFormats\n * @param {String} [...formats] i.e. 'mp3', 'wav', 'ogg'\n * @example\n *
\n * function preload() {\n * // set the global sound formats\n * soundFormats('mp3', 'ogg');\n *\n * // load either beatbox.mp3, or .ogg, depending on browser\n * mySound = loadSound('assets/beatbox.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * text('sound loaded! tap to play', 10, 20, width - 20);\n * cnv.mousePressed(function() {\n * mySound.play();\n * });\n * }\n *
\n */\n\nfunction soundFormats() {\n // reset extensions array\n p5sound.extensions = [];\n // add extensions\n for (var i = 0; i < arguments.length; i++) {\n arguments[i] = arguments[i].toLowerCase();\n if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(arguments[i]) > -1) {\n p5sound.extensions.push(arguments[i]);\n } else {\n throw arguments[i] + ' is not a valid sound format!';\n }\n }\n}\n\nfunction disposeSound() {\n for (var i = 0; i < p5sound.soundArray.length; i++) {\n p5sound.soundArray[i].dispose();\n }\n}\n\nfunction _checkFileFormats(paths) {\n var path;\n // if path is a single string, check to see if extension is provided\n if (typeof paths === 'string') {\n path = paths;\n // see if extension is provided\n var extTest = path.split('.').pop();\n // if an extension is provided...\n if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(extTest) > -1) {\n if (!p5.prototype.isFileSupported(extTest)) {\n var pathSplit = path.split('.');\n var pathCore = pathSplit[pathSplit.length - 1];\n for (let i = 0; i < p5sound.extensions.length; i++) {\n const extension = p5sound.extensions[i];\n const supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n pathCore = '';\n if (pathSplit.length === 2) {\n pathCore += pathSplit[0];\n }\n for (let i = 1; i <= pathSplit.length - 2; i++) {\n var p = pathSplit[i];\n pathCore += '.' + p;\n }\n path = pathCore += '.';\n path = path += extension;\n break;\n }\n }\n }\n }\n // if no extension is provided...\n else {\n for (let i = 0; i < p5sound.extensions.length; i++) {\n const extension = p5sound.extensions[i];\n const supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n path = path + '.' + extension;\n break;\n }\n }\n }\n } // end 'if string'\n\n // path can either be a single string, or an array\n else if (typeof paths === 'object') {\n for (var i = 0; i < paths.length; i++) {\n var extension = paths[i].split('.').pop();\n var supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n // console.log('.'+extension + ' is ' + supported +\n // ' supported by your browser.');\n path = paths[i];\n break;\n }\n }\n }\n return path;\n}\n\n/**\n * Used by Osc and Envelope to chain signal math\n */\nfunction _mathChain(o, math, thisChain, nextChain, type) {\n // if this type of math already exists in the chain, replace it\n for (var i in o.mathOps) {\n if (o.mathOps[i] instanceof type) {\n o.mathOps[i].dispose();\n thisChain = i;\n if (thisChain < o.mathOps.length - 1) {\n nextChain = o.mathOps[i + 1];\n }\n }\n }\n o.mathOps[thisChain - 1].disconnect();\n o.mathOps[thisChain - 1].connect(math);\n math.connect(nextChain);\n o.mathOps[thisChain] = math;\n return o;\n}\n\n// helper methods to convert audio file as .wav format,\n// will use as saving .wav file and saving blob object\n// Thank you to Matt Diamond's RecorderJS (MIT License)\n// https://github.com/mattdiamond/Recorderjs\nfunction convertToWav(audioBuffer) {\n var leftChannel, rightChannel;\n leftChannel = audioBuffer.getChannelData(0);\n\n // handle mono files\n if (audioBuffer.numberOfChannels > 1) {\n rightChannel = audioBuffer.getChannelData(1);\n } else {\n rightChannel = leftChannel;\n }\n\n var interleaved = interleave(leftChannel, rightChannel);\n\n // create the buffer and view to create the .WAV file\n var buffer = new window.ArrayBuffer(44 + interleaved.length * 2);\n var view = new window.DataView(buffer);\n\n // write the WAV container,\n // check spec at: https://web.archive.org/web/20171215131933/http://tiny.systems/software/soundProgrammer/WavFormatDocs.pdf\n\n // RIFF chunk descriptor\n writeUTFBytes(view, 0, 'RIFF');\n view.setUint32(4, 36 + interleaved.length * 2, true);\n writeUTFBytes(view, 8, 'WAVE');\n // FMT sub-chunk\n writeUTFBytes(view, 12, 'fmt ');\n view.setUint32(16, 16, true);\n view.setUint16(20, 1, true);\n // stereo (2 channels)\n view.setUint16(22, 2, true);\n view.setUint32(24, p5sound.audiocontext.sampleRate, true);\n view.setUint32(28, p5sound.audiocontext.sampleRate * 4, true);\n view.setUint16(32, 4, true);\n view.setUint16(34, 16, true);\n // data sub-chunk\n writeUTFBytes(view, 36, 'data');\n view.setUint32(40, interleaved.length * 2, true);\n\n // write the PCM samples\n var lng = interleaved.length;\n var index = 44;\n var volume = 1;\n for (var i = 0; i < lng; i++) {\n view.setInt16(index, interleaved[i] * (0x7fff * volume), true);\n index += 2;\n }\n\n return view;\n}\n\n// helper methods to save waves\nfunction interleave(leftChannel, rightChannel) {\n var length = leftChannel.length + rightChannel.length;\n var result = new Float32Array(length);\n\n var inputIndex = 0;\n\n for (var index = 0; index < length; ) {\n result[index++] = leftChannel[inputIndex];\n result[index++] = rightChannel[inputIndex];\n inputIndex++;\n }\n return result;\n}\n\nfunction writeUTFBytes(view, offset, string) {\n var lng = string.length;\n for (var i = 0; i < lng; i++) {\n view.setUint8(offset + i, string.charCodeAt(i));\n }\n}\n\nfunction safeBufferSize(idealBufferSize) {\n let bufferSize = idealBufferSize;\n\n // if the AudioWorkletNode is actually a ScriptProcessorNode created via polyfill,\n // make sure that our chosen buffer size isn't smaller than the buffer size automatically\n // selected by the polyfill\n // reference: https://github.com/GoogleChromeLabs/audioworklet-polyfill/issues/13#issuecomment-425014930\n let tempAudioWorkletNode = new AudioWorkletNode(\n p5sound.audiocontext,\n processorNames.soundFileProcessor\n );\n if (tempAudioWorkletNode instanceof ScriptProcessorNode) {\n bufferSize = tempAudioWorkletNode.bufferSize;\n }\n tempAudioWorkletNode.disconnect();\n tempAudioWorkletNode = null;\n\n return bufferSize;\n}\n\n/**\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\n * to download the file to their device.\n * For uploading audio to a server, use\n * `p5.SoundFile.saveBlob`.\n *\n * @for p5\n * @method saveSound\n * @param {p5.SoundFile} soundFile p5.SoundFile that you wish to save\n * @param {String} fileName name of the resulting .wav file.\n */\n// add to p5.prototype as this is used by the p5 `save()` method.\nfunction saveSound(soundFile, fileName) {\n const dataView = convertToWav(soundFile.buffer);\n p5.prototype.writeFile([dataView], fileName, 'wav');\n}\n\nexport {\n sampleRate,\n freqToMidi,\n midiToFreq,\n noteToFreq,\n soundFormats,\n disposeSound,\n _checkFileFormats,\n _mathChain,\n convertToWav,\n interleave,\n writeUTFBytes,\n safeBufferSize,\n saveSound,\n};\n","/*\n Helper function to generate an error\n with a custom stack trace that points to the sketch\n and removes other parts of the stack trace.\n\n @private\n @class customError\n @constructor\n @param {String} name custom error name\n @param {String} errorTrace custom error trace\n @param {String} failedPath path to the file that failed to load\n @property {String} name custom error name\n @property {String} message custom error message\n @property {String} stack trace the error back to a line in the user's sketch.\n Note: this edits out stack trace within p5.js and p5.sound.\n @property {String} originalStack unedited, original stack trace\n @property {String} failedPath path to the file that failed to load\n @return {Error} returns a custom Error object\n */\nvar CustomError = function (name, errorTrace, failedPath) {\n var err = new Error();\n var tempStack, splitStack;\n\n err.name = name;\n err.originalStack = err.stack + errorTrace;\n tempStack = err.stack + errorTrace;\n err.failedPath = failedPath;\n\n // only print the part of the stack trace that refers to the user code:\n splitStack = tempStack.split('\\n').filter(function (ln) {\n return !ln.match(/(p5.|native code|globalInit)/g);\n });\n err.stack = splitStack.join('\\n');\n\n return err; // TODO: is this really a constructor?\n};\nexport default CustomError;\n","import p5sound from '../master.js';\nconst moduleSources = [\n require('raw-loader!./recorderProcessor').default,\n require('raw-loader!./soundFileProcessor').default,\n require('raw-loader!./amplitudeProcessor').default,\n];\nconst ac = p5sound.audiocontext;\nlet initializedAudioWorklets = false;\n\nfunction loadAudioWorkletModules() {\n return Promise.all(\n moduleSources.map(function (moduleSrc) {\n const blob = new Blob([moduleSrc], { type: 'application/javascript' });\n const objectURL = URL.createObjectURL(blob);\n return ac.audioWorklet.addModule(objectURL);\n })\n );\n}\n\np5.prototype.registerMethod('init', function () {\n if (initializedAudioWorklets) return;\n // ensure that a preload function exists so that p5 will wait for preloads to finish\n if (!this.preload && !window.preload) {\n this.preload = function () {};\n }\n\n // use p5's preload system to load necessary AudioWorklet modules before setup()\n this._incrementPreload();\n const onWorkletModulesLoad = function () {\n initializedAudioWorklets = true;\n this._decrementPreload();\n }.bind(this);\n loadAudioWorkletModules().then(onWorkletModulesLoad);\n});\n","import p5sound from './master';\nvar ac = p5sound.audiocontext;\nvar panner;\n// Stereo panner\n// if there is a stereo panner node use it\nif (typeof ac.createStereoPanner !== 'undefined') {\n class Panner {\n constructor(input, output) {\n this.stereoPanner = this.input = ac.createStereoPanner();\n input.connect(this.stereoPanner);\n this.stereoPanner.connect(output);\n }\n\n pan(val, tFromNow) {\n var time = tFromNow || 0;\n var t = ac.currentTime + time;\n\n this.stereoPanner.pan.linearRampToValueAtTime(val, t);\n }\n\n //not implemented because stereopanner\n //node does not require this and will automatically\n //convert single channel or multichannel to stereo.\n //tested with single and stereo, not with (>2) multichannel\n inputChannels() {}\n\n connect(obj) {\n this.stereoPanner.connect(obj);\n }\n\n disconnect() {\n if (this.stereoPanner) {\n this.stereoPanner.disconnect();\n }\n }\n }\n\n panner = Panner;\n} else {\n // if there is no createStereoPanner object\n // such as in safari 7.1.7 at the time of writing this\n // use this method to create the effect\n class Panner {\n constructor(input, output, numInputChannels) {\n this.input = ac.createGain();\n input.connect(this.input);\n\n this.left = ac.createGain();\n this.right = ac.createGain();\n this.left.channelInterpretation = 'discrete';\n this.right.channelInterpretation = 'discrete';\n\n // if input is stereo\n if (numInputChannels > 1) {\n this.splitter = ac.createChannelSplitter(2);\n this.input.connect(this.splitter);\n\n this.splitter.connect(this.left, 1);\n this.splitter.connect(this.right, 0);\n } else {\n this.input.connect(this.left);\n this.input.connect(this.right);\n }\n\n this.output = ac.createChannelMerger(2);\n this.left.connect(this.output, 0, 1);\n this.right.connect(this.output, 0, 0);\n this.output.connect(output);\n }\n\n // -1 is left, +1 is right\n pan(val, tFromNow) {\n var time = tFromNow || 0;\n var t = ac.currentTime + time;\n var v = (val + 1) / 2;\n var rightVal = Math.cos((v * Math.PI) / 2);\n var leftVal = Math.sin((v * Math.PI) / 2);\n this.left.gain.linearRampToValueAtTime(leftVal, t);\n this.right.gain.linearRampToValueAtTime(rightVal, t);\n }\n\n inputChannels(numChannels) {\n if (numChannels === 1) {\n this.input.disconnect();\n this.input.connect(this.left);\n this.input.connect(this.right);\n } else if (numChannels === 2) {\n if (typeof this.splitter === 'undefined') {\n this.splitter = ac.createChannelSplitter(2);\n }\n this.input.disconnect();\n this.input.connect(this.splitter);\n this.splitter.connect(this.left, 1);\n this.splitter.connect(this.right, 0);\n }\n }\n\n connect(obj) {\n this.output.connect(obj);\n }\n\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n }\n panner = Panner;\n}\n\nexport default panner;\n","import CustomError from './errorHandler';\nimport p5sound from './master';\nimport { midiToFreq, convertToWav, safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\nimport Panner from './panner';\n\nconst ac = p5sound.audiocontext;\n\nvar _createCounterBuffer = function (buffer) {\n const len = buffer.length;\n const audioBuf = ac.createBuffer(1, buffer.length, ac.sampleRate);\n const arrayBuffer = audioBuf.getChannelData(0);\n for (var index = 0; index < len; index++) {\n arrayBuffer[index] = index;\n }\n return audioBuf;\n};\n\n/*** SCHEDULE EVENTS ***/\n\n// Cue inspired by JavaScript setTimeout, and the\n// Tone.js Transport Timeline Event, MIT License Yotam Mann 2015 tonejs.org\nclass Cue {\n constructor(callback, time, id, val) {\n this.callback = callback;\n this.time = time;\n this.id = id;\n this.val = val;\n }\n}\n\n// event handler to remove references to the bufferSourceNode when it is done playing\nfunction _clearOnEnd(e) {\n const thisBufferSourceNode = e.target;\n const soundFile = this;\n\n // delete this.bufferSourceNode from the sources array when it is done playing:\n thisBufferSourceNode._playing = false;\n thisBufferSourceNode.removeEventListener('ended', soundFile._clearOnEnd);\n\n // call the onended callback\n soundFile._onended(soundFile);\n\n // delete bufferSourceNode(s) in soundFile.bufferSourceNodes\n // iterate in reverse order because the index changes by splice\n soundFile.bufferSourceNodes\n .map((_, i) => i)\n .reverse()\n .forEach(function (i) {\n const n = soundFile.bufferSourceNodes[i];\n\n if (n._playing === false) {\n soundFile.bufferSourceNodes.splice(i, 1);\n }\n });\n\n if (soundFile.bufferSourceNodes.length === 0) {\n soundFile._playing = false;\n }\n}\n\n/**\n *

SoundFile object with a path to a file.

\n *\n *

The p5.SoundFile may not be available immediately because\n * it loads the file information asynchronously.

\n *\n *

To do something with the sound as soon as it loads\n * pass the name of a function as the second parameter.

\n *\n *

Only one file path is required. However, audio file formats\n * (i.e. mp3, ogg, wav and m4a/aac) are not supported by all\n * web browsers. If you want to ensure compatability, instead of a single\n * file path, you may include an Array of filepaths, and the browser will\n * choose a format that works.

\n *\n * @class p5.SoundFile\n * @constructor\n * @param {String|Array} path path to a sound file (String). Optionally,\n * you may include multiple file formats in\n * an array. Alternately, accepts an object\n * from the HTML5 File API, or a p5.File.\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if file fails to\n * load. This function will receive an error or\n * XMLHttpRequest object with information\n * about what went wrong.\n * @param {Function} [whileLoadingCallback] Name of a function to call while file\n * is loading. That function will\n * receive progress of the request to\n * load the sound file\n * (between 0 and 1) as its first\n * parameter. This progress\n * does not account for the additional\n * time needed to decode the audio data.\n *\n * @example\n *
\n * let mySound;\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * mySound = loadSound('assets/doorbell');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap here to play', 10, 20);\n * }\n *\n * function canvasPressed() {\n * // playing a sound file on a user gesture\n * // is equivalent to `userStartAudio()`\n * mySound.play();\n * }\n *
\n */\nclass SoundFile {\n constructor(paths, onload, onerror, whileLoading) {\n if (typeof paths !== 'undefined') {\n if (typeof paths === 'string' || typeof paths[0] === 'string') {\n var path = p5.prototype._checkFileFormats(paths);\n this.url = path;\n } else if (typeof paths === 'object') {\n if (\n !(window.File && window.FileReader && window.FileList && window.Blob)\n ) {\n // The File API isn't supported in this browser\n throw 'Unable to load file because the File API is not supported';\n }\n }\n\n // if type is a p5.File...get the actual file\n if (paths.file) {\n paths = paths.file;\n }\n\n this.file = paths;\n }\n\n // private _onended callback, set by the method: onended(callback)\n this._onended = function () {};\n\n this._looping = false;\n this._playing = false;\n this._paused = false;\n this._pauseTime = 0;\n\n // cues for scheduling events with addCue() removeCue()\n this._cues = [];\n this._cueIDCounter = 0;\n\n // position of the most recently played sample\n this._lastPos = 0;\n this._counterNode = null;\n this._workletNode = null;\n\n // array of sources so that they can all be stopped!\n this.bufferSourceNodes = [];\n\n // current source\n this.bufferSourceNode = null;\n\n this.buffer = null;\n this.playbackRate = 1;\n\n this.input = p5sound.audiocontext.createGain();\n this.output = p5sound.audiocontext.createGain();\n\n this.reversed = false;\n\n // start and end of playback / loop\n this.startTime = 0;\n this.endTime = null;\n this.pauseTime = 0;\n\n // \"restart\" would stop playback before retriggering\n this.mode = 'sustain';\n\n // time that playback was started, in millis\n this.startMillis = null;\n\n // stereo panning\n this.panPosition = 0.0;\n this.panner = new Panner(this.output, p5sound.input, 2);\n\n // it is possible to instantiate a soundfile with no path\n if (this.url || this.file) {\n this.load(onload, onerror);\n }\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n\n if (typeof whileLoading === 'function') {\n this._whileLoading = whileLoading;\n } else {\n this._whileLoading = function () {};\n }\n\n this._clearOnEnd = _clearOnEnd.bind(this);\n\n // same as setVolume, to match Processing Sound\n this.amp = this.setVolume;\n\n // these are the same thing\n this.fade = this.setVolume;\n }\n\n /**\n * This is a helper function that the p5.SoundFile calls to load\n * itself. Accepts a callback (the name of another function)\n * as an optional parameter.\n *\n * @private\n * @for p5.SoundFile\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if there is an error\n */\n load(callback, errorCallback) {\n var self = this;\n var errorTrace = new Error().stack;\n\n if (this.url !== undefined && this.url !== '') {\n var request = new XMLHttpRequest();\n request.addEventListener(\n 'progress',\n function (evt) {\n self._updateProgress(evt);\n },\n false\n );\n request.open('GET', this.url, true);\n request.responseType = 'arraybuffer';\n\n request.onload = function () {\n if (request.status === 200) {\n // on sucess loading file:\n if (!self.panner) return;\n ac.decodeAudioData(\n request.response,\n // success decoding buffer:\n function (buff) {\n if (!self.panner) return;\n self.buffer = buff;\n self.panner.inputChannels(buff.numberOfChannels);\n if (callback) {\n callback(self);\n }\n },\n // error decoding buffer. \"e\" is undefined in Chrome 11/22/2015\n function () {\n if (!self.panner) return;\n var err = new CustomError(\n 'decodeAudioData',\n errorTrace,\n self.url\n );\n var msg = 'AudioContext error at decodeAudioData for ' + self.url;\n if (errorCallback) {\n err.msg = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n );\n }\n // if request status != 200, it failed\n else {\n if (!self.panner) return;\n var err = new CustomError('loadSound', errorTrace, self.url);\n var msg =\n 'Unable to load ' +\n self.url +\n '. The request status was: ' +\n request.status +\n ' (' +\n request.statusText +\n ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n };\n\n // if there is another error, aside from 404...\n request.onerror = function () {\n var err = new CustomError('loadSound', errorTrace, self.url);\n var msg =\n 'There was no response from the server at ' +\n self.url +\n '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n };\n\n request.send();\n } else if (this.file !== undefined) {\n var reader = new FileReader();\n reader.onload = function () {\n if (!self.panner) return;\n ac.decodeAudioData(reader.result, function (buff) {\n if (!self.panner) return;\n self.buffer = buff;\n self.panner.inputChannels(buff.numberOfChannels);\n if (callback) {\n callback(self);\n }\n });\n };\n reader.onerror = function (e) {\n if (!self.panner) return;\n if (onerror) {\n onerror(e);\n }\n };\n reader.readAsArrayBuffer(this.file);\n }\n }\n\n // TO DO: use this method to create a loading bar that shows progress during file upload/decode.\n _updateProgress(evt) {\n if (evt.lengthComputable) {\n var percentComplete = (evt.loaded / evt.total) * 0.99;\n this._whileLoading(percentComplete, evt);\n // ...\n } else {\n // Unable to compute progress information since the total size is unknown\n this._whileLoading('size unknown');\n }\n }\n\n /**\n * Returns true if the sound file finished loading successfully.\n *\n * @method isLoaded\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isLoaded() {\n if (this.buffer) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Play the p5.SoundFile\n *\n * @method play\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule playback to start (in seconds from now).\n * @param {Number} [rate] (optional) playback rate\n * @param {Number} [amp] (optional) amplitude (volume)\n * of playback\n * @param {Number} [cueStart] (optional) cue start time in seconds\n * @param {Number} [duration] (optional) duration of playback in seconds\n */\n play(startTime, rate, amp, _cueStart, duration) {\n if (!this.output) {\n console.warn('SoundFile.play() called after dispose');\n return;\n }\n\n var now = p5sound.audiocontext.currentTime;\n var cueStart, cueEnd;\n var time = startTime || 0;\n if (time < 0) {\n time = 0;\n }\n\n time = time + now;\n\n if (typeof rate !== 'undefined') {\n this.rate(rate);\n }\n\n if (typeof amp !== 'undefined') {\n this.setVolume(amp);\n }\n\n // TO DO: if already playing, create array of buffers for easy stop()\n if (this.buffer) {\n // reset the pause time (if it was paused)\n this._pauseTime = 0;\n\n // handle restart playmode\n if (this.mode === 'restart' && this.buffer && this.bufferSourceNode) {\n this.bufferSourceNode.stop(time);\n this._counterNode.stop(time);\n }\n\n //dont create another instance if already playing\n if (this.mode === 'untildone' && this.isPlaying()) {\n return;\n }\n // make a new source and counter. They are automatically assigned playbackRate and buffer\n this.bufferSourceNode = this._initSourceNode();\n\n // garbage collect counterNode and create a new one\n delete this._counterNode;\n this._counterNode = this._initCounterNode();\n\n if (_cueStart) {\n if (_cueStart >= 0 && _cueStart < this.buffer.duration) {\n // this.startTime = cueStart;\n cueStart = _cueStart;\n } else {\n throw 'start time out of range';\n }\n } else {\n cueStart = 0;\n }\n\n if (duration) {\n // if duration is greater than buffer.duration, just play entire file anyway rather than throw an error\n duration =\n duration <= this.buffer.duration - cueStart\n ? duration\n : this.buffer.duration;\n }\n\n // if it was paused, play at the pause position\n if (this._paused) {\n this.bufferSourceNode.start(time, this.pauseTime, duration);\n this._counterNode.start(time, this.pauseTime, duration);\n } else {\n this.bufferSourceNode.start(time, cueStart, duration);\n this._counterNode.start(time, cueStart, duration);\n }\n\n this._playing = true;\n this._paused = false;\n\n // add source to sources array, which is used in stopAll()\n this.bufferSourceNodes.push(this.bufferSourceNode);\n this.bufferSourceNode._arrayIndex = this.bufferSourceNodes.length - 1;\n\n this.bufferSourceNode.addEventListener('ended', this._clearOnEnd);\n }\n // If soundFile hasn't loaded the buffer yet, throw an error\n else {\n throw 'not ready to play file, buffer has yet to load. Try preload()';\n }\n\n // if looping, will restart at original time\n this.bufferSourceNode.loop = this._looping;\n this._counterNode.loop = this._looping;\n\n if (this._looping === true) {\n cueEnd = duration ? duration : cueStart - 0.000000000000001;\n this.bufferSourceNode.loopStart = cueStart;\n this.bufferSourceNode.loopEnd = cueEnd;\n this._counterNode.loopStart = cueStart;\n this._counterNode.loopEnd = cueEnd;\n }\n }\n\n /**\n * p5.SoundFile has two play modes: restart and\n * sustain. Play Mode determines what happens to a\n * p5.SoundFile if it is triggered while in the middle of playback.\n * In sustain mode, playback will continue simultaneous to the\n * new playback. In restart mode, play() will stop playback\n * and start over. With untilDone, a sound will play only if it's\n * not already playing. Sustain is the default mode.\n *\n * @method playMode\n * @for p5.SoundFile\n * @param {String} str 'restart' or 'sustain' or 'untilDone'\n * @example\n *
\n * let mySound;\n * function preload(){\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * noFill();\n * rect(0, height/2, width - 1, height/2 - 1);\n * rect(0, 0, width - 1, height/2);\n * textAlign(CENTER, CENTER);\n * fill(20);\n * text('restart', width/2, 1 * height/4);\n * text('sustain', width/2, 3 * height/4);\n * }\n * function canvasPressed() {\n * if (mouseX < height/2) {\n * mySound.playMode('restart');\n * } else {\n * mySound.playMode('sustain');\n * }\n * mySound.play();\n * }\n *\n *
\n */\n playMode(str) {\n var s = str.toLowerCase();\n\n // if restart, stop all other sounds from playing\n if (s === 'restart' && this.buffer && this.bufferSourceNode) {\n for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {\n var now = p5sound.audiocontext.currentTime;\n this.bufferSourceNodes[i].stop(now);\n }\n }\n\n // set play mode to effect future playback\n if (s === 'restart' || s === 'sustain' || s === 'untildone') {\n this.mode = s;\n } else {\n throw 'Invalid play mode. Must be either \"restart\" or \"sustain\"';\n }\n }\n\n /**\n * Pauses a file that is currently playing. If the file is not\n * playing, then nothing will happen.\n *\n * After pausing, .play() will resume from the paused\n * position.\n * If p5.SoundFile had been set to loop before it was paused,\n * it will continue to loop after it is unpaused with .play().\n *\n * @method pause\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * seconds from now\n * @example\n *
\n * let soundFile;\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play, release to pause', 10, 20, width - 20);\n * }\n * function canvasPressed() {\n * soundFile.loop();\n * background(0, 200, 50);\n * }\n * function mouseReleased() {\n * soundFile.pause();\n * background(220);\n * }\n * \n *
\n */\n pause(startTime) {\n var now = p5sound.audiocontext.currentTime;\n var time = startTime || 0;\n var pTime = time + now;\n\n if (this.isPlaying() && this.buffer && this.bufferSourceNode) {\n this._paused = true;\n this._playing = false;\n\n this.pauseTime = this.currentTime();\n this.bufferSourceNode.stop(pTime);\n this._counterNode.stop(pTime);\n\n this._pauseTime = this.currentTime();\n // TO DO: make sure play() still starts from orig start position\n } else {\n this._pauseTime = 0;\n }\n }\n\n /**\n * Loop the p5.SoundFile. Accepts optional parameters to set the\n * playback rate, playback volume, loopStart, loopEnd.\n *\n * @method loop\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * seconds from now\n * @param {Number} [rate] (optional) playback rate\n * @param {Number} [amp] (optional) playback volume\n * @param {Number} [cueLoopStart] (optional) startTime in seconds\n * @param {Number} [duration] (optional) loop duration in seconds\n * @example\n *
\n * let soundFile;\n * let loopStart = 0.5;\n * let loopDuration = 0.2;\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play, release to pause', 10, 20, width - 20);\n * }\n * function canvasPressed() {\n * soundFile.loop();\n * background(0, 200, 50);\n * }\n * function mouseReleased() {\n * soundFile.pause();\n * background(220);\n * }\n * \n *
\n */\n loop(startTime, rate, amp, loopStart, duration) {\n this._looping = true;\n this.play(startTime, rate, amp, loopStart, duration);\n }\n\n /**\n * Set a p5.SoundFile's looping flag to true or false. If the sound\n * is currently playing, this change will take effect when it\n * reaches the end of the current playback.\n *\n * @method setLoop\n * @for p5.SoundFile\n * @param {Boolean} Boolean set looping to true or false\n */\n setLoop(bool) {\n if (bool === true) {\n this._looping = true;\n } else if (bool === false) {\n this._looping = false;\n } else {\n throw 'Error: setLoop accepts either true or false';\n }\n if (this.bufferSourceNode) {\n this.bufferSourceNode.loop = this._looping;\n this._counterNode.loop = this._looping;\n }\n }\n\n /**\n * Returns 'true' if a p5.SoundFile is currently looping and playing, 'false' if not.\n *\n * @method isLooping\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isLooping() {\n if (!this.bufferSourceNode) {\n return false;\n }\n if (this._looping === true && this.isPlaying() === true) {\n return true;\n }\n return false;\n }\n\n /**\n * Returns true if a p5.SoundFile is playing, false if not (i.e.\n * paused or stopped).\n *\n * @method isPlaying\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isPlaying() {\n return this._playing;\n }\n\n /**\n * Returns true if a p5.SoundFile is paused, false if not (i.e.\n * playing or stopped).\n *\n * @method isPaused\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isPaused() {\n return this._paused;\n }\n\n /**\n * Stop soundfile playback.\n *\n * @method stop\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * in seconds from now\n */\n stop(timeFromNow) {\n var time = timeFromNow || 0;\n\n if (this.mode === 'sustain' || this.mode === 'untildone') {\n this.stopAll(time);\n this._playing = false;\n this.pauseTime = 0;\n this._paused = false;\n } else if (this.buffer && this.bufferSourceNode) {\n var now = p5sound.audiocontext.currentTime;\n var t = time || 0;\n this.pauseTime = 0;\n this.bufferSourceNode.stop(now + t);\n this._counterNode.stop(now + t);\n this._playing = false;\n this._paused = false;\n }\n }\n\n /**\n * Stop playback on all of this soundfile's sources.\n * @private\n */\n stopAll(_time) {\n var now = p5sound.audiocontext.currentTime;\n var time = _time || 0;\n if (this.buffer && this.bufferSourceNode) {\n for (var i in this.bufferSourceNodes) {\n const bufferSourceNode = this.bufferSourceNodes[i];\n if (bufferSourceNode) {\n try {\n bufferSourceNode.stop(now + time);\n } catch (e) {\n // this was throwing errors only on Safari\n }\n }\n }\n this._counterNode.stop(now + time);\n }\n }\n\n getVolume() {\n return this.output.gain.value;\n }\n\n /**\n * Set the stereo panning of a p5.sound object to\n * a floating point number between -1.0 (left) and 1.0 (right).\n * Default is 0.0 (center).\n *\n * @method pan\n * @for p5.SoundFile\n * @param {Number} [panValue] Set the stereo panner\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @example\n *
\n * let ballX = 0;\n * let soundFile;\n *\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/beatbox.mp3');\n * }\n *\n * function draw() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * ballX = constrain(mouseX, 0, width);\n * ellipse(ballX, height/2, 20, 20);\n * }\n *\n * function canvasPressed(){\n * // map the ball's x location to a panning degree\n * // between -1.0 (left) and 1.0 (right)\n * let panning = map(ballX, 0., width,-1.0, 1.0);\n * soundFile.pan(panning);\n * soundFile.play();\n * }\n *
\n */\n pan(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n }\n\n /**\n * Returns the current stereo pan position (-1.0 to 1.0)\n *\n * @method getPan\n * @for p5.SoundFile\n * @return {Number} Returns the stereo pan setting of the Oscillator\n * as a number between -1.0 (left) and 1.0 (right).\n * 0.0 is center and default.\n */\n getPan() {\n return this.panPosition;\n }\n\n /**\n * Set the playback rate of a sound file. Will change the speed and the pitch.\n * Values less than zero will reverse the audio buffer.\n *\n * @method rate\n * @for p5.SoundFile\n * @param {Number} [playbackRate] Set the playback rate. 1.0 is normal,\n * .5 is half-speed, 2.0 is twice as fast.\n * Values less than zero play backwards.\n * @example\n *
\n * let mySound;\n *\n * function preload() {\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * }\n * function canvasPressed() {\n * mySound.loop();\n * }\n * function mouseReleased() {\n * mySound.pause();\n * }\n * function draw() {\n * background(220);\n *\n * // Set the rate to a range between 0.1 and 4\n * // Changing the rate also alters the pitch\n * let playbackRate = map(mouseY, 0.1, height, 2, 0);\n * playbackRate = constrain(playbackRate, 0.01, 4);\n * mySound.rate(playbackRate);\n *\n * line(0, mouseY, width, mouseY);\n * text('rate: ' + round(playbackRate * 100) + '%', 10, 20);\n * }\n *\n * \n *
\n *\n */\n rate(playbackRate) {\n var reverse = false;\n if (typeof playbackRate === 'undefined') {\n return this.playbackRate;\n }\n\n this.playbackRate = playbackRate;\n\n if (playbackRate === 0) {\n playbackRate = 0.0000000000001;\n } else if (playbackRate < 0 && !this.reversed) {\n playbackRate = Math.abs(playbackRate);\n reverse = true;\n } else if (playbackRate > 0 && this.reversed) {\n reverse = true;\n }\n\n if (this.bufferSourceNode) {\n var now = p5sound.audiocontext.currentTime;\n this.bufferSourceNode.playbackRate.cancelScheduledValues(now);\n this.bufferSourceNode.playbackRate.linearRampToValueAtTime(\n Math.abs(playbackRate),\n now\n );\n this._counterNode.playbackRate.cancelScheduledValues(now);\n this._counterNode.playbackRate.linearRampToValueAtTime(\n Math.abs(playbackRate),\n now\n );\n }\n\n if (reverse) {\n this.reverseBuffer();\n }\n return this.playbackRate;\n }\n\n // TO DO: document this\n setPitch(num) {\n var newPlaybackRate = midiToFreq(num) / midiToFreq(60);\n this.rate(newPlaybackRate);\n }\n\n getPlaybackRate() {\n return this.playbackRate;\n }\n\n /**\n * Multiply the output volume (amplitude) of a sound file\n * between 0.0 (silence) and 1.0 (full volume).\n * 1.0 is the maximum amplitude of a digital sound, so multiplying\n * by greater than 1.0 may cause digital distortion. To\n * fade, provide a rampTime parameter. For more\n * complex fades, see the Envelope class.\n *\n * Alternately, you can pass in a signal source such as an\n * oscillator to modulate the amplitude with an audio signal.\n *\n * @method setVolume\n * @for p5.SoundFile\n * @param {Number|Object} volume Volume (amplitude) between 0.0\n * and 1.0 or modulating signal/oscillator\n * @param {Number} [rampTime] Fade for t seconds\n * @param {Number} [timeFromNow] Schedule this event to happen at\n * t seconds in the future\n */\n setVolume(vol, _rampTime, _tFromNow) {\n if (typeof vol === 'number') {\n var rampTime = _rampTime || 0;\n var tFromNow = _tFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now + tFromNow);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(this.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n }\n /**\n * Returns the duration of a sound file in seconds.\n *\n * @method duration\n * @for p5.SoundFile\n * @return {Number} The duration of the soundFile in seconds.\n */\n duration() {\n // Return Duration\n if (this.buffer) {\n return this.buffer.duration;\n } else {\n return 0;\n }\n }\n\n /**\n * Return the current position of the p5.SoundFile playhead, in seconds.\n * Time is relative to the normal buffer direction, so if `reverseBuffer`\n * has been called, currentTime will count backwards.\n *\n * @method currentTime\n * @for p5.SoundFile\n * @return {Number} currentTime of the soundFile in seconds.\n */\n currentTime() {\n return this.reversed\n ? Math.abs(this._lastPos - this.buffer.length) / ac.sampleRate\n : this._lastPos / ac.sampleRate;\n }\n\n /**\n * Move the playhead of a soundfile that is currently playing to a\n * new position and a new duration, in seconds.\n * If none are given, will reset the file to play entire duration\n * from start to finish. To set the position of a soundfile that is\n * not currently playing, use the `play` or `loop` methods.\n *\n * @method jump\n * @for p5.SoundFile\n * @param {Number} cueTime cueTime of the soundFile in seconds.\n * @param {Number} duration duration in seconds.\n */\n jump(cueTime, duration) {\n if (cueTime < 0 || cueTime > this.buffer.duration) {\n throw 'jump time out of range';\n }\n if (duration > this.buffer.duration - cueTime) {\n throw 'end time out of range';\n }\n\n var cTime = cueTime || 0;\n var dur = duration || undefined;\n if (this.isPlaying()) {\n this.stop(0);\n this.play(0, this.playbackRate, this.output.gain.value, cTime, dur);\n }\n }\n\n /**\n * Return the number of channels in a sound file.\n * For example, Mono = 1, Stereo = 2.\n *\n * @method channels\n * @for p5.SoundFile\n * @return {Number} [channels]\n */\n channels() {\n return this.buffer.numberOfChannels;\n }\n\n /**\n * Return the sample rate of the sound file.\n *\n * @method sampleRate\n * @for p5.SoundFile\n * @return {Number} [sampleRate]\n */\n sampleRate() {\n return this.buffer.sampleRate;\n }\n\n /**\n * Return the number of samples in a sound file.\n * Equal to sampleRate * duration.\n *\n * @method frames\n * @for p5.SoundFile\n * @return {Number} [sampleCount]\n */\n frames() {\n return this.buffer.length;\n }\n\n /**\n * Returns an array of amplitude peaks in a p5.SoundFile that can be\n * used to draw a static waveform. Scans through the p5.SoundFile's\n * audio buffer to find the greatest amplitudes. Accepts one\n * parameter, 'length', which determines size of the array.\n * Larger arrays result in more precise waveform visualizations.\n *\n * Inspired by Wavesurfer.js.\n *\n * @method getPeaks\n * @for p5.SoundFile\n * @params {Number} [length] length is the size of the returned array.\n * Larger length results in more precision.\n * Defaults to 5*width of the browser window.\n * @returns {Float32Array} Array of peaks.\n */\n getPeaks(length) {\n if (this.buffer) {\n // set length to window's width if no length is provided\n if (!length) {\n length = window.width * 5;\n }\n if (this.buffer) {\n var buffer = this.buffer;\n var sampleSize = buffer.length / length;\n var sampleStep = ~~(sampleSize / 10) || 1;\n var channels = buffer.numberOfChannels;\n var peaks = new Float32Array(Math.round(length));\n\n for (var c = 0; c < channels; c++) {\n var chan = buffer.getChannelData(c);\n for (var i = 0; i < length; i++) {\n var start = ~~(i * sampleSize);\n var end = ~~(start + sampleSize);\n var max = 0;\n for (var j = start; j < end; j += sampleStep) {\n var value = chan[j];\n if (value > max) {\n max = value;\n // faster than Math.abs\n } else if (-value > max) {\n max = value;\n }\n }\n if (c === 0 || Math.abs(max) > peaks[i]) {\n peaks[i] = max;\n }\n }\n }\n\n return peaks;\n }\n } else {\n throw 'Cannot load peaks yet, buffer is not loaded';\n }\n }\n\n /**\n * Reverses the p5.SoundFile's buffer source.\n * Playback must be handled separately (see example).\n *\n * @method reverseBuffer\n * @for p5.SoundFile\n * @example\n *
\n * let drum;\n * function preload() {\n * drum = loadSound('assets/drum.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function canvasPressed() {\n * drum.stop();\n * drum.reverseBuffer();\n * drum.play();\n * }\n * \n *
\n */\n reverseBuffer() {\n if (this.buffer) {\n var currentPos = this._lastPos / ac.sampleRate;\n var curVol = this.getVolume();\n this.setVolume(0, 0.001);\n\n const numChannels = this.buffer.numberOfChannels;\n for (var i = 0; i < numChannels; i++) {\n this.buffer.getChannelData(i).reverse();\n }\n // set reversed flag\n this.reversed = !this.reversed;\n\n if (this.isPlaying() && currentPos) {\n this.jump(this.duration() - currentPos);\n }\n this.setVolume(curVol, 0.001);\n } else {\n throw 'SoundFile is not done loading';\n }\n }\n\n /**\n * Schedule an event to be called when the soundfile\n * reaches the end of a buffer. If the soundfile is\n * playing through once, this will be called when it\n * ends. If it is looping, it will be called when\n * stop is called.\n *\n * @method onended\n * @for p5.SoundFile\n * @param {Function} callback function to call when the\n * soundfile has ended.\n */\n onended(callback) {\n this._onended = callback;\n return this;\n }\n\n add() {\n // TO DO\n }\n\n dispose() {\n var now = p5sound.audiocontext.currentTime;\n\n // remove reference to soundfile\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.stop(now);\n if (this.buffer && this.bufferSourceNode) {\n for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {\n if (this.bufferSourceNodes[i] !== null) {\n this.bufferSourceNodes[i].disconnect();\n try {\n this.bufferSourceNodes[i].stop(now);\n } catch (e) {\n console.warn('no buffer source node to dispose');\n }\n this.bufferSourceNodes[i] = null;\n }\n }\n if (this.isPlaying()) {\n try {\n this._counterNode.stop(now);\n } catch (e) {\n console.log(e);\n }\n this._counterNode = null;\n }\n }\n if (this.output) {\n this.output.disconnect();\n this.output = null;\n }\n if (this.panner) {\n this.panner.disconnect();\n this.panner = null;\n }\n }\n\n /**\n * Connects the output of a p5sound object to input of another\n * p5.sound object. For example, you may connect a p5.SoundFile to an\n * FFT or an Effect. If no parameter is given, it will connect to\n * the master output. Most p5sound objects connect to the master\n * output when they are created.\n *\n * @method connect\n * @for p5.SoundFile\n * @param {Object} [object] Audio object that accepts an input\n */\n connect(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n } else {\n if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n } else {\n this.panner.connect(unit);\n }\n }\n }\n\n /**\n * Disconnects the output of this p5sound object.\n *\n * @method disconnect\n * @for p5.SoundFile\n */\n disconnect() {\n if (this.panner) {\n this.panner.disconnect();\n }\n }\n\n /**\n */\n getLevel() {\n console.warn(\n 'p5.SoundFile.getLevel has been removed from the library. Use p5.Amplitude instead'\n );\n }\n\n /**\n * Reset the source for this SoundFile to a\n * new path (URL).\n *\n * @method setPath\n * @for p5.SoundFile\n * @param {String} path path to audio file\n * @param {Function} callback Callback\n */\n setPath(p, callback) {\n var path = p5.prototype._checkFileFormats(p);\n this.url = path;\n this.load(callback);\n }\n\n /**\n * Replace the current Audio Buffer with a new Buffer.\n *\n * @method setBuffer\n * @for p5.SoundFile\n * @param {Array} buf Array of Float32 Array(s). 2 Float32 Arrays\n * will create a stereo source. 1 will create\n * a mono source.\n */\n setBuffer(buf) {\n var numChannels = buf.length;\n var size = buf[0].length;\n var newBuffer = ac.createBuffer(numChannels, size, ac.sampleRate);\n\n if (!(buf[0] instanceof Float32Array)) {\n buf[0] = new Float32Array(buf[0]);\n }\n\n for (var channelNum = 0; channelNum < numChannels; channelNum++) {\n var channel = newBuffer.getChannelData(channelNum);\n channel.set(buf[channelNum]);\n }\n\n this.buffer = newBuffer;\n\n // set numbers of channels on input to the panner\n this.panner.inputChannels(numChannels);\n }\n\n // initialize counterNode, set its initial buffer and playbackRate\n _initCounterNode() {\n var self = this;\n var now = ac.currentTime;\n var cNode = ac.createBufferSource();\n\n const workletBufferSize = safeBufferSize(256);\n\n // dispose of worklet node if it already exists\n if (self._workletNode) {\n self._workletNode.disconnect();\n delete self._workletNode;\n }\n self._workletNode = new AudioWorkletNode(\n ac,\n processorNames.soundFileProcessor,\n {\n processorOptions: { bufferSize: workletBufferSize },\n }\n );\n self._workletNode.port.onmessage = (event) => {\n if (event.data.name === 'position') {\n // event.data.position should only be 0 when paused\n if (event.data.position === 0) {\n return;\n }\n this._lastPos = event.data.position;\n\n // do any callbacks that have been scheduled\n this._onTimeUpdate(self._lastPos);\n }\n };\n\n // create counter buffer of the same length as self.buffer\n cNode.buffer = _createCounterBuffer(self.buffer);\n\n cNode.playbackRate.setValueAtTime(self.playbackRate, now);\n\n cNode.connect(self._workletNode);\n self._workletNode.connect(p5.soundOut._silentNode);\n\n return cNode;\n }\n\n // initialize sourceNode, set its initial buffer and playbackRate\n _initSourceNode() {\n var bufferSourceNode = ac.createBufferSource();\n bufferSourceNode.buffer = this.buffer;\n bufferSourceNode.playbackRate.value = this.playbackRate;\n bufferSourceNode.connect(this.output);\n return bufferSourceNode;\n }\n\n processPeaks(callback, _initThreshold, _minThreshold, _minPeaks) {\n console.warn('processPeaks is deprecated');\n }\n\n /**\n * Schedule events to trigger every time a MediaElement\n * (audio/video) reaches a playback cue point.\n *\n * Accepts a callback function, a time (in seconds) at which to trigger\n * the callback, and an optional parameter for the callback.\n *\n * Time will be passed as the first parameter to the callback function,\n * and param will be the second parameter.\n *\n *\n * @method addCue\n * @for p5.SoundFile\n * @param {Number} time Time in seconds, relative to this media\n * element's playback. For example, to trigger\n * an event every time playback reaches two\n * seconds, pass in the number 2. This will be\n * passed as the first parameter to\n * the callback function.\n * @param {Function} callback Name of a function that will be\n * called at the given time. The callback will\n * receive time and (optionally) param as its\n * two parameters.\n * @param {Object} [value] An object to be passed as the\n * second parameter to the\n * callback function.\n * @return {Number} id ID of this cue,\n * useful for removeCue(id)\n * @example\n *
\n * let mySound;\n * function preload() {\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play', 10, 20);\n *\n * // schedule calls to changeText\n * mySound.addCue(0, changeText, \"hello\" );\n * mySound.addCue(0.5, changeText, \"hello,\" );\n * mySound.addCue(1, changeText, \"hello, p5!\");\n * mySound.addCue(1.5, changeText, \"hello, p5!!\");\n * mySound.addCue(2, changeText, \"hello, p5!!!!!\");\n * }\n *\n * function changeText(val) {\n * background(220);\n * text(val, 10, 20);\n * }\n *\n * function canvasPressed() {\n * mySound.play();\n * }\n *
\n */\n addCue(time, callback, val) {\n var id = this._cueIDCounter++;\n\n var cue = new Cue(callback, time, id, val);\n this._cues.push(cue);\n\n // if (!this.elt.ontimeupdate) {\n // this.elt.ontimeupdate = this._onTimeUpdate.bind(this);\n // }\n\n return id;\n }\n\n /**\n * Remove a callback based on its ID. The ID is returned by the\n * addCue method.\n *\n * @method removeCue\n * @for p5.SoundFile\n * @param {Number} id ID of the cue, as returned by addCue\n */\n removeCue(id) {\n var cueLength = this._cues.length;\n for (var i = 0; i < cueLength; i++) {\n var cue = this._cues[i];\n if (cue.id === id) {\n this._cues.splice(i, 1);\n break;\n }\n }\n\n if (this._cues.length === 0) {\n // TO DO: remove callback\n // this.elt.ontimeupdate = null\n }\n }\n\n /**\n * Remove all of the callbacks that had originally been scheduled\n * via the addCue method.\n *\n * @method clearCues\n */\n clearCues() {\n this._cues = [];\n // this.elt.ontimeupdate = null;\n }\n\n // private method that checks for cues to be fired if events\n // have been scheduled using addCue(callback, time).\n _onTimeUpdate(position) {\n var playbackTime = position / this.buffer.sampleRate;\n var cueLength = this._cues.length;\n\n for (var i = 0; i < cueLength; i++) {\n var cue = this._cues[i];\n var callbackTime = cue.time;\n var val = cue.val;\n var leftLimit = this._prevUpdateTime || 0;\n var rightLimit = playbackTime;\n if (leftLimit <= callbackTime && callbackTime <= rightLimit) {\n // pass the scheduled callbackTime as parameter to the callback\n cue.callback(val);\n }\n }\n\n this._prevUpdateTime = playbackTime;\n }\n\n /**\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\n * to download the file to their device. To upload a file to a server, see\n * getBlob\n *\n * @method save\n * @for p5.SoundFile\n * @param {String} [fileName] name of the resulting .wav file.\n * @example\n *
\n * let mySound;\n * function preload() {\n * mySound = loadSound('assets/doorbell.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to download', 10, 20);\n * }\n *\n * function canvasPressed() {\n * mySound.save('my cool filename');\n * }\n *
\n */\n save(fileName) {\n p5.prototype.saveSound(this, fileName, 'wav');\n }\n\n /**\n * This method is useful for sending a SoundFile to a server. It returns the\n * .wav-encoded audio data as a \"Blob\".\n * A Blob is a file-like data object that can be uploaded to a server\n * with an http request. We'll\n * use the `httpDo` options object to send a POST request with some\n * specific options: we encode the request as `multipart/form-data`,\n * and attach the blob as one of the form values using `FormData`.\n *\n *\n * @method getBlob\n * @for p5.SoundFile\n * @returns {Blob} A file-like data object\n * @example\n *
\n * function preload() {\n * mySound = loadSound('assets/doorbell.mp3');\n * }\n *\n * function setup() {\n * noCanvas();\n * let soundBlob = mySound.getBlob();\n *\n * // Now we can send the blob to a server...\n * let serverUrl = 'https://jsonplaceholder.typicode.com/posts';\n * let httpRequestOptions = {\n * method: 'POST',\n * body: new FormData().append('soundBlob', soundBlob),\n * headers: new Headers({\n * 'Content-Type': 'multipart/form-data'\n * })\n * };\n * httpDo(serverUrl, httpRequestOptions);\n *\n * // We can also create an `ObjectURL` pointing to the Blob\n * let blobUrl = URL.createObjectURL(soundBlob);\n *\n * // The `
\n */\n getBlob() {\n const dataView = convertToWav(this.buffer);\n return new Blob([dataView], { type: 'audio/wav' });\n }\n}\n\n/**\n * loadSound() returns a new p5.SoundFile from a specified\n * path. If called during preload(), the p5.SoundFile will be ready\n * to play in time for setup() and draw(). If called outside of\n * preload, the p5.SoundFile will not be ready immediately, so\n * loadSound accepts a callback as the second parameter. Using a\n * \n * local server is recommended when loading external files.\n *\n * @method loadSound\n * @for p5\n * @param {String|Array} path Path to the sound file, or an array with\n * paths to soundfiles in multiple formats\n * i.e. ['sound.ogg', 'sound.mp3'].\n * Alternately, accepts an object: either\n * from the HTML5 File API, or a p5.File.\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if there is\n * an error loading the file.\n * @param {Function} [whileLoading] Name of a function to call while file is loading.\n * This function will receive the percentage loaded\n * so far, from 0.0 to 1.0.\n * @return {SoundFile} Returns a p5.SoundFile\n * @example\n *
\n * let mySound;\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * mySound = loadSound('assets/doorbell');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap here to play', 10, 20);\n * }\n *\n * function canvasPressed() {\n * // playing a sound file on a user gesture\n * // is equivalent to `userStartAudio()`\n * mySound.play();\n * }\n *
\n */\nfunction loadSound(path, callback, onerror, whileLoading) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n window.alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n\n var self = this;\n var s = new SoundFile(\n path,\n function () {\n if (typeof callback === 'function') {\n callback.apply(self, arguments);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n },\n onerror,\n whileLoading\n );\n\n return s;\n}\n\nexport default SoundFile;\nexport { loadSound };\n","import p5sound from './master';\nimport { safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\n\n/**\n * Amplitude measures volume between 0.0 and 1.0.\n * Listens to all p5sound by default, or use setInput()\n * to listen to a specific sound source. Accepts an optional\n * smoothing value, which defaults to 0.\n *\n * @class p5.Amplitude\n * @constructor\n * @param {Number} [smoothing] between 0.0 and .999 to smooth\n * amplitude readings (defaults to 0)\n * @example\n *
\n * let sound, amplitude;\n *\n * function preload(){\n * sound = loadSound('assets/beat.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100,100);\n * cnv.mouseClicked(toggleSound);\n * amplitude = new p5.Amplitude();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 20, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function togglePlay() {\n * if (sound.isPlaying() ){\n * sound.pause();\n * } else {\n * sound.loop();\n *\t\tamplitude = new p5.Amplitude();\n *\t\tamplitude.setInput(sound);\n * }\n * }\n *\n *
\n */\nclass Amplitude {\n constructor(smoothing) {\n // Set to 2048 for now. In future iterations, this should be inherited or parsed from p5sound's default\n this.bufferSize = safeBufferSize(2048);\n\n // set audio context\n this.audiocontext = p5sound.audiocontext;\n this._workletNode = new AudioWorkletNode(\n this.audiocontext,\n processorNames.amplitudeProcessor,\n {\n outputChannelCount: [1],\n\n parameterData: { smoothing: smoothing || 0 },\n processorOptions: {\n normalize: false,\n smoothing: smoothing || 0,\n numInputChannels: 2,\n bufferSize: this.bufferSize,\n },\n }\n );\n\n this._workletNode.port.onmessage = function (event) {\n if (event.data.name === 'amplitude') {\n this.volume = event.data.volume;\n this.volNorm = event.data.volNorm;\n this.stereoVol = event.data.stereoVol;\n this.stereoVolNorm = event.data.stereoVolNorm;\n }\n }.bind(this);\n\n // for connections\n this.input = this._workletNode;\n\n this.output = this.audiocontext.createGain();\n\n // the variables to return\n this.volume = 0;\n this.volNorm = 0;\n this.stereoVol = [0, 0];\n this.stereoVolNorm = [0, 0];\n\n this.normalize = false;\n\n this._workletNode.connect(this.output);\n this.output.gain.value = 0;\n\n // this may only be necessary because of a Chrome bug\n this.output.connect(this.audiocontext.destination);\n\n // connect to p5sound master output by default, unless set by input()\n p5sound.meter.connect(this._workletNode);\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connects to the p5sound instance (master output) by default.\n * Optionally, you can pass in a specific source (i.e. a soundfile).\n *\n * @method setInput\n * @for p5.Amplitude\n * @param {soundObject|undefined} [snd] set the sound source\n * (optional, defaults to\n * master output)\n * @param {Number|undefined} [smoothing] a range between 0.0 and 1.0\n * to smooth amplitude readings\n * @example\n *
\n * function preload(){\n * sound1 = loadSound('assets/beat.mp3');\n * sound2 = loadSound('assets/drum.mp3');\n * }\n * function setup(){\n * cnv = createCanvas(100, 100);\n * cnv.mouseClicked(toggleSound);\n *\n * amplitude = new p5.Amplitude();\n * amplitude.setInput(sound2);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 20, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function toggleSound(){\n * if (sound1.isPlaying() && sound2.isPlaying()) {\n * sound1.stop();\n * sound2.stop();\n * } else {\n * sound1.play();\n * sound2.play();\n * }\n * }\n *
\n */\n setInput(source, smoothing) {\n p5sound.meter.disconnect();\n\n if (smoothing) {\n this._workletNode.parameters.get('smoothing').value = smoothing;\n }\n\n // connect to the master out of p5s instance if no snd is provided\n if (source == null) {\n console.log(\n 'Amplitude input source is not ready! Connecting to master output instead'\n );\n p5sound.meter.connect(this._workletNode);\n }\n\n // connect to the sound if it is available\n else if (source) {\n source.connect(this._workletNode);\n this._workletNode.disconnect();\n this._workletNode.connect(this.output);\n }\n\n // otherwise, connect to the master out of p5s instance (default)\n else {\n p5sound.meter.connect(this._workletNode);\n }\n }\n\n connect(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n } else {\n this.output.connect(unit);\n }\n } else {\n this.output.connect(this.panner.connect(p5sound.input));\n }\n }\n\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Returns a single Amplitude reading at the moment it is called.\n * For continuous readings, run in the draw loop.\n *\n * @method getLevel\n * @for p5.Amplitude\n * @param {Number} [channel] Optionally return only channel 0 (left) or 1 (right)\n * @return {Number} Amplitude as a number between 0.0 and 1.0\n * @example\n *
\n * function preload(){\n * sound = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mouseClicked(toggleSound);\n * amplitude = new p5.Amplitude();\n * }\n *\n * function draw() {\n * background(220, 150);\n * textAlign(CENTER);\n * text('tap to play', width/2, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function toggleSound(){\n * if (sound.isPlaying()) {\n * sound.stop();\n * } else {\n * sound.play();\n * }\n * }\n *
\n */\n getLevel(channel) {\n if (typeof channel !== 'undefined') {\n if (this.normalize) {\n return this.stereoVolNorm[channel];\n } else {\n return this.stereoVol[channel];\n }\n } else if (this.normalize) {\n return this.volNorm;\n } else {\n return this.volume;\n }\n }\n\n /**\n * Determines whether the results of Amplitude.process() will be\n * Normalized. To normalize, Amplitude finds the difference the\n * loudest reading it has processed and the maximum amplitude of\n * 1.0. Amplitude adds this difference to all values to produce\n * results that will reliably map between 0.0 and 1.0. However,\n * if a louder moment occurs, the amount that Normalize adds to\n * all the values will change. Accepts an optional boolean parameter\n * (true or false). Normalizing is off by default.\n *\n * @method toggleNormalize\n * @for p5.Amplitude\n * @param {boolean} [boolean] set normalize to true (1) or false (0)\n */\n toggleNormalize(bool) {\n if (typeof bool === 'boolean') {\n this.normalize = bool;\n } else {\n this.normalize = !this.normalize;\n }\n this._workletNode.port.postMessage({\n name: 'toggleNormalize',\n normalize: this.normalize,\n });\n }\n /**\n * Smooth Amplitude analysis by averaging with the last analysis\n * frame. Off by default.\n *\n * @method smooth\n * @for p5.Amplitude\n * @param {Number} set smoothing from 0.0 <= 1\n */\n smooth(s) {\n if (s >= 0 && s < 1) {\n this._workletNode.port.postMessage({ name: 'smoothing', smoothing: s });\n } else {\n console.log('Error: smoothing must be between 0 and 1');\n }\n }\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n\n this._workletNode.disconnect();\n delete this._workletNode;\n }\n}\n\nexport default Amplitude;\n","import p5sound from './master';\n\n/**\n *

FFT (Fast Fourier Transform) is an analysis algorithm that\n * isolates individual\n * \n * audio frequencies within a waveform.

\n *\n *

Once instantiated, a p5.FFT object can return an array based on\n * two types of analyses:
• FFT.waveform() computes\n * amplitude values along the time domain. The array indices correspond\n * to samples across a brief moment in time. Each value represents\n * amplitude of the waveform at that sample of time.
\n * • FFT.analyze() computes amplitude values along the\n * frequency domain. The array indices correspond to frequencies (i.e.\n * pitches), from the lowest to the highest that humans can hear. Each\n * value represents amplitude at that slice of the frequency spectrum.\n * Use with getEnergy() to measure amplitude at specific\n * frequencies, or within a range of frequencies.

\n *\n *

FFT analyzes a very short snapshot of sound called a sample\n * buffer. It returns an array of amplitude measurements, referred\n * to as bins. The array is 1024 bins long by default.\n * You can change the bin array length, but it must be a power of 2\n * between 16 and 1024 in order for the FFT algorithm to function\n * correctly. The actual size of the FFT buffer is twice the\n * number of bins, so given a standard sample rate, the buffer is\n * 2048/44100 seconds long.

\n *\n *\n * @class p5.FFT\n * @constructor\n * @param {Number} [smoothing] Smooth results of Freq Spectrum.\n * 0.0 < smoothing < 1.0.\n * Defaults to 0.8.\n * @param {Number} [bins] Length of resulting array.\n * Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @example\n *
\n * function preload(){\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup(){\n * let cnv = createCanvas(100,100);\n * cnv.mouseClicked(togglePlay);\n * fft = new p5.FFT();\n * sound.amp(0.2);\n * }\n *\n * function draw(){\n * background(220);\n *\n * let spectrum = fft.analyze();\n * noStroke();\n * fill(255, 0, 255);\n * for (let i = 0; i< spectrum.length; i++){\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width / spectrum.length, h )\n * }\n *\n * let waveform = fft.waveform();\n * noFill();\n * beginShape();\n * stroke(20);\n * for (let i = 0; i < waveform.length; i++){\n * let x = map(i, 0, waveform.length, 0, width);\n * let y = map( waveform[i], -1, 1, 0, height);\n * vertex(x,y);\n * }\n * endShape();\n *\n * text('tap to play', 20, 20);\n * }\n *\n * function togglePlay() {\n * if (sound.isPlaying()) {\n * sound.pause();\n * } else {\n * sound.loop();\n * }\n * }\n *
\n */\nclass FFT {\n constructor(smoothing, bins) {\n this.input = this.analyser = p5sound.audiocontext.createAnalyser();\n\n Object.defineProperties(this, {\n bins: {\n get: function () {\n return this.analyser.fftSize / 2;\n },\n set: function (b) {\n this.analyser.fftSize = b * 2;\n },\n configurable: true,\n enumerable: true,\n },\n smoothing: {\n get: function () {\n return this.analyser.smoothingTimeConstant;\n },\n set: function (s) {\n this.analyser.smoothingTimeConstant = s;\n },\n configurable: true,\n enumerable: true,\n },\n });\n\n // set default smoothing and bins\n this.smooth(smoothing);\n this.bins = bins || 1024;\n\n // default connections to p5sound fftMeter\n p5sound.fftMeter.connect(this.analyser);\n\n this.freqDomain = new Uint8Array(this.analyser.frequencyBinCount);\n this.timeDomain = new Uint8Array(this.analyser.frequencyBinCount);\n\n // predefined frequency ranges, these will be tweakable\n this.bass = [20, 140];\n this.lowMid = [140, 400];\n this.mid = [400, 2600];\n this.highMid = [2600, 5200];\n this.treble = [5200, 14000];\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Set the input source for the FFT analysis. If no source is\n * provided, FFT will analyze all sound in the sketch.\n *\n * @method setInput\n * @for p5.FFT\n * @param {Object} [source] p5.sound object (or web audio API source node)\n */\n setInput(source) {\n if (!source) {\n p5sound.fftMeter.connect(this.analyser);\n } else {\n if (source.output) {\n source.output.connect(this.analyser);\n } else if (source.connect) {\n source.connect(this.analyser);\n }\n p5sound.fftMeter.disconnect();\n }\n }\n\n /**\n * Returns an array of amplitude values (between -1.0 and +1.0) that represent\n * a snapshot of amplitude readings in a single buffer. Length will be\n * equal to bins (defaults to 1024). Can be used to draw the waveform\n * of a sound.\n *\n * @method waveform\n * @for p5.FFT\n * @param {Number} [bins] Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @param {String} [precision] If any value is provided, will return results\n * in a Float32 Array which is more precise\n * than a regular array.\n * @return {Array} Array Array of amplitude values (-1 to 1)\n * over time. Array length = bins.\n *\n */\n waveform() {\n var bins, mode;\n var normalArray = new Array();\n\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'number') {\n bins = arguments[i];\n this.analyser.fftSize = bins * 2;\n }\n if (typeof arguments[i] === 'string') {\n mode = arguments[i];\n }\n }\n\n // getFloatFrequencyData doesnt work in Safari as of 5/2015\n if (mode && !p5.prototype._isSafari()) {\n timeToFloat(this, this.timeDomain);\n this.analyser.getFloatTimeDomainData(this.timeDomain);\n return this.timeDomain;\n } else {\n timeToInt(this, this.timeDomain);\n this.analyser.getByteTimeDomainData(this.timeDomain);\n for (var j = 0; j < this.timeDomain.length; j++) {\n var scaled = p5.prototype.map(this.timeDomain[j], 0, 255, -1, 1);\n normalArray.push(scaled);\n }\n return normalArray;\n }\n }\n\n /**\n * Returns an array of amplitude values (between 0 and 255)\n * across the frequency spectrum. Length is equal to FFT bins\n * (1024 by default). The array indices correspond to frequencies\n * (i.e. pitches), from the lowest to the highest that humans can\n * hear. Each value represents amplitude at that slice of the\n * frequency spectrum. Must be called prior to using\n * getEnergy().\n *\n * @method analyze\n * @for p5.FFT\n * @param {Number} [bins] Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @param {Number} [scale] If \"dB,\" returns decibel\n * float measurements between\n * -140 and 0 (max).\n * Otherwise returns integers from 0-255.\n * @return {Array} spectrum Array of energy (amplitude/volume)\n * values across the frequency spectrum.\n * Lowest energy (silence) = 0, highest\n * possible is 255.\n * @example\n *
\n * let osc, fft;\n *\n * function setup(){\n * let cnv = createCanvas(100,100);\n * cnv.mousePressed(startSound);\n * osc = new p5.Oscillator();\n * osc.amp(0);\n * fft = new p5.FFT();\n * }\n *\n * function draw(){\n * background(220);\n *\n * let freq = map(mouseX, 0, windowWidth, 20, 10000);\n * freq = constrain(freq, 1, 20000);\n * osc.freq(freq);\n *\n * let spectrum = fft.analyze();\n * noStroke();\n * fill(255, 0, 255);\n * for (let i = 0; i< spectrum.length; i++){\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width / spectrum.length, h );\n * }\n *\n * stroke(255);\n * if (!osc.started) {\n * text('tap here and drag to change frequency', 10, 20, width - 20);\n * } else {\n * text(round(freq)+'Hz', 10, 20);\n * }\n * }\n *\n * function startSound() {\n * osc.start();\n * osc.amp(0.5, 0.2);\n * }\n *\n * function mouseReleased() {\n * osc.amp(0, 0.2);\n * }\n *
\n *\n *\n */\n analyze() {\n var mode;\n\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'number') {\n this.bins = arguments[i];\n this.analyser.fftSize = this.bins * 2;\n }\n if (typeof arguments[i] === 'string') {\n mode = arguments[i];\n }\n }\n\n if (mode && mode.toLowerCase() === 'db') {\n freqToFloat(this);\n this.analyser.getFloatFrequencyData(this.freqDomain);\n return this.freqDomain;\n } else {\n freqToInt(this, this.freqDomain);\n this.analyser.getByteFrequencyData(this.freqDomain);\n var normalArray = Array.apply([], this.freqDomain);\n\n return normalArray;\n }\n }\n\n /**\n * Returns the amount of energy (volume) at a specific\n * \n * frequency, or the average amount of energy between two\n * frequencies. Accepts Number(s) corresponding\n * to frequency (in Hz), or a \"string\" corresponding to predefined\n * frequency ranges (\"bass\", \"lowMid\", \"mid\", \"highMid\", \"treble\").\n * Returns a range between 0 (no energy/volume at that frequency) and\n * 255 (maximum energy).\n * NOTE: analyze() must be called prior to getEnergy(). analyze()\n * tells the FFT to analyze frequency data, and getEnergy() uses\n * the results to determine the value at a specific frequency or\n * range of frequencies.

\n *\n * @method getEnergy\n * @for p5.FFT\n * @param {Number|String} frequency1 Will return a value representing\n * energy at this frequency. Alternately,\n * the strings \"bass\", \"lowMid\" \"mid\",\n * \"highMid\", and \"treble\" will return\n * predefined frequency ranges.\n * @param {Number} [frequency2] If a second frequency is given,\n * will return average amount of\n * energy that exists between the\n * two frequencies.\n * @return {Number} Energy Energy (volume/amplitude) from\n * 0 and 255.\n *\n */\n getEnergy(frequency1, frequency2) {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n\n if (frequency1 === 'bass') {\n frequency1 = this.bass[0];\n frequency2 = this.bass[1];\n } else if (frequency1 === 'lowMid') {\n frequency1 = this.lowMid[0];\n frequency2 = this.lowMid[1];\n } else if (frequency1 === 'mid') {\n frequency1 = this.mid[0];\n frequency2 = this.mid[1];\n } else if (frequency1 === 'highMid') {\n frequency1 = this.highMid[0];\n frequency2 = this.highMid[1];\n } else if (frequency1 === 'treble') {\n frequency1 = this.treble[0];\n frequency2 = this.treble[1];\n }\n\n if (typeof frequency1 !== 'number') {\n throw 'invalid input for getEnergy()';\n } else if (!frequency2) {\n // if only one parameter:\n var index = Math.round((frequency1 / nyquist) * this.freqDomain.length);\n return this.freqDomain[index];\n } else if (frequency1 && frequency2) {\n // if two parameters:\n // if second is higher than first\n if (frequency1 > frequency2) {\n var swap = frequency2;\n frequency2 = frequency1;\n frequency1 = swap;\n }\n var lowIndex = Math.round(\n (frequency1 / nyquist) * this.freqDomain.length\n );\n var highIndex = Math.round(\n (frequency2 / nyquist) * this.freqDomain.length\n );\n\n var total = 0;\n var numFrequencies = 0;\n // add up all of the values for the frequencies\n for (var i = lowIndex; i <= highIndex; i++) {\n total += this.freqDomain[i];\n numFrequencies += 1;\n }\n // divide by total number of frequencies\n var toReturn = total / numFrequencies;\n return toReturn;\n } else {\n throw 'invalid input for getEnergy()';\n }\n }\n\n // compatability with v.012, changed to getEnergy in v.0121. Will be deprecated...\n getFreq(freq1, freq2) {\n console.log('getFreq() is deprecated. Please use getEnergy() instead.');\n var x = this.getEnergy(freq1, freq2);\n return x;\n }\n\n /**\n * Returns the\n * \n * spectral centroid of the input signal.\n * NOTE: analyze() must be called prior to getCentroid(). Analyze()\n * tells the FFT to analyze frequency data, and getCentroid() uses\n * the results determine the spectral centroid.

\n *\n * @method getCentroid\n * @for p5.FFT\n * @return {Number} Spectral Centroid Frequency of the spectral centroid in Hz.\n *\n *\n * @example\n *
\n * function setup(){\n * cnv = createCanvas(100,100);\n * cnv.mousePressed(userStartAudio);\n * sound = new p5.AudioIn();\n * sound.start();\n * fft = new p5.FFT();\n * sound.connect(fft);\n *}\n *\n *function draw() {\n * if (getAudioContext().state !== 'running') {\n * background(220);\n * text('tap here and enable mic to begin', 10, 20, width - 20);\n * return;\n * }\n * let centroidplot = 0.0;\n * let spectralCentroid = 0;\n *\n * background(0);\n * stroke(0,255,0);\n * let spectrum = fft.analyze();\n * fill(0,255,0); // spectrum is green\n *\n * //draw the spectrum\n * for (let i = 0; i < spectrum.length; i++){\n * let x = map(log(i), 0, log(spectrum.length), 0, width);\n * let h = map(spectrum[i], 0, 255, 0, height);\n * let rectangle_width = (log(i+1)-log(i))*(width/log(spectrum.length));\n * rect(x, height, rectangle_width, -h )\n * }\n * let nyquist = 22050;\n *\n * // get the centroid\n * spectralCentroid = fft.getCentroid();\n *\n * // the mean_freq_index calculation is for the display.\n * let mean_freq_index = spectralCentroid/(nyquist/spectrum.length);\n *\n * centroidplot = map(log(mean_freq_index), 0, log(spectrum.length), 0, width);\n *\n * stroke(255,0,0); // the line showing where the centroid is will be red\n *\n * rect(centroidplot, 0, width / spectrum.length, height)\n * noStroke();\n * fill(255,255,255); // text is white\n * text('centroid: ', 10, 20);\n * text(round(spectralCentroid)+' Hz', 10, 40);\n *}\n *
\n */\n getCentroid() {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n var cumulative_sum = 0;\n var centroid_normalization = 0;\n\n for (var i = 0; i < this.freqDomain.length; i++) {\n cumulative_sum += i * this.freqDomain[i];\n centroid_normalization += this.freqDomain[i];\n }\n\n var mean_freq_index = 0;\n\n if (centroid_normalization !== 0) {\n mean_freq_index = cumulative_sum / centroid_normalization;\n }\n\n var spec_centroid_freq =\n mean_freq_index * (nyquist / this.freqDomain.length);\n return spec_centroid_freq;\n }\n\n /**\n * Smooth FFT analysis by averaging with the last analysis frame.\n *\n * @method smooth\n * @param {Number} smoothing 0.0 < smoothing < 1.0.\n * Defaults to 0.8.\n */\n smooth(s) {\n if (typeof s !== 'undefined') {\n this.smoothing = s;\n }\n return this.smoothing;\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.analyser) {\n this.analyser.disconnect();\n delete this.analyser;\n }\n }\n\n /**\n * Returns an array of average amplitude values for a given number\n * of frequency bands split equally. N defaults to 16.\n * NOTE: analyze() must be called prior to linAverages(). Analyze()\n * tells the FFT to analyze frequency data, and linAverages() uses\n * the results to group them into a smaller set of averages.

\n *\n * @method linAverages\n * @for p5.FFT\n * @param {Number} N Number of returned frequency groups\n * @return {Array} linearAverages Array of average amplitude values for each group\n */\n\n linAverages(_N) {\n var N = _N || 16; // This prevents undefined, null or 0 values of N\n\n var spectrum = this.freqDomain;\n var spectrumLength = spectrum.length;\n var spectrumStep = Math.floor(spectrumLength / N);\n\n var linearAverages = new Array(N);\n // Keep a second index for the current average group and place the values accordingly\n // with only one loop in the spectrum data\n var groupIndex = 0;\n\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\n linearAverages[groupIndex] =\n linearAverages[groupIndex] !== undefined\n ? (linearAverages[groupIndex] + spectrum[specIndex]) / 2\n : spectrum[specIndex];\n\n // Increase the group index when the last element of the group is processed\n if (specIndex % spectrumStep === spectrumStep - 1) {\n groupIndex++;\n }\n }\n\n return linearAverages;\n }\n\n /**\n * Returns an array of average amplitude values of the spectrum, for a given\n * set of \n * Octave Bands\n * NOTE: analyze() must be called prior to logAverages(). Analyze()\n * tells the FFT to analyze frequency data, and logAverages() uses\n * the results to group them into a smaller set of averages.

\n *\n * @method logAverages\n * @for p5.FFT\n * @param {Array} octaveBands Array of Octave Bands objects for grouping\n * @return {Array} logAverages Array of average amplitude values for each group\n */\n logAverages(octaveBands) {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n var spectrum = this.freqDomain;\n var spectrumLength = spectrum.length;\n\n var logAverages = new Array(octaveBands.length);\n // Keep a second index for the current average group and place the values accordingly\n // With only one loop in the spectrum data\n var octaveIndex = 0;\n\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\n var specIndexFrequency = Math.round(\n (specIndex * nyquist) / this.freqDomain.length\n );\n\n // Increase the group index if the current frequency exceeds the limits of the band\n if (specIndexFrequency > octaveBands[octaveIndex].hi) {\n octaveIndex++;\n }\n\n logAverages[octaveIndex] =\n logAverages[octaveIndex] !== undefined\n ? (logAverages[octaveIndex] + spectrum[specIndex]) / 2\n : spectrum[specIndex];\n }\n\n return logAverages;\n }\n\n /**\n * Calculates and Returns the 1/N\n * Octave Bands\n * N defaults to 3 and minimum central frequency to 15.625Hz.\n * (1/3 Octave Bands ~= 31 Frequency Bands)\n * Setting fCtr0 to a central value of a higher octave will ignore the lower bands\n * and produce less frequency groups.\n *\n * @method getOctaveBands\n * @for p5.FFT\n * @param {Number} N Specifies the 1/N type of generated octave bands\n * @param {Number} fCtr0 Minimum central frequency for the lowest band\n * @return {Array} octaveBands Array of octave band objects with their bounds\n */\n getOctaveBands(_N, _fCtr0) {\n var N = _N || 3; // Default to 1/3 Octave Bands\n var fCtr0 = _fCtr0 || 15.625; // Minimum central frequency, defaults to 15.625Hz\n\n var octaveBands = [];\n var lastFrequencyBand = {\n lo: fCtr0 / Math.pow(2, 1 / (2 * N)),\n ctr: fCtr0,\n hi: fCtr0 * Math.pow(2, 1 / (2 * N)),\n };\n octaveBands.push(lastFrequencyBand);\n\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n while (lastFrequencyBand.hi < nyquist) {\n var newFrequencyBand = {};\n newFrequencyBand.lo = lastFrequencyBand.hi;\n newFrequencyBand.ctr = lastFrequencyBand.ctr * Math.pow(2, 1 / N);\n newFrequencyBand.hi = newFrequencyBand.ctr * Math.pow(2, 1 / (2 * N));\n\n octaveBands.push(newFrequencyBand);\n lastFrequencyBand = newFrequencyBand;\n }\n\n return octaveBands;\n }\n}\n\n// helper methods to convert type from float (dB) to int (0-255)\nfunction freqToFloat(fft) {\n if (fft.freqDomain instanceof Float32Array === false) {\n fft.freqDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction freqToInt(fft) {\n if (fft.freqDomain instanceof Uint8Array === false) {\n fft.freqDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction timeToFloat(fft) {\n if (fft.timeDomain instanceof Float32Array === false) {\n fft.timeDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction timeToInt(fft) {\n if (fft.timeDomain instanceof Uint8Array === false) {\n fft.timeDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n}\n\nexport default FFT;\n","import p5sound from './master';\nimport Add from 'Tone/signal/Add';\nimport Mult from 'Tone/signal/Multiply';\nimport Scale from 'Tone/signal/Scale';\nimport Panner from './panner';\n// ========================== //\n// SIGNAL MATH FOR MODULATION //\n// ========================== //\n\n// return sigChain(this, scale, thisChain, nextChain, Scale);\nfunction sigChain(o, mathObj, thisChain, nextChain, type) {\n var chainSource = o.oscillator;\n // if this type of math already exists in the chain, replace it\n for (var i in o.mathOps) {\n if (o.mathOps[i] instanceof type) {\n chainSource.disconnect();\n o.mathOps[i].dispose();\n thisChain = i;\n // assume nextChain is output gain node unless...\n if (thisChain < o.mathOps.length - 2) {\n nextChain = o.mathOps[i + 1];\n }\n }\n }\n if (thisChain === o.mathOps.length - 1) {\n o.mathOps.push(nextChain);\n }\n // assume source is the oscillator unless i > 0\n if (i > 0) {\n chainSource = o.mathOps[i - 1];\n }\n chainSource.disconnect();\n chainSource.connect(mathObj);\n mathObj.connect(nextChain);\n o.mathOps[thisChain] = mathObj;\n return o;\n}\n\n/**\n *

Creates a signal that oscillates between -1.0 and 1.0.\n * By default, the oscillation takes the form of a sinusoidal\n * shape ('sine'). Additional types include 'triangle',\n * 'sawtooth' and 'square'. The frequency defaults to\n * 440 oscillations per second (440Hz, equal to the pitch of an\n * 'A' note).

\n *\n *

Set the type of oscillation with setType(), or by instantiating a\n * specific oscillator: p5.SinOsc, p5.TriOsc, p5.SqrOsc, or p5.SawOsc.\n *

\n *\n * @class p5.Oscillator\n * @constructor\n * @param {Number} [freq] frequency defaults to 440Hz\n * @param {String} [type] type of oscillator. Options:\n * 'sine' (default), 'triangle',\n * 'sawtooth', 'square'\n * @example\n *
\n * let osc, playing, freq, amp;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playOscillator);\n * osc = new p5.Oscillator('sine');\n * }\n *\n * function draw() {\n * background(220)\n * freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\n * amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\n *\n * text('tap to play', 20, 20);\n * text('freq: ' + freq, 20, 40);\n * text('amp: ' + amp, 20, 60);\n *\n * if (playing) {\n * // smooth the transitions by 0.1 seconds\n * osc.freq(freq, 0.1);\n * osc.amp(amp, 0.1);\n * }\n * }\n *\n * function playOscillator() {\n * // starting an oscillator on a user gesture will enable audio\n * // in browsers that have a strict autoplay policy.\n * // See also: userStartAudio();\n * osc.start();\n * playing = true;\n * }\n *\n * function mouseReleased() {\n * // ramp amplitude to 0 over 0.5 seconds\n * osc.amp(0, 0.5);\n * playing = false;\n * }\n *
\n */\nclass Oscillator {\n constructor(freq, type) {\n if (typeof freq === 'string') {\n let f = type;\n type = freq;\n freq = f;\n }\n if (typeof type === 'number') {\n let f = type;\n type = freq;\n freq = f;\n }\n this.started = false;\n\n // components\n this.phaseAmount = undefined;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.f = freq || 440.0; // frequency\n this.oscillator.type = type || 'sine';\n this.oscillator.frequency.setValueAtTime(\n this.f,\n p5sound.audiocontext.currentTime\n );\n\n // connections\n this.output = p5sound.audiocontext.createGain();\n\n this._freqMods = []; // modulators connected to this oscillator's frequency\n\n // set default output gain to 0.5\n this.output.gain.value = 0.5;\n this.output.gain.setValueAtTime(0.5, p5sound.audiocontext.currentTime);\n\n this.oscillator.connect(this.output);\n // stereo panning\n this.panPosition = 0.0;\n this.connection = p5sound.input; // connect to p5sound by default\n this.panner = new Panner(this.output, this.connection, 1);\n\n //array of math operation signal chaining\n this.mathOps = [this.output];\n\n // add to the soundArray so we can dispose of the osc later\n p5sound.soundArray.push(this);\n\n // these methods are now the same thing\n this.fade = this.amp;\n }\n\n /**\n * Start an oscillator.\n *\n * Starting an oscillator on a user gesture will enable audio in browsers\n * that have a strict autoplay policy, including Chrome and most mobile\n * devices. See also: `userStartAudio()`.\n *\n * @method start\n * @for p5.Oscillator\n * @param {Number} [time] startTime in seconds from now.\n * @param {Number} [frequency] frequency in Hz.\n */\n start(time, f) {\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n }\n if (!this.started) {\n var freq = f || this.f;\n var type = this.oscillator.type;\n\n // set old osc free to be garbage collected (memory)\n if (this.oscillator) {\n this.oscillator.disconnect();\n delete this.oscillator;\n }\n\n // var detune = this.oscillator.frequency.value;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.oscillator.frequency.value = Math.abs(freq);\n this.oscillator.type = type;\n // this.oscillator.detune.value = detune;\n this.oscillator.connect(this.output);\n time = time || 0;\n this.oscillator.start(time + p5sound.audiocontext.currentTime);\n this.freqNode = this.oscillator.frequency;\n\n // if other oscillators are already connected to this osc's freq\n for (var i in this._freqMods) {\n if (typeof this._freqMods[i].connect !== 'undefined') {\n this._freqMods[i].connect(this.oscillator.frequency);\n }\n }\n\n this.started = true;\n }\n }\n\n /**\n * Stop an oscillator. Accepts an optional parameter\n * to determine how long (in seconds from now) until the\n * oscillator stops.\n *\n * @method stop\n * @for p5.Oscillator\n * @param {Number} secondsFromNow Time, in seconds from now.\n */\n stop(time) {\n if (this.started) {\n var t = time || 0;\n var now = p5sound.audiocontext.currentTime;\n this.oscillator.stop(t + now);\n this.started = false;\n }\n }\n\n /**\n * Set the amplitude between 0 and 1.0. Or, pass in an object\n * such as an oscillator to modulate amplitude with an audio signal.\n *\n * @method amp\n * @for p5.Oscillator\n * @param {Number|Object} vol between 0 and 1.0\n * or a modulating signal/oscillator\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {AudioParam} gain If no value is provided,\n * returns the Web Audio API\n * AudioParam that controls\n * this oscillator's\n * gain/amplitude/volume)\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n if (typeof vol === 'number') {\n var now = p5sound.audiocontext.currentTime;\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(this.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n }\n\n /**\n * Returns the value of output gain\n *\n * @method getAmp\n * @for p5.Oscillator\n *\n * @returns {number} Amplitude value between 0.0 and 1.0\n */\n\n getAmp() {\n return this.output.gain.value;\n }\n\n /**\n * Set frequency of an oscillator to a value. Or, pass in an object\n * such as an oscillator to modulate the frequency with an audio signal.\n *\n * @method freq\n * @for p5.Oscillator\n * @param {Number|Object} Frequency Frequency in Hz\n * or modulating signal/oscillator\n * @param {Number} [rampTime] Ramp time (in seconds)\n * @param {Number} [timeFromNow] Schedule this event to happen\n * at x seconds from now\n * @return {AudioParam} Frequency If no value is provided,\n * returns the Web Audio API\n * AudioParam that controls\n * this oscillator's frequency\n * @example\n *
\n * let osc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playOscillator);\n * osc = new p5.Oscillator(300);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playOscillator() {\n * osc.start();\n * osc.amp(0.5);\n * // start at 700Hz\n * osc.freq(700);\n * // ramp to 60Hz over 0.7 seconds\n * osc.freq(60, 0.7);\n * osc.amp(0, 0.1, 0.7);\n * }\n *
\n */\n freq(val, rampTime = 0, tFromNow = 0) {\n if (typeof val === 'number' && !isNaN(val)) {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n\n if (rampTime === 0) {\n this.oscillator.frequency.setValueAtTime(val, tFromNow + now);\n } else {\n if (val > 0) {\n this.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n } else {\n this.oscillator.frequency.linearRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n }\n }\n\n // reset phase if oscillator has a phase\n if (this.phaseAmount) {\n this.phase(this.phaseAmount);\n }\n } else if (val) {\n if (val.output) {\n val = val.output;\n }\n val.connect(this.oscillator.frequency);\n\n // keep track of what is modulating this param\n // so it can be re-connected if\n this._freqMods.push(val);\n } else {\n // return the Frequency Node\n return this.oscillator.frequency;\n }\n }\n /**\n * Returns the value of frequency of oscillator\n *\n * @method getFreq\n * @for p5.Oscillator\n * @returns {number} Frequency of oscillator in Hertz\n */\n\n getFreq() {\n return this.oscillator.frequency.value;\n }\n\n /**\n * Set type to 'sine', 'triangle', 'sawtooth' or 'square'.\n *\n * @method setType\n * @for p5.Oscillator\n * @param {String} type 'sine', 'triangle', 'sawtooth' or 'square'.\n */\n setType(type) {\n this.oscillator.type = type;\n }\n /**\n * Returns current type of oscillator eg. 'sine', 'triangle', 'sawtooth' or 'square'.\n *\n * @method getType\n * @for p5.Oscillator\n * @returns {String} type of oscillator eg . 'sine', 'triangle', 'sawtooth' or 'square'.\n */\n\n getType() {\n return this.oscillator.type;\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.Oscillator\n * @param {Object} unit A p5.sound or Web Audio object\n */\n connect(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n } else if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n this.connection = unit.input;\n } else {\n this.panner.connect(unit);\n this.connection = unit;\n }\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.Oscillator\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n if (this.panner) {\n this.panner.disconnect();\n if (this.output) {\n this.output.connect(this.panner);\n }\n }\n this.oscMods = [];\n }\n\n /**\n * Pan between Left (-1) and Right (1)\n *\n * @method pan\n * @for p5.Oscillator\n * @param {Number} panning Number between -1 and 1\n * @param {Number} timeFromNow schedule this event to happen\n * seconds from now\n */\n pan(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n }\n\n /**\n * Returns the current value of panPosition , between Left (-1) and Right (1)\n *\n * @method getPan\n * @for p5.Oscillator\n *\n * @returns {number} panPosition of oscillator , between Left (-1) and Right (1)\n */\n\n getPan() {\n return this.panPosition;\n }\n\n // get rid of the oscillator\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.oscillator) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.disconnect();\n this.panner = null;\n this.oscillator = null;\n }\n // if it is a Pulse\n if (this.osc2) {\n this.osc2.dispose();\n }\n }\n\n /**\n * Set the phase of an oscillator between 0.0 and 1.0.\n * In this implementation, phase is a delay time\n * based on the oscillator's current frequency.\n *\n * @method phase\n * @for p5.Oscillator\n * @param {Number} phase float between 0.0 and 1.0\n */\n phase(p) {\n var delayAmt = p5.prototype.map(p, 0, 1.0, 0, 1 / this.f);\n var now = p5sound.audiocontext.currentTime;\n\n this.phaseAmount = p;\n\n if (!this.dNode) {\n // create a delay node\n this.dNode = p5sound.audiocontext.createDelay();\n // put the delay node in between output and panner\n this.oscillator.disconnect();\n this.oscillator.connect(this.dNode);\n this.dNode.connect(this.output);\n }\n\n // set delay time to match phase:\n this.dNode.delayTime.setValueAtTime(delayAmt, now);\n }\n\n /**\n * Add a value to the p5.Oscillator's output amplitude,\n * and return the oscillator. Calling this method again\n * will override the initial add() with a new value.\n *\n * @method add\n * @for p5.Oscillator\n * @param {Number} number Constant number to add\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with scaled output\n *\n */\n add(num) {\n var add = new Add(num);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, add, thisChain, nextChain, Add);\n }\n /**\n * Multiply the p5.Oscillator's output amplitude\n * by a fixed value (i.e. turn it up!). Calling this method\n * again will override the initial mult() with a new value.\n *\n * @method mult\n * @for p5.Oscillator\n * @param {Number} number Constant number to multiply\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with multiplied output\n */\n mult(num) {\n var mult = new Mult(num);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, mult, thisChain, nextChain, Mult);\n }\n\n /**\n * Scale this oscillator's amplitude values to a given\n * range, and return the oscillator. Calling this method\n * again will override the initial scale() with new values.\n *\n * @method scale\n * @for p5.Oscillator\n * @param {Number} inMin input range minumum\n * @param {Number} inMax input range maximum\n * @param {Number} outMin input range minumum\n * @param {Number} outMax input range maximum\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with scaled output\n */\n scale(inMin, inMax, outMin, outMax) {\n var mapOutMin, mapOutMax;\n if (arguments.length === 4) {\n mapOutMin = p5.prototype.map(outMin, inMin, inMax, 0, 1) - 0.5; //find a way to get rid of p5.prototype ?\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5; //find a way to get rid of p5.prototype ?\n } else {\n mapOutMin = arguments[0];\n mapOutMax = arguments[1];\n }\n var scale = new Scale(mapOutMin, mapOutMax);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, scale, thisChain, nextChain, Scale);\n\n // this.output.disconnect();\n // this.output.connect(scale)\n }\n}\n\n// ============================== //\n// SinOsc, TriOsc, SqrOsc, SawOsc //\n// ============================== //\n\n/**\n * Constructor: new p5.SinOsc().\n * This creates a Sine Wave Oscillator and is\n * equivalent to new p5.Oscillator('sine')\n * or creating a p5.Oscillator and then calling\n * its method setType('sine').\n * See p5.Oscillator for methods.\n *\n * @class p5.SinOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SinOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'sine');\n }\n}\n\n/**\n * Constructor: new p5.TriOsc().\n * This creates a Triangle Wave Oscillator and is\n * equivalent to new p5.Oscillator('triangle')\n * or creating a p5.Oscillator and then calling\n * its method setType('triangle').\n * See p5.Oscillator for methods.\n *\n * @class p5.TriOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass TriOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'triangle');\n }\n}\n\n/**\n * Constructor: new p5.SawOsc().\n * This creates a SawTooth Wave Oscillator and is\n * equivalent to new p5.Oscillator('sawtooth')\n * or creating a p5.Oscillator and then calling\n * its method setType('sawtooth').\n * See p5.Oscillator for methods.\n *\n * @class p5.SawOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SawOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'sawtooth');\n }\n}\n\n/**\n * Constructor: new p5.SqrOsc().\n * This creates a Square Wave Oscillator and is\n * equivalent to new p5.Oscillator('square')\n * or creating a p5.Oscillator and then calling\n * its method setType('square').\n * See p5.Oscillator for methods.\n *\n * @class p5.SqrOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SqrOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'square');\n }\n}\n\nexport default Oscillator;\nexport { SinOsc, TriOsc, SawOsc, SqrOsc };\n","import p5sound from './master';\nimport Add from 'Tone/signal/Add';\nimport Mult from 'Tone/signal/Multiply';\nimport Scale from 'Tone/signal/Scale';\nimport TimelineSignal from 'Tone/signal/TimelineSignal.js';\n\n/**\n *

Envelopes are pre-defined amplitude distribution over time.\n * Typically, envelopes are used to control the output volume\n * of an object, a series of fades referred to as Attack, Decay,\n * Sustain and Release (\n * ADSR\n * ). Envelopes can also control other Web Audio Parameters—for example, a p5.Envelope can\n * control an Oscillator's frequency like this: osc.freq(env).

\n *

Use setRange to change the attack/release level.\n * Use setADSR to change attackTime, decayTime, sustainPercent and releaseTime.

\n *

Use the play method to play the entire envelope,\n * the ramp method for a pingable trigger,\n * or triggerAttack/\n * triggerRelease to trigger noteOn/noteOff.

\n *\n * @class p5.Envelope\n * @constructor\n * @example\n *
\n * let t1 = 0.1; // attack time in seconds\n * let l1 = 0.7; // attack level 0.0 to 1.0\n * let t2 = 0.3; // decay time in seconds\n * let l2 = 0.1; // decay level 0.0 to 1.0\n *\n * let env;\n * let triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * text('tap to play', 20, 20);\n * cnv.mousePressed(playSound);\n *\n * env = new p5.Envelope(t1, l1, t2, l2);\n * triOsc = new p5.Oscillator('triangle');\n * }\n *\n * function playSound() {\n * // starting the oscillator ensures that audio is enabled.\n * triOsc.start();\n * env.play(triOsc);\n * }\n *
\n */\np5.Envelope = function (t1, l1, t2, l2, t3, l3) {\n /**\n * Time until envelope reaches attackLevel\n * @property attackTime\n */\n this.aTime = t1 || 0.1;\n /**\n * Level once attack is complete.\n * @property attackLevel\n */\n this.aLevel = l1 || 1;\n /**\n * Time until envelope reaches decayLevel.\n * @property decayTime\n */\n this.dTime = t2 || 0.5;\n /**\n * Level after decay. The envelope will sustain here until it is released.\n * @property decayLevel\n */\n this.dLevel = l2 || 0;\n /**\n * Duration of the release portion of the envelope.\n * @property releaseTime\n */\n this.rTime = t3 || 0;\n /**\n * Level at the end of the release.\n * @property releaseLevel\n */\n this.rLevel = l3 || 0;\n\n this._rampHighPercentage = 0.98;\n\n this._rampLowPercentage = 0.02;\n\n this.output = p5sound.audiocontext.createGain();\n\n this.control = new TimelineSignal();\n\n this._init(); // this makes sure the envelope starts at zero\n\n this.control.connect(this.output); // connect to the output\n\n this.connection = null; // store connection\n\n //array of math operation signal chaining\n this.mathOps = [this.control];\n\n //whether envelope should be linear or exponential curve\n this.isExponential = false;\n\n // oscillator or buffer source to clear on env complete\n // to save resources if/when it is retriggered\n this.sourceToClear = null;\n\n // set to true if attack is set, then false on release\n this.wasTriggered = false;\n\n // add to the soundArray so we can dispose of the env later\n p5sound.soundArray.push(this);\n};\n\n// this init function just smooths the starting value to zero and gives a start point for the timeline\n// - it was necessary to remove glitches at the beginning.\np5.Envelope.prototype._init = function () {\n var now = p5sound.audiocontext.currentTime;\n var t = now;\n this.control.setTargetAtTime(0.00001, t, 0.001);\n //also, compute the correct time constants\n this._setRampAD(this.aTime, this.dTime);\n};\n\n/**\n * Reset the envelope with a series of time/value pairs.\n *\n * @method set\n * @for p5.Envelope\n * @param {Number} attackTime Time (in seconds) before level\n * reaches attackLevel\n * @param {Number} attackLevel Typically an amplitude between\n * 0.0 and 1.0\n * @param {Number} decayTime Time\n * @param {Number} decayLevel Amplitude (In a standard ADSR envelope,\n * decayLevel = sustainLevel)\n * @param {Number} releaseTime Release Time (in seconds)\n * @param {Number} releaseLevel Amplitude\n * @example\n *
\n * let attackTime;\n * let l1 = 0.7; // attack level 0.0 to 1.0\n * let t2 = 0.3; // decay time in seconds\n * let l2 = 0.1; // decay level 0.0 to 1.0\n * let l3 = 0.2; // release time in seconds\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n *\n * attackTime = map(mouseX, 0, width, 0.0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 20);\n * }\n *\n * // mouseClick triggers envelope if over canvas\n * function playSound() {\n * env.set(attackTime, l1, t2, l2, l3);\n *\n * triOsc.start();\n * env.play(triOsc);\n * }\n *
\n *\n */\np5.Envelope.prototype.set = function (t1, l1, t2, l2, t3, l3) {\n this.aTime = t1;\n this.aLevel = l1;\n this.dTime = t2 || 0;\n this.dLevel = l2 || 0;\n this.rTime = t3 || 0;\n this.rLevel = l3 || 0;\n\n // set time constants for ramp\n this._setRampAD(t1, t2);\n};\n\n/**\n * Set values like a traditional\n * \n * ADSR envelope\n * .\n *\n * @method setADSR\n * @for p5.Envelope\n * @param {Number} attackTime Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackTime = map(mouseX, 0, width, 0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 40);\n * }\n *\n * function playEnv() {\n * triOsc.start();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.setADSR = function (aTime, dTime, sPercent, rTime) {\n this.aTime = aTime;\n this.dTime = dTime || 0;\n\n // lerp\n this.sPercent = sPercent || 0;\n this.dLevel =\n typeof sPercent !== 'undefined'\n ? sPercent * (this.aLevel - this.rLevel) + this.rLevel\n : 0;\n\n this.rTime = rTime || 0;\n\n // also set time constants for ramp\n this._setRampAD(aTime, dTime);\n};\n\n/**\n * Set max (attackLevel) and min (releaseLevel) of envelope.\n *\n * @method setRange\n * @for p5.Envelope\n * @param {Number} aLevel attack level (defaults to 1)\n * @param {Number} rLevel release level (defaults to 0)\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackLevel = map(mouseY, height, 0, 0, 1.0);\n * text('attack level: ' + attackLevel, 5, height - 20);\n * }\n *\n * function playEnv() {\n * triOsc.start();\n * env.setRange(attackLevel, releaseLevel);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.setRange = function (aLevel, rLevel) {\n this.aLevel = aLevel || 1;\n this.rLevel = rLevel || 0;\n\n // not sure if this belongs here:\n\n // {Number} [dLevel] decay/sustain level (optional)\n // if (typeof(dLevel) !== 'undefined') {\n // this.dLevel = dLevel\n // } else if (this.sPercent) {\n // this.dLevel = this.sPercent ? this.sPercent * (this.aLevel - this.rLevel) + this.rLevel : 0;\n // }\n};\n\n// private (undocumented) method called when ADSR is set to set time constants for ramp\n//\n// Set the \n// time constants for simple exponential ramps.\n// The larger the time constant value, the slower the\n// transition will be.\n//\n// method _setRampAD\n// param {Number} attackTimeConstant attack time constant\n// param {Number} decayTimeConstant decay time constant\n//\np5.Envelope.prototype._setRampAD = function (t1, t2) {\n this._rampAttackTime = this.checkExpInput(t1);\n this._rampDecayTime = this.checkExpInput(t2);\n\n var TCDenominator = 1.0;\n /// Aatish Bhatia's calculation for time constant for rise(to adjust 1/1-e calculation to any percentage)\n TCDenominator = Math.log(\n 1.0 / this.checkExpInput(1.0 - this._rampHighPercentage)\n );\n this._rampAttackTC = t1 / this.checkExpInput(TCDenominator);\n TCDenominator = Math.log(1.0 / this._rampLowPercentage);\n this._rampDecayTC = t2 / this.checkExpInput(TCDenominator);\n};\n\n// private method\np5.Envelope.prototype.setRampPercentages = function (p1, p2) {\n //set the percentages that the simple exponential ramps go to\n this._rampHighPercentage = this.checkExpInput(p1);\n this._rampLowPercentage = this.checkExpInput(p2);\n var TCDenominator = 1.0;\n //now re-compute the time constants based on those percentages\n /// Aatish Bhatia's calculation for time constant for rise(to adjust 1/1-e calculation to any percentage)\n TCDenominator = Math.log(\n 1.0 / this.checkExpInput(1.0 - this._rampHighPercentage)\n );\n this._rampAttackTC = this._rampAttackTime / this.checkExpInput(TCDenominator);\n TCDenominator = Math.log(1.0 / this._rampLowPercentage);\n this._rampDecayTC = this._rampDecayTime / this.checkExpInput(TCDenominator);\n};\n\n/**\n * Assign a parameter to be controlled by this envelope.\n * If a p5.Sound object is given, then the p5.Envelope will control its\n * output gain. If multiple inputs are provided, the env will\n * control all of them.\n *\n * @method setInput\n * @for p5.Envelope\n * @param {Object} [...inputs] A p5.sound object or\n * Web Audio Param.\n */\np5.Envelope.prototype.setInput = function () {\n for (var i = 0; i < arguments.length; i++) {\n this.connect(arguments[i]);\n }\n};\n\n/**\n * Set whether the envelope ramp is linear (default) or exponential.\n * Exponential ramps can be useful because we perceive amplitude\n * and frequency logarithmically.\n *\n * @method setExp\n * @for p5.Envelope\n * @param {Boolean} isExp true is exponential, false is linear\n */\np5.Envelope.prototype.setExp = function (isExp) {\n this.isExponential = isExp;\n};\n\n//helper method to protect against zero values being sent to exponential functions\np5.Envelope.prototype.checkExpInput = function (value) {\n if (value <= 0) {\n value = 0.00000001;\n }\n return value;\n};\n\n/**\n *

Play tells the envelope to start acting on a given input.\n * If the input is a p5.sound object (i.e. AudioIn, Oscillator,\n * SoundFile), then Envelope will control its output volume.\n * Envelopes can also be used to control any \n * Web Audio Audio Param.

\n *\n * @method play\n * @for p5.Envelope\n * @param {Object} unit A p5.sound object or\n * Web Audio Param.\n * @param {Number} [startTime] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * triOsc.start();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackTime = map(mouseX, 0, width, 0, 1.0);\n * attackLevel = map(mouseY, height, 0, 0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 40);\n * text('attack level: ' + attackLevel, 5, height - 20);\n * }\n *\n * function playEnv() {\n * // ensure that audio is enabled\n * userStartAudio();\n *\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(attackLevel, releaseLevel);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.play = function (unit, secondsFromNow, susTime) {\n var tFromNow = secondsFromNow || 0;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n this.triggerAttack(unit, tFromNow);\n\n this.triggerRelease(unit, tFromNow + this.aTime + this.dTime + ~~susTime);\n};\n\n/**\n * Trigger the Attack, and Decay portion of the Envelope.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go. Input can be\n * any p5.sound object, or a \n * Web Audio Param.\n *\n * @method triggerAttack\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow time from now (in seconds)\n * @example\n *
\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.3;\n * let releaseTime = 0.4;\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * textSize(10);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(1.0, 0.0);\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.freq(220);\n *\n * cnv.mousePressed(envAttack);\n * }\n *\n * function envAttack() {\n * background(0, 255, 255);\n * text('release to release', width/2, height/2);\n *\n * // ensures audio is enabled. See also: `userStartAudio`\n * triOsc.start();\n *\n * env.triggerAttack(triOsc);\n * }\n *\n * function mouseReleased() {\n * background(220);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env.triggerRelease(triOsc);\n * }\n *
\n */\np5.Envelope.prototype.triggerAttack = function (unit, secondsFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n this.lastAttack = t;\n this.wasTriggered = true;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n // get and set value (with linear ramp) to anchor automation\n var valToSet = this.control.getValueAtTime(t);\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n } else {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // after each ramp completes, cancel scheduled values\n // (so they can be overridden in case env has been re-triggered)\n // then, set current value (with linearRamp to avoid click)\n // then, schedule the next automation...\n\n // attack\n t += this.aTime;\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.aLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.aLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // decay to decay level (if using ADSR, then decay level == sustain level)\n t += this.dTime;\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.dLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.dLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n};\n\n/**\n * Trigger the Release of the Envelope. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @method triggerRelease\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow time to trigger the release\n * @example\n *
\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.3;\n * let releaseTime = 0.4;\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * textSize(10);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(1.0, 0.0);\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.freq(220);\n *\n * cnv.mousePressed(envAttack);\n * }\n *\n * function envAttack() {\n * background(0, 255, 255);\n * text('release to release', width/2, height/2);\n *\n * // ensures audio is enabled. See also: `userStartAudio`\n * triOsc.start();\n *\n * env.triggerAttack(triOsc);\n * }\n *\n * function mouseReleased() {\n * background(220);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env.triggerRelease(triOsc);\n * }\n *
\n */\np5.Envelope.prototype.triggerRelease = function (unit, secondsFromNow) {\n // only trigger a release if an attack was triggered\n if (!this.wasTriggered) {\n // this currently causes a bit of trouble:\n // if a later release has been scheduled (via the play function)\n // a new earlier release won't interrupt it, because\n // this.wasTriggered has already been set to false.\n // If we want new earlier releases to override, then we need to\n // keep track of the last release time, and if the new release time is\n // earlier, then use it.\n return;\n }\n\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n // get and set value (with linear or exponential ramp) to anchor automation\n var valToSet = this.control.getValueAtTime(t);\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n } else {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // release\n t += this.rTime;\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.rLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.rLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n this.wasTriggered = false;\n};\n\n/**\n * Exponentially ramp to a value using the first two\n * values from setADSR(attackTime, decayTime)\n * as \n * time constants for simple exponential ramps.\n * If the value is higher than current value, it uses attackTime,\n * while a decrease uses decayTime.\n *\n * @method ramp\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow When to trigger the ramp\n * @param {Number} v Target value\n * @param {Number} [v2] Second target value\n * @example\n *
\n * let env, osc, amp;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let attackLevel = 1;\n * let decayLevel = 0;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * fill(0,255,0);\n * noStroke();\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime);\n * osc = new p5.Oscillator();\n * osc.amp(env);\n * amp = new p5.Amplitude();\n *\n * cnv.mousePressed(triggerRamp);\n * }\n *\n * function triggerRamp() {\n * // ensures audio is enabled. See also: `userStartAudio`\n * osc.start();\n *\n * env.ramp(osc, 0, attackLevel, decayLevel);\n * }\n *\n * function draw() {\n * background(20);\n * text('tap to play', 10, 20);\n * let h = map(amp.getLevel(), 0, 0.4, 0, height);;\n * rect(0, height, width, -h);\n * }\n *
\n */\np5.Envelope.prototype.ramp = function (unit, secondsFromNow, v1, v2) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n var destination1 = this.checkExpInput(v1);\n var destination2 =\n typeof v2 !== 'undefined' ? this.checkExpInput(v2) : undefined;\n\n // connect env to unit if not already connected\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n //get current value\n var currentVal = this.checkExpInput(this.control.getValueAtTime(t));\n // this.control.cancelScheduledValues(t);\n\n //if it's going up\n if (destination1 > currentVal) {\n this.control.setTargetAtTime(destination1, t, this._rampAttackTC);\n t += this._rampAttackTime;\n }\n\n //if it's going down\n else if (destination1 < currentVal) {\n this.control.setTargetAtTime(destination1, t, this._rampDecayTC);\n t += this._rampDecayTime;\n }\n\n // Now the second part of envelope begins\n if (destination2 === undefined) return;\n\n //if it's going up\n if (destination2 > destination1) {\n this.control.setTargetAtTime(destination2, t, this._rampAttackTC);\n }\n\n //if it's going down\n else if (destination2 < destination1) {\n this.control.setTargetAtTime(destination2, t, this._rampDecayTC);\n }\n};\n\np5.Envelope.prototype.connect = function (unit) {\n this.connection = unit;\n\n // assume we're talking about output gain\n // unless given a different audio param\n if (\n unit instanceof p5.Oscillator ||\n unit instanceof p5.SoundFile ||\n unit instanceof p5.AudioIn ||\n unit instanceof p5.Reverb ||\n unit instanceof p5.Noise ||\n unit instanceof p5.Filter ||\n unit instanceof p5.Delay\n ) {\n unit = unit.output.gain;\n }\n if (unit instanceof AudioParam) {\n //set the initial value\n unit.setValueAtTime(0, p5sound.audiocontext.currentTime);\n }\n\n this.output.connect(unit);\n};\n\np5.Envelope.prototype.disconnect = function () {\n if (this.output) {\n this.output.disconnect();\n }\n};\n\n// Signal Math\n\n/**\n * Add a value to the p5.Oscillator's output amplitude,\n * and return the oscillator. Calling this method\n * again will override the initial add() with new values.\n *\n * @method add\n * @for p5.Envelope\n * @param {Number} number Constant number to add\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.add = function (num) {\n var add = new Add(num);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, add, thisChain, nextChain, Add);\n};\n\n/**\n * Multiply the p5.Envelope's output amplitude\n * by a fixed value. Calling this method\n * again will override the initial mult() with new values.\n *\n * @method mult\n * @for p5.Envelope\n * @param {Number} number Constant number to multiply\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.mult = function (num) {\n var mult = new Mult(num);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, mult, thisChain, nextChain, Mult);\n};\n\n/**\n * Scale this envelope's amplitude values to a given\n * range, and return the envelope. Calling this method\n * again will override the initial scale() with new values.\n *\n * @method scale\n * @for p5.Envelope\n * @param {Number} inMin input range minumum\n * @param {Number} inMax input range maximum\n * @param {Number} outMin input range minumum\n * @param {Number} outMax input range maximum\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.scale = function (inMin, inMax, outMin, outMax) {\n var scale = new Scale(inMin, inMax, outMin, outMax);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, scale, thisChain, nextChain, Scale);\n};\n\n// get rid of the oscillator\np5.Envelope.prototype.dispose = function () {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.disconnect();\n if (this.control) {\n this.control.dispose();\n this.control = null;\n }\n for (var i = 1; i < this.mathOps.length; i++) {\n this.mathOps[i].dispose();\n }\n};\n\n// Different name for backwards compatibility, replicates p5.Envelope class\np5.Env = function (t1, l1, t2, l2, t3, l3) {\n console.warn(\n 'WARNING: p5.Env is now deprecated and may be removed in future versions. ' +\n 'Please use the new p5.Envelope instead.'\n );\n p5.Envelope.call(this, t1, l1, t2, l2, t3, l3);\n};\np5.Env.prototype = Object.create(p5.Envelope.prototype);\n\nconst Envelope = p5.Envelope;\nexport default Envelope;\n","import p5sound from './master';\nimport Oscillator from './oscillator';\n\n// generate noise buffers\nconst _whiteNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var whiteBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = whiteBuffer.getChannelData(0);\n for (var i = 0; i < bufferSize; i++) {\n noiseData[i] = Math.random() * 2 - 1;\n }\n whiteBuffer.type = 'white';\n return whiteBuffer;\n})();\n\nconst _pinkNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var pinkBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = pinkBuffer.getChannelData(0);\n var b0, b1, b2, b3, b4, b5, b6;\n b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0.0;\n for (var i = 0; i < bufferSize; i++) {\n var white = Math.random() * 2 - 1;\n b0 = 0.99886 * b0 + white * 0.0555179;\n b1 = 0.99332 * b1 + white * 0.0750759;\n b2 = 0.969 * b2 + white * 0.153852;\n b3 = 0.8665 * b3 + white * 0.3104856;\n b4 = 0.55 * b4 + white * 0.5329522;\n b5 = -0.7616 * b5 - white * 0.016898;\n noiseData[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362;\n noiseData[i] *= 0.11; // (roughly) compensate for gain\n b6 = white * 0.115926;\n }\n pinkBuffer.type = 'pink';\n return pinkBuffer;\n})();\n\nconst _brownNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var brownBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = brownBuffer.getChannelData(0);\n var lastOut = 0.0;\n for (var i = 0; i < bufferSize; i++) {\n var white = Math.random() * 2 - 1;\n noiseData[i] = (lastOut + 0.02 * white) / 1.02;\n lastOut = noiseData[i];\n noiseData[i] *= 3.5;\n }\n brownBuffer.type = 'brown';\n return brownBuffer;\n})();\n\n/**\n * Noise is a type of oscillator that generates a buffer with random values.\n *\n * @class p5.Noise\n * @extends p5.Oscillator\n * @constructor\n * @param {String} type Type of noise can be 'white' (default),\n * 'brown' or 'pink'.\n */\nclass Noise extends Oscillator {\n constructor(type) {\n super();\n var assignType;\n delete this.f;\n delete this.freq;\n delete this.oscillator;\n\n if (type === 'brown') {\n assignType = _brownNoiseBuffer;\n } else if (type === 'pink') {\n assignType = _pinkNoiseBuffer;\n } else {\n assignType = _whiteNoiseBuffer;\n }\n this.buffer = assignType;\n }\n\n /**\n * Set type of noise to 'white', 'pink' or 'brown'.\n * White is the default.\n *\n * @method setType\n * @param {String} [type] 'white', 'pink' or 'brown'\n */\n setType(type) {\n switch (type) {\n case 'white':\n this.buffer = _whiteNoiseBuffer;\n break;\n case 'pink':\n this.buffer = _pinkNoiseBuffer;\n break;\n case 'brown':\n this.buffer = _brownNoiseBuffer;\n break;\n default:\n this.buffer = _whiteNoiseBuffer;\n }\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.start(now + 0.01);\n }\n }\n\n getType() {\n return this.buffer.type;\n }\n start() {\n if (this.started) {\n this.stop();\n }\n this.noise = p5sound.audiocontext.createBufferSource();\n this.noise.buffer = this.buffer;\n this.noise.loop = true;\n this.noise.connect(this.output);\n var now = p5sound.audiocontext.currentTime;\n this.noise.start(now);\n this.started = true;\n }\n\n stop() {\n var now = p5sound.audiocontext.currentTime;\n if (this.noise) {\n this.noise.stop(now);\n this.started = false;\n }\n }\n\n dispose() {\n var now = p5sound.audiocontext.currentTime;\n\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.noise) {\n this.noise.disconnect();\n this.stop(now);\n }\n if (this.output) {\n this.output.disconnect();\n }\n if (this.panner) {\n this.panner.disconnect();\n }\n this.output = null;\n this.panner = null;\n this.buffer = null;\n this.noise = null;\n }\n}\n\nexport default Noise;\n","import Signal from 'Tone/signal/Signal';\nimport Multiply from 'Tone/signal/Multiply';\n\nimport p5sound from './master';\nimport Oscillator, { SawOsc } from './oscillator';\n\n/**\n * Creates a Pulse object, an oscillator that implements\n * Pulse Width Modulation.\n * The pulse is created with two oscillators.\n * Accepts a parameter for frequency, and to set the\n * width between the pulses. See \n * p5.Oscillator for a full list of methods.\n *\n * @class p5.Pulse\n * @extends p5.Oscillator\n * @constructor\n * @param {Number} [freq] Frequency in oscillations per second (Hz)\n * @param {Number} [w] Width between the pulses (0 to 1.0,\n * defaults to 0)\n * @example\n *
\n * let pulse;\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startPulse);\n * background(220);\n *\n * pulse = new p5.Pulse();\n * pulse.amp(0.5);\n * pulse.freq(220);\n * }\n * function startPulse() {\n * pulse.start();\n * pulse.amp(0.5, 0.02);\n * }\n * function mouseReleased() {\n * pulse.amp(0, 0.2);\n * }\n * function draw() {\n * background(220);\n * text('tap to play', 5, 20, width - 20);\n * let w = map(mouseX, 0, width, 0, 1);\n * w = constrain(w, 0, 1);\n * pulse.width(w);\n * text('pulse width: ' + w, 5, height - 20);\n * }\n *
\n */\nclass Pulse extends Oscillator {\n constructor(freq, w) {\n super(freq, 'sawtooth');\n\n // width of PWM, should be betw 0 to 1.0\n this.w = w || 0;\n\n // create a second oscillator with inverse frequency\n this.osc2 = new SawOsc(freq);\n\n // create a delay node\n this.dNode = p5sound.audiocontext.createDelay();\n\n // dc offset\n this.dcOffset = createDCOffset();\n this.dcGain = p5sound.audiocontext.createGain();\n this.dcOffset.connect(this.dcGain);\n this.dcGain.connect(this.output);\n // set delay time based on PWM width\n this.f = freq || 440;\n var mW = this.w / this.oscillator.frequency.value;\n this.dNode.delayTime.value = mW;\n this.dcGain.gain.value = 1.7 * (0.5 - this.w);\n\n // disconnect osc2 and connect it to delay, which is connected to output\n this.osc2.disconnect();\n this.osc2.panner.disconnect();\n this.osc2.amp(-1); // inverted amplitude\n this.osc2.output.connect(this.dNode);\n this.dNode.connect(this.output);\n\n this.output.gain.value = 1;\n this.output.connect(this.panner);\n }\n\n /**\n * Set the width of a Pulse object (an oscillator that implements\n * Pulse Width Modulation).\n *\n * @method width\n * @param {Number} [width] Width between the pulses (0 to 1.0,\n * defaults to 0)\n */\n width(w) {\n if (typeof w === 'number') {\n if (w <= 1.0 && w >= 0.0) {\n this.w = w;\n // set delay time based on PWM width\n\n // var mW = map(this.w, 0, 1.0, 0, 1/this.f);\n var mW = this.w / this.oscillator.frequency.value;\n this.dNode.delayTime.value = mW;\n }\n\n this.dcGain.gain.value = 1.7 * (0.5 - this.w);\n } else {\n w.connect(this.dNode.delayTime);\n let sig = new Signal(-0.5); //repalce it with tones Signals Method\n w.connect(sig);\n let mult1 = new Multiply(-1);\n let mult2 = new Multiply(1.7);\n sig = sig.connect(mult1).connect(mult2);\n sig.connect(this.dcGain.gain);\n }\n }\n\n start(f, time) {\n var now = p5sound.audiocontext.currentTime;\n var t = time || 0;\n if (!this.started) {\n var freq = f || this.f;\n var type = this.oscillator.type;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.oscillator.frequency.setValueAtTime(freq, now);\n this.oscillator.type = type;\n this.oscillator.connect(this.output);\n this.oscillator.start(t + now);\n\n // set up osc2\n this.osc2.oscillator = p5sound.audiocontext.createOscillator();\n this.osc2.oscillator.frequency.setValueAtTime(freq, t + now);\n this.osc2.oscillator.type = type;\n this.osc2.oscillator.connect(this.osc2.output);\n this.osc2.start(t + now);\n this.freqNode = [\n this.oscillator.frequency,\n this.osc2.oscillator.frequency,\n ];\n\n // start dcOffset, too\n this.dcOffset = createDCOffset();\n this.dcOffset.connect(this.dcGain);\n this.dcOffset.start(t + now);\n\n // if LFO connections depend on these oscillators\n if (this.mods !== undefined && this.mods.frequency !== undefined) {\n this.mods.frequency.connect(this.freqNode[0]);\n this.mods.frequency.connect(this.freqNode[1]);\n }\n this.started = true;\n this.osc2.started = true;\n }\n }\n\n stop(time) {\n if (this.started) {\n var t = time || 0;\n var now = p5sound.audiocontext.currentTime;\n this.oscillator.stop(t + now);\n if (this.osc2.oscillator) {\n this.osc2.oscillator.stop(t + now);\n }\n this.dcOffset.stop(t + now);\n this.started = false;\n this.osc2.started = false;\n }\n }\n\n freq(val, rampTime = 0, tFromNow = 0) {\n if (typeof val === 'number') {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n var currentFreq = this.oscillator.frequency.value;\n this.oscillator.frequency.cancelScheduledValues(now);\n this.oscillator.frequency.setValueAtTime(currentFreq, now + tFromNow);\n this.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n this.osc2.oscillator.frequency.cancelScheduledValues(now);\n this.osc2.oscillator.frequency.setValueAtTime(\n currentFreq,\n now + tFromNow\n );\n this.osc2.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n\n if (this.freqMod) {\n this.freqMod.output.disconnect();\n this.freqMod = null;\n }\n } else if (val.output) {\n val.output.disconnect();\n val.output.connect(this.oscillator.frequency);\n val.output.connect(this.osc2.oscillator.frequency);\n this.freqMod = val;\n }\n }\n}\n\n// inspiration: http://webaudiodemos.appspot.com/oscilloscope/\nfunction createDCOffset() {\n var ac = p5sound.audiocontext;\n var buffer = ac.createBuffer(1, 2048, ac.sampleRate);\n var data = buffer.getChannelData(0);\n for (var i = 0; i < 2048; i++) data[i] = 1.0;\n var bufferSource = ac.createBufferSource();\n bufferSource.buffer = buffer;\n bufferSource.loop = true;\n return bufferSource;\n}\n\nexport default Pulse;\n","import p5sound from './master';\nimport Amplitude from './amplitude';\n\n// an array of input sources\np5sound.inputSources = [];\n\n/**\n *

Get audio from an input, i.e. your computer's microphone.

\n *\n *

Turn the mic on/off with the start() and stop() methods. When the mic\n * is on, its volume can be measured with getLevel or by connecting an\n * FFT object.

\n *\n *

If you want to hear the AudioIn, use the .connect() method.\n * AudioIn does not connect to p5.sound output by default to prevent\n * feedback.

\n *\n *

Note: This uses the getUserMedia/\n * Stream API, which is not supported by certain browsers. Access in Chrome browser\n * is limited to localhost and https, but access over http may be limited.

\n *\n * @class p5.AudioIn\n * @constructor\n * @param {Function} [errorCallback] A function to call if there is an error\n * accessing the AudioIn. For example,\n * Safari and iOS devices do not\n * currently allow microphone access.\n * @example\n *
\n * let mic;\n *\n * function setup(){\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(useraudiocontextStartAudio);\n * textAlign(CENTER);\n * mic = new p5.AudioIn();\n * mic.start();\n * }\n *\n * function draw(){\n * background(0);\n * fill(255);\n * text('tap to start', width/2, 20);\n *\n * micLevel = mic.getLevel();\n * let y = height - micLevel * height;\n * ellipse(width/2, y, 10, 10);\n * }\n *
\n */\nclass AudioIn {\n constructor(errorCallback) {\n // set up audio input\n /**\n * @property {GainNode} input\n */\n this.input = p5sound.audiocontext.createGain();\n /**\n * @property {GainNode} output\n */\n this.output = p5sound.audiocontext.createGain();\n\n /**\n * @property {MediaStream|null} stream\n */\n this.stream = null;\n /**\n * @property {MediaStreamAudioSourceNode|null} mediaStream\n */\n this.mediaStream = null;\n /**\n * @property {Number|null} currentSource\n */\n this.currentSource = null;\n\n /**\n * Client must allow browser to access their microphone / audioin source.\n * Default: false. Will become true when the client enables access.\n *\n * @property {Boolean} enabled\n */\n this.enabled = false;\n\n /**\n * Input amplitude, connect to it by default but not to master out\n *\n * @property {p5.Amplitude} amplitude\n */\n this.amplitude = new Amplitude();\n this.output.connect(this.amplitude.input);\n\n if (\n !window.MediaStreamTrack ||\n !window.navigator.mediaDevices ||\n !window.navigator.mediaDevices.getUserMedia\n ) {\n errorCallback\n ? errorCallback()\n : window.alert(\n 'This browser does not support MediaStreamTrack and mediaDevices'\n );\n }\n\n // add to soundArray so we can dispose on close\n p5sound.soundArray.push(this);\n }\n /**\n * Start processing audio input. This enables the use of other\n * AudioIn methods like getLevel(). Note that by default, AudioIn\n * is not connected to p5.sound's output. So you won't hear\n * anything unless you use the connect() method.
\n *\n * Certain browsers limit access to the user's microphone. For example,\n * Chrome only allows access from localhost and over https. For this reason,\n * you may want to include an errorCallback—a function that is called in case\n * the browser won't provide mic access.\n *\n * @method start\n * @for p5.AudioIn\n * @param {Function} [successCallback] Name of a function to call on\n * success.\n * @param {Function} [errorCallback] Name of a function to call if\n * there was an error. For example,\n * some browsers do not support\n * getUserMedia.\n */\n start(successCallback, errorCallback) {\n var self = this;\n\n if (this.stream) {\n this.stop();\n }\n\n // set the audio source\n var audioSource = p5sound.inputSources[self.currentSource];\n var constraints = {\n audio: {\n sampleRate: p5sound.audiocontext.sampleRate,\n echoCancellation: false,\n },\n };\n\n // if developers determine which source to use\n if (p5sound.inputSources[this.currentSource]) {\n constraints.audio.deviceId = audioSource.deviceId;\n }\n\n window.navigator.mediaDevices\n .getUserMedia(constraints)\n .then(function (stream) {\n self.stream = stream;\n self.enabled = true;\n // Wrap a MediaStreamSourceNode around the live input\n self.mediaStream = p5sound.audiocontext.createMediaStreamSource(stream);\n self.mediaStream.connect(self.output);\n // only send to the Amplitude reader, so we can see it but not hear it.\n self.amplitude.setInput(self.output);\n if (successCallback) successCallback();\n })\n .catch(function (err) {\n if (errorCallback) errorCallback(err);\n else console.error(err);\n });\n }\n\n /**\n * Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().\n * If re-starting, the user may be prompted for permission access.\n *\n * @method stop\n * @for p5.AudioIn\n */\n stop() {\n if (this.stream) {\n this.stream.getTracks().forEach(function (track) {\n track.stop();\n });\n\n this.mediaStream.disconnect();\n\n delete this.mediaStream;\n delete this.stream;\n }\n }\n\n /**\n * Connect to an audio unit. If no parameter is provided, will\n * connect to the master output (i.e. your speakers).
\n *\n * @method connect\n * @for p5.AudioIn\n * @param {Object} [unit] An object that accepts audio input,\n * such as an FFT\n */\n connect(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n } else if (unit.hasOwnProperty('analyser')) {\n this.output.connect(unit.analyser);\n } else {\n this.output.connect(unit);\n }\n } else {\n this.output.connect(p5sound.input);\n }\n }\n\n /**\n * Disconnect the AudioIn from all audio units. For example, if\n * connect() had been called, disconnect() will stop sending\n * signal to your speakers.
\n *\n * @method disconnect\n * @for p5.AudioIn\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n // stay connected to amplitude even if not outputting to p5\n this.output.connect(this.amplitude.input);\n }\n }\n\n /**\n * Read the Amplitude (volume level) of an AudioIn. The AudioIn\n * class contains its own instance of the Amplitude class to help\n * make it easy to get a microphone's volume level. Accepts an\n * optional smoothing value (0.0 < 1.0). NOTE: AudioIn must\n * .start() before using .getLevel().
\n *\n * @method getLevel\n * @for p5.AudioIn\n * @param {Number} [smoothing] Smoothing is 0.0 by default.\n * Smooths values based on previous values.\n * @return {Number} Volume level (between 0.0 and 1.0)\n */\n getLevel(smoothing) {\n if (smoothing) {\n this.amplitude.smoothing = smoothing;\n }\n return this.amplitude.getLevel();\n }\n\n /**\n * Set amplitude (volume) of a mic input between 0 and 1.0.
\n *\n * @method amp\n * @for p5.AudioIn\n * @param {Number} vol between 0 and 1.0\n * @param {Number} [time] ramp time (optional)\n */\n amp(vol, t) {\n if (t) {\n var rampTime = t || 0;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\n this.output.gain.setValueAtTime(\n currentVol,\n p5sound.audiocontext.currentTime\n );\n this.output.gain.linearRampToValueAtTime(\n vol,\n rampTime + p5sound.audiocontext.currentTime\n );\n } else {\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\n this.output.gain.setValueAtTime(vol, p5sound.audiocontext.currentTime);\n }\n }\n\n /**\n * Returns a list of available input sources. This is a wrapper\n * for \n * MediaDevices.enumerateDevices() - Web APIs | MDN\n * and it returns a Promise.\n * @method getSources\n * @for p5.AudioIn\n * @param {Function} [successCallback] This callback function handles the sources when they\n * have been enumerated. The callback function\n * receives the deviceList array as its only argument\n * @param {Function} [errorCallback] This optional callback receives the error\n * message as its argument.\n * @returns {Promise} Returns a Promise that can be used in place of the callbacks, similar\n * to the enumerateDevices() method\n * @example\n *
\n * let audioIn;\n *\n * function setup(){\n * text('getting sources...', 0, 20);\n * audioIn = new p5.AudioIn();\n * audioIn.getSources(gotSources);\n * }\n *\n * function gotSources(deviceList) {\n * if (deviceList.length > 0) {\n * //set the source to the first item in the deviceList array\n * audioIn.setSource(0);\n * let currentSource = deviceList[audioIn.currentSource];\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\n * }\n * }\n *
\n */\n getSources(onSuccess, onError) {\n return new Promise(function (resolve, reject) {\n window.navigator.mediaDevices\n .enumerateDevices()\n .then(function (devices) {\n p5sound.inputSources = devices.filter(function (device) {\n return device.kind === 'audioinput';\n });\n resolve(p5sound.inputSources);\n if (onSuccess) {\n onSuccess(p5sound.inputSources);\n }\n })\n .catch(function (error) {\n reject(error);\n if (onError) {\n onError(error);\n } else {\n console.error(\n 'This browser does not support MediaStreamTrack.getSources()'\n );\n }\n });\n });\n }\n\n /**\n * Set the input source. Accepts a number representing a\n * position in the array returned by getSources().\n * This is only available in browsers that support\n * \n * navigator.mediaDevices.enumerateDevices()\n *\n * @method setSource\n * @for p5.AudioIn\n * @param {number} num position of input source in the array\n * @example\n *
\n * let audioIn;\n *\n * function setup(){\n * text('getting sources...', 0, 20);\n * audioIn = new p5.AudioIn();\n * audioIn.getSources(gotSources);\n * }\n *\n * function gotSources(deviceList) {\n * if (deviceList.length > 0) {\n * //set the source to the first item in the deviceList array\n * audioIn.setSource(0);\n * let currentSource = deviceList[audioIn.currentSource];\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\n * }\n * }\n *
\n */\n setSource(num) {\n if (p5sound.inputSources.length > 0 && num < p5sound.inputSources.length) {\n // set the current source\n this.currentSource = num;\n console.log('set source to ', p5sound.inputSources[this.currentSource]);\n } else {\n console.log('unable to set input source');\n }\n\n // restart stream if currently active\n if (this.stream && this.stream.active) {\n this.start();\n }\n }\n\n // private method\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.stop();\n\n if (this.output) {\n this.output.disconnect();\n }\n if (this.amplitude) {\n this.amplitude.disconnect();\n }\n delete this.amplitude;\n delete this.output;\n }\n}\n\nexport default AudioIn;\n","import p5sound from './master';\nimport CrossFade from 'Tone/component/CrossFade.js';\n\n/**\n * Effect is a base class for audio effects in p5.
\n * This module handles the nodes and methods that are\n * common and useful for current and future effects.\n *\n *\n * This class is extended by p5.Distortion,\n * p5.Compressor,\n * p5.Delay,\n * p5.Filter,\n * p5.Reverb.\n *\n * @class p5.Effect\n * @constructor\n *\n * @param {Object} [ac] Reference to the audio context of the p5 object\n * @param {AudioNode} [input] Gain Node effect wrapper\n * @param {AudioNode} [output] Gain Node effect wrapper\n * @param {Object} [_drywet] Tone.JS CrossFade node (defaults to value: 1)\n * @param {AudioNode} [wet] Effects that extend this class should connect\n * to the wet signal to this gain node, so that dry and wet\n * signals are mixed properly.\n */\nclass Effect {\n constructor() {\n this.ac = p5sound.audiocontext;\n\n this.input = this.ac.createGain();\n this.output = this.ac.createGain();\n\n /**\n *\tThe p5.Effect class is built\n * \tusing Tone.js CrossFade\n * \t@private\n */\n\n this._drywet = new CrossFade(1);\n\n /**\n *\tIn classes that extend\n *\tp5.Effect, connect effect nodes\n *\tto the wet parameter\n */\n this.wet = this.ac.createGain();\n\n this.input.connect(this._drywet.a);\n this.wet.connect(this._drywet.b);\n this._drywet.connect(this.output);\n\n this.connect();\n\n //Add to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Set the output volume of the filter.\n *\n * @method amp\n * @for p5.Effect\n * @param {Number} [vol] amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts until rampTime\n * @param {Number} [tFromNow] schedule this event to happen in tFromNow seconds\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n const now = p5sound.audiocontext.currentTime;\n const startTime = now + tFromNow;\n const endTime = startTime + rampTime + 0.001;\n const currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now);\n this.output.gain.linearRampToValueAtTime(currentVol, startTime + 0.001);\n this.output.gain.linearRampToValueAtTime(vol, endTime);\n }\n\n /**\n * Link effects together in a chain\n * Example usage: filter.chain(reverb, delay, panner);\n * May be used with an open-ended number of arguments\n *\n * @method chain\n * @for p5.Effect\n * @param {Object} [arguments] Chain together multiple sound objects\n */\n chain() {\n if (arguments.length > 0) {\n this.connect(arguments[0]);\n for (var i = 1; i < arguments.length; i += 1) {\n arguments[i - 1].connect(arguments[i]);\n }\n }\n return this;\n }\n\n /**\n * Adjust the dry/wet value.\n *\n * @method drywet\n * @for p5.Effect\n * @param {Number} [fade] The desired drywet value (0 - 1.0)\n */\n drywet(fade) {\n if (typeof fade !== 'undefined') {\n this._drywet.fade.value = fade;\n }\n return this._drywet.fade.value;\n }\n\n /**\n * Send output to a p5.js-sound, Web Audio Node, or use signal to\n * control an AudioParam\n *\n * @method connect\n * @for p5.Effect\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5.soundOut.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all output.\n * @method disconnect\n * @for p5.Effect\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n dispose() {\n // remove refernce form soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n\n if (this._drywet) {\n this._drywet.disconnect();\n delete this._drywet;\n }\n\n if (this.wet) {\n this.wet.disconnect();\n delete this.wet;\n }\n\n this.ac = undefined;\n }\n}\n\nexport default Effect;\n","import Effect from './effect';\n\n/**\n *

A p5.Filter uses a Web Audio Biquad Filter to filter\n * the frequency response of an input source. Subclasses\n * include:

\n * p5.LowPass:\n * Allows frequencies below the cutoff frequency to pass through,\n * and attenuates frequencies above the cutoff.
\n * p5.HighPass:\n * The opposite of a lowpass filter.
\n * p5.BandPass:\n * Allows a range of frequencies to pass through and attenuates\n * the frequencies below and above this frequency range.
\n *\n * The .res() method controls either width of the\n * bandpass, or resonance of the low/highpass cutoff frequency.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Filter\n * @extends p5.Effect\n * @constructor\n * @param {String} [type] 'lowpass' (default), 'highpass', 'bandpass'\n * @example\n *
\n * let fft, noise, filter;\n *\n * function setup() {\n * let cnv = createCanvas(100,100);\n * cnv.mousePressed(makeNoise);\n * fill(255, 0, 255);\n *\n * filter = new p5.BandPass();\n * noise = new p5.Noise();\n * noise.disconnect();\n * noise.connect(filter);\n *\n * fft = new p5.FFT();\n * }\n *\n * function draw() {\n * background(220);\n *\n * // set the BandPass frequency based on mouseX\n * let freq = map(mouseX, 0, width, 20, 10000);\n * freq = constrain(freq, 0, 22050);\n * filter.freq(freq);\n * // give the filter a narrow band (lower res = wider bandpass)\n * filter.res(50);\n *\n * // draw filtered spectrum\n * let spectrum = fft.analyze();\n * noStroke();\n * for (let i = 0; i < spectrum.length; i++) {\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width/spectrum.length, h);\n * }\n * if (!noise.started) {\n * text('tap here and drag to change frequency', 10, 20, width - 20);\n * } else {\n * text('Frequency: ' + round(freq)+'Hz', 20, 20, width - 20);\n * }\n * }\n *\n * function makeNoise() {\n * // see also: `userStartAudio()`\n * noise.start();\n * noise.amp(0.5, 0.2);\n * }\n *\n * function mouseReleased() {\n * noise.amp(0, 0.2);\n * }\n *\n *
\n */\nclass Filter extends Effect {\n constructor(type) {\n super();\n //add extend Effect by adding a Biquad Filter\n\n /**\n * The p5.Filter is built with a\n * \n * Web Audio BiquadFilter Node.\n *\n * @property {DelayNode} biquadFilter\n */\n\n this.biquad = this.ac.createBiquadFilter();\n\n this.input.connect(this.biquad);\n\n this.biquad.connect(this.wet);\n\n if (type) {\n this.setType(type);\n }\n\n //Properties useful for the toggle method.\n this._on = true;\n this._untoggledType = this.biquad.type;\n }\n\n /**\n * Filter an audio signal according to a set\n * of filter parameters.\n *\n * @method process\n * @param {Object} Signal An object that outputs audio\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\n * @param {Number} [res] Resonance/Width of the filter frequency\n * from 0.001 to 1000\n */\n process(src, freq, res, time) {\n src.connect(this.input);\n this.set(freq, res, time);\n }\n\n /**\n * Set the frequency and the resonance of the filter.\n *\n * @method set\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\n * @param {Number} [res] Resonance (Q) from 0.001 to 1000\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n set(freq, res, time) {\n if (freq) {\n this.freq(freq, time);\n }\n if (res) {\n this.res(res, time);\n }\n }\n\n /**\n * Set the filter frequency, in Hz, from 10 to 22050 (the range of\n * human hearing, although in reality most people hear in a narrower\n * range).\n *\n * @method freq\n * @param {Number} freq Filter Frequency\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {Number} value Returns the current frequency value\n */\n freq(freq, time) {\n var t = time || 0;\n if (freq <= 0) {\n freq = 1;\n }\n if (typeof freq === 'number') {\n this.biquad.frequency.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.biquad.frequency.exponentialRampToValueAtTime(\n freq,\n this.ac.currentTime + 0.02 + t\n );\n } else if (freq) {\n freq.connect(this.biquad.frequency);\n }\n return this.biquad.frequency.value;\n }\n\n /**\n * Controls either width of a bandpass frequency,\n * or the resonance of a low/highpass cutoff frequency.\n *\n * @method res\n * @param {Number} res Resonance/Width of filter freq\n * from 0.001 to 1000\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {Number} value Returns the current res value\n */\n res(res, time) {\n var t = time || 0;\n if (typeof res === 'number') {\n this.biquad.Q.value = res;\n this.biquad.Q.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.biquad.Q.linearRampToValueAtTime(\n res,\n this.ac.currentTime + 0.02 + t\n );\n } else if (res) {\n res.connect(this.biquad.Q);\n }\n return this.biquad.Q.value;\n }\n\n /**\n * Controls the gain attribute of a Biquad Filter.\n * This is distinctly different from .amp() which is inherited from p5.Effect\n * .amp() controls the volume via the output gain node\n * p5.Filter.gain() controls the gain parameter of a Biquad Filter node.\n *\n * @method gain\n * @param {Number} gain\n * @return {Number} Returns the current or updated gain value\n */\n gain(gain, time) {\n var t = time || 0;\n if (typeof gain === 'number') {\n this.biquad.gain.value = gain;\n this.biquad.gain.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.biquad.gain.linearRampToValueAtTime(\n gain,\n this.ac.currentTime + 0.02 + t\n );\n } else if (gain) {\n gain.connect(this.biquad.gain);\n }\n return this.biquad.gain.value;\n }\n\n /**\n * Toggle function. Switches between the specified type and allpass\n *\n * @method toggle\n * @return {boolean} [Toggle value]\n */\n toggle() {\n this._on = !this._on;\n\n if (this._on === true) {\n this.biquad.type = this._untoggledType;\n } else if (this._on === false) {\n this.biquad.type = 'allpass';\n }\n\n return this._on;\n }\n\n /**\n * Set the type of a p5.Filter. Possible types include:\n * \"lowpass\" (default), \"highpass\", \"bandpass\",\n * \"lowshelf\", \"highshelf\", \"peaking\", \"notch\",\n * \"allpass\".\n *\n * @method setType\n * @param {String} t\n */\n setType(t) {\n this.biquad.type = t;\n this._untoggledType = this.biquad.type;\n }\n\n dispose() {\n // remove reference from soundArray\n super.dispose();\n if (this.biquad) {\n this.biquad.disconnect();\n delete this.biquad;\n }\n }\n}\n\n/**\n * Constructor: new p5.LowPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('lowpass').\n * See p5.Filter for methods.\n *\n * @class p5.LowPass\n * @constructor\n * @extends p5.Filter\n */\nclass LowPass extends Filter {\n constructor() {\n super('lowpass');\n }\n}\n\n/**\n * Constructor: new p5.HighPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('highpass').\n * See p5.Filter for methods.\n *\n * @class p5.HighPass\n * @constructor\n * @extends p5.Filter\n */\nclass HighPass extends Filter {\n constructor() {\n super('highpass');\n }\n}\n\n/**\n * Constructor: new p5.BandPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('bandpass').\n * See p5.Filter for methods.\n *\n * @class p5.BandPass\n * @constructor\n * @extends p5.Filter\n */\nclass BandPass extends Filter {\n constructor() {\n super('bandpass');\n }\n}\nexport default Filter;\nexport { LowPass, HighPass, BandPass };\n","import Filter from './filter';\nimport p5sound from './master';\n\n/**\n * EQFilter extends p5.Filter with constraints\n * necessary for the p5.EQ\n *\n * @private\n */\nclass EQFilter extends Filter {\n constructor(freq, res) {\n super('peaking');\n\n this.disconnect();\n this.set(freq, res);\n this.biquad.gain.value = 0;\n delete this.input;\n delete this.output;\n delete this._drywet;\n delete this.wet;\n }\n\n amp() {\n console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');\n }\n\n drywet() {\n console.warn('`drywet()` is not available for p5.EQ bands.');\n }\n\n connect(unit) {\n var u = unit || p5.soundOut.input;\n if (this.biquad) {\n this.biquad.connect(u.input ? u.input : u);\n } else {\n this.output.connect(u.input ? u.input : u);\n }\n }\n disconnect() {\n if (this.biquad) {\n this.biquad.disconnect();\n }\n }\n\n dispose() {\n // remove reference form soundArray\n const index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n this.disconnect();\n delete this.biquad;\n }\n}\n\nexport default EQFilter;\n","import Effect from './effect';\nimport EQFilter from './eqFilter';\n\n/**\n * p5.EQ is an audio effect that performs the function of a multiband\n * audio equalizer. Equalization is used to adjust the balance of\n * frequency compoenents of an audio signal. This process is commonly used\n * in sound production and recording to change the waveform before it reaches\n * a sound output device. EQ can also be used as an audio effect to create\n * interesting distortions by filtering out parts of the spectrum. p5.EQ is\n * built using a chain of Web Audio Biquad Filter Nodes and can be\n * instantiated with 3 or 8 bands. Bands can be added or removed from\n * the EQ by directly modifying p5.EQ.bands (the array that stores filters).\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.EQ\n * @constructor\n * @extends p5.Effect\n * @param {Number} [_eqsize] Constructor will accept 3 or 8, defaults to 3\n * @return {Object} p5.EQ object\n *\n * @example\n *
\n * let eq, soundFile\n * let eqBandIndex = 0;\n * let eqBandNames = ['lows', 'mids', 'highs'];\n *\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * soundFile = loadSound('assets/beat');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(toggleSound);\n *\n * eq = new p5.EQ(eqBandNames.length);\n * soundFile.disconnect();\n * eq.process(soundFile);\n * }\n *\n * function draw() {\n * background(30);\n * noStroke();\n * fill(255);\n * textAlign(CENTER);\n * text('filtering ', 50, 25);\n *\n * fill(255, 40, 255);\n * textSize(26);\n * text(eqBandNames[eqBandIndex], 50, 55);\n *\n * fill(255);\n * textSize(9);\n *\n * if (!soundFile.isPlaying()) {\n * text('tap to play', 50, 80);\n * } else {\n * text('tap to filter next band', 50, 80)\n * }\n * }\n *\n * function toggleSound() {\n * if (!soundFile.isPlaying()) {\n * soundFile.play();\n * } else {\n * eqBandIndex = (eqBandIndex + 1) % eq.bands.length;\n * }\n *\n * for (let i = 0; i < eq.bands.length; i++) {\n * eq.bands[i].gain(0);\n * }\n * // filter the band we want to filter\n * eq.bands[eqBandIndex].gain(-40);\n * }\n *
\n */\nclass EQ extends Effect {\n constructor(_eqsize) {\n super();\n\n //p5.EQ can be of size (3) or (8), defaults to 3\n _eqsize = _eqsize === 3 || _eqsize === 8 ? _eqsize : 3;\n\n var factor;\n _eqsize === 3 ? (factor = Math.pow(2, 3)) : (factor = 2);\n\n /**\n * The p5.EQ is built with abstracted p5.Filter objects.\n * To modify any bands, use methods of the \n * p5.Filter API, especially `gain` and `freq`.\n * Bands are stored in an array, with indices 0 - 3, or 0 - 7\n * @property {Array} bands\n *\n */\n this.bands = [];\n\n var freq, res;\n for (var i = 0; i < _eqsize; i++) {\n if (i === _eqsize - 1) {\n freq = 21000;\n res = 0.01;\n } else if (i === 0) {\n freq = 100;\n res = 0.1;\n } else if (i === 1) {\n freq = _eqsize === 3 ? 360 * factor : 360;\n res = 1;\n } else {\n freq = this.bands[i - 1].freq() * factor;\n res = 1;\n }\n this.bands[i] = this._newBand(freq, res);\n\n if (i > 0) {\n this.bands[i - 1].connect(this.bands[i].biquad);\n } else {\n this.input.connect(this.bands[i].biquad);\n }\n }\n this.bands[_eqsize - 1].connect(this.output);\n }\n\n /**\n * Process an input by connecting it to the EQ\n * @method process\n * @param {Object} src Audio source\n */\n process(src) {\n src.connect(this.input);\n }\n\n // /**\n // * Set the frequency and gain of each band in the EQ. This method should be\n // * called with 3 or 8 frequency and gain pairs, depending on the size of the EQ.\n // * ex. eq.set(freq0, gain0, freq1, gain1, freq2, gain2);\n // *\n // * @method set\n // * @for p5.EQ\n // * @param {Number} [freq0] Frequency value for band with index 0\n // * @param {Number} [gain0] Gain value for band with index 0\n // * @param {Number} [freq1] Frequency value for band with index 1\n // * @param {Number} [gain1] Gain value for band with index 1\n // * @param {Number} [freq2] Frequency value for band with index 2\n // * @param {Number} [gain2] Gain value for band with index 2\n // * @param {Number} [freq3] Frequency value for band with index 3\n // * @param {Number} [gain3] Gain value for band with index 3\n // * @param {Number} [freq4] Frequency value for band with index 4\n // * @param {Number} [gain4] Gain value for band with index 4\n // * @param {Number} [freq5] Frequency value for band with index 5\n // * @param {Number} [gain5] Gain value for band with index 5\n // * @param {Number} [freq6] Frequency value for band with index 6\n // * @param {Number} [gain6] Gain value for band with index 6\n // * @param {Number} [freq7] Frequency value for band with index 7\n // * @param {Number} [gain7] Gain value for band with index 7\n // */\n set() {\n if (arguments.length === this.bands.length * 2) {\n for (var i = 0; i < arguments.length; i += 2) {\n this.bands[i / 2].freq(arguments[i]);\n this.bands[i / 2].gain(arguments[i + 1]);\n }\n } else {\n console.error(\n 'Argument mismatch. .set() should be called with ' +\n this.bands.length * 2 +\n ' arguments. (one frequency and gain value pair for each band of the eq)'\n );\n }\n }\n\n /**\n * Add a new band. Creates a p5.Filter and strips away everything but\n * the raw biquad filter. This method returns an abstracted p5.Filter,\n * which can be added to p5.EQ.bands, in order to create new EQ bands.\n * @private\n * @for p5.EQ\n * @method _newBand\n * @param {Number} freq\n * @param {Number} res\n * @return {Object} Abstracted Filter\n */\n _newBand(freq, res) {\n return new EQFilter(freq, res);\n }\n\n dispose() {\n super.dispose();\n\n if (this.bands) {\n while (this.bands.length > 0) {\n delete this.bands.pop().dispose();\n }\n delete this.bands;\n }\n }\n}\nexport default EQ;\n","import p5sound from './master';\n\n// /**\n// * listener is a class that can construct both a Spatial Panner\n// * and a Spatial Listener. The panner is based on the\n// * Web Audio Spatial Panner Node\n// * https://www.w3.org/TR/webaudio/#the-listenernode-interface\n// * This panner is a spatial processing node that allows audio to be positioned\n// * and oriented in 3D space.\n// *\n// * The Listener modifies the properties of the Audio Context Listener.\n// * Both objects types use the same methods. The default is a spatial panner.\n// *\n// * p5.Panner3D - Constructs a Spatial Panner
\n// * p5.Listener3D - Constructs a Spatial Listener
\n// *\n// * @class listener\n// * @constructor\n// * @return {Object} p5.Listener3D Object\n// *\n// * @param {Web Audio Node} listener Web Audio Spatial Panning Node\n// * @param {AudioParam} listener.panningModel \"equal power\" or \"HRTF\"\n// * @param {AudioParam} listener.distanceModel \"linear\", \"inverse\", or \"exponential\"\n// * @param {String} [type] [Specify construction of a spatial panner or listener]\n// */\n\nclass Listener3D {\n constructor(type) {\n this.ac = p5sound.audiocontext;\n this.listener = this.ac.listener;\n }\n\n // /**\n // * Connect an audio sorce\n // * @param {Object} src Input source\n // */\n process(src) {\n src.connect(this.input);\n }\n // /**\n // * Set the X,Y,Z position of the Panner\n // * @param {[Number]} xVal\n // * @param {[Number]} yVal\n // * @param {[Number]} zVal\n // * @param {[Number]} time\n // * @return {[Array]} [Updated x, y, z values as an array]\n // */\n position(xVal, yVal, zVal, time) {\n this.positionX(xVal, time);\n this.positionY(yVal, time);\n this.positionZ(zVal, time);\n return [\n this.listener.positionX.value,\n this.listener.positionY.value,\n this.listener.positionZ.value,\n ];\n }\n\n // /**\n // * Getter and setter methods for position coordinates\n // * @return {Number} [updated coordinate value]\n // */\n positionX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.positionX.value = xVal;\n this.listener.positionX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.positionX);\n }\n return this.listener.positionX.value;\n }\n positionY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.positionY.value = yVal;\n this.listener.positionY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.positionY);\n }\n return this.listener.positionY.value;\n }\n positionZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.positionZ.value = zVal;\n this.listener.positionZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.positionZ);\n }\n return this.listener.positionZ.value;\n }\n\n // cannot define method when class definition is commented\n // /**\n // * Overrides the listener orient() method because Listener has slightly\n // * different params. In human terms, Forward vectors are the direction the\n // * nose is pointing. Up vectors are the direction of the top of the head.\n // *\n // * @method orient\n // * @param {Number} xValF Forward vector X direction\n // * @param {Number} yValF Forward vector Y direction\n // * @param {Number} zValF Forward vector Z direction\n // * @param {Number} xValU Up vector X direction\n // * @param {Number} yValU Up vector Y direction\n // * @param {Number} zValU Up vector Z direction\n // * @param {Number} time\n // * @return {Array} All orienation params\n // */\n orient(xValF, yValF, zValF, xValU, yValU, zValU, time) {\n if (arguments.length === 3 || arguments.length === 4) {\n time = arguments[3];\n this.orientForward(xValF, yValF, zValF, time);\n } else if (arguments.length === 6 || arguments === 7) {\n this.orientForward(xValF, yValF, zValF);\n this.orientUp(xValU, yValU, zValU, time);\n }\n\n return [\n this.listener.forwardX.value,\n this.listener.forwardY.value,\n this.listener.forwardZ.value,\n this.listener.upX.value,\n this.listener.upY.value,\n this.listener.upZ.value,\n ];\n }\n\n orientForward(xValF, yValF, zValF, time) {\n this.forwardX(xValF, time);\n this.forwardY(yValF, time);\n this.forwardZ(zValF, time);\n\n return [\n this.listener.forwardX,\n this.listener.forwardY,\n this.listener.forwardZ,\n ];\n }\n\n orientUp(xValU, yValU, zValU, time) {\n this.upX(xValU, time);\n this.upY(yValU, time);\n this.upZ(zValU, time);\n\n return [this.listener.upX, this.listener.upY, this.listener.upZ];\n }\n // /**\n // * Getter and setter methods for orient coordinates\n // * @return {Number} [updated coordinate value]\n // */\n forwardX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.forwardX.value = xVal;\n this.listener.forwardX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.forwardX);\n }\n return this.listener.forwardX.value;\n }\n forwardY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.forwardY.value = yVal;\n this.listener.forwardY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.forwardY);\n }\n return this.listener.forwardY.value;\n }\n forwardZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.forwardZ.value = zVal;\n this.listener.forwardZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.forwardZ);\n }\n return this.listener.forwardZ.value;\n }\n upX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.upX.value = xVal;\n this.listener.upX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.upX);\n }\n return this.listener.upX.value;\n }\n upY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.upY.value = yVal;\n this.listener.upY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.upY);\n }\n return this.listener.upY.value;\n }\n upZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.upZ.value = zVal;\n this.listener.upZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.upZ);\n }\n return this.listener.upZ.value;\n }\n}\n\nexport default Listener3D;\n","import Effect from './effect';\n\n/**\n * Panner3D is based on the \n * Web Audio Spatial Panner Node.\n * This panner is a spatial processing node that allows audio to be positioned\n * and oriented in 3D space.\n *\n * The position is relative to an \n * Audio Context Listener, which can be accessed\n * by p5.soundOut.audiocontext.listener\n *\n *\n * @class p5.Panner3D\n * @constructor\n */\n\nclass Panner3D extends Effect {\n constructor() {\n super();\n /**\n * \n * Web Audio Spatial Panner Node\n *\n * Properties include
\n * [Panning Model](https://www.w3.org/TR/webaudio/#idl-def-PanningModelType)\n * : \"equal power\" or \"HRTF\"
\n * [DistanceModel](https://www.w3.org/TR/webaudio/#idl-def-DistanceModelType)\n * : \"linear\", \"inverse\", or \"exponential\"\n *\n * @property {AudioNode} panner\n *\n */\n this.panner = this.ac.createPanner();\n this.panner.panningModel = 'HRTF';\n this.panner.distanceModel = 'linear';\n this.panner.connect(this.output);\n this.input.connect(this.panner);\n }\n\n /**\n * Connect an audio sorce\n *\n * @method process\n * @for p5.Panner3D\n * @param {Object} src Input source\n */\n process(src) {\n src.connect(this.input);\n }\n /**\n * Set the X,Y,Z position of the Panner\n * @method set\n * @for p5.Panner3D\n * @param {Number} xVal\n * @param {Number} yVal\n * @param {Number} zVal\n * @param {Number} time\n * @return {Array} Updated x, y, z values as an array\n */\n set(xVal, yVal, zVal, time) {\n this.positionX(xVal, time);\n this.positionY(yVal, time);\n this.positionZ(zVal, time);\n return [\n this.panner.positionX.value,\n this.panner.positionY.value,\n this.panner.positionZ.value,\n ];\n }\n\n /**\n * Getter and setter methods for position coordinates\n * @method positionX\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for position coordinates\n * @method positionY\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for position coordinates\n * @method positionZ\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n positionX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.positionX.value = xVal;\n this.panner.positionX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.panner.positionX);\n }\n return this.panner.positionX.value;\n }\n positionY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.positionY.value = yVal;\n this.panner.positionY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.panner.positionY);\n }\n return this.panner.positionY.value;\n }\n positionZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.positionZ.value = zVal;\n this.panner.positionZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.panner.positionZ);\n }\n return this.panner.positionZ.value;\n }\n\n /**\n * Set the X,Y,Z position of the Panner\n * @method orient\n * @for p5.Panner3D\n * @param {Number} xVal\n * @param {Number} yVal\n * @param {Number} zVal\n * @param {Number} time\n * @return {Array} Updated x, y, z values as an array\n */\n orient(xVal, yVal, zVal, time) {\n this.orientX(xVal, time);\n this.orientY(yVal, time);\n this.orientZ(zVal, time);\n return [\n this.panner.orientationX.value,\n this.panner.orientationY.value,\n this.panner.orientationZ.value,\n ];\n }\n\n /**\n * Getter and setter methods for orient coordinates\n * @method orientX\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for orient coordinates\n * @method orientY\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for orient coordinates\n * @method orientZ\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n orientX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.orientationX.value = xVal;\n this.panner.orientationX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.panner.orientationX);\n }\n return this.panner.orientationX.value;\n }\n orientY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.orientationY.value = yVal;\n this.panner.orientationY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.panner.orientationY);\n }\n return this.panner.orientationY.value;\n }\n orientZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.orientationZ.value = zVal;\n this.panner.orientationZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.panner.orientationZ);\n }\n return this.panner.orientationZ.value;\n }\n\n /**\n * Set the rolloff factor and max distance\n * @method setFalloff\n * @for p5.Panner3D\n * @param {Number} [maxDistance]\n * @param {Number} [rolloffFactor]\n */\n setFalloff(maxDistance, rolloffFactor) {\n this.maxDist(maxDistance);\n this.rolloff(rolloffFactor);\n }\n /**\n * Maxium distance between the source and the listener\n * @method maxDist\n * @for p5.Panner3D\n * @param {Number} maxDistance\n * @return {Number} updated value\n */\n maxDist(maxDistance) {\n if (typeof maxDistance === 'number') {\n this.panner.maxDistance = maxDistance;\n }\n return this.panner.maxDistance;\n }\n\n /**\n * How quickly the volume is reduced as the source moves away from the listener\n * @method rollof\n * @for p5.Panner3D\n * @param {Number} rolloffFactor\n * @return {Number} updated value\n */\n rolloff(rolloffFactor) {\n if (typeof rolloffFactor === 'number') {\n this.panner.rolloffFactor = rolloffFactor;\n }\n return this.panner.rolloffFactor;\n }\n\n dispose() {\n super.dispose();\n if (this.panner) {\n this.panner.disconnect();\n delete this.panner;\n }\n }\n}\n\nexport default Panner3D;\n","import Filter from './filter';\nimport Effect from './effect';\n\n/**\n * Delay is an echo effect. It processes an existing sound source,\n * and outputs a delayed version of that sound. The p5.Delay can\n * produce different effects depending on the delayTime, feedback,\n * filter, and type. In the example below, a feedback of 0.5 (the\n * default value) will produce a looping delay that decreases in\n * volume by 50% each repeat. A filter will cut out the high\n * frequencies so that the delay does not sound as piercing as the\n * original source.\n *\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n * @class p5.Delay\n * @extends p5.Effect\n * @constructor\n * @example\n *
\n * let osc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * osc = new p5.Oscillator('square');\n * osc.amp(0.5);\n * delay = new p5.Delay();\n *\n * // delay.process() accepts 4 parameters:\n * // source, delayTime (in seconds), feedback, filter frequency\n * delay.process(osc, 0.12, .7, 2300);\n *\n * cnv.mousePressed(oscStart);\n * }\n *\n * function oscStart() {\n * osc.start();\n * }\n *\n * function mouseReleased() {\n * osc.stop();\n * }\n *
\n */\nclass Delay extends Effect {\n constructor() {\n super();\n\n this._split = this.ac.createChannelSplitter(2);\n this._merge = this.ac.createChannelMerger(2);\n\n this._leftGain = this.ac.createGain();\n this._rightGain = this.ac.createGain();\n /**\n * The p5.Delay is built with two\n * \n * Web Audio Delay Nodes, one for each stereo channel.\n *\n * @for p5.Delay\n * @property {DelayNode} leftDelay\n */\n this.leftDelay = this.ac.createDelay();\n /**\n * The p5.Delay is built with two\n * \n * Web Audio Delay Nodes, one for each stereo channel.\n * @for p5.Delay\n * @property {DelayNode} rightDelay\n */\n this.rightDelay = this.ac.createDelay();\n\n this._leftFilter = new Filter();\n this._rightFilter = new Filter();\n this._leftFilter.disconnect();\n this._rightFilter.disconnect();\n\n this._leftFilter.biquad.frequency.setValueAtTime(1200, this.ac.currentTime);\n this._rightFilter.biquad.frequency.setValueAtTime(\n 1200,\n this.ac.currentTime\n );\n this._leftFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\n this._rightFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\n\n // graph routing\n this.input.connect(this._split);\n this.leftDelay.connect(this._leftGain);\n this.rightDelay.connect(this._rightGain);\n this._leftGain.connect(this._leftFilter.input);\n this._rightGain.connect(this._rightFilter.input);\n this._merge.connect(this.wet);\n\n this._leftFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\n this._rightFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\n\n // default routing\n this.setType(0);\n\n this._maxDelay = this.leftDelay.delayTime.maxValue;\n\n // set initial feedback to 0.5\n this.feedback(0.5);\n }\n /**\n * Add delay to an audio signal according to a set\n * of delay parameters.\n *\n * @method process\n * @for p5.Delay\n * @param {Object} Signal An object that outputs audio\n * @param {Number} [delayTime] Time (in seconds) of the delay/echo.\n * Some browsers limit delayTime to\n * 1 second.\n * @param {Number} [feedback] sends the delay back through itself\n * in a loop that decreases in volume\n * each time.\n * @param {Number} [lowPass] Cutoff frequency. Only frequencies\n * below the lowPass will be part of the\n * delay.\n */\n process(src, _delayTime, _feedback, _filter) {\n var feedback = _feedback || 0;\n var delayTime = _delayTime || 0;\n if (feedback >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n }\n if (delayTime >= this._maxDelay) {\n throw new Error(\n 'Delay Time exceeds maximum delay time of ' +\n this._maxDelay +\n ' second.'\n );\n }\n\n src.connect(this.input);\n this.leftDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\n this.rightDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\n this._leftGain.gain.value = feedback;\n this._rightGain.gain.value = feedback;\n\n if (_filter) {\n this._leftFilter.freq(_filter);\n this._rightFilter.freq(_filter);\n }\n }\n\n /**\n * Set the delay (echo) time, in seconds. Usually this value will be\n * a floating point number between 0.0 and 1.0.\n *\n * @method delayTime\n * @for p5.Delay\n * @param {Number} delayTime Time (in seconds) of the delay\n */\n delayTime(t) {\n // if t is an audio node...\n if (typeof t !== 'number') {\n t.connect(this.leftDelay.delayTime);\n t.connect(this.rightDelay.delayTime);\n } else {\n this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\n this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\n this.leftDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\n this.rightDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\n }\n }\n\n /**\n * Feedback occurs when Delay sends its signal back through its input\n * in a loop. The feedback amount determines how much signal to send each\n * time through the loop. A feedback greater than 1.0 is not desirable because\n * it will increase the overall output each time through the loop,\n * creating an infinite feedback loop. The default value is 0.5\n *\n * @method feedback\n * @for p5.Delay\n * @param {Number|Object} feedback 0.0 to 1.0, or an object such as an\n * Oscillator that can be used to\n * modulate this param\n * @returns {Number} Feedback value\n *\n */\n feedback(f) {\n // if f is an audio node...\n if (f && typeof f !== 'number') {\n f.connect(this._leftGain.gain);\n f.connect(this._rightGain.gain);\n } else if (f >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n } else if (typeof f === 'number') {\n this._leftGain.gain.value = f;\n this._rightGain.gain.value = f;\n }\n\n // return value of feedback\n return this._leftGain.gain.value;\n }\n\n /**\n * Set a lowpass filter frequency for the delay. A lowpass filter\n * will cut off any frequencies higher than the filter frequency.\n *\n * @method filter\n * @for p5.Delay\n * @param {Number|Object} cutoffFreq A lowpass filter will cut off any\n * frequencies higher than the filter frequency.\n * @param {Number|Object} res Resonance of the filter frequency\n * cutoff, or an object (i.e. a p5.Oscillator)\n * that can be used to modulate this parameter.\n * High numbers (i.e. 15) will produce a resonance,\n * low numbers (i.e. .2) will produce a slope.\n */\n filter(freq, q) {\n this._leftFilter.set(freq, q);\n this._rightFilter.set(freq, q);\n }\n\n /**\n * Choose a preset type of delay. 'pingPong' bounces the signal\n * from the left to the right channel to produce a stereo effect.\n * Any other parameter will revert to the default delay setting.\n *\n * @method setType\n * @for p5.Delay\n * @param {String|Number} type 'pingPong' (1) or 'default' (0)\n */\n setType(t) {\n if (t === 1) {\n t = 'pingPong';\n }\n this._split.disconnect();\n this._leftFilter.disconnect();\n this._rightFilter.disconnect();\n this._split.connect(this.leftDelay, 0);\n this._split.connect(this.rightDelay, 1);\n switch (t) {\n case 'pingPong':\n this._rightFilter.setType(this._leftFilter.biquad.type);\n this._leftFilter.output.connect(this._merge, 0, 0);\n this._rightFilter.output.connect(this._merge, 0, 1);\n this._leftFilter.output.connect(this.rightDelay);\n this._rightFilter.output.connect(this.leftDelay);\n break;\n default:\n this._leftFilter.output.connect(this._merge, 0, 0);\n this._rightFilter.output.connect(this._merge, 0, 1);\n this._leftFilter.output.connect(this.leftDelay);\n this._rightFilter.output.connect(this.rightDelay);\n }\n }\n\n // DocBlocks for methods inherited from p5.Effect\n /**\n * Set the output level of the delay effect.\n *\n * @method amp\n * @for p5.Delay\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Delay\n * @param {Object} unit\n */\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Delay\n */\n\n dispose() {\n super.dispose();\n\n this._split.disconnect();\n this._leftFilter.dispose();\n this._rightFilter.dispose();\n this._merge.disconnect();\n this._leftGain.disconnect();\n this._rightGain.disconnect();\n this.leftDelay.disconnect();\n this.rightDelay.disconnect();\n\n this._split = undefined;\n this._leftFilter = undefined;\n this._rightFilter = undefined;\n this._merge = undefined;\n this._leftGain = undefined;\n this._rightGain = undefined;\n this.leftDelay = undefined;\n this.rightDelay = undefined;\n }\n}\n\nexport default Delay;\n","import { getAudioContext } from './audiocontext';\nimport CustomError from './errorHandler';\nimport Effect from './effect';\n\n/**\n * Reverb adds depth to a sound through a large number of decaying\n * echoes. It creates the perception that sound is occurring in a\n * physical space. The p5.Reverb has paramters for Time (how long does the\n * reverb last) and decayRate (how much the sound decays with each echo)\n * that can be set with the .set() or .process() methods. The p5.Convolver\n * extends p5.Reverb allowing you to recreate the sound of actual physical\n * spaces through convolution.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Reverb\n * @extends p5.Effect\n * @constructor\n * @example\n *
\n * let soundFile, reverb;\n * function preload() {\n * soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n *\n * reverb = new p5.Reverb();\n * soundFile.disconnect(); // so we'll only hear reverb...\n *\n * // connect soundFile to reverb, process w/\n * // 3 second reverbTime, decayRate of 2%\n * reverb.process(soundFile, 3, 2);\n * }\n *\n * function draw() {\n * let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);\n * // 1 = all reverb, 0 = no reverb\n * reverb.drywet(dryWet);\n *\n * background(220);\n * text('tap to play', 10, 20);\n * text('dry/wet: ' + round(dryWet * 100) + '%', 10, height - 20);\n * }\n *\n * function playSound() {\n * soundFile.play();\n * }\n *
\n */\n\nclass Reverb extends Effect {\n constructor() {\n super();\n this._initConvolverNode();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n\n // default params\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n _initConvolverNode() {\n this.convolverNode = this.ac.createConvolver();\n this.input.connect(this.convolverNode);\n this.convolverNode.connect(this.wet);\n }\n\n _teardownConvolverNode() {\n if (this.convolverNode) {\n this.convolverNode.disconnect();\n delete this.convolverNode;\n }\n }\n\n _setBuffer(audioBuffer) {\n this._teardownConvolverNode();\n this._initConvolverNode();\n this.convolverNode.buffer = audioBuffer;\n }\n /**\n * Connect a source to the reverb, and assign reverb parameters.\n *\n * @method process\n * @for p5.Reverb\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n * @param {Number} [seconds] Duration of the reverb, in seconds.\n * Min: 0, Max: 10. Defaults to 3.\n * @param {Number} [decayRate] Percentage of decay with each echo.\n * Min: 0, Max: 100. Defaults to 2.\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\n */\n process(src, seconds, decayRate, reverse) {\n src.connect(this.input);\n var rebuild = false;\n if (seconds) {\n this._seconds = seconds;\n rebuild = true;\n }\n if (decayRate) {\n this._decay = decayRate;\n }\n if (reverse) {\n this._reverse = reverse;\n }\n if (rebuild) {\n this._buildImpulse();\n }\n }\n\n /**\n * Set the reverb settings. Similar to .process(), but without\n * assigning a new input.\n *\n * @method set\n * @for p5.Reverb\n * @param {Number} [seconds] Duration of the reverb, in seconds.\n * Min: 0, Max: 10. Defaults to 3.\n * @param {Number} [decayRate] Percentage of decay with each echo.\n * Min: 0, Max: 100. Defaults to 2.\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\n */\n set(seconds, decayRate, reverse) {\n var rebuild = false;\n if (seconds) {\n this._seconds = seconds;\n rebuild = true;\n }\n if (decayRate) {\n this._decay = decayRate;\n }\n if (reverse) {\n this._reverse = reverse;\n }\n if (rebuild) {\n this._buildImpulse();\n }\n }\n\n // DocBlocks for methods inherited from p5.Effect\n /**\n * Set the output level of the reverb effect.\n *\n * @method amp\n * @for p5.Reverb\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Reverb\n * @param {Object} unit\n */\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Reverb\n */\n\n /**\n * Inspired by Simple Reverb by Jordan Santell\n * https://github.com/web-audio-components/simple-reverb/blob/master/index.js\n *\n * Utility function for building an impulse response\n * based on the module parameters.\n *\n * @private\n */\n _buildImpulse() {\n var rate = this.ac.sampleRate;\n var length = rate * this._seconds;\n var decay = this._decay;\n var impulse = this.ac.createBuffer(2, length, rate);\n var impulseL = impulse.getChannelData(0);\n var impulseR = impulse.getChannelData(1);\n var n, i;\n for (i = 0; i < length; i++) {\n n = this._reverse ? length - i : i;\n impulseL[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\n impulseR[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\n }\n this._setBuffer(impulse);\n }\n\n dispose() {\n super.dispose();\n this._teardownConvolverNode();\n }\n}\n\n// =======================================================================\n// *** p5.Convolver ***\n// =======================================================================\n\n/**\n *

p5.Convolver extends p5.Reverb. It can emulate the sound of real\n * physical spaces through a process called \n * convolution.

\n *\n *

Convolution multiplies any audio input by an \"impulse response\"\n * to simulate the dispersion of sound over time. The impulse response is\n * generated from an audio file that you provide. One way to\n * generate an impulse response is to pop a balloon in a reverberant space\n * and record the echo. Convolution can also be used to experiment with\n * sound.

\n *\n *

Use the method createConvolution(path) to instantiate a\n * p5.Convolver with a path to your impulse response audio file.

\n *\n * @class p5.Convolver\n * @extends p5.Effect\n * @constructor\n * @param {String} path path to a sound file\n * @param {Function} [callback] function to call when loading succeeds\n * @param {Function} [errorCallback] function to call if loading fails.\n * This function will receive an error or\n * XMLHttpRequest object with information\n * about what went wrong.\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from master output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *
\n */\nclass Convolver extends Reverb {\n constructor(path, callback, errorCallback) {\n super();\n /**\n * Internally, the p5.Convolver uses the a\n * \n * Web Audio Convolver Node.\n *\n * @property {ConvolverNode} convolverNode\n */\n this._initConvolverNode();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n\n if (path) {\n this.impulses = [];\n this._loadBuffer(path, callback, errorCallback);\n } else {\n // parameters\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n /**\n * If you load multiple impulse files using the .addImpulse method,\n * they will be stored as Objects in this Array. Toggle between them\n * with the toggleImpulse(id) method.\n *\n * @property {Array} impulses\n * @for p5.Convolver\n */\n this.impulses = [];\n this.set = null;\n }\n\n /**\n * Private method to load a buffer as an Impulse Response,\n * assign it to the convolverNode, and add to the Array of .impulses.\n *\n * @param {String} path\n * @param {Function} callback\n * @param {Function} errorCallback\n * @private\n */\n _loadBuffer(_path, callback, errorCallback) {\n var path = p5.prototype._checkFileFormats(_path);\n var self = this;\n var errorTrace = new Error().stack;\n var ac = getAudioContext();\n\n var request = new XMLHttpRequest();\n request.open('GET', path, true);\n request.responseType = 'arraybuffer';\n\n request.onload = function () {\n if (request.status === 200) {\n // on success loading file:\n ac.decodeAudioData(\n request.response,\n function (buff) {\n var buffer = {};\n var chunks = path.split('/');\n buffer.name = chunks[chunks.length - 1];\n buffer.audioBuffer = buff;\n self.impulses.push(buffer);\n self._setBuffer(buffer.audioBuffer);\n if (callback) {\n callback(buffer);\n }\n },\n // error decoding buffer. \"e\" is undefined in Chrome 11/22/2015\n function () {\n var err = new CustomError('decodeAudioData', errorTrace, self.url);\n var msg = 'AudioContext error at decodeAudioData for ' + self.url;\n if (errorCallback) {\n err.msg = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n );\n }\n // if request status != 200, it failed\n else {\n var err = new CustomError('loadConvolver', errorTrace, self.url);\n var msg =\n 'Unable to load ' +\n self.url +\n '. The request status was: ' +\n request.status +\n ' (' +\n request.statusText +\n ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n };\n\n // if there is another error, aside from 404...\n request.onerror = function () {\n var err = new CustomError('loadConvolver', errorTrace, self.url);\n var msg =\n 'There was no response from the server at ' +\n self.url +\n '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n };\n request.send();\n }\n\n /**\n * Connect a source to the convolver.\n *\n * @method process\n * @for p5.Convolver\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from master output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *\n *
\n */\n process(src) {\n src.connect(this.input);\n }\n\n /**\n * Load and assign a new Impulse Response to the p5.Convolver.\n * The impulse is added to the .impulses array. Previous\n * impulses can be accessed with the .toggleImpulse(id)\n * method.\n *\n * @method addImpulse\n * @for p5.Convolver\n * @param {String} path path to a sound file\n * @param {Function} callback function (optional)\n * @param {Function} errorCallback function (optional)\n */\n addImpulse(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n this._loadBuffer(path, callback, errorCallback);\n }\n\n /**\n * Similar to .addImpulse, except that the .impulses\n * Array is reset to save memory. A new .impulses\n * array is created with this impulse as the only item.\n *\n * @method resetImpulse\n * @for p5.Convolver\n * @param {String} path path to a sound file\n * @param {Function} callback function (optional)\n * @param {Function} errorCallback function (optional)\n */\n resetImpulse(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n this.impulses = [];\n this._loadBuffer(path, callback, errorCallback);\n }\n\n /**\n * If you have used .addImpulse() to add multiple impulses\n * to a p5.Convolver, then you can use this method to toggle between\n * the items in the .impulses Array. Accepts a parameter\n * to identify which impulse you wish to use, identified either by its\n * original filename (String) or by its position in the .impulses\n * Array (Number).
\n * You can access the objects in the .impulses Array directly. Each\n * Object has two attributes: an .audioBuffer (type:\n * Web Audio \n * AudioBuffer) and a .name, a String that corresponds\n * with the original filename.\n *\n * @method toggleImpulse\n * @for p5.Convolver\n * @param {String|Number} id Identify the impulse by its original filename\n * (String), or by its position in the\n * .impulses Array (Number).\n */\n toggleImpulse(id) {\n if (typeof id === 'number' && id < this.impulses.length) {\n this._setBuffer(this.impulses[id].audioBuffer);\n }\n if (typeof id === 'string') {\n for (var i = 0; i < this.impulses.length; i++) {\n if (this.impulses[i].name === id) {\n this._setBuffer(this.impulses[i].audioBuffer);\n break;\n }\n }\n }\n }\n\n dispose() {\n super.dispose();\n\n // remove all the Impulse Response buffers\n for (var i in this.impulses) {\n if (this.impulses[i]) {\n this.impulses[i] = null;\n }\n }\n }\n}\n\n/**\n * Create a p5.Convolver. Accepts a path to a soundfile\n * that will be used to generate an impulse response.\n *\n * @method createConvolver\n * @for p5\n * @param {String} path path to a sound file\n * @param {Function} [callback] function to call if loading is successful.\n * The object will be passed in as the argument\n * to the callback function.\n * @param {Function} [errorCallback] function to call if loading is not successful.\n * A custom error will be passed in as the argument\n * to the callback function.\n * @return {p5.Convolver}\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from master output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *
\n */\nfunction createConvolver(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n var self = this;\n var cReverb = new Convolver(\n path,\n function (buffer) {\n if (typeof callback === 'function') {\n callback(buffer);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n },\n errorCallback\n );\n cReverb.impulses = [];\n return cReverb;\n}\n\nexport { Reverb, Convolver, createConvolver };\n","import p5sound from './master';\n// requires the Tone.js library's Clock (MIT license, Yotam Mann)\n// https://github.com/TONEnoTONE/Tone.js/\nimport Clock from 'Tone/core/Clock';\n\nclass Metro {\n constructor() {\n this.clock = new Clock({\n callback: this.ontick.bind(this),\n });\n this.syncedParts = [];\n this.bpm = 120; // gets overridden by p5.Part\n this._init();\n\n this.prevTick = 0;\n this.tatumTime = 0;\n\n this.tickCallback = function () {};\n }\n\n ontick(tickTime) {\n var elapsedTime = tickTime - this.prevTick;\n var secondsFromNow = tickTime - p5sound.audiocontext.currentTime;\n if (elapsedTime - this.tatumTime <= -0.02) {\n return;\n } else {\n // console.log('ok', this.syncedParts[0].phrases[0].name);\n this.prevTick = tickTime;\n\n // for all of the active things on the metro:\n var self = this;\n this.syncedParts.forEach(function (thisPart) {\n if (!thisPart.isPlaying) return;\n thisPart.incrementStep(secondsFromNow);\n // each synced source keeps track of its own beat number\n thisPart.phrases.forEach(function (thisPhrase) {\n var phraseArray = thisPhrase.sequence;\n var bNum = self.metroTicks % phraseArray.length;\n if (\n phraseArray[bNum] !== 0 &&\n (self.metroTicks < phraseArray.length || !thisPhrase.looping)\n ) {\n thisPhrase.callback(secondsFromNow, phraseArray[bNum]);\n }\n });\n });\n this.metroTicks += 1;\n this.tickCallback(secondsFromNow);\n }\n }\n\n setBPM(bpm, rampTime = 0) {\n var beatTime = 60 / (bpm * this.tatums);\n var now = p5sound.audiocontext.currentTime;\n this.tatumTime = beatTime;\n\n this.clock.frequency.setValueAtTime(this.clock.frequency.value, now);\n this.clock.frequency.linearRampToValueAtTime(bpm, now + rampTime);\n this.bpm = bpm;\n }\n\n getBPM() {\n return (this.clock.getRate() / this.tatums) * 60;\n }\n\n _init() {\n this.metroTicks = 0;\n // this.setBPM(120);\n }\n\n // clear existing synced parts, add only this one\n resetSync(part) {\n this.syncedParts = [part];\n }\n\n // push a new synced part to the array\n pushSync(part) {\n this.syncedParts.push(part);\n }\n\n start(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.start(now + t);\n this.setBPM(this.bpm);\n }\n\n stop(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.stop(now + t);\n }\n\n beatLength(tatums) {\n this.tatums = 1 / tatums / 4; // lowest possible division of a beat\n }\n}\nexport default Metro;\n","import p5sound from './master';\nimport Metro from './metro';\n\nvar BPM = 120;\n\n/**\n * Set the global tempo, in beats per minute, for all\n * p5.Parts. This method will impact all active p5.Parts.\n *\n * @method setBPM\n * @for p5\n * @param {Number} BPM Beats Per Minute\n * @param {Number} rampTime Seconds from now\n */\np5.prototype.setBPM = function (bpm, rampTime) {\n BPM = bpm;\n for (var i in p5sound.parts) {\n if (p5sound.parts[i]) {\n p5sound.parts[i].setBPM(bpm, rampTime);\n }\n }\n};\n\n/**\n *

A phrase is a pattern of musical events over time, i.e.\n * a series of notes and rests.

\n *\n *

Phrases must be added to a p5.Part for playback, and\n * each part can play multiple phrases at the same time.\n * For example, one Phrase might be a kick drum, another\n * could be a snare, and another could be the bassline.

\n *\n *

The first parameter is a name so that the phrase can be\n * modified or deleted later. The callback is a a function that\n * this phrase will call at every step—for example it might be\n * called playNote(value){}. The array determines\n * which value is passed into the callback at each step of the\n * phrase. It can be numbers, an object with multiple numbers,\n * or a zero (0) indicates a rest so the callback won't be called).

\n *\n * @class p5.Phrase\n * @constructor\n * @param {String} name Name so that you can access the Phrase.\n * @param {Function} callback The name of a function that this phrase\n * will call. Typically it will play a sound,\n * and accept two parameters: a time at which\n * to play the sound (in seconds from now),\n * and a value from the sequence array. The\n * time should be passed into the play() or\n * start() method to ensure precision.\n * @param {Array} sequence Array of values to pass into the callback\n * at each step of the phrase.\n * @example\n *
\n * let mySound, myPhrase, myPart;\n * let pattern = [1,0,0,2,0,2,0,0];\n *\n * function preload() {\n * mySound = loadSound('assets/beatbox.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playMyPart);\n * background(220);\n * text('tap to play', width/2, height/2);\n * textAlign(CENTER, CENTER);\n *\n * myPhrase = new p5.Phrase('bbox', onEachStep, pattern);\n * myPart = new p5.Part();\n * myPart.addPhrase(myPhrase);\n * myPart.setBPM(60);\n * }\n *\n * function onEachStep(time, playbackRate) {\n * mySound.rate(playbackRate);\n * mySound.play(time);\n * }\n *\n * function playMyPart() {\n * userStartAudio();\n * myPart.start();\n * }\n *
\n */\nclass Phrase {\n constructor(name, callback, sequence) {\n this.phraseStep = 0;\n this.name = name;\n this.callback = callback;\n /**\n * Array of values to pass into the callback\n * at each step of the phrase. Depending on the callback\n * function's requirements, these values may be numbers,\n * strings, or an object with multiple parameters.\n * Zero (0) indicates a rest.\n *\n * @property {Array} sequence\n */\n this.sequence = sequence;\n }\n}\n\n/**\n *

A p5.Part plays back one or more p5.Phrases. Instantiate a part\n * with steps and tatums. By default, each step represents a 1/16th note.

\n *\n *

See p5.Phrase for more about musical timing.

\n *\n * @class p5.Part\n * @constructor\n * @param {Number} [steps] Steps in the part\n * @param {Number} [tatums] Divisions of a beat, e.g. use 1/4, or 0.25 for a quater note (default is 1/16, a sixteenth note)\n * @example\n *
\n * let box, drum, myPart;\n * let boxPat = [1,0,0,2,0,2,0,0];\n * let drumPat = [0,1,1,0,2,0,1,0];\n *\n * function preload() {\n * box = loadSound('assets/beatbox.mp3');\n * drum = loadSound('assets/drum.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playMyPart);\n * background(220);\n * textAlign(CENTER, CENTER);\n * text('tap to play', width/2, height/2);\n *\n * let boxPhrase = new p5.Phrase('box', playBox, boxPat);\n * let drumPhrase = new p5.Phrase('drum', playDrum, drumPat);\n * myPart = new p5.Part();\n * myPart.addPhrase(boxPhrase);\n * myPart.addPhrase(drumPhrase);\n * myPart.setBPM(60);\n * }\n *\n * function playBox(time, playbackRate) {\n * box.rate(playbackRate);\n * box.play(time);\n * }\n *\n * function playDrum(time, playbackRate) {\n * drum.rate(playbackRate);\n * drum.play(time);\n * }\n *\n * function playMyPart() {\n * userStartAudio();\n *\n * myPart.start();\n * }\n *
\n */\nclass Part {\n constructor(steps, bLength) {\n this.length = steps || 0; // how many beats\n this.partStep = 0;\n this.phrases = [];\n this.isPlaying = false;\n this.noLoop();\n this.tatums = bLength || 0.0625; // defaults to quarter note\n\n this.metro = new Metro();\n this.metro._init();\n this.metro.beatLength(this.tatums);\n this.metro.setBPM(BPM);\n p5sound.parts.push(this);\n this.callback = function () {};\n }\n\n /**\n * Set the tempo of this part, in Beats Per Minute.\n *\n * @method setBPM\n * @for p5.Part\n * @param {Number} BPM Beats Per Minute\n * @param {Number} [rampTime] Seconds from now\n */\n setBPM(tempo, rampTime) {\n this.metro.setBPM(tempo, rampTime);\n }\n\n /**\n * Returns the tempo, in Beats Per Minute, of this part.\n *\n * @method getBPM\n * @for p5.Part\n * @return {Number}\n */\n getBPM() {\n return this.metro.getBPM();\n }\n\n /**\n * Start playback of this part. It will play\n * through all of its phrases at a speed\n * determined by setBPM.\n *\n * @method start\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n start(time) {\n if (!this.isPlaying) {\n this.isPlaying = true;\n this.metro.resetSync(this);\n var t = time || 0;\n this.metro.start(t);\n }\n }\n\n /**\n * Loop playback of this part. It will begin\n * looping through all of its phrases at a speed\n * determined by setBPM.\n *\n * @method loop\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n loop(time) {\n this.looping = true;\n // rest onended function\n this.onended = function () {\n this.partStep = 0;\n };\n var t = time || 0;\n this.start(t);\n }\n\n /**\n * Tell the part to stop looping.\n *\n * @method noLoop\n * @for p5.Part\n */\n noLoop() {\n this.looping = false;\n // rest onended function\n this.onended = function () {\n this.stop();\n };\n }\n\n /**\n * Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.\n *\n * @method stop\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n stop(time) {\n this.partStep = 0;\n this.pause(time);\n }\n\n /**\n * Pause the part. Playback will resume\n * from the current step.\n *\n * @method pause\n * @for p5.Part\n * @param {Number} time seconds from now\n */\n pause(time) {\n this.isPlaying = false;\n var t = time || 0;\n this.metro.stop(t);\n }\n\n /**\n * Add a p5.Phrase to this Part.\n *\n * @method addPhrase\n * @for p5.Part\n * @param {p5.Phrase} phrase reference to a p5.Phrase\n */\n addPhrase(name, callback, array) {\n var p;\n if (arguments.length === 3) {\n p = new Phrase(name, callback, array);\n } else if (arguments[0] instanceof Phrase) {\n p = arguments[0];\n } else {\n throw 'invalid input. addPhrase accepts name, callback, array or a p5.Phrase';\n }\n this.phrases.push(p);\n // reset the length if phrase is longer than part's existing length\n if (p.sequence.length > this.length) {\n this.length = p.sequence.length;\n }\n }\n\n /**\n * Remove a phrase from this part, based on the name it was\n * given when it was created.\n *\n * @method removePhrase\n * @for p5.Part\n * @param {String} phraseName\n */\n removePhrase(name) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n this.phrases.splice(i, 1);\n }\n }\n }\n\n /**\n * Get a phrase from this part, based on the name it was\n * given when it was created. Now you can modify its array.\n *\n * @method getPhrase\n * @for p5.Part\n * @param {String} phraseName\n */\n getPhrase(name) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n return this.phrases[i];\n }\n }\n }\n\n /**\n * Find all sequences with the specified name, and replace their patterns with the specified array.\n *\n * @method replaceSequence\n * @for p5.Part\n * @param {String} phraseName\n * @param {Array} sequence Array of values to pass into the callback\n * at each step of the phrase.\n */\n replaceSequence(name, array) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n this.phrases[i].sequence = array;\n }\n }\n }\n\n incrementStep(time) {\n if (this.partStep < this.length - 1) {\n this.callback(time);\n this.partStep += 1;\n } else {\n if (!this.looping && this.partStep === this.length - 1) {\n // this.callback(time);\n this.onended();\n }\n }\n }\n\n /**\n * Set the function that will be called at every step. This will clear the previous function.\n *\n * @method onStep\n * @for p5.Part\n * @param {Function} callback The name of the callback\n * you want to fire\n * on every beat/tatum.\n */\n onStep(callback) {\n this.callback = callback;\n }\n}\n\n// ===============\n// p5.Score\n// ===============\n\n/**\n * A Score consists of a series of Parts. The parts will\n * be played back in order. For example, you could have an\n * A part, a B part, and a C part, and play them back in this order\n * new p5.Score(a, a, b, a, c)\n *\n * @class p5.Score\n * @constructor\n * @param {p5.Part} [...parts] One or multiple parts, to be played in sequence.\n */\nclass Score {\n constructor() {\n // for all of the arguments\n this.parts = [];\n this.currentPart = 0;\n\n var thisScore = this;\n for (var i in arguments) {\n if (arguments[i] && this.parts[i]) {\n this.parts[i] = arguments[i];\n this.parts[i].nextPart = this.parts[i + 1];\n this.parts[i].onended = function () {\n thisScore.resetPart(i);\n playNextPart(thisScore);\n };\n }\n }\n this.looping = false;\n }\n\n onended() {\n if (this.looping) {\n // this.resetParts();\n this.parts[0].start();\n } else {\n this.parts[this.parts.length - 1].onended = function () {\n this.stop();\n this.resetParts();\n };\n }\n this.currentPart = 0;\n }\n\n /**\n * Start playback of the score.\n *\n * @method start\n * @for p5.Score\n */\n start() {\n this.parts[this.currentPart].start();\n this.scoreStep = 0;\n }\n\n /**\n * Stop playback of the score.\n *\n * @method stop\n * @for p5.Score\n */\n stop() {\n this.parts[this.currentPart].stop();\n this.currentPart = 0;\n this.scoreStep = 0;\n }\n\n /**\n * Pause playback of the score.\n *\n * @method pause\n * @for p5.Score\n */\n pause() {\n this.parts[this.currentPart].stop();\n }\n\n /**\n * Loop playback of the score.\n *\n * @method loop\n * @for p5.Score\n */\n loop() {\n this.looping = true;\n this.start();\n }\n\n /**\n * Stop looping playback of the score. If it\n * is currently playing, this will go into effect\n * after the current round of playback completes.\n *\n * @method noLoop\n * @for p5.Score\n */\n noLoop() {\n this.looping = false;\n }\n\n resetParts() {\n var self = this;\n this.parts.forEach(function (part) {\n self.resetParts[part];\n });\n }\n\n resetPart(i) {\n this.parts[i].stop();\n this.parts[i].partStep = 0;\n for (var p in this.parts[i].phrases) {\n if (this.parts[i]) {\n this.parts[i].phrases[p].phraseStep = 0;\n }\n }\n }\n\n /**\n * Set the tempo for all parts in the score\n *\n * @method setBPM\n * @for p5.Score\n * @param {Number} BPM Beats Per Minute\n * @param {Number} rampTime Seconds from now\n */\n setBPM(bpm, rampTime) {\n for (var i in this.parts) {\n if (this.parts[i]) {\n this.parts[i].setBPM(bpm, rampTime);\n }\n }\n }\n}\n\nfunction playNextPart(aScore) {\n aScore.currentPart++;\n if (aScore.currentPart >= aScore.parts.length) {\n aScore.scoreStep = 0;\n aScore.onended();\n } else {\n aScore.scoreStep = 0;\n aScore.parts[aScore.currentPart - 1].stop();\n aScore.parts[aScore.currentPart].start();\n }\n}\n\nexport { Phrase, Part, Score };\n","import p5sound from './master';\nimport Clock from 'Tone/core/Clock';\n\n/**\n * SoundLoop\n *\n * @class p5.SoundLoop\n * @constructor\n *\n * @param {Function} callback this function will be called on each iteration of theloop\n * @param {Number|String} [interval] amount of time (if a number) or beats (if a string, following Tone.Time convention) for each iteration of the loop. Defaults to 1 second.\n *\n * @example\n *
\n * let synth, soundLoop;\n * let notePattern = [60, 62, 64, 67, 69, 72];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * colorMode(HSB);\n * background(0, 0, 86);\n * text('tap to start/stop', 10, 20);\n *\n * //the looper's callback is passed the timeFromNow\n * //this value should be used as a reference point from\n * //which to schedule sounds\n * let intervalInSeconds = 0.2;\n * soundLoop = new p5.SoundLoop(onSoundLoop, intervalInSeconds);\n *\n * synth = new p5.MonoSynth();\n * }\n *\n * function canvasPressed() {\n * // ensure audio is enabled\n * userStartAudio();\n *\n * if (soundLoop.isPlaying) {\n * soundLoop.stop();\n * } else {\n * // start the loop\n * soundLoop.start();\n * }\n * }\n *\n * function onSoundLoop(timeFromNow) {\n * let noteIndex = (soundLoop.iterations - 1) % notePattern.length;\n * let note = midiToFreq(notePattern[noteIndex]);\n * synth.play(note, 0.5, timeFromNow);\n * background(noteIndex * 360 / notePattern.length, 50, 100);\n * }\n *
\n */\nclass SoundLoop {\n constructor(callback, interval) {\n /**\n * Getters and Setters, setting any paramter will result in a change in the clock's\n * frequency, that will be reflected after the next callback\n * beats per minute (defaults to 60)\n * @property {Number} bpm\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'bpm', {\n get: function () {\n return this._bpm;\n },\n set: function (bpm) {\n if (!this.musicalTimeMode) {\n console.warn(\n 'Changing the BPM in \"seconds\" mode has no effect. ' +\n 'BPM is only relevant in musicalTimeMode ' +\n 'when the interval is specified as a string ' +\n '(\"2n\", \"4n\", \"1m\"...etc)'\n );\n }\n this._bpm = bpm;\n this._update();\n },\n });\n\n /**\n * number of quarter notes in a measure (defaults to 4)\n * @property {Number} timeSignature\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'timeSignature', {\n get: function () {\n return this._timeSignature;\n },\n set: function (timeSig) {\n if (!this.musicalTimeMode) {\n console.warn(\n 'Changing the timeSignature in \"seconds\" mode has no effect. ' +\n 'BPM is only relevant in musicalTimeMode ' +\n 'when the interval is specified as a string ' +\n '(\"2n\", \"4n\", \"1m\"...etc)'\n );\n }\n this._timeSignature = timeSig;\n this._update();\n },\n });\n\n /**\n * length of the loops interval\n * @property {Number|String} interval\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'interval', {\n get: function () {\n return this._interval;\n },\n set: function (interval) {\n this.musicalTimeMode = typeof interval === 'number' ? false : true;\n this._interval = interval;\n this._update();\n },\n });\n\n /**\n * how many times the callback has been called so far\n * @property {Number} iterations\n * @for p5.SoundLoop\n * @readonly\n */\n Object.defineProperty(this, 'iterations', {\n get: function () {\n return this.clock.ticks;\n },\n });\n\n this.callback = callback;\n /**\n * musicalTimeMode uses Tone.Time convention\n * true if string, false if number\n * @property {Boolean} musicalTimeMode\n */\n this.musicalTimeMode = typeof this._interval === 'number' ? false : true;\n\n this._interval = interval || 1;\n\n /**\n * musicalTimeMode variables\n * modify these only when the interval is specified in musicalTime format as a string\n */\n this._timeSignature = 4;\n this._bpm = 60;\n\n this.isPlaying = false;\n\n /**\n * Set a limit to the number of loops to play. defaults to Infinity\n * @property {Number} maxIterations\n */\n this.maxIterations = Infinity;\n var self = this;\n\n this.clock = new Clock({\n callback: function (time) {\n var timeFromNow = time - p5sound.audiocontext.currentTime;\n /**\n * Do not initiate the callback if timeFromNow is < 0\n * This ususually occurs for a few milliseconds when the page\n * is not fully loaded\n *\n * The callback should only be called until maxIterations is reached\n */\n if (timeFromNow > 0 && self.iterations <= self.maxIterations) {\n self.callback(timeFromNow);\n }\n },\n frequency: this._calcFreq(),\n });\n }\n\n /**\n * Start the loop\n * @method start\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a starting time\n */\n start(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (!this.isPlaying) {\n this.clock.start(now + t);\n this.isPlaying = true;\n }\n }\n\n /**\n * Stop the loop\n * @method stop\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a stopping time\n */\n stop(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (this.isPlaying) {\n this.clock.stop(now + t);\n this.isPlaying = false;\n }\n }\n\n /**\n * Pause the loop\n * @method pause\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a pausing time\n */\n pause(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (this.isPlaying) {\n this.clock.pause(now + t);\n this.isPlaying = false;\n }\n }\n\n /**\n * Synchronize loops. Use this method to start two or more loops in synchronization\n * or to start a loop in synchronization with a loop that is already playing\n * This method will schedule the implicit loop in sync with the explicit master loop\n * i.e. loopToStart.syncedStart(loopToSyncWith)\n *\n * @method syncedStart\n * @for p5.SoundLoop\n * @param {Object} otherLoop a p5.SoundLoop to sync with\n * @param {Number} [timeFromNow] Start the loops in sync after timeFromNow seconds\n */\n syncedStart(otherLoop, timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n\n if (!otherLoop.isPlaying) {\n otherLoop.clock.start(now + t);\n otherLoop.isPlaying = true;\n this.clock.start(now + t);\n this.isPlaying = true;\n } else if (otherLoop.isPlaying) {\n var time = otherLoop.clock._nextTick - p5sound.audiocontext.currentTime;\n this.clock.start(now + time);\n this.isPlaying = true;\n }\n }\n /**\n * Updates frequency value, reflected in next callback\n * @private\n * @for p5.SoundLoop\n * @method _update\n */\n _update() {\n this.clock.frequency.value = this._calcFreq();\n }\n\n /**\n * Calculate the frequency of the clock's callback based on bpm, interval, and timesignature\n * @private\n * @for p5.SoundLoop\n * @method _calcFreq\n * @return {Number} new clock frequency value\n */\n _calcFreq() {\n //Seconds mode, bpm / timesignature has no effect\n if (typeof this._interval === 'number') {\n this.musicalTimeMode = false;\n return 1 / this._interval;\n }\n //Musical timing mode, calculate interval based bpm, interval,and time signature\n else if (typeof this._interval === 'string') {\n this.musicalTimeMode = true;\n return (\n (this._bpm / 60 / this._convertNotation(this._interval)) *\n (this._timeSignature / 4)\n );\n }\n }\n\n /**\n * Convert notation from musical time format to seconds\n * Uses Tone.Time convention\n * @private\n * @for p5.SoundLoop\n * @method _convertNotation\n * @param {String} value value to be converted\n * @return {Number} converted value in seconds\n */\n _convertNotation(value) {\n var type = value.slice(-1);\n value = Number(value.slice(0, -1));\n switch (type) {\n case 'm':\n return this._measure(value);\n case 'n':\n return this._note(value);\n default:\n console.warn(\n 'Specified interval is not formatted correctly. See Tone.js ' +\n 'timing reference for more info: https://github.com/Tonejs/Tone.js/wiki/Time'\n );\n }\n }\n\n /**\n * Helper conversion methods of measure and note\n * @private\n * @for p5.SoundLoop\n * @method _measure\n */\n _measure(value) {\n return value * this._timeSignature;\n }\n\n /**\n * @private\n * @method _note\n * @for p5.SoundLoop\n */\n _note(value) {\n return this._timeSignature / value;\n }\n}\n\nexport default SoundLoop;\n","import Effect from './effect';\n\n/**\n * Compressor is an audio effect class that performs dynamics compression\n * on an audio input source. This is a very commonly used technique in music\n * and sound production. Compression creates an overall louder, richer,\n * and fuller sound by lowering the volume of louds and raising that of softs.\n * Compression can be used to avoid clipping (sound distortion due to\n * peaks in volume) and is especially useful when many sounds are played\n * at once. Compression can be used on indivudal sound sources in addition\n * to the master output.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Compressor\n * @constructor\n * @extends p5.Effect\n *\n *\n */\nclass Compressor extends Effect {\n constructor() {\n super();\n /**\n *\n * The p5.Compressor is built with a Web Audio Dynamics Compressor Node\n * \n * @property {AudioNode} compressor\n */\n\n this.compressor = this.ac.createDynamicsCompressor();\n\n this.input.connect(this.compressor);\n this.compressor.connect(this.wet);\n }\n\n /**\n * Performs the same function as .connect, but also accepts\n * optional parameters to set compressor's audioParams\n * @method process\n * @for p5.Compressor\n *\n * @param {Object} src Sound source to be connected\n *\n * @param {Number} [attack] The amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} [knee] A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} [threshold] The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} [release] The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n */\n process(src, attack, knee, ratio, threshold, release) {\n src.connect(this.input);\n this.set(attack, knee, ratio, threshold, release);\n }\n\n /**\n * Set the paramters of a compressor.\n * @method set\n * @for p5.Compressor\n * @param {Number} attack The amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} knee A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} ratio The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} threshold The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n */\n set(attack, knee, ratio, threshold, release) {\n if (typeof attack !== 'undefined') {\n this.attack(attack);\n }\n if (typeof knee !== 'undefined') {\n this.knee(knee);\n }\n if (typeof ratio !== 'undefined') {\n this.ratio(ratio);\n }\n if (typeof threshold !== 'undefined') {\n this.threshold(threshold);\n }\n if (typeof release !== 'undefined') {\n this.release(release);\n }\n }\n\n /**\n * Get current attack or set value w/ time ramp\n *\n *\n * @method attack\n * @for p5.Compressor\n * @param {Number} [attack] Attack is the amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n attack(attack, time) {\n var t = time || 0;\n if (typeof attack === 'number') {\n this.compressor.attack.value = attack;\n this.compressor.attack.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.attack.linearRampToValueAtTime(\n attack,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof attack !== 'undefined') {\n attack.connect(this.compressor.attack);\n }\n return this.compressor.attack.value;\n }\n\n /**\n * Get current knee or set value w/ time ramp\n *\n * @method knee\n * @for p5.Compressor\n * @param {Number} [knee] A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n knee(knee, time) {\n var t = time || 0;\n if (typeof knee === 'number') {\n this.compressor.knee.value = knee;\n this.compressor.knee.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.knee.linearRampToValueAtTime(\n knee,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof knee !== 'undefined') {\n knee.connect(this.compressor.knee);\n }\n return this.compressor.knee.value;\n }\n\n /**\n * Get current ratio or set value w/ time ramp\n * @method ratio\n * @for p5.Compressor\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n ratio(ratio, time) {\n var t = time || 0;\n if (typeof ratio === 'number') {\n this.compressor.ratio.value = ratio;\n this.compressor.ratio.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.ratio.linearRampToValueAtTime(\n ratio,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof ratio !== 'undefined') {\n ratio.connect(this.compressor.ratio);\n }\n return this.compressor.ratio.value;\n }\n\n /**\n * Get current threshold or set value w/ time ramp\n * @method threshold\n * @for p5.Compressor\n * @param {Number} threshold The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n threshold(threshold, time) {\n var t = time || 0;\n if (typeof threshold === 'number') {\n this.compressor.threshold.value = threshold;\n this.compressor.threshold.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.threshold.linearRampToValueAtTime(\n threshold,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof threshold !== 'undefined') {\n threshold.connect(this.compressor.threshold);\n }\n return this.compressor.threshold.value;\n }\n\n /**\n * Get current release or set value w/ time ramp\n * @method release\n * @for p5.Compressor\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n *\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n release(release, time) {\n var t = time || 0;\n if (typeof release === 'number') {\n this.compressor.release.value = release;\n this.compressor.release.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.release.linearRampToValueAtTime(\n release,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof number !== 'undefined') {\n release.connect(this.compressor.release);\n }\n return this.compressor.release.value;\n }\n\n /**\n * Return the current reduction value\n *\n * @method reduction\n * @for p5.Compressor\n * @return {Number} Value of the amount of gain reduction that is applied to the signal\n */\n reduction() {\n return this.compressor.reduction.value;\n }\n\n dispose() {\n super.dispose();\n if (this.compressor) {\n this.compressor.disconnect();\n delete this.compressor;\n }\n }\n}\n\nexport default Compressor;\n","/**\n *

PeakDetect works in conjunction with p5.FFT to\n * look for onsets in some or all of the frequency spectrum.\n *

\n *

\n * To use p5.PeakDetect, call update in the draw loop\n * and pass in a p5.FFT object.\n *

\n *

\n * You can listen for a specific part of the frequency spectrum by\n * setting the range between freq1 and freq2.\n *

\n *\n *

threshold is the threshold for detecting a peak,\n * scaled between 0 and 1. It is logarithmic, so 0.1 is half as loud\n * as 1.0.

\n *\n *

\n * The update method is meant to be run in the draw loop, and\n * frames determines how many loops must pass before\n * another peak can be detected.\n * For example, if the frameRate() = 60, you could detect the beat of a\n * 120 beat-per-minute song with this equation:\n * framesPerPeak = 60 / (estimatedBPM / 60 );\n *

\n *\n *

\n * Based on example contribtued by @b2renger, and a simple beat detection\n * explanation by Felix Turner.\n *

\n *\n * @class p5.PeakDetect\n * @constructor\n * @param {Number} [freq1] lowFrequency - defaults to 20Hz\n * @param {Number} [freq2] highFrequency - defaults to 20000 Hz\n * @param {Number} [threshold] Threshold for detecting a beat between 0 and 1\n * scaled logarithmically where 0.1 is 1/2 the loudness\n * of 1.0. Defaults to 0.35.\n * @param {Number} [framesPerPeak] Defaults to 20.\n * @example\n *
\n *\n * var cnv, soundFile, fft, peakDetect;\n * var ellipseWidth = 10;\n *\n * function preload() {\n * soundFile = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * background(0);\n * noStroke();\n * fill(255);\n * textAlign(CENTER);\n *\n * // p5.PeakDetect requires a p5.FFT\n * fft = new p5.FFT();\n * peakDetect = new p5.PeakDetect();\n * }\n *\n * function draw() {\n * background(0);\n * text('click to play/pause', width/2, height/2);\n *\n * // peakDetect accepts an fft post-analysis\n * fft.analyze();\n * peakDetect.update(fft);\n *\n * if ( peakDetect.isDetected ) {\n * ellipseWidth = 50;\n * } else {\n * ellipseWidth *= 0.95;\n * }\n *\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n * }\n *\n * // toggle play/stop when canvas is clicked\n * function mouseClicked() {\n * if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n * if (soundFile.isPlaying() ) {\n * soundFile.stop();\n * } else {\n * soundFile.play();\n * }\n * }\n * }\n *
\n */\nclass PeakDetect {\n // framesPerPeak determines how often to look for a beat.\n // If a beat is provided, try to look for a beat based on bpm\n constructor(freq1, freq2, threshold, _framesPerPeak) {\n this.framesPerPeak = _framesPerPeak || 20;\n this.framesSinceLastPeak = 0;\n this.decayRate = 0.95;\n\n this.threshold = threshold || 0.35;\n this.cutoff = 0;\n\n // how much to increase the cutoff\n // TO DO: document this / figure out how to make it accessible\n this.cutoffMult = 1.5;\n\n this.energy = 0;\n this.penergy = 0;\n\n // TO DO: document this property / figure out how to make it accessible\n this.currentValue = 0;\n\n /**\n * isDetected is set to true when a peak is detected.\n *\n * @attribute isDetected {Boolean}\n * @default false\n */\n this.isDetected = false;\n\n this.f1 = freq1 || 40;\n this.f2 = freq2 || 20000;\n\n // function to call when a peak is detected\n this._onPeak = function () {};\n }\n\n /**\n * The update method is run in the draw loop.\n *\n * Accepts an FFT object. You must call .analyze()\n * on the FFT object prior to updating the peakDetect\n * because it relies on a completed FFT analysis.\n *\n * @method update\n * @param {p5.FFT} fftObject A p5.FFT object\n */\n update(fftObject) {\n var nrg = (this.energy = fftObject.getEnergy(this.f1, this.f2) / 255);\n if (nrg > this.cutoff && nrg > this.threshold && nrg - this.penergy > 0) {\n // trigger callback\n this._onPeak();\n this.isDetected = true;\n\n // debounce\n this.cutoff = nrg * this.cutoffMult;\n this.framesSinceLastPeak = 0;\n } else {\n this.isDetected = false;\n if (this.framesSinceLastPeak <= this.framesPerPeak) {\n this.framesSinceLastPeak++;\n } else {\n this.cutoff *= this.decayRate;\n this.cutoff = Math.max(this.cutoff, this.threshold);\n }\n }\n\n this.currentValue = nrg;\n this.penergy = nrg;\n }\n\n /**\n * onPeak accepts two arguments: a function to call when\n * a peak is detected. The value of the peak,\n * between 0.0 and 1.0, is passed to the callback.\n *\n * @method onPeak\n * @param {Function} callback Name of a function that will\n * be called when a peak is\n * detected.\n * @param {Object} [val] Optional value to pass\n * into the function when\n * a peak is detected.\n * @example\n *
\n * var cnv, soundFile, fft, peakDetect;\n * var ellipseWidth = 0;\n *\n * function preload() {\n * soundFile = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * cnv = createCanvas(100,100);\n * textAlign(CENTER);\n *\n * fft = new p5.FFT();\n * peakDetect = new p5.PeakDetect();\n *\n * setupSound();\n *\n * // when a beat is detected, call triggerBeat()\n * peakDetect.onPeak(triggerBeat);\n * }\n *\n * function draw() {\n * background(0);\n * fill(255);\n * text('click to play', width/2, height/2);\n *\n * fft.analyze();\n * peakDetect.update(fft);\n *\n * ellipseWidth *= 0.95;\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n * }\n *\n * // this function is called by peakDetect.onPeak\n * function triggerBeat() {\n * ellipseWidth = 50;\n * }\n *\n * // mouseclick starts/stops sound\n * function setupSound() {\n * cnv.mouseClicked( function() {\n * if (soundFile.isPlaying() ) {\n * soundFile.stop();\n * } else {\n * soundFile.play();\n * }\n * });\n * }\n *
\n */\n onPeak(callback, val) {\n var self = this;\n\n self._onPeak = function () {\n callback(self.energy, val);\n };\n }\n}\n\nexport default PeakDetect;\n","// inspiration: recorder.js, Tone.js & typedarray.org\n\nimport p5sound from './master';\nimport { safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\n\nconst ac = p5sound.audiocontext;\n\n/**\n *

Record sounds for playback and/or to save as a .wav file.\n * The p5.SoundRecorder records all sound output from your sketch,\n * or can be assigned a specific source with setInput().

\n *

The record() method accepts a p5.SoundFile as a parameter.\n * When playback is stopped (either after the given amount of time,\n * or with the stop() method), the p5.SoundRecorder will send its\n * recording to that p5.SoundFile for playback.

\n *\n * @class p5.SoundRecorder\n * @constructor\n * @example\n *
\n * let mic, recorder, soundFile;\n * let state = 0;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * textAlign(CENTER, CENTER);\n *\n * // create an audio in\n * mic = new p5.AudioIn();\n *\n * // prompts user to enable their browser mic\n * mic.start();\n *\n * // create a sound recorder\n * recorder = new p5.SoundRecorder();\n *\n * // connect the mic to the recorder\n * recorder.setInput(mic);\n *\n * // this sound file will be used to\n * // playback & save the recording\n * soundFile = new p5.SoundFile();\n *\n * text('tap to record', width/2, height/2);\n * }\n *\n * function canvasPressed() {\n * // ensure audio is enabled\n * userStartAudio();\n *\n * // make sure user enabled the mic\n * if (state === 0 && mic.enabled) {\n *\n * // record to our p5.SoundFile\n * recorder.record(soundFile);\n *\n * background(255,0,0);\n * text('Recording!', width/2, height/2);\n * state++;\n * }\n * else if (state === 1) {\n * background(0,255,0);\n *\n * // stop recorder and\n * // send result to soundFile\n * recorder.stop();\n *\n * text('Done! Tap to play and download', width/2, height/2, width - 20);\n * state++;\n * }\n *\n * else if (state === 2) {\n * soundFile.play(); // play the result!\n * save(soundFile, 'mySound.wav');\n * state++;\n * }\n * }\n *
\n */\nclass SoundRecorder {\n constructor() {\n this.input = ac.createGain();\n this.output = ac.createGain();\n\n this._inputChannels = 2;\n this._outputChannels = 2; // stereo output, even if input is mono\n\n const workletBufferSize = safeBufferSize(1024);\n\n this._workletNode = new AudioWorkletNode(\n ac,\n processorNames.recorderProcessor,\n {\n outputChannelCount: [this._outputChannels],\n processorOptions: {\n numInputChannels: this._inputChannels,\n bufferSize: workletBufferSize,\n },\n }\n );\n\n this._workletNode.port.onmessage = function (event) {\n if (event.data.name === 'buffers') {\n const buffers = [\n new Float32Array(event.data.leftBuffer),\n new Float32Array(event.data.rightBuffer),\n ];\n this._callback(buffers);\n }\n }.bind(this);\n\n /**\n * callback invoked when the recording is over\n * @private\n * @type Function(Float32Array)\n */\n this._callback = function () {};\n\n // connections\n this._workletNode.connect(p5.soundOut._silentNode);\n this.setInput();\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connect a specific device to the p5.SoundRecorder.\n * If no parameter is given, p5.SoundRecorer will record\n * all audible p5.sound from your sketch.\n *\n * @method setInput\n * @for p5.SoundRecorder\n * @param {Object} [unit] p5.sound object or a web audio unit\n * that outputs sound\n */\n setInput(unit) {\n this.input.disconnect();\n this.input = null;\n this.input = ac.createGain();\n this.input.connect(this._workletNode);\n this.input.connect(this.output);\n if (unit) {\n unit.connect(this.input);\n } else {\n p5.soundOut.output.connect(this.input);\n }\n }\n\n /**\n * Start recording. To access the recording, provide\n * a p5.SoundFile as the first parameter. The p5.SoundRecorder\n * will send its recording to that p5.SoundFile for playback once\n * recording is complete. Optional parameters include duration\n * (in seconds) of the recording, and a callback function that\n * will be called once the complete recording has been\n * transfered to the p5.SoundFile.\n *\n * @method record\n * @for p5.SoundRecorder\n * @param {p5.SoundFile} soundFile p5.SoundFile\n * @param {Number} [duration] Time (in seconds)\n * @param {Function} [callback] The name of a function that will be\n * called once the recording completes\n */\n record(sFile, duration, callback) {\n this._workletNode.port.postMessage({ name: 'start', duration: duration });\n\n if (sFile && callback) {\n this._callback = function (buffer) {\n sFile.setBuffer(buffer);\n callback();\n };\n } else if (sFile) {\n this._callback = function (buffer) {\n sFile.setBuffer(buffer);\n };\n }\n }\n\n /**\n * Stop the recording. Once the recording is stopped,\n * the results will be sent to the p5.SoundFile that\n * was given on .record(), and if a callback function\n * was provided on record, that function will be called.\n *\n * @method stop\n * @for p5.SoundRecorder\n */\n stop() {\n this._workletNode.port.postMessage({ name: 'stop' });\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this._callback = function () {};\n if (this.input) {\n this.input.disconnect();\n }\n this.input = null;\n this._workletNode = null;\n }\n}\n\nexport default SoundRecorder;\n","import Effect from './effect.js';\n\n/*\n * Adapted from [Kevin Ennis on StackOverflow](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n */\nfunction makeDistortionCurve(amount) {\n var k = typeof amount === 'number' ? amount : 50;\n var numSamples = 44100;\n var curve = new Float32Array(numSamples);\n var deg = Math.PI / 180;\n var i = 0;\n var x;\n for (; i < numSamples; ++i) {\n x = (i * 2) / numSamples - 1;\n curve[i] = ((3 + k) * x * 20 * deg) / (Math.PI + k * Math.abs(x));\n }\n return curve;\n}\n\n/**\n * A Distortion effect created with a Waveshaper Node,\n * with an approach adapted from\n * [Kevin Ennis](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Distortion\n * @extends p5.Effect\n * @constructor\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n *\n */\nclass Distortion extends Effect {\n constructor(amount, oversample) {\n super();\n if (typeof amount === 'undefined') {\n amount = 0.25;\n }\n if (typeof amount !== 'number') {\n throw new Error('amount must be a number');\n }\n if (typeof oversample === 'undefined') {\n oversample = '2x';\n }\n if (typeof oversample !== 'string') {\n throw new Error('oversample must be a String');\n }\n\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\n\n /**\n * The p5.Distortion is built with a\n * \n * Web Audio WaveShaper Node.\n *\n * @property {AudioNode} WaveShaperNode\n */\n this.waveShaperNode = this.ac.createWaveShaper();\n\n this.amount = curveAmount;\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\n this.waveShaperNode.oversample = oversample;\n\n this.input.connect(this.waveShaperNode);\n\n this.waveShaperNode.connect(this.wet);\n }\n\n /**\n * Process a sound source, optionally specify amount and oversample values.\n *\n * @method process\n * @for p5.Distortion\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n */\n process(src, amount, oversample) {\n src.connect(this.input);\n this.set(amount, oversample);\n }\n\n /**\n * Set the amount and oversample of the waveshaper distortion.\n *\n * @method set\n * @for p5.Distortion\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n */\n set(amount, oversample) {\n if (amount) {\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\n this.amount = curveAmount;\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\n }\n if (oversample) {\n this.waveShaperNode.oversample = oversample;\n }\n }\n\n /**\n * Return the distortion amount, typically between 0-1.\n *\n * @method getAmount\n * @for p5.Distortion\n * @return {Number} Unbounded distortion amount.\n * Normal values range from 0-1.\n */\n getAmount() {\n return this.amount;\n }\n\n /**\n * Return the oversampling.\n *\n * @method getOversample\n * @for p5.Distortion\n * @return {String} Oversample can either be 'none', '2x', or '4x'.\n */\n getOversample() {\n return this.waveShaperNode.oversample;\n }\n\n dispose() {\n super.dispose();\n if (this.waveShaperNode) {\n this.waveShaperNode.disconnect();\n this.waveShaperNode = null;\n }\n }\n}\n\nexport default Distortion;\n","import p5sound from './master';\n\n/**\n * A gain node is usefull to set the relative volume of sound.\n * It's typically used to build mixers.\n *\n * @class p5.Gain\n * @constructor\n * @example\n *
\n *\n * // load two soundfile and crossfade beetween them\n * let sound1,sound2;\n * let sound1Gain, sound2Gain, masterGain;\n * function preload(){\n * soundFormats('ogg', 'mp3');\n * sound1 = loadSound('assets/Damscray_-_Dancing_Tiger_01');\n * sound2 = loadSound('assets/beat');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startSound);\n * // create a 'master' gain to which we will connect both soundfiles\n * masterGain = new p5.Gain();\n * masterGain.connect();\n * sound1.disconnect(); // diconnect from p5 output\n * sound1Gain = new p5.Gain(); // setup a gain node\n * sound1Gain.setInput(sound1); // connect the first sound to its input\n * sound1Gain.connect(masterGain); // connect its output to the 'master'\n * sound2.disconnect();\n * sound2Gain = new p5.Gain();\n * sound2Gain.setInput(sound2);\n * sound2Gain.connect(masterGain);\n * }\n * function startSound() {\n * sound1.loop();\n * sound2.loop();\n * loop();\n * }\n * function mouseReleased() {\n * sound1.stop();\n * sound2.stop();\n * }\n * function draw(){\n * background(220);\n * textAlign(CENTER);\n * textSize(11);\n * fill(0);\n * if (!sound1.isPlaying()) {\n * text('tap and drag to play', width/2, height/2);\n * return;\n * }\n * // map the horizontal position of the mouse to values useable for volume * control of sound1\n * var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);\n * var sound2Volume = 1-sound1Volume;\n * sound1Gain.amp(sound1Volume);\n * sound2Gain.amp(sound2Volume);\n * // map the vertical position of the mouse to values useable for 'master * volume control'\n * var masterVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\n * masterGain.amp(masterVolume);\n * text('master', width/2, height - masterVolume * height * 0.9)\n * fill(255, 0, 255);\n * textAlign(LEFT);\n * text('sound1', 5, height - sound1Volume * height * 0.9);\n * textAlign(RIGHT);\n * text('sound2', width - 5, height - sound2Volume * height * 0.9);\n * }\n *
\n */\n\nclass Gain {\n constructor() {\n this.ac = p5sound.audiocontext;\n\n this.input = this.ac.createGain();\n this.output = this.ac.createGain();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n this.input.connect(this.output);\n\n // add to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connect a source to the gain node.\n *\n * @method setInput\n * @for p5.Gain\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n */\n\n setInput(src) {\n src.connect(this.input);\n }\n\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Gain\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5.soundOut.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Gain\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Set the output level of the gain node.\n *\n * @method amp\n * @for p5.Gain\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n var now = p5sound.audiocontext.currentTime;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n }\n}\n\nexport default Gain;\n","import p5sound from './master';\n\n/**\n * Base class for monophonic synthesizers. Any extensions of this class\n * should follow the API and implement the methods below in order to\n * remain compatible with p5.PolySynth();\n *\n * @class p5.AudioVoice\n * @constructor\n */\nclass AudioVoice {\n constructor() {\n this.ac = p5sound.audiocontext;\n this.output = this.ac.createGain();\n this.connect();\n p5sound.soundArray.push(this);\n }\n play(note, velocity, secondsFromNow, sustime) {}\n\n triggerAttack(note, velocity, secondsFromNow) {}\n\n triggerRelease(secondsFromNow) {}\n\n amp(vol, rampTime) {}\n\n /**\n * Connect to p5 objects or Web Audio Nodes\n * @method connect\n * @for p5.AudioVoice\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect from soundOut\n * @method disconnect\n * @for p5.AudioVoice\n */\n disconnect() {\n this.output.disconnect();\n }\n\n dispose() {\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n }\n}\n\nexport default AudioVoice;\n","import AudioVoice from './audioVoice';\nimport Envelope from './envelope';\nimport p5sound from './master';\nimport Oscillator from './oscillator';\nimport { noteToFreq } from './helpers';\n\nvar DEFAULT_SUSTAIN = 0.15;\n\n/**\n * A MonoSynth is used as a single voice for sound synthesis.\n * This is a class to be used in conjunction with the PolySynth\n * class. Custom synthetisers should be built inheriting from\n * this class.\n *\n * @class p5.MonoSynth\n * @constructor\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * let note = random(['Fb4', 'G4']);\n * // note velocity (volume, from 0 to 1)\n * let velocity = random();\n * // time from now (in seconds)\n * let time = 0;\n * // note duration (in seconds)\n * let dur = 1/6;\n *\n * monoSynth.play(note, velocity, time, dur);\n * }\n *
\n **/\n\nclass MonoSynth extends AudioVoice {\n constructor() {\n super();\n this.oscillator = new Oscillator();\n\n this.env = new Envelope(); //to be changed\n this.env.setRange(1, 0);\n this.env.setExp(true);\n\n //set params\n this.setADSR(0.02, 0.25, 0.05, 0.35);\n\n // oscillator --> env --> this.output (gain) --> p5.soundOut\n this.oscillator.disconnect();\n this.oscillator.connect(this.output);\n\n this.env.disconnect();\n this.env.setInput(this.output.gain);\n\n // reset oscillator gain to 1.0\n this.oscillator.output.gain.value = 1.0;\n\n this.oscillator.start();\n this.connect();\n\n p5sound.soundArray.push(this);\n\n /**\n * Getters and Setters\n * @property {Number} attack\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} decay\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} sustain\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} release\n * @for p5.MonoSynth\n */\n Object.defineProperties(this, {\n attack: {\n get: function () {\n return this.env.aTime;\n },\n set: function (attack) {\n this.env.setADSR(\n attack,\n this.env.dTime,\n this.env.sPercent,\n this.env.rTime\n );\n },\n },\n decay: {\n get: function () {\n return this.env.dTime;\n },\n set: function (decay) {\n this.env.setADSR(\n this.env.aTime,\n decay,\n this.env.sPercent,\n this.env.rTime\n );\n },\n },\n sustain: {\n get: function () {\n return this.env.sPercent;\n },\n set: function (sustain) {\n this.env.setADSR(\n this.env.aTime,\n this.env.dTime,\n sustain,\n this.env.rTime\n );\n },\n },\n release: {\n get: function () {\n return this.env.rTime;\n },\n set: function (release) {\n this.env.setADSR(\n this.env.aTime,\n this.env.dTime,\n this.env.sPercent,\n release\n );\n },\n },\n });\n }\n\n /**\n * Play tells the MonoSynth to start playing a note. This method schedules\n * the calling of .triggerAttack and .triggerRelease.\n *\n * @method play\n * @for p5.MonoSynth\n * @param {String | Number} note the note you want to play, specified as a\n * frequency in Hertz (Number) or as a midi\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n * See \n * Tone. Defaults to 440 hz.\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope. Defaults to 0.15 seconds.\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * let note = random(['Fb4', 'G4']);\n * // note velocity (volume, from 0 to 1)\n * let velocity = random();\n * // time from now (in seconds)\n * let time = 0;\n * // note duration (in seconds)\n * let dur = 1/6;\n *\n * monoSynth.play(note, velocity, time, dur);\n * }\n *
\n *\n */\n play(note, velocity, secondsFromNow, susTime) {\n this.triggerAttack(note, velocity, ~~secondsFromNow);\n this.triggerRelease(~~secondsFromNow + (susTime || DEFAULT_SUSTAIN));\n }\n\n /**\n * Trigger the Attack, and Decay portion of the Envelope.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go.\n *\n * @param {String | Number} note the note you want to play, specified as a\n * frequency in Hertz (Number) or as a midi\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n * See \n * Tone. Defaults to 440 hz\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @method triggerAttack\n * @for p5.MonoSynth\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(triggerAttack);\n * background(220);\n * text('tap here for attack, let go to release', 5, 20, width - 20);\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function triggerAttack() {\n * userStartAudio();\n *\n * monoSynth.triggerAttack(\"E3\");\n * }\n *\n * function mouseReleased() {\n * monoSynth.triggerRelease();\n * }\n *
\n */\n triggerAttack(note, velocity, secondsFromNow = 0) {\n var freq = noteToFreq(note);\n var vel = velocity || 0.1;\n this.oscillator.freq(freq, 0, secondsFromNow);\n this.env.ramp(this.output.gain, secondsFromNow, vel);\n }\n\n /**\n * Trigger the release of the Envelope. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @param {Number} secondsFromNow time to trigger the release\n * @method triggerRelease\n * @for p5.MonoSynth\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(triggerAttack);\n * background(220);\n * text('tap here for attack, let go to release', 5, 20, width - 20);\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function triggerAttack() {\n * userStartAudio();\n *\n * monoSynth.triggerAttack(\"E3\");\n * }\n *\n * function mouseReleased() {\n * monoSynth.triggerRelease();\n * }\n *
\n */\n triggerRelease(secondsFromNow = 0) {\n this.env.ramp(this.output.gain, secondsFromNow, 0);\n }\n\n /**\n * Set values like a traditional\n * \n * ADSR envelope\n * .\n *\n * @method setADSR\n * @for p5.MonoSynth\n * @param {Number} attackTime Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n */\n setADSR(attack, decay, sustain, release) {\n this.env.setADSR(attack, decay, sustain, release);\n }\n\n /**\n * MonoSynth amp\n * @method amp\n * @for p5.MonoSynth\n * @param {Number} vol desired volume\n * @param {Number} [rampTime] Time to reach new volume\n * @return {Number} new volume value\n */\n amp(vol, rampTime) {\n var t = rampTime || 0;\n if (typeof vol !== 'undefined') {\n this.oscillator.amp(vol, t);\n }\n return this.oscillator.amp().value;\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.MonoSynth\n * @param {Object} unit A p5.sound or Web Audio object\n */\n\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.MonoSynth\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Get rid of the MonoSynth and free up its resources / memory.\n *\n * @method dispose\n * @for p5.MonoSynth\n */\n dispose() {\n super.dispose();\n\n if (this.env) {\n this.env.dispose();\n }\n if (this.oscillator) {\n this.oscillator.dispose();\n }\n }\n}\n\nexport default MonoSynth;\n","/**\n * Listen for onsets (a sharp increase in volume) within a given\n * frequency range.\n *\n * @class p5.OnsetDetect\n * @constructor\n * @param {Number} freqLow Low frequency\n * @param {Number} freqHigh High frequency\n * @param {Number} threshold Amplitude threshold between 0 (no energy) and 1 (maximum)\n * @param {Function} callback Function to call when an onset is detected\n */\nclass OnsetDetect {\n constructor(freqLow, freqHigh, threshold, callback) {\n this.isDetected = false;\n this.freqLow = freqLow;\n this.freqHigh = freqHigh;\n this.treshold = threshold;\n this.energy = 0;\n this.penergy = 0;\n\n // speed of decay\n this.sensitivity = 500;\n\n this.callback = callback;\n }\n\n // callback here too?\n update(fftObject, callback) {\n this.energy = fftObject.getEnergy(this.freqLow, this.freqHigh) / 255;\n\n if (this.isDetected === false) {\n if (this.energy - this.penergy > this.treshold) {\n this.isDetected = true;\n\n if (this.callback) {\n this.callback(this.energy);\n } else if (callback) {\n callback(this.energy);\n }\n\n var self = this;\n setTimeout(function () {\n self.isDetected = false;\n }, this.sensitivity);\n }\n }\n\n this.penergy = this.energy;\n }\n}\n\nexport default OnsetDetect;\n","import p5sound from './master';\nimport TimelineSignal from 'Tone/signal/TimelineSignal.js';\nimport { noteToFreq, freqToMidi } from './helpers';\n\n/**\n * An AudioVoice is used as a single voice for sound synthesis.\n * The PolySynth class holds an array of AudioVoice, and deals\n * with voices allocations, with setting notes to be played, and\n * parameters to be set.\n *\n * @class p5.PolySynth\n * @constructor\n *\n * @param {Number} [synthVoice] A monophonic synth voice inheriting\n * the AudioVoice class. Defaults to p5.MonoSynth\n * @param {Number} [maxVoices] Number of voices, defaults to 8;\n * @example\n *
\n * let polySynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * text('click to play', 20, 20);\n *\n * polySynth = new p5.PolySynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * // note duration (in seconds)\n * let dur = 1.5;\n *\n * // time from now (in seconds)\n * let time = 0;\n *\n * // velocity (volume, from 0 to 1)\n * let vel = 0.1;\n *\n * // notes can overlap with each other\n * polySynth.play('G2', vel, 0, dur);\n * polySynth.play('C3', vel, time += 1/3, dur);\n * polySynth.play('G3', vel, time += 1/3, dur);\n * }\n *
\n **/\nclass PolySynth {\n constructor(audioVoice, maxVoices) {\n //audiovoices will contain maxVoices many monophonic synths\n this.audiovoices = [];\n\n /**\n * An object that holds information about which notes have been played and\n * which notes are currently being played. New notes are added as keys\n * on the fly. While a note has been attacked, but not released, the value of the\n * key is the audiovoice which is generating that note. When notes are released,\n * the value of the key becomes undefined.\n * @property notes\n */\n this.notes = {};\n\n //indices of the most recently used, and least recently used audiovoice\n this._newest = 0;\n this._oldest = 0;\n\n /**\n * A PolySynth must have at least 1 voice, defaults to 8\n * @property polyvalue\n */\n this.maxVoices = maxVoices || 8;\n\n /**\n * Monosynth that generates the sound for each note that is triggered. The\n * p5.PolySynth defaults to using the p5.MonoSynth as its voice.\n * @property AudioVoice\n */\n this.AudioVoice = audioVoice === undefined ? p5.MonoSynth : audioVoice;\n\n /**\n * This value must only change as a note is attacked or released. Due to delay\n * and sustain times, Tone.TimelineSignal is required to schedule the change in value.\n * @private\n * @property {Tone.TimelineSignal} _voicesInUse\n */\n this._voicesInUse = new TimelineSignal(0);\n\n this.output = p5sound.audiocontext.createGain();\n this.connect();\n\n //Construct the appropriate number of audiovoices\n this._allocateVoices();\n p5sound.soundArray.push(this);\n }\n\n /**\n * Construct the appropriate number of audiovoices\n * @private\n * @for p5.PolySynth\n * @method _allocateVoices\n */\n _allocateVoices() {\n for (var i = 0; i < this.maxVoices; i++) {\n this.audiovoices.push(new this.AudioVoice());\n this.audiovoices[i].disconnect();\n this.audiovoices[i].connect(this.output);\n }\n }\n\n /**\n * Play a note by triggering noteAttack and noteRelease with sustain time\n *\n * @method play\n * @for p5.PolySynth\n * @param {Number} [note] midi note to play (ranging from 0 to 127 - 60 being a middle C)\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\n * @example\n *
\n * let polySynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * text('click to play', 20, 20);\n *\n * polySynth = new p5.PolySynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * // note duration (in seconds)\n * let dur = 1.5;\n *\n * // time from now (in seconds)\n * let time = 0;\n *\n * // velocity (volume, from 0 to 1)\n * let vel = 0.1;\n *\n * // notes can overlap with each other\n * polySynth.play('G2', vel, 0, dur);\n * polySynth.play('C3', vel, time += 1/3, dur);\n * polySynth.play('G3', vel, time += 1/3, dur);\n * }\n *
\n */\n play(note, velocity, secondsFromNow, susTime = 1) {\n this.noteAttack(note, velocity, secondsFromNow);\n this.noteRelease(note, secondsFromNow + susTime);\n }\n\n /**\n * noteADSR sets the envelope for a specific note that has just been triggered.\n * Using this method modifies the envelope of whichever audiovoice is being used\n * to play the desired note. The envelope should be reset before noteRelease is called\n * in order to prevent the modified envelope from being used on other notes.\n *\n * @method noteADSR\n * @for p5.PolySynth\n * @param {Number} [note] Midi note on which ADSR should be set.\n * @param {Number} [attackTime] Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n **/\n\n noteADSR(note, a, d, s, r, timeFromNow = 0) {\n var now = p5sound.audiocontext.currentTime;\n var t = now + timeFromNow;\n this.audiovoices[this.notes[note].getValueAtTime(t)].setADSR(a, d, s, r);\n }\n\n /**\n * Set the PolySynths global envelope. This method modifies the envelopes of each\n * monosynth so that all notes are played with this envelope.\n *\n * @method setADSR\n * @for p5.PolySynth\n * @param {Number} [attackTime] Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n **/\n setADSR(a, d, s, r) {\n this.audiovoices.forEach(function (voice) {\n voice.setADSR(a, d, s, r);\n });\n }\n\n /**\n * Trigger the Attack, and Decay portion of a MonoSynth.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go.\n *\n * @method noteAttack\n * @for p5.PolySynth\n * @param {Number} [note] midi note on which attack should be triggered.\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)/\n * @param {Number} [secondsFromNow] time from now (in seconds)\n * @example\n *
\n * let polySynth = new p5.PolySynth();\n * let pitches = ['G', 'D', 'G', 'C'];\n * let octaves = [2, 3, 4];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playChord);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playChord() {\n * userStartAudio();\n *\n * // play a chord: multiple notes at the same time\n * for (let i = 0; i < 4; i++) {\n * let note = random(pitches) + random(octaves);\n * polySynth.noteAttack(note, 0.1);\n * }\n * }\n *\n * function mouseReleased() {\n * // release all voices\n * polySynth.noteRelease();\n * }\n *
\n */\n noteAttack(_note, _velocity, secondsFromNow = 0) {\n //this value is used by this._voicesInUse\n var acTime = p5sound.audiocontext.currentTime + secondsFromNow;\n\n //Convert note to frequency if necessary. This is because entries into this.notes\n //should be based on frequency for the sake of consistency.\n var note = noteToFreq(_note);\n var velocity = _velocity || 0.1;\n\n var currentVoice;\n\n //Release the note if it is already playing\n if (this.notes[note] && this.notes[note].getValueAtTime(acTime) !== null) {\n this.noteRelease(note, 0);\n }\n\n //Check to see how many voices are in use at the time the note will start\n if (this._voicesInUse.getValueAtTime(acTime) < this.maxVoices) {\n currentVoice = Math.max(~~this._voicesInUse.getValueAtTime(acTime), 0);\n }\n //If we are exceeding the polyvalue, bump off the oldest notes and replace\n //with a new note\n else {\n currentVoice = this._oldest;\n\n oldestNote = freqToMidi(\n this.audiovoices[this._oldest].oscillator.freq().value\n );\n this.noteRelease(oldestNote);\n this._oldest = (this._oldest + 1) % (this.maxVoices - 1);\n }\n\n //Overrite the entry in the notes object. A note (frequency value)\n //corresponds to the index of the audiovoice that is playing it\n this.notes[note] = new TimelineSignal();\n this.notes[note].setValueAtTime(currentVoice, acTime);\n\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\n //Add 1 and schedule this value at time 't', when this note will start playing\n var previousVal =\n this._voicesInUse._searchBefore(acTime) === null\n ? 0\n : this._voicesInUse._searchBefore(acTime).value;\n this._voicesInUse.setValueAtTime(previousVal + 1, acTime);\n\n //Then update all scheduled values that follow to increase by 1\n this._updateAfter(acTime, 1);\n\n this._newest = currentVoice;\n //The audiovoice handles the actual scheduling of the note\n if (typeof velocity === 'number') {\n var maxRange = (1 / this._voicesInUse.getValueAtTime(acTime)) * 2;\n velocity = velocity > maxRange ? maxRange : velocity;\n }\n\n // use secondsFromNow because this method will add AudioContext currentTime\n this.audiovoices[currentVoice].triggerAttack(\n note,\n velocity,\n secondsFromNow\n );\n }\n\n /**\n * Private method to ensure accurate values of this._voicesInUse\n * Any time a new value is scheduled, it is necessary to increment all subsequent\n * scheduledValues after attack, and decrement all subsequent\n * scheduledValues after release\n *\n * @private\n * @for p5.PolySynth\n * @param {[type]} time [description]\n * @param {[type]} value [description]\n * @return {[type]} [description]\n */\n _updateAfter(time, value) {\n if (this._voicesInUse._searchAfter(time) === null) {\n return;\n } else {\n this._voicesInUse._searchAfter(time).value += value;\n var nextTime = this._voicesInUse._searchAfter(time).time;\n this._updateAfter(nextTime, value);\n }\n }\n\n /**\n * Trigger the Release of an AudioVoice note. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @method noteRelease\n * @for p5.PolySynth\n * @param {Number} [note] midi note on which attack should be triggered.\n * If no value is provided, all notes will be released.\n * @param {Number} [secondsFromNow] time to trigger the release\n * @example\n *
\n * let polySynth = new p5.PolySynth();\n * let pitches = ['G', 'D', 'G', 'C'];\n * let octaves = [2, 3, 4];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playChord);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playChord() {\n * userStartAudio();\n *\n * // play a chord: multiple notes at the same time\n * for (let i = 0; i < 4; i++) {\n * let note = random(pitches) + random(octaves);\n * polySynth.noteAttack(note, 0.1);\n * }\n * }\n *\n * function mouseReleased() {\n * // release all voices\n * polySynth.noteRelease();\n * }\n *
\n *\n */\n noteRelease(_note, secondsFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n\n // if a note value is not provided, release all voices\n if (!_note) {\n this.audiovoices.forEach(function (voice) {\n voice.triggerRelease(tFromNow);\n });\n this._voicesInUse.setValueAtTime(0, t);\n for (var n in this.notes) {\n this.notes[n].dispose();\n delete this.notes[n];\n }\n return;\n }\n\n //Make sure note is in frequency inorder to query the this.notes object\n var note = noteToFreq(_note);\n\n if (!this.notes[note] || this.notes[note].getValueAtTime(t) === null) {\n console.warn('Cannot release a note that is not already playing');\n } else {\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\n //subtract 1 and schedule this value at time 't', when this note will stop playing\n var previousVal = Math.max(\n ~~this._voicesInUse.getValueAtTime(t).value,\n 1\n );\n this._voicesInUse.setValueAtTime(previousVal - 1, t);\n //Then update all scheduled values that follow to decrease by 1 but never go below 0\n if (previousVal > 0) {\n this._updateAfter(t, -1);\n }\n\n this.audiovoices[this.notes[note].getValueAtTime(t)].triggerRelease(\n tFromNow\n );\n this.notes[note].dispose();\n delete this.notes[note];\n\n this._newest =\n this._newest === 0 ? 0 : (this._newest - 1) % (this.maxVoices - 1);\n }\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.PolySynth\n * @param {Object} unit A p5.sound or Web Audio object\n */\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.PolySynth\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Get rid of the MonoSynth and free up its resources / memory.\n *\n * @method dispose\n * @for p5.PolySynth\n */\n dispose() {\n this.audiovoices.forEach(function (voice) {\n voice.dispose();\n });\n\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n }\n}\n\nexport default PolySynth;\n","class Signal {\n constructor() {\n console.warn('p5.Signal is deprecated , Use Tone.js Signal instead ');\n }\n}\n\nexport default Signal;\n","import 'audioworklet-polyfill';\nimport './shims';\n\nimport { getAudioContext, userStartAudio } from './audiocontext';\np5.prototype.getAudioContext = getAudioContext;\np5.prototype.userStartAudio = userStartAudio;\n\nimport './master';\n\nimport {\n sampleRate,\n freqToMidi,\n midiToFreq,\n noteToFreq,\n soundFormats,\n disposeSound,\n _checkFileFormats,\n _mathChain,\n convertToWav,\n interleave,\n writeUTFBytes,\n safeBufferSize,\n saveSound,\n} from './helpers';\np5.prototype.sampleRate = sampleRate;\np5.prototype.freqToMidi = freqToMidi;\np5.prototype.midiToFreq = midiToFreq;\np5.prototype.noteToFreq = noteToFreq;\np5.prototype.soundFormats = soundFormats;\np5.prototype.disposeSound = disposeSound;\np5.prototype._checkFileFormats = _checkFileFormats;\np5.prototype._mathChain = _mathChain;\np5.prototype.convertToWav = convertToWav;\np5.prototype.interleave = interleave;\np5.prototype.writeUTFBytes = writeUTFBytes;\np5.prototype.safeBufferSize = safeBufferSize;\np5.prototype.saveSound = saveSound;\n\n// register removeSound to dispose of p5sound SoundFiles, Convolvers,\n// Oscillators etc when sketch ends\np5.prototype.registerMethod('remove', p5.prototype.disposeSound);\n\nimport './errorHandler';\nimport './audioWorklet';\n\nimport Panner from './panner';\np5.Panner = Panner;\n\nimport SoundFile, { loadSound } from './soundfile';\np5.SoundFile = SoundFile;\np5.prototype.loadSound = loadSound;\n// register preload handling of loadSound\np5.prototype.registerPreloadMethod('loadSound', p5.prototype);\n\nimport Amplitude from './amplitude';\np5.Amplitude = Amplitude;\n\nimport FFT from './fft';\np5.FFT = FFT;\n\nimport Oscillator, { SinOsc, TriOsc, SawOsc, SqrOsc } from './oscillator';\np5.Oscillator = Oscillator;\np5.SinOsc = SinOsc;\np5.TriOsc = TriOsc;\np5.SawOsc = SawOsc;\np5.SqrOsc = SqrOsc;\n\nimport './envelope';\n\nimport Noise from './noise';\np5.Noise = Noise;\n\nimport Pulse from './pulse';\np5.Pulse = Pulse;\n\nimport AudioIn from './audioin';\np5.AudioIn = AudioIn;\n\nimport Effect from './effect';\np5.Effect = Effect;\n\nimport Filter, { LowPass, HighPass, BandPass } from './filter';\np5.Filter = Filter;\np5.LowPass = LowPass;\np5.HighPass = HighPass;\np5.BandPass = BandPass;\n\nimport EQ from './eq';\np5.EQ = EQ;\n\nimport listener3D from './listener3d';\np5.listener3D = listener3D;\n\nimport Panner3D from './panner3d';\np5.Panner3D = Panner3D;\n\nimport Delay from './delay';\np5.Delay = Delay;\n\nimport { Reverb, Convolver, createConvolver } from './reverb';\np5.Reverb = Reverb;\np5.Convolver = Convolver;\np5.prototype.createConvolver = createConvolver;\np5.prototype.registerPreloadMethod('createConvolver', p5.prototype);\n\nimport Metro from './metro';\np5.Metro = Metro;\n\nimport { Phrase, Part, Score } from './looper';\np5.Phrase = Phrase;\np5.Part = Part;\np5.Score = Score;\n\nimport SoundLoop from './soundLoop';\np5.SoundLoop = SoundLoop;\n\nimport Compressor from './compressor';\np5.Compressor = Compressor;\n\nimport peakDetect from './peakDetect';\np5.peakDetect = peakDetect;\n\nimport SoundRecorder from './soundRecorder';\np5.SoundRecorder = SoundRecorder;\n\nimport Distortion from './distortion';\np5.Distortion = Distortion;\n\nimport Gain from './gain';\np5.Gain = Gain;\n\nimport AudioVoice from './audioVoice';\np5.AudioVoice = AudioVoice;\n\nimport MonoSynth from './monosynth';\np5.MonoSynth = MonoSynth;\n\nimport OnsetDetect from './onsetDetect';\np5.OnsetDetect = OnsetDetect;\n\nimport PolySynth from './polysynth';\np5.PolySynth = PolySynth;\n\n// Following are the deprecated classes\nimport Signal from './deprecations/Signal';\np5.Signal = Signal;\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../node_modules/tone/Tone/core/Tone.js","webpack:///../node_modules/tone/Tone/signal/Multiply.js","webpack:///../node_modules/tone/Tone/signal/Signal.js","webpack:///./audiocontext.js","webpack:///../node_modules/tone/Tone/signal/Add.js","webpack:///./audioWorklet/processorNames.js","webpack:///../node_modules/tone/Tone/signal/WaveShaper.js","webpack:///../node_modules/tone/Tone/signal/TimelineSignal.js","webpack:///../node_modules/tone/Tone/signal/Scale.js","webpack:///../node_modules/tone/Tone/type/Type.js","webpack:///../node_modules/tone/Tone/core/Gain.js","webpack:///../node_modules/tone/Tone/core/Clock.js","webpack:///../node_modules/tone/Tone/core/Context.js","webpack:///../node_modules/tone/Tone/signal/Subtract.js","webpack:///../node_modules/tone/Tone/core/Emitter.js","webpack:///../node_modules/tone/Tone/signal/SignalBase.js","webpack:///../node_modules/tone/Tone/type/Time.js","webpack:///../node_modules/tone/Tone/type/TimeBase.js","webpack:///../node_modules/tone/Tone/core/Param.js","webpack:///../node_modules/tone/Tone/core/Timeline.js","webpack:///../node_modules/tone/Tone/signal/Negate.js","webpack:///../node_modules/tone/Tone/signal/GreaterThanZero.js","webpack:///../node_modules/startaudiocontext/StartAudioContext.js","webpack:///../node_modules/tone/Tone/component/CrossFade.js","webpack:///../node_modules/audioworklet-polyfill/dist/audioworklet-polyfill.js","webpack:///./shims.js","webpack:///../node_modules/webpack/buildin/global.js","webpack:///./audioWorklet/recorderProcessor.js","webpack:///./audioWorklet/soundFileProcessor.js","webpack:///./audioWorklet/amplitudeProcessor.js","webpack:///../node_modules/tone/Tone/type/Frequency.js","webpack:///../node_modules/tone/Tone/type/TransportTime.js","webpack:///../node_modules/tone/Tone/signal/Expr.js","webpack:///../node_modules/tone/Tone/signal/GreaterThan.js","webpack:///../node_modules/tone/Tone/signal/Abs.js","webpack:///../node_modules/tone/Tone/signal/Modulo.js","webpack:///../node_modules/tone/Tone/signal/Pow.js","webpack:///../node_modules/tone/Tone/signal/AudioToGain.js","webpack:///../node_modules/tone/Tone/signal/EqualPowerGain.js","webpack:///../node_modules/tone/Tone/core/TimelineState.js","webpack:///./main.js","webpack:///./helpers.js","webpack:///./errorHandler.js","webpack:///./audioWorklet/index.js","webpack:///./panner.js","webpack:///./soundfile.js","webpack:///./amplitude.js","webpack:///./fft.js","webpack:///./oscillator.js","webpack:///./envelope.js","webpack:///./noise.js","webpack:///./pulse.js","webpack:///./audioin.js","webpack:///./effect.js","webpack:///./filter.js","webpack:///./eqFilter.js","webpack:///./eq.js","webpack:///./listener3d.js","webpack:///./panner3d.js","webpack:///./delay.js","webpack:///./reverb.js","webpack:///./metro.js","webpack:///./looper.js","webpack:///./soundLoop.js","webpack:///./compressor.js","webpack:///./peakDetect.js","webpack:///./soundRecorder.js","webpack:///./distortion.js","webpack:///./gain.js","webpack:///./audioVoice.js","webpack:///./monosynth.js","webpack:///./onsetDetect.js","webpack:///./polysynth.js","webpack:///./deprecations/Signal.js","webpack:///./app.js"],"names":["define","Tone","inputs","outputs","this","isUndef","input","context","createGain","Array","output","audioContext","prototype","set","params","value","rampTime","isObject","isString","tmpObj","paramLoop","attr","parent","indexOf","attrSplit","split","i","length","splice","innerParam","join","param","Signal","Param","rampTo","AudioParam","get","_collectDefaults","constructor","ret","subRet","j","subAttr","isFunction","constr","defaults","Object","keys","_super","superDefs","push","toString","className","isLetter","match","sameConstructor","defineProperty","isArray","dispose","AudioNode","disconnect","connect","unit","outputNum","inputNum","defaultArg","destination","isNumber","apply","arguments","connectSeries","currentUnit","toUnit","chain","fan","given","fallback","givenProp","fallbackProp","optionsObject","values","options","val","arg","call","isBoolean","noOp","_readOnly","property","writable","enumerable","_writable","State","Started","Stopped","Paused","equalPowerScale","percent","piFactor","Math","PI","sin","dbToGain","db","pow","gainToDb","gain","log","LN10","intervalToFrequencyRatio","interval","now","extend","child","TempConstructor","Context","emit","setContext","ctx","sampleRate","hasAudioContext","window","hasOwnProperty","hasPromises","hasWorkers","version","TONE_SILENCE_VERSION_LOGGING","console","Multiply","createInsOuts","_mult","Gain","_param","_gain","getConstant","units","Type","Default","convert","SignalBase","global","audiocontext","AudioContext","getAudioContext","userStartAudio","elements","callback","elt","p5","Element","map","e","StartAudioContext","Add","_sum","module","exports","recorderProcessor","soundFileProcessor","amplitudeProcessor","WaveShaper","mapping","bufferLen","_shaper","createWaveShaper","_curve","curve","isFinite","Float32Array","setMap","len","normalized","oversample","oversampling","RangeError","TimelineSignal","_events","Timeline","_initial","_fromUnits","Linear","Exponential","Target","Curve","Set","getValueAtTime","_toUnits","convertedVal","cancelScheduledValues","setValueAtTime","startTime","toSeconds","add","type","time","linearRampToValueAtTime","endTime","exponentialRampToValueAtTime","beforeEvent","_searchBefore","_minOutput","setValue","max","sampleTime","setTargetAtTime","timeConstant","constant","setValueCurveAtTime","duration","scaling","floats","segmentTime","after","cancel","setRampPoint","before","_searchAfter","linearRampToValueBetween","start","finish","exponentialRampToValueBetween","getAfter","previouVal","previous","getBefore","_exponentialApproach","_curveInterpolate","_linearInterpolate","_exponentialInterpolate","t0","v0","v1","t","exp","t1","progress","lowerIndex","floor","upperIndex","ceil","lowerVal","upperVal","Scale","outputMin","outputMax","_outputMin","_outputMax","_scale","_add","_setRange","min","Time","Frequency","TransportTime","Ticks","NormalRange","AudioRange","Decibels","Interval","BPM","Positive","Cents","Degrees","MIDI","BarsBeatsSixteenths","Samples","Hertz","Note","Milliseconds","Seconds","Notation","TimeBase","toFrequency","freq","valueOf","toTicks","Transport","ticks","GainNode","createGainNode","_gainNode","Clock","Emitter","_nextTick","_lastState","frequency","_state","TimelineState","_boundLoop","_loop","bind","on","lookAhead","offset","state","stop","setStateAtTime","pause","loopInterval","updateInterval","lag","currentState","event","tickTime","getStateAtTime","off","Infinity","toneConnect","B","outNum","inNum","nativeConnect","Error","nativeDisconnect","webkitAudioContext","prop","_context","_defineProperty","_latencyHint","_lookAhead","_updateInterval","_computedUpdateInterval","_worker","_createWorker","_constants","mixin","currentTime","URL","webkitURL","blob","Blob","toFixed","blobUrl","createObjectURL","worker","Worker","addEventListener","_lastUpdate","diff","buffer","createBuffer","arr","getChannelData","createBufferSource","channelCount","channelCountMode","loop","lA","blockTime","postMessage","hint","latencyHint","supported","warn","Subtract","_neg","Negate","events","eventName","ev","eventList","args","slice","object","functions","func","emitterFunc","node","outputNumber","inputNumber","overridden","_plusNow","_unaryExpressions","create","quantize","regexp","method","rh","nextSubdivision","lh","subdiv","_expr","expr","subdivision","round","addNow","_defaultExpr","_noOp","copy","toNotation","retNotation","_toNotationHelper","retTripletNotation","testNotations","threshold","_notationToUnits","notationTime","multiple","notation","primaryExprs","_primaryExpressions","notationExprs","n","m","toBarsBeatsSixteenths","quarterTime","_beatsToUnits","quarters","measures","_timeSignature","sixteenths","parseFloat","PPQ","toSamples","toMilliseconds","_defaultUnits","exprString","_parseExprString","clone","instance","parseInt","_ticksToUnits","hz","_frequencyToUnits","tr","q","s","total","_secondsToUnits","samples","default","_binaryExpressions","+","precedence","-","*","/","neg","_syntaxGlue","(",")","_tokenize","position","tokens","token","getNextToken","trim","substr","expressions","group","opName","op","reg","SyntaxError","next","peek","_matchGroup","prec","test","_parseBinary","lexer","_parseUnary","_parsePrimary","matching","beats","bpm","seconds","timeSignature","_pushExpr","name","sub","mult","div","_lfo","lfo","undefined","LFO","currentVal","exponentialRampToValue","linearRampToValue","_timeline","_toRemove","_iterating","memory","index","_search","remove","shift","cancelBefore","beginning","end","midPoint","nextEvent","_iterate","lowerBound","upperBound","forEach","forEachBefore","forEachAfter","forEachFrom","forEachAtTime","_multiply","GreaterThanZero","_thresh","root","factory","amd","TapListener","element","_dragged","_element","_bindedMove","_moved","_bindedEnd","_ended","isStarted","source","resume","startContext","removeEventListener","promise","Promise","success","checkLoop","requestAnimationFrame","onStarted","tapListeners","bindTapListener","NodeList","document","querySelectorAll","jquery","toArray","tap","body","then","CrossFade","initialFade","a","b","fade","_equalPowerA","EqualPowerGain","_equalPowerB","_invert","Expr","r","parameters","o","bufferSize","fill","processor","realm","exec","inputBuffer","outputBuffer","process","numberOfChannels","$$processors","$$context","AudioWorkletNode","self","createScriptProcessor","outputChannelCount","Map","properties","u","c","l","defaultValue","p","MessageChannel","port2","f","Processor","port","port1","onaudioprocess","$$audioWorklet","AudioWorklet","addModule","fetch","ok","status","text","AudioWorkletProcessor","registerProcessor","parameterDescriptors","createElement","style","cssText","appendChild","contentWindow","createTextNode","$hook","documentElement","transpile","String","fixSetTarget","setTargetValueAtTime","createDelay","createDelayNode","createJavaScriptNode","createPeriodicWave","createWaveTable","internal_createGain","internal_createDelay","maxDelayTime","delayTime","internal_createBufferSource","when","noteGrainOn","noteOn","internal_start","noteOff","internal_stop","playbackRate","internal_createDynamicsCompressor","createDynamicsCompressor","knee","ratio","reduction","attack","release","internal_createBiquadFilter","createBiquadFilter","detune","Q","createOscillator","internal_createOscillator","setPeriodicWave","setWaveTable","OfflineAudioContext","webkitOfflineAudioContext","navigator","getUserMedia","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","el","isSupported","canPlayType","isOGGSupported","isMP3Supported","isWAVSupported","isAACSupported","isAIFSupported","isFileSupported","extension","toLowerCase","g","Function","midi","midiToFrequency","note","pitch","octave","noteNumber","noteToScaleIndex","transpose","harmonize","intervals","toMidi","frequencyToMidi","toNote","A4","LN2","scaleIndexToNote","cbb","cb","c#","cx","dbb","d","d#","dx","ebb","eb","e#","ex","fbb","fb","f#","fx","gbb","gb","g#","gx","abb","ab","a#","ax","bbb","bb","b#","bx","_secondsToTicks","applyBinary","Constructor","_eval","applyUnary","getNumber","literalNumber","_replacements","inputCount","_parseInputs","_nodes","result","tree","_parseTree","_disposeNodes","_Expressions","signal","glue",",","abs","Abs","mod","modulus","Modulo","Pow","a2g","AudioToGain","binary","unary","!","NOT","inputArray","inputMax","replace","matchSyntax","syn","matchGroup","groupName","parseExpression","parseUnary","operator","parsePrimary","parseArgumentList","parseFunctionCall","GreaterThan","_gtz","_abs","_subtract","_modSignal","_setWaveShaper","_exp","_expScaler","_expFunc","_norm","x","_eqPower","initial","Main","limiter","meter","fftMeter","soundArray","parts","extensions","p5sound","getOutputVolume","outputVolume","vol","tFromNow","currentVol","soundOut","_silentNode","freqToMidi","mathlog2","midiToFreq","noteToFreq","wholeNotes","A","C","D","E","F","G","toUpperCase","soundFormats","disposeSound","_checkFileFormats","paths","path","extTest","pop","pathSplit","pathCore","_mathChain","math","thisChain","nextChain","mathOps","convertToWav","audioBuffer","leftChannel","rightChannel","interleaved","interleave","ArrayBuffer","view","DataView","writeUTFBytes","setUint32","setUint16","lng","volume","setInt16","inputIndex","string","setUint8","charCodeAt","safeBufferSize","idealBufferSize","tempAudioWorkletNode","processorNames","ScriptProcessorNode","saveSound","soundFile","fileName","dataView","writeFile","CustomError","errorTrace","failedPath","err","tempStack","splitStack","originalStack","stack","filter","ln","moduleSources","require","ac","initializedAudioWorklets","loadAudioWorkletModules","all","moduleSrc","objectURL","audioWorklet","registerMethod","preload","_incrementPreload","onWorkletModulesLoad","_decrementPreload","panner","createStereoPanner","Panner","stereoPanner","pan","obj","numInputChannels","left","right","channelInterpretation","splitter","createChannelSplitter","createChannelMerger","v","rightVal","cos","leftVal","numChannels","_createCounterBuffer","audioBuf","arrayBuffer","Cue","id","_clearOnEnd","thisBufferSourceNode","target","_playing","_onended","bufferSourceNodes","_","reverse","SoundFile","onload","onerror","whileLoading","url","File","FileReader","FileList","file","_looping","_paused","_pauseTime","_cues","_cueIDCounter","_lastPos","_counterNode","_workletNode","bufferSourceNode","reversed","pauseTime","mode","startMillis","panPosition","load","_whileLoading","amp","setVolume","errorCallback","request","XMLHttpRequest","evt","_updateProgress","open","responseType","decodeAudioData","response","buff","inputChannels","msg","error","statusText","message","send","reader","readAsArrayBuffer","lengthComputable","percentComplete","loaded","rate","_cueStart","cueStart","cueEnd","isPlaying","_initSourceNode","_initCounterNode","_arrayIndex","loopStart","loopEnd","str","pTime","play","bool","timeFromNow","stopAll","_time","pval","reverseBuffer","num","newPlaybackRate","_rampTime","_tFromNow","cueTime","cTime","dur","width","sampleSize","sampleStep","channels","peaks","chan","currentPos","curVol","getVolume","jump","buf","size","newBuffer","channelNum","channel","cNode","workletBufferSize","processorOptions","onmessage","data","_onTimeUpdate","_initThreshold","_minThreshold","_minPeaks","cue","cueLength","playbackTime","callbackTime","leftLimit","_prevUpdateTime","rightLimit","loadSound","location","origin","cordova","alert","Amplitude","smoothing","parameterData","normalize","volNorm","stereoVol","stereoVolNorm","FFT","bins","analyser","createAnalyser","defineProperties","fftSize","configurable","smoothingTimeConstant","smooth","freqDomain","Uint8Array","frequencyBinCount","timeDomain","bass","lowMid","mid","highMid","treble","normalArray","_isSafari","timeToFloat","getFloatTimeDomainData","timeToInt","getByteTimeDomainData","scaled","freqToFloat","getFloatFrequencyData","freqToInt","getByteFrequencyData","frequency1","frequency2","nyquist","swap","lowIndex","highIndex","numFrequencies","toReturn","freq1","freq2","getEnergy","cumulative_sum","centroid_normalization","mean_freq_index","spec_centroid_freq","_N","N","spectrum","spectrumLength","spectrumStep","linearAverages","groupIndex","specIndex","octaveBands","logAverages","octaveIndex","specIndexFrequency","hi","_fCtr0","fCtr0","lastFrequencyBand","lo","ctr","newFrequencyBand","fft","sigChain","mathObj","chainSource","oscillator","Oscillator","started","phaseAmount","_freqMods","connection","freqNode","isNaN","phase","oscMods","osc2","delayAmt","dNode","Mult","inMin","inMax","outMin","outMax","mapOutMin","mapOutMax","scale","SinOsc","TriOsc","SawOsc","SqrOsc","Envelope","l1","t2","l2","t3","l3","aTime","aLevel","dTime","dLevel","rTime","rLevel","_rampHighPercentage","_rampLowPercentage","control","_init","isExponential","sourceToClear","wasTriggered","_setRampAD","setADSR","sPercent","setRange","_rampAttackTime","checkExpInput","_rampDecayTime","TCDenominator","_rampAttackTC","_rampDecayTC","setRampPercentages","p1","p2","setInput","setExp","isExp","secondsFromNow","susTime","triggerAttack","triggerRelease","lastAttack","valToSet","ramp","v2","destination1","destination2","AudioIn","Reverb","Noise","Filter","Delay","Env","_whiteNoiseBuffer","whiteBuffer","noiseData","random","_pinkNoiseBuffer","pinkBuffer","b0","b1","b2","b3","b4","b5","b6","white","_brownNoiseBuffer","brownBuffer","lastOut","assignType","noise","Pulse","w","dcOffset","createDCOffset","dcGain","mW","sig","mult1","mult2","mods","currentFreq","freqMod","bufferSource","inputSources","stream","mediaStream","currentSource","enabled","amplitude","MediaStreamTrack","mediaDevices","successCallback","audioSource","constraints","audio","echoCancellation","deviceId","createMediaStreamSource","getTracks","track","getLevel","onSuccess","onError","resolve","reject","enumerateDevices","devices","device","kind","active","Effect","_drywet","wet","biquad","setType","_on","_untoggledType","src","res","LowPass","HighPass","BandPass","EQFilter","EQ","_eqsize","factor","bands","_newBand","Listener3D","listener","xVal","yVal","zVal","positionX","positionY","positionZ","xValF","yValF","zValF","xValU","yValU","zValU","orientForward","orientUp","forwardX","forwardY","forwardZ","upX","upY","upZ","Panner3D","createPanner","panningModel","distanceModel","orientX","orientY","orientZ","orientationX","orientationY","orientationZ","maxDistance","rolloffFactor","maxDist","rolloff","_split","_merge","_leftGain","_rightGain","leftDelay","rightDelay","_leftFilter","_rightFilter","_maxDelay","maxValue","feedback","_delayTime","_feedback","_filter","_initConvolverNode","_seconds","_decay","_reverse","_buildImpulse","convolverNode","createConvolver","_teardownConvolverNode","decayRate","rebuild","decay","impulse","impulseL","impulseR","_setBuffer","Convolver","impulses","_loadBuffer","_path","chunks","cReverb","Metro","clock","ontick","syncedParts","prevTick","tatumTime","tickCallback","elapsedTime","thisPart","incrementStep","phrases","thisPhrase","phraseArray","sequence","bNum","metroTicks","looping","beatTime","tatums","getRate","part","setBPM","Phrase","phraseStep","Part","steps","bLength","partStep","noLoop","metro","beatLength","tempo","getBPM","resetSync","onended","array","Score","currentPart","thisScore","nextPart","resetPart","playNextPart","resetParts","scoreStep","aScore","SoundLoop","_bpm","musicalTimeMode","_update","timeSig","_interval","maxIterations","iterations","_calcFreq","otherLoop","_convertNotation","Number","_measure","_note","Compressor","compressor","number","PeakDetect","_framesPerPeak","framesPerPeak","framesSinceLastPeak","cutoff","cutoffMult","energy","penergy","currentValue","isDetected","f1","f2","_onPeak","fftObject","nrg","SoundRecorder","_inputChannels","_outputChannels","buffers","leftBuffer","rightBuffer","_callback","sFile","setBuffer","makeDistortionCurve","amount","k","numSamples","deg","Distortion","curveAmount","waveShaperNode","AudioVoice","velocity","sustime","DEFAULT_SUSTAIN","MonoSynth","env","sustain","vel","OnsetDetect","freqLow","freqHigh","treshold","sensitivity","setTimeout","PolySynth","audioVoice","maxVoices","audiovoices","notes","_newest","_oldest","_voicesInUse","_allocateVoices","noteAttack","noteRelease","voice","_velocity","acTime","currentVoice","oldestNote","previousVal","_updateAfter","maxRange","nextTime","registerPreload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AAE,CAACy9B,MAAH,GAAYA,MAAZ;AACAz9B,EAAE,CAAC4mC,SAAH,GAAeA,gBAAf;AACA5mC,EAAE,CAACxI,SAAH,CAAa2uC,eAAb,GAA+BA,eAA/B;AACAnmC,EAAE,CAACxI,SAAH,CAAa03C,qBAAb,CAAmC,iBAAnC,EAAsDlvC,EAAE,CAACxI,SAAzD;AAEA;AACAwI,EAAE,CAACknC,KAAH,GAAWA,KAAX;AAEA;AACAlnC,EAAE,CAACwoC,MAAH,GAAYA,MAAZ;AACAxoC,EAAE,CAAC0oC,IAAH,GAAUA,WAAV;AACA1oC,EAAE,CAACspC,KAAH,GAAWA,KAAX;AAEA;AACAtpC,EAAE,CAAC+pC,SAAH,GAAeA,SAAf;AAEA;AACA/pC,EAAE,CAAC6qC,UAAH,GAAgBA,UAAhB;AAEA;AACA7qC,EAAE,CAACovC,UAAH,GAAgBA,UAAhB;AAEA;AACApvC,EAAE,CAAC+rC,aAAH,GAAmBA,aAAnB;AAEA;AACA/rC,EAAE,CAAC6sC,UAAH,GAAgBA,UAAhB;AAEA;AACA7sC,EAAE,CAACjB,IAAH,GAAUA,IAAV;AAEA;AACAiB,EAAE,CAACgtC,UAAH,GAAgBA,YAAhB;AAEA;AACAhtC,EAAE,CAACotC,SAAH,GAAeA,SAAf;AAEA;AACAptC,EAAE,CAACwtC,WAAH,GAAiBA,WAAjB;AAEA;AACAxtC,EAAE,CAAC8tC,SAAH,GAAeA,SAAf,C,CAEA;;AACA;AACA9tC,EAAE,CAACpH,MAAH,GAAYA,mBAAZ,C","file":"p5.sound.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 40);\n","/**\n * Tone.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2014-2017 Yotam Mann\n */\ndefine(function(){\n\n\t\"use strict\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTONE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * @class Tone is the base class of all other classes. It provides \n\t * a lot of methods and functionality to all classes that extend\n\t * it. \n\t * \n\t * @constructor\n\t * @alias Tone\n\t * @param {number} [inputs=1] the number of input nodes\n\t * @param {number} [outputs=1] the number of output nodes\n\t */\n\tvar Tone = function(inputs, outputs){\n\n\t\t/**\n\t\t * the input node(s)\n\t\t * @type {GainNode|Array}\n\t\t */\n\t\tif (this.isUndef(inputs) || inputs === 1){\n\t\t\tthis.input = this.context.createGain();\n\t\t} else if (inputs > 1){\n\t\t\tthis.input = new Array(inputs);\n\t\t}\n\n\t\t/**\n\t\t * the output node(s)\n\t\t * @type {GainNode|Array}\n\t\t */\n\t\tif (this.isUndef(outputs) || outputs === 1){\n\t\t\tthis.output = this.context.createGain();\n\t\t} else if (outputs > 1){\n\t\t\tthis.output = new Array(inputs);\n\t\t}\n\t};\n\n\t/**\n\t * Set the parameters at once. Either pass in an\n\t * object mapping parameters to values, or to set a\n\t * single parameter, by passing in a string and value.\n\t * The last argument is an optional ramp time which \n\t * will ramp any signal values to their destination value\n\t * over the duration of the rampTime.\n\t * @param {Object|string} params\n\t * @param {number=} value\n\t * @param {Time=} rampTime\n\t * @returns {Tone} this\n\t * @example\n\t * //set values using an object\n\t * filter.set({\n\t * \t\"frequency\" : 300,\n\t * \t\"type\" : highpass\n\t * });\n\t * @example\n\t * filter.set(\"type\", \"highpass\");\n\t * @example\n\t * //ramp to the value 220 over 3 seconds. \n\t * oscillator.set({\n\t * \t\"frequency\" : 220\n\t * }, 3);\n\t */\n\tTone.prototype.set = function(params, value, rampTime){\n\t\tif (this.isObject(params)){\n\t\t\trampTime = value;\n\t\t} else if (this.isString(params)){\n\t\t\tvar tmpObj = {};\n\t\t\ttmpObj[params] = value;\n\t\t\tparams = tmpObj;\n\t\t}\n\n\t\tparamLoop:\n\t\tfor (var attr in params){\n\t\t\tvalue = params[attr];\n\t\t\tvar parent = this;\n\t\t\tif (attr.indexOf(\".\") !== -1){\n\t\t\t\tvar attrSplit = attr.split(\".\");\n\t\t\t\tfor (var i = 0; i < attrSplit.length - 1; i++){\n\t\t\t\t\tparent = parent[attrSplit[i]];\n\t\t\t\t\tif (parent instanceof Tone) {\n\t\t\t\t\t\tattrSplit.splice(0,i+1);\n\t\t\t\t\t\tvar innerParam = attrSplit.join(\".\");\n\t\t\t\t\t\tparent.set(innerParam, value);\n\t\t\t\t\t\tcontinue paramLoop;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tattr = attrSplit[attrSplit.length - 1];\n\t\t\t}\n\t\t\tvar param = parent[attr];\n\t\t\tif (this.isUndef(param)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((Tone.Signal && param instanceof Tone.Signal) || \n\t\t\t\t\t(Tone.Param && param instanceof Tone.Param)){\n\t\t\t\tif (param.value !== value){\n\t\t\t\t\tif (this.isUndef(rampTime)){\n\t\t\t\t\t\tparam.value = value;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparam.rampTo(value, rampTime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (param instanceof AudioParam){\n\t\t\t\tif (param.value !== value){\n\t\t\t\t\tparam.value = value;\n\t\t\t\t}\t\t\t\t\n\t\t\t} else if (param instanceof Tone){\n\t\t\t\tparam.set(value);\n\t\t\t} else if (param !== value){\n\t\t\t\tparent[attr] = value;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Get the object's attributes. Given no arguments get\n\t * will return all available object properties and their corresponding\n\t * values. Pass in a single attribute to retrieve or an array\n\t * of attributes. The attribute strings can also include a \".\"\n\t * to access deeper properties.\n\t * @example\n\t * osc.get();\n\t * //returns {\"type\" : \"sine\", \"frequency\" : 440, ...etc}\n\t * @example\n\t * osc.get(\"type\");\n\t * //returns { \"type\" : \"sine\"}\n\t * @example\n\t * //use dot notation to access deep properties\n\t * synth.get([\"envelope.attack\", \"envelope.release\"]);\n\t * //returns {\"envelope\" : {\"attack\" : 0.2, \"release\" : 0.4}}\n\t * @param {Array=|string|undefined} params the parameters to get, otherwise will return \n\t * \t\t\t\t\t all available.\n\t * @returns {Object}\n\t */\n\tTone.prototype.get = function(params){\n\t\tif (this.isUndef(params)){\n\t\t\tparams = this._collectDefaults(this.constructor);\n\t\t} else if (this.isString(params)){\n\t\t\tparams = [params];\n\t\t} \n\t\tvar ret = {};\n\t\tfor (var i = 0; i < params.length; i++){\n\t\t\tvar attr = params[i];\n\t\t\tvar parent = this;\n\t\t\tvar subRet = ret;\n\t\t\tif (attr.indexOf(\".\") !== -1){\n\t\t\t\tvar attrSplit = attr.split(\".\");\n\t\t\t\tfor (var j = 0; j < attrSplit.length - 1; j++){\n\t\t\t\t\tvar subAttr = attrSplit[j];\n\t\t\t\t\tsubRet[subAttr] = subRet[subAttr] || {};\n\t\t\t\t\tsubRet = subRet[subAttr];\n\t\t\t\t\tparent = parent[subAttr];\n\t\t\t\t}\n\t\t\t\tattr = attrSplit[attrSplit.length - 1];\n\t\t\t}\n\t\t\tvar param = parent[attr];\n\t\t\tif (this.isObject(params[attr])){\n\t\t\t\tsubRet[attr] = param.get();\n\t\t\t} else if (Tone.Signal && param instanceof Tone.Signal){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (Tone.Param && param instanceof Tone.Param){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (param instanceof AudioParam){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (param instanceof Tone){\n\t\t\t\tsubRet[attr] = param.get();\n\t\t\t} else if (!this.isFunction(param) && !this.isUndef(param)){\n\t\t\t\tsubRet[attr] = param;\n\t\t\t} \n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * collect all of the default attributes in one\n\t * @private\n\t * @param {function} constr the constructor to find the defaults from\n\t * @return {Array} all of the attributes which belong to the class\n\t */\n\tTone.prototype._collectDefaults = function(constr){\n\t\tvar ret = [];\n\t\tif (!this.isUndef(constr.defaults)){\n\t\t\tret = Object.keys(constr.defaults);\n\t\t}\n\t\tif (!this.isUndef(constr._super)){\n\t\t\tvar superDefs = this._collectDefaults(constr._super);\n\t\t\t//filter out repeats\n\t\t\tfor (var i = 0; i < superDefs.length; i++){\n\t\t\t\tif (ret.indexOf(superDefs[i]) === -1){\n\t\t\t\t\tret.push(superDefs[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * @returns {string} returns the name of the class as a string\n\t */\n\tTone.prototype.toString = function(){\n\t\tfor (var className in Tone){\n\t\t\tvar isLetter = className[0].match(/^[A-Z]$/);\n\t\t\tvar sameConstructor = Tone[className] === this.constructor;\n\t\t\tif (this.isFunction(Tone[className]) && isLetter && sameConstructor){\n\t\t\t\treturn className;\n\t\t\t}\n\t\t}\n\t\treturn \"Tone\";\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCLASS VARS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The number of inputs feeding into the AudioNode. \n\t * For source nodes, this will be 0.\n\t * @memberOf Tone#\n\t * @name numberOfInputs\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"numberOfInputs\", {\n\t\tget : function(){\n\t\t\tif (this.input){\n\t\t\t\tif (this.isArray(this.input)){\n\t\t\t\t\treturn this.input.length;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * The number of outputs coming out of the AudioNode. \n\t * For source nodes, this will be 0.\n\t * @memberOf Tone#\n\t * @name numberOfInputs\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"numberOfOutputs\", {\n\t\tget : function(){\n\t\t\tif (this.output){\n\t\t\t\tif (this.isArray(this.output)){\n\t\t\t\t\treturn this.output.length;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\t\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCONNECTIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * disconnect and dispose\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.dispose = function(){\n\t\tif (!this.isUndef(this.input)){\n\t\t\tif (this.input instanceof AudioNode){\n\t\t\t\tthis.input.disconnect();\n\t\t\t} \n\t\t\tthis.input = null;\n\t\t}\n\t\tif (!this.isUndef(this.output)){\n\t\t\tif (this.output instanceof AudioNode){\n\t\t\t\tthis.output.disconnect();\n\t\t\t} \n\t\t\tthis.output = null;\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode\n\t * @param {Tone | AudioParam | AudioNode} unit \n\t * @param {number} [outputNum=0] optionally which output to connect from\n\t * @param {number} [inputNum=0] optionally which input to connect to\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.connect = function(unit, outputNum, inputNum){\n\t\tif (Array.isArray(this.output)){\n\t\t\toutputNum = this.defaultArg(outputNum, 0);\n\t\t\tthis.output[outputNum].connect(unit, 0, inputNum);\n\t\t} else {\n\t\t\tthis.output.connect(unit, outputNum, inputNum);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * disconnect the output\n\t * @param {Number|AudioNode} output Either the output index to disconnect\n\t * if the output is an array, or the\n\t * node to disconnect from.\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.disconnect = function(destination, outputNum, inputNum){\n\t\tif (this.isArray(this.output)){\n\t\t\tif (this.isNumber(destination)){\n\t\t\t\tthis.output[destination].disconnect();\n\t\t\t} else {\n\t\t\t\toutputNum = this.defaultArg(outputNum, 0);\n\t\t\t\tthis.output[outputNum].disconnect(destination, 0, inputNum);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.output.disconnect.apply(this.output, arguments);\n\t\t}\n\t};\n\n\t/**\n\t * connect together all of the arguments in series\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.connectSeries = function(){\n\t\tif (arguments.length > 1){\n\t\t\tvar currentUnit = arguments[0];\n\t\t\tfor (var i = 1; i < arguments.length; i++){\n\t\t\t\tvar toUnit = arguments[i];\n\t\t\t\tcurrentUnit.connect(toUnit);\n\t\t\t\tcurrentUnit = toUnit;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Connect the output of this node to the rest of the nodes in series.\n\t * @example\n\t * //connect a node to an effect, panVol and then to the master output\n\t * node.chain(effect, panVol, Tone.Master);\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.chain = function(){\n\t\tif (arguments.length > 0){\n\t\t\tvar currentUnit = this;\n\t\t\tfor (var i = 0; i < arguments.length; i++){\n\t\t\t\tvar toUnit = arguments[i];\n\t\t\t\tcurrentUnit.connect(toUnit);\n\t\t\t\tcurrentUnit = toUnit;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * connect the output of this node to the rest of the nodes in parallel.\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.fan = function(){\n\t\tif (arguments.length > 0){\n\t\t\tfor (var i = 0; i < arguments.length; i++){\n\t\t\t\tthis.connect(arguments[i]);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t//give native nodes chain and fan methods\n\tAudioNode.prototype.chain = Tone.prototype.chain;\n\tAudioNode.prototype.fan = Tone.prototype.fan;\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUTILITIES / HELPERS / MATHS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * If the `given` parameter is undefined, use the `fallback`. \n\t * If both `given` and `fallback` are object literals, it will\n\t * return a deep copy which includes all of the parameters from both \n\t * objects. If a parameter is undefined in given, it will return\n\t * the fallback property. \n\t *

\n\t * WARNING: if object is self referential, it will go into an an \n\t * infinite recursive loop.\n\t * \n\t * @param {*} given \n\t * @param {*} fallback \n\t * @return {*} \n\t */\n\tTone.prototype.defaultArg = function(given, fallback){\n\t\tif (this.isObject(given) && this.isObject(fallback)){\n\t\t\tvar ret = {};\n\t\t\t//make a deep copy of the given object\n\t\t\tfor (var givenProp in given) {\n\t\t\t\tret[givenProp] = this.defaultArg(fallback[givenProp], given[givenProp]);\n\t\t\t}\n\t\t\tfor (var fallbackProp in fallback) {\n\t\t\t\tret[fallbackProp] = this.defaultArg(given[fallbackProp], fallback[fallbackProp]);\n\t\t\t}\n\t\t\treturn ret;\n\t\t} else {\n\t\t\treturn this.isUndef(given) ? fallback : given;\n\t\t}\n\t};\n\n\t/**\n\t * returns the args as an options object with given arguments\n\t * mapped to the names provided. \n\t *\n\t * if the args given is an array containing only one object, it is assumed\n\t * that that's already the options object and will just return it. \n\t * \n\t * @param {Array} values the 'arguments' object of the function\n\t * @param {Array} keys the names of the arguments as they\n\t * should appear in the options object\n\t * @param {Object=} defaults optional defaults to mixin to the returned \n\t * options object \n\t * @return {Object} the options object with the names mapped to the arguments\n\t */\n\tTone.prototype.optionsObject = function(values, keys, defaults){\n\t\tvar options = {};\n\t\tif (values.length === 1 && this.isObject(values[0])){\n\t\t\toptions = values[0];\n\t\t} else {\n\t\t\tfor (var i = 0; i < keys.length; i++){\n\t\t\t\toptions[keys[i]] = values[i];\n\t\t\t}\n\t\t}\n\t\tif (!this.isUndef(defaults)){\n\t\t\treturn this.defaultArg(options, defaults);\n\t\t} else {\n\t\t\treturn options;\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// TYPE CHECKING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * test if the arg is undefined\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is undefined\n\t * @function\n\t */\n\tTone.prototype.isUndef = function(val){\n\t\treturn typeof val === \"undefined\";\n\t};\n\n\t/**\n\t * test if the arg is a function\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a function\n\t * @function\n\t */\n\tTone.prototype.isFunction = function(val){\n\t\treturn typeof val === \"function\";\n\t};\n\n\t/**\n\t * Test if the argument is a number.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a number\n\t */\n\tTone.prototype.isNumber = function(arg){\n\t\treturn (typeof arg === \"number\");\n\t};\n\n\t/**\n\t * Test if the given argument is an object literal (i.e. `{}`);\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is an object literal.\n\t */\n\tTone.prototype.isObject = function(arg){\n\t\treturn (Object.prototype.toString.call(arg) === \"[object Object]\" && arg.constructor === Object);\n\t};\n\n\t/**\n\t * Test if the argument is a boolean.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a boolean\n\t */\n\tTone.prototype.isBoolean = function(arg){\n\t\treturn (typeof arg === \"boolean\");\n\t};\n\n\t/**\n\t * Test if the argument is an Array\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is an array\n\t */\n\tTone.prototype.isArray = function(arg){\n\t\treturn (Array.isArray(arg));\n\t};\n\n\t/**\n\t * Test if the argument is a string.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a string\n\t */\n\tTone.prototype.isString = function(arg){\n\t\treturn (typeof arg === \"string\");\n\t};\n\n \t/**\n\t * An empty function.\n\t * @static\n\t */\n\tTone.noOp = function(){};\n\n\t/**\n\t * Make the property not writable. Internal use only. \n\t * @private\n\t * @param {string} property the property to make not writable\n\t */\n\tTone.prototype._readOnly = function(property){\n\t\tif (Array.isArray(property)){\n\t\t\tfor (var i = 0; i < property.length; i++){\n\t\t\t\tthis._readOnly(property[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tObject.defineProperty(this, property, { \n\t\t\t\twritable: false,\n\t\t\t\tenumerable : true,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Make an attribute writeable. Interal use only. \n\t * @private\n\t * @param {string} property the property to make writable\n\t */\n\tTone.prototype._writable = function(property){\n\t\tif (Array.isArray(property)){\n\t\t\tfor (var i = 0; i < property.length; i++){\n\t\t\t\tthis._writable(property[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tObject.defineProperty(this, property, { \n\t\t\t\twritable: true,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Possible play states. \n\t * @enum {string}\n\t */\n\tTone.State = {\n\t\tStarted : \"started\",\n\t\tStopped : \"stopped\",\n\t\tPaused : \"paused\",\n \t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Equal power gain scale. Good for cross-fading.\n\t * @param {NormalRange} percent (0-1)\n\t * @return {Number} output gain (0-1)\n\t */\n\tTone.prototype.equalPowerScale = function(percent){\n\t\tvar piFactor = 0.5 * Math.PI;\n\t\treturn Math.sin(percent * piFactor);\n\t};\n\n\t/**\n\t * Convert decibels into gain.\n\t * @param {Decibels} db\n\t * @return {Number} \n\t */\n\tTone.prototype.dbToGain = function(db) {\n\t\treturn Math.pow(2, db / 6);\n\t};\n\n\t/**\n\t * Convert gain to decibels.\n\t * @param {Number} gain (0-1)\n\t * @return {Decibels} \n\t */\n\tTone.prototype.gainToDb = function(gain) {\n\t\treturn 20 * (Math.log(gain) / Math.LN10);\n\t};\n\n\t/**\n\t * Convert an interval (in semitones) to a frequency ratio.\n\t * @param {Interval} interval the number of semitones above the base note\n\t * @return {number} the frequency ratio\n\t * @example\n\t * tone.intervalToFrequencyRatio(0); // 1\n\t * tone.intervalToFrequencyRatio(12); // 2\n\t * tone.intervalToFrequencyRatio(-12); // 0.5\n\t */\n\tTone.prototype.intervalToFrequencyRatio = function(interval){\n\t\treturn Math.pow(2,(interval/12));\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTIMING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Return the current time of the AudioContext clock.\n\t * @return {Number} the currentTime from the AudioContext\n\t */\n\tTone.prototype.now = function(){\n\t\treturn Tone.context.now();\n\t};\n\n\t/**\n\t * Return the current time of the AudioContext clock.\n\t * @return {Number} the currentTime from the AudioContext\n\t * @static\n\t */\n\tTone.now = function(){\n\t\treturn Tone.context.now();\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tINHERITANCE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * have a child inherit all of Tone's (or a parent's) prototype\n\t * to inherit the parent's properties, make sure to call \n\t * Parent.call(this) in the child's constructor\n\t *\n\t * based on closure library's inherit function\n\t *\n\t * @static\n\t * @param {function} \tchild \n\t * @param {function=} parent (optional) parent to inherit from\n\t * if no parent is supplied, the child\n\t * will inherit from Tone\n\t */\n\tTone.extend = function(child, parent){\n\t\tif (Tone.prototype.isUndef(parent)){\n\t\t\tparent = Tone;\n\t\t}\n\t\tfunction TempConstructor(){}\n\t\tTempConstructor.prototype = parent.prototype;\n\t\tchild.prototype = new TempConstructor();\n\t\t/** @override */\n\t\tchild.prototype.constructor = child;\n\t\tchild._super = parent;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCONTEXT\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The private audio context shared by all Tone Nodes. \n\t * @private\n\t * @type {Tone.Context|undefined}\n\t */\n\tvar audioContext;\n\n\t/**\n\t * A static pointer to the audio context accessible as Tone.context. \n\t * @type {Tone.Context}\n\t * @name context\n\t * @memberOf Tone\n\t */\n\tObject.defineProperty(Tone, \"context\", {\n\t\tget : function(){\n\t\t\treturn audioContext;\n\t\t},\n\t\tset : function(context){\n\t\t\tif (Tone.Context && context instanceof Tone.Context){\n\t\t\t\taudioContext = context;\n\t\t\t} else {\n\t\t\t\taudioContext = new Tone.Context(context);\n\t\t\t}\n\t\t\t//initialize the new audio context\n\t\t\tif (Tone.Context){\n\t\t\t\tTone.Context.emit(\"init\", audioContext);\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * The AudioContext\n\t * @type {Tone.Context}\n\t * @name context\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"context\", {\n\t\tget : function(){\n\t\t\treturn Tone.context;\n\t\t}\n\t});\n\n\t/**\n\t * Tone automatically creates a context on init, but if you are working\n\t * with other libraries which also create an AudioContext, it can be\n\t * useful to set your own. If you are going to set your own context, \n\t * be sure to do it at the start of your code, before creating any objects.\n\t * @static\n\t * @param {AudioContext} ctx The new audio context to set\n\t */\n\tTone.setContext = function(ctx){\n\t\tTone.context = ctx;\n\t};\n\n\t/**\n\t * The number of seconds of 1 processing block (128 samples)\n\t * @type {Number}\n\t * @name blockTime\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"blockTime\", {\n\t\tget : function(){\n\t\t\treturn 128 / this.context.sampleRate;\n\t\t}\n\t});\n\n\t/**\n\t * The duration in seconds of one sample.\n\t * @type {Number}\n\t * @name sampleTime\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"sampleTime\", {\n\t\tget : function(){\n\t\t\treturn 1 / this.context.sampleRate;\n\t\t}\n\t});\n\n\t/**\n\t * Whether or not all the technologies that Tone.js relies on are supported by the current browser. \n\t * @type {Boolean}\n\t * @name supported\n\t * @memberOf Tone\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone, \"supported\", {\n\t\tget : function(){\n\t\t\tvar hasAudioContext = window.hasOwnProperty(\"AudioContext\") || window.hasOwnProperty(\"webkitAudioContext\");\n\t\t\tvar hasPromises = window.hasOwnProperty(\"Promise\");\n\t\t\tvar hasWorkers = window.hasOwnProperty(\"Worker\");\n\t\t\treturn hasAudioContext && hasPromises && hasWorkers;\n\t\t}\n\t});\n\n\tTone.version = \"r10\";\n\n\t// allow optional silencing of this log\n\tif (!window.TONE_SILENCE_VERSION_LOGGING) {\n\t\tconsole.log(\"%c * Tone.js \" + Tone.version + \" * \", \"background: #000; color: #fff\");\n\t}\n\n\treturn Tone;\n});\n","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Multiply two incoming signals. Or, if a number is given in the constructor, \n\t * multiplies the incoming signal by that value. \n\t *\n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number=} value Constant value to multiple. If no value is provided,\n\t * it will return the product of the first and second inputs\n\t * @example\n\t * var mult = new Tone.Multiply();\n\t * var sigA = new Tone.Signal(3);\n\t * var sigB = new Tone.Signal(4);\n\t * sigA.connect(mult, 0, 0);\n\t * sigB.connect(mult, 0, 1);\n\t * //output of mult is 12.\n\t * @example\n\t * var mult = new Tone.Multiply(10);\n\t * var sig = new Tone.Signal(2).connect(mult);\n\t * //the output of mult is 20. \n\t */\n\tTone.Multiply = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the input node is the same as the output node\n\t\t * it is also the GainNode which handles the scaling of incoming signal\n\t\t * \n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._mult = this.input[0] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * the scaling parameter\n\t\t * @type {AudioParam}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input[1] = this.output.gain;\n\t\t\n\t\tthis._param.value = this.defaultArg(value, 0);\n\t};\n\n\tTone.extend(Tone.Multiply, Tone.Signal);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Multiply} this\n\t */\n\tTone.Multiply.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._mult.dispose();\n\t\tthis._mult = null;\n\t\tthis._param = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Multiply;\n});\n","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/type/Type\", \"Tone/core/Param\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class A signal is an audio-rate value. Tone.Signal is a core component of the library.\n\t * Unlike a number, Signals can be scheduled with sample-level accuracy. Tone.Signal\n\t * has all of the methods available to native Web Audio \n\t * [AudioParam](http://webaudio.github.io/web-audio-api/#the-audioparam-interface)\n\t * as well as additional conveniences. Read more about working with signals \n\t * [here](https://github.com/Tonejs/Tone.js/wiki/Signals).\n\t *\n\t * @constructor\n\t * @extends {Tone.Param}\n\t * @param {Number|AudioParam} [value] Initial value of the signal. If an AudioParam\n\t * is passed in, that parameter will be wrapped\n\t * and controlled by the Signal. \n\t * @param {string} [units=Number] unit The units the signal is in. \n\t * @example\n\t * var signal = new Tone.Signal(10);\n\t */\n\tTone.Signal = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"value\", \"units\"], Tone.Signal.defaults);\n\n\t\t/**\n\t\t * The node where the constant signal value is scaled.\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis.output = this._gain = this.context.createGain();\n\n\t\toptions.param = this._gain.gain;\n\t\tTone.Param.call(this, options);\n\n\t\t/**\n\t\t * The node where the value is set.\n\t\t * @type {Tone.Param}\n\t\t * @private\n\t\t */\n\t\tthis.input = this._param = this._gain.gain;\n\n\t\t//connect the const output to the node output\n\t\tthis.context.getConstant(1).chain(this._gain);\n\t};\n\n\tTone.extend(Tone.Signal, Tone.Param);\n\n\t/**\n\t * The default values\n\t * @type {Object}\n\t * @static\n\t * @const\n\t */\n\tTone.Signal.defaults = {\n\t\t\"value\" : 0,\n\t\t\"units\" : Tone.Type.Default,\n\t\t\"convert\" : true,\n\t};\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.SignalBase} this\n\t * @method\n\t */\n\tTone.Signal.prototype.connect = Tone.SignalBase.prototype.connect;\n\n\t/**\n\t * dispose and disconnect\n\t * @returns {Tone.Signal} this\n\t */\n\tTone.Signal.prototype.dispose = function(){\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._param = null;\n\t\tthis._gain.disconnect();\n\t\tthis._gain = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Signal;\n});","global.TONE_SILENCE_VERSION_LOGGING = true;\n\nimport StartAudioContext from 'startaudiocontext';\nimport Tone from 'Tone/core/Tone';\nimport 'Tone/core/Context';\n\n// Create the Audio Context\nconst audiocontext = new window.AudioContext();\n\n// Tone and p5.sound share the same audio context\nTone.setContext(audiocontext);\n\n/**\n *

Returns the Audio Context for this sketch. Useful for users\n * who would like to dig deeper into the Web Audio API\n * .

\n *\n *

Some browsers require users to startAudioContext\n * with a user gesture, such as touchStarted in the example below.

\n *\n * @for p5\n * @method getAudioContext\n * @return {Object} AudioContext for this sketch\n * @example\n *
\n * function draw() {\n * background(255);\n * textAlign(CENTER);\n *\n * if (getAudioContext().state !== 'running') {\n * text('click to start audio', width/2, height/2);\n * } else {\n * text('audio is enabled', width/2, height/2);\n * }\n * }\n *\n * function touchStarted() {\n * if (getAudioContext().state !== 'running') {\n * getAudioContext().resume();\n * }\n * var synth = new p5.MonoSynth();\n * synth.play('A4', 0.5, 0, 0.2);\n * }\n *\n *
\n */\nexport function getAudioContext() {\n return audiocontext;\n}\n\n/**\n *

It is not only a good practice to give users control over starting\n * audio. This policy is enforced by many web browsers, including iOS and\n * Google Chrome, which create the Web Audio API's\n * Audio Context\n * in a suspended state.

\n *\n *

In these browser-specific policies, sound will not play until a user\n * interaction event (i.e. mousePressed()) explicitly resumes\n * the AudioContext, or starts an audio node. This can be accomplished by\n * calling start() on a p5.Oscillator,\n * play() on a p5.SoundFile, or simply\n * userStartAudio().

\n *\n *

userStartAudio() starts the AudioContext on a user\n * gesture. The default behavior will enable audio on any\n * mouseUp or touchEnd event. It can also be placed in a specific\n * interaction function, such as mousePressed() as in the\n * example below. This method utilizes\n * StartAudioContext\n * , a library by Yotam Mann (MIT Licence, 2016).

\n * @param {Element|Array} [element(s)] This argument can be an Element,\n * Selector String, NodeList, p5.Element,\n * jQuery Element, or an Array of any of those.\n * @param {Function} [callback] Callback to invoke when the AudioContext\n * has started\n * @return {Promise} Returns a Promise that resolves when\n * the AudioContext state is 'running'\n * @method userStartAudio\n * @for p5\n * @example\n *
\n * function setup() {\n * // mimics the autoplay policy\n * getAudioContext().suspend();\n *\n * let mySynth = new p5.MonoSynth();\n *\n * // This won't play until the context has resumed\n * mySynth.play('A6');\n * }\n * function draw() {\n * background(220);\n * textAlign(CENTER, CENTER);\n * text(getAudioContext().state, width/2, height/2);\n * }\n * function mousePressed() {\n * userStartAudio();\n * }\n *
\n */\nexport function userStartAudio(elements, callback) {\n var elt = elements;\n if (elements instanceof p5.Element) {\n elt = elements.elt;\n } else if (elements instanceof Array && elements[0] instanceof p5.Element) {\n elt = elements.map(function (e) {\n return e.elt;\n });\n }\n return StartAudioContext(audiocontext, elt, callback);\n}\n\nexport default audiocontext;\n","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Add a signal and a number or two signals. When no value is\n\t * passed into the constructor, Tone.Add will sum input[0]\n\t * and input[1]. If a value is passed into the constructor, \n\t * the it will be added to the input.\n\t * \n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number=} value If no value is provided, Tone.Add will sum the first\n\t * and second inputs. \n\t * @example\n\t * var signal = new Tone.Signal(2);\n\t * var add = new Tone.Add(2);\n\t * signal.connect(add);\n\t * //the output of add equals 4\n\t * @example\n\t * //if constructed with no arguments\n\t * //it will add the first and second inputs\n\t * var add = new Tone.Add();\n\t * var sig0 = new Tone.Signal(3).connect(add, 0, 0);\n\t * var sig1 = new Tone.Signal(4).connect(add, 0, 1);\n\t * //the output of add equals 7. \n\t */\n\tTone.Add = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the summing node\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._sum = this.input[0] = this.input[1] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * @private\n\t\t * @type {Tone.Signal}\n\t\t */\n\t\tthis._param = this.input[1] = new Tone.Signal(value);\n\n\t\tthis._param.connect(this._sum);\n\t};\n\n\tTone.extend(Tone.Add, Tone.Signal);\n\t\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Add} this\n\t */\n\tTone.Add.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._sum.dispose();\n\t\tthis._sum = null;\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Add;\n});","module.exports = {\n recorderProcessor: 'recorder-processor',\n soundFileProcessor: 'sound-file-processor',\n amplitudeProcessor: 'amplitude-processor',\n};\n","define([\"Tone/core/Tone\", \"Tone/signal/SignalBase\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Wraps the native Web Audio API \n\t * [WaveShaperNode](http://webaudio.github.io/web-audio-api/#the-waveshapernode-interface).\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {function|Array|Number} mapping The function used to define the values. \n\t * The mapping function should take two arguments: \n\t * the first is the value at the current position \n\t * and the second is the array position. \n\t * If the argument is an array, that array will be\n\t * set as the wave shaping function. The input\n\t * signal is an AudioRange [-1, 1] value and the output\n\t * signal can take on any numerical values. \n\t * \n\t * @param {Number} [bufferLen=1024] The length of the WaveShaperNode buffer.\n\t * @example\n\t * var timesTwo = new Tone.WaveShaper(function(val){\n\t * \treturn val * 2;\n\t * }, 2048);\n\t * @example\n\t * //a waveshaper can also be constructed with an array of values\n\t * var invert = new Tone.WaveShaper([1, -1]);\n\t */\n\tTone.WaveShaper = function(mapping, bufferLen){\n\n\t\t/**\n\t\t * the waveshaper\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._shaper = this.input = this.output = this.context.createWaveShaper();\n\n\t\t/**\n\t\t * the waveshapers curve\n\t\t * @type {Float32Array}\n\t\t * @private\n\t\t */\n\t\tthis._curve = null;\n\n\t\tif (Array.isArray(mapping)){\n\t\t\tthis.curve = mapping;\n\t\t} else if (isFinite(mapping) || this.isUndef(mapping)){\n\t\t\tthis._curve = new Float32Array(this.defaultArg(mapping, 1024));\n\t\t} else if (this.isFunction(mapping)){\n\t\t\tthis._curve = new Float32Array(this.defaultArg(bufferLen, 1024));\n\t\t\tthis.setMap(mapping);\n\t\t} \n\t};\n\n\tTone.extend(Tone.WaveShaper, Tone.SignalBase);\n\n\t/**\n\t * Uses a mapping function to set the value of the curve. \n\t * @param {function} mapping The function used to define the values. \n\t * The mapping function take two arguments: \n\t * the first is the value at the current position \n\t * which goes from -1 to 1 over the number of elements\n\t * in the curve array. The second argument is the array position. \n\t * @returns {Tone.WaveShaper} this\n\t * @example\n\t * //map the input signal from [-1, 1] to [0, 10]\n\t * shaper.setMap(function(val, index){\n\t * \treturn (val + 1) * 5;\n\t * })\n\t */\n\tTone.WaveShaper.prototype.setMap = function(mapping){\n\t\tfor (var i = 0, len = this._curve.length; i < len; i++){\n\t\t\tvar normalized = (i / (len - 1)) * 2 - 1;\n\t\t\tthis._curve[i] = mapping(normalized, i);\n\t\t}\n\t\tthis._shaper.curve = this._curve;\n\t\treturn this;\n\t};\n\n\t/**\n\t * The array to set as the waveshaper curve. For linear curves\n\t * array length does not make much difference, but for complex curves\n\t * longer arrays will provide smoother interpolation. \n\t * @memberOf Tone.WaveShaper#\n\t * @type {Array}\n\t * @name curve\n\t */\n\tObject.defineProperty(Tone.WaveShaper.prototype, \"curve\", {\n\t\tget : function(){\n\t\t\treturn this._shaper.curve;\n\t\t},\n\t\tset : function(mapping){\n\t\t\tthis._curve = new Float32Array(mapping);\n\t\t\tthis._shaper.curve = this._curve;\n\t\t}\n\t});\n\n\t/**\n\t * Specifies what type of oversampling (if any) should be used when \n\t * applying the shaping curve. Can either be \"none\", \"2x\" or \"4x\". \n\t * @memberOf Tone.WaveShaper#\n\t * @type {string}\n\t * @name oversample\n\t */\n\tObject.defineProperty(Tone.WaveShaper.prototype, \"oversample\", {\n\t\tget : function(){\n\t\t\treturn this._shaper.oversample;\n\t\t},\n\t\tset : function(oversampling){\n\t\t\tif ([\"none\", \"2x\", \"4x\"].indexOf(oversampling) !== -1){\n\t\t\t\tthis._shaper.oversample = oversampling;\n\t\t\t} else {\n\t\t\t\tthrow new RangeError(\"Tone.WaveShaper: oversampling must be either 'none', '2x', or '4x'\");\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.WaveShaper} this\n\t */\n\tTone.WaveShaper.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._shaper.disconnect();\n\t\tthis._shaper = null;\n\t\tthis._curve = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.WaveShaper;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Timeline\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A signal which adds the method getValueAtTime. \n\t * Code and inspiration from https://github.com/jsantell/web-audio-automation-timeline\n\t * @extends {Tone.Param}\n\t * @param {Number=} value The initial value of the signal\n\t * @param {String=} units The conversion units of the signal.\n\t */\n\tTone.TimelineSignal = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"value\", \"units\"], Tone.Signal.defaults);\n\t\t\n\t\t/**\n\t\t * The scheduled events\n\t\t * @type {Tone.Timeline}\n\t\t * @private\n\t\t */\n\t\tthis._events = new Tone.Timeline(10);\n\n\t\t//constructors\n\t\tTone.Signal.apply(this, options);\n\t\toptions.param = this._param;\n\t\tTone.Param.call(this, options);\n\n\t\t/**\n\t\t * The initial scheduled value\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._initial = this._fromUnits(this._param.value);\n\t};\n\n\tTone.extend(Tone.TimelineSignal, Tone.Param);\n\n\t/**\n\t * The event types of a schedulable signal.\n\t * @enum {String}\n\t * @private\n\t */\n\tTone.TimelineSignal.Type = {\n\t\tLinear : \"linear\",\n\t\tExponential : \"exponential\",\n\t\tTarget : \"target\",\n\t\tCurve : \"curve\",\n\t\tSet : \"set\"\n\t};\n\n\t/**\n\t * The current value of the signal. \n\t * @memberOf Tone.TimelineSignal#\n\t * @type {Number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.TimelineSignal.prototype, \"value\", {\n\t\tget : function(){\n\t\t\tvar now = this.now();\n\t\t\tvar val = this.getValueAtTime(now);\n\t\t\treturn this._toUnits(val);\n\t\t},\n\t\tset : function(value){\n\t\t\tvar convertedVal = this._fromUnits(value);\n\t\t\tthis._initial = convertedVal;\n\t\t\tthis.cancelScheduledValues();\n\t\t\tthis._param.value = convertedVal;\n\t\t}\n\t});\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tSCHEDULING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Schedules a parameter value change at the given time.\n\t * @param {*}\tvalue The value to set the signal.\n\t * @param {Time} time The time when the change should occur.\n\t * @returns {Tone.TimelineSignal} this\n\t * @example\n\t * //set the frequency to \"G4\" in exactly 1 second from now. \n\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t */\n\tTone.TimelineSignal.prototype.setValueAtTime = function (value, startTime) {\n\t\tvalue = this._fromUnits(value);\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Set,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : startTime\n\t\t});\n\t\t//invoke the original event\n\t\tthis._param.setValueAtTime(value, startTime);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules a linear continuous change in parameter value from the \n\t * previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.linearRampToValueAtTime = function (value, endTime) {\n\t\tvalue = this._fromUnits(value);\n\t\tendTime = this.toSeconds(endTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Linear,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : endTime\n\t\t});\n\t\tthis._param.linearRampToValueAtTime(value, endTime);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.exponentialRampToValueAtTime = function (value, endTime) {\n\t\t//get the previous event and make sure it's not starting from 0\n\t\tendTime = this.toSeconds(endTime);\n\t\tvar beforeEvent = this._searchBefore(endTime);\n\t\tif (beforeEvent && beforeEvent.value === 0){\n\t\t\t//reschedule that event\n\t\t\tthis.setValueAtTime(this._minOutput, beforeEvent.time);\n\t\t}\n\t\tvalue = this._fromUnits(value);\n\t\tvar setValue = Math.max(value, this._minOutput);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Exponential,\n\t\t\t\"value\" : setValue,\n\t\t\t\"time\" : endTime\n\t\t});\n\t\t//if the ramped to value is 0, make it go to the min output, and then set to 0.\n\t\tif (value < this._minOutput){\n\t\t\tthis._param.exponentialRampToValueAtTime(this._minOutput, endTime - this.sampleTime);\n\t\t\tthis.setValueAtTime(0, endTime);\n\t\t} else {\n\t\t\tthis._param.exponentialRampToValueAtTime(value, endTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Start exponentially approaching the target value at the given time with\n\t * a rate having the given time constant.\n\t * @param {number} value \n\t * @param {Time} startTime \n\t * @param {number} timeConstant \n\t * @returns {Tone.TimelineSignal} this \n\t */\n\tTone.TimelineSignal.prototype.setTargetAtTime = function (value, startTime, timeConstant) {\n\t\tvalue = this._fromUnits(value);\n\t\tvalue = Math.max(this._minOutput, value);\n\t\ttimeConstant = Math.max(this._minOutput, timeConstant);\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Target,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : startTime,\n\t\t\t\"constant\" : timeConstant\n\t\t});\n\t\tthis._param.setTargetAtTime(value, startTime, timeConstant);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Set an array of arbitrary values starting at the given time for the given duration.\n\t * @param {Float32Array} values \n\t * @param {Time} startTime \n\t * @param {Time} duration\n\t * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value\n\t * @returns {Tone.TimelineSignal} this \n\t */\n\tTone.TimelineSignal.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) {\n\t\tscaling = this.defaultArg(scaling, 1);\n\t\t//copy the array\n\t\tvar floats = new Array(values.length);\n\t\tfor (var i = 0; i < floats.length; i++){\n\t\t\tfloats[i] = this._fromUnits(values[i]) * scaling;\n\t\t}\n\t\tstartTime = this.toSeconds(startTime);\n\t\tduration = this.toSeconds(duration);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Curve,\n\t\t\t\"value\" : floats,\n\t\t\t\"time\" : startTime,\n\t\t\t\"duration\" : duration\n\t\t});\n\t\t//set the first value\n\t\tthis._param.setValueAtTime(floats[0], startTime);\n\t\t//schedule a lienar ramp for each of the segments\n\t\tfor (var j = 1; j < floats.length; j++){\n\t\t\tvar segmentTime = startTime + (j / (floats.length - 1) * duration);\n\t\t\tthis._param.linearRampToValueAtTime(floats[j], segmentTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancels all scheduled parameter changes with times greater than or \n\t * equal to startTime.\n\t * \n\t * @param {Time} startTime\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.cancelScheduledValues = function (after) {\n\t\tafter = this.toSeconds(after);\n\t\tthis._events.cancel(after);\n\t\tthis._param.cancelScheduledValues(after);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Sets the computed value at the given time. This provides\n\t * a point from which a linear or exponential curve\n\t * can be scheduled after. Will cancel events after \n\t * the given time and shorten the currently scheduled\n\t * linear or exponential ramp so that it ends at `time` .\n\t * This is to avoid discontinuities and clicks in envelopes. \n\t * @param {Time} time When to set the ramp point\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.setRampPoint = function (time) {\n\t\ttime = this.toSeconds(time);\n\t\t//get the value at the given time\n\t\tvar val = this._toUnits(this.getValueAtTime(time));\n\t\t//if there is an event at the given time\n\t\t//and that even is not a \"set\"\n\t\tvar before = this._searchBefore(time);\n\t\tif (before && before.time === time){\n\t\t\t//remove everything after\n\t\t\tthis.cancelScheduledValues(time + this.sampleTime);\n\t\t} else if (before && \n\t\t\t\t before.type === Tone.TimelineSignal.Type.Curve &&\n\t\t\t\t before.time + before.duration > time){\n\t\t\t//if the curve is still playing\n\t\t\t//cancel the curve\n\t\t\tthis.cancelScheduledValues(time);\n\t\t\tthis.linearRampToValueAtTime(val, time);\n\t\t} else {\n\t\t\t//reschedule the next event to end at the given time\n\t\t\tvar after = this._searchAfter(time);\n\t\t\tif (after){\n\t\t\t\t//cancel the next event(s)\n\t\t\t\tthis.cancelScheduledValues(time);\n\t\t\t\tif (after.type === Tone.TimelineSignal.Type.Linear){\n\t\t\t\t\tthis.linearRampToValueAtTime(val, time);\n\t\t\t\t} else if (after.type === Tone.TimelineSignal.Type.Exponential){\n\t\t\t\t\tthis.exponentialRampToValueAtTime(val, time);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setValueAtTime(val, time);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Do a linear ramp to the given value between the start and finish times.\n\t * @param {Number} value The value to ramp to.\n\t * @param {Time} start The beginning anchor point to do the linear ramp\n\t * @param {Time} finish The ending anchor point by which the value of\n\t * the signal will equal the given value.\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.linearRampToValueBetween = function (value, start, finish) {\n\t\tthis.setRampPoint(start);\n\t\tthis.linearRampToValueAtTime(value, finish);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Do a exponential ramp to the given value between the start and finish times.\n\t * @param {Number} value The value to ramp to.\n\t * @param {Time} start The beginning anchor point to do the exponential ramp\n\t * @param {Time} finish The ending anchor point by which the value of\n\t * the signal will equal the given value.\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.exponentialRampToValueBetween = function (value, start, finish) {\n\t\tthis.setRampPoint(start);\n\t\tthis.exponentialRampToValueAtTime(value, finish);\n\t\treturn this;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tGETTING SCHEDULED VALUES\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value before or equal to the given time\n\t * @param {Number} time The time to query\n\t * @return {Object} The event at or before the given time.\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._searchBefore = function(time){\n\t\treturn this._events.get(time);\n\t};\n\n\t/**\n\t * The event after the given time\n\t * @param {Number} time The time to query.\n\t * @return {Object} The next event after the given time\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._searchAfter = function(time){\n\t\treturn this._events.getAfter(time);\n\t};\n\n\t/**\n\t * Get the scheduled value at the given time. This will\n\t * return the unconverted (raw) value.\n\t * @param {Number} time The time in seconds.\n\t * @return {Number} The scheduled value at the given time.\n\t */\n\tTone.TimelineSignal.prototype.getValueAtTime = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tvar after = this._searchAfter(time);\n\t\tvar before = this._searchBefore(time);\n\t\tvar value = this._initial;\n\t\t//if it was set by\n\t\tif (before === null){\n\t\t\tvalue = this._initial;\n\t\t} else if (before.type === Tone.TimelineSignal.Type.Target){\n\t\t\tvar previous = this._events.getBefore(before.time);\n\t\t\tvar previouVal;\n\t\t\tif (previous === null){\n\t\t\t\tpreviouVal = this._initial;\n\t\t\t} else {\n\t\t\t\tpreviouVal = previous.value;\n\t\t\t}\n\t\t\tvalue = this._exponentialApproach(before.time, previouVal, before.value, before.constant, time);\n\t\t} else if (before.type === Tone.TimelineSignal.Type.Curve){\n\t\t\tvalue = this._curveInterpolate(before.time, before.value, before.duration, time);\n\t\t} else if (after === null){\n\t\t\tvalue = before.value;\n\t\t} else if (after.type === Tone.TimelineSignal.Type.Linear){\n\t\t\tvalue = this._linearInterpolate(before.time, before.value, after.time, after.value, time);\n\t\t} else if (after.type === Tone.TimelineSignal.Type.Exponential){\n\t\t\tvalue = this._exponentialInterpolate(before.time, before.value, after.time, after.value, time);\n\t\t} else {\n\t\t\tvalue = before.value;\n\t\t}\n\t\treturn value;\n\t};\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.TimelineSignal} this\n\t * @method\n\t */\n\tTone.TimelineSignal.prototype.connect = Tone.SignalBase.prototype.connect;\n\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tAUTOMATION CURVE CALCULATIONS\n\t//\tMIT License, copyright (c) 2014 Jordan Santell\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Calculates the the value along the curve produced by setTargetAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._exponentialApproach = function (t0, v0, v1, timeConstant, t) {\n\t\treturn v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant);\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by linearRampToValueAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._linearInterpolate = function (t0, v0, t1, v1, t) {\n\t\treturn v0 + (v1 - v0) * ((t - t0) / (t1 - t0));\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by exponentialRampToValueAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._exponentialInterpolate = function (t0, v0, t1, v1, t) {\n\t\tv0 = Math.max(this._minOutput, v0);\n\t\treturn v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0));\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by setValueCurveAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._curveInterpolate = function (start, curve, duration, time) {\n\t\tvar len = curve.length;\n\t\t// If time is after duration, return the last curve value\n\t\tif (time >= start + duration) {\n\t\t\treturn curve[len - 1];\n\t\t} else if (time <= start){\n\t\t\treturn curve[0];\n\t\t} else {\n\t\t\tvar progress = (time - start) / duration;\n\t\t\tvar lowerIndex = Math.floor((len - 1) * progress);\n\t\t\tvar upperIndex = Math.ceil((len - 1) * progress);\n\t\t\tvar lowerVal = curve[lowerIndex];\n\t\t\tvar upperVal = curve[upperIndex];\n\t\t\tif (upperIndex === lowerIndex){\n\t\t\t\treturn lowerVal;\n\t\t\t} else {\n\t\t\t\treturn this._linearInterpolate(lowerIndex, lowerVal, upperIndex, upperVal, progress * (len - 1));\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.dispose = function(){\n\t\tTone.Signal.prototype.dispose.call(this);\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._events.dispose();\n\t\tthis._events = null;\n\t};\n\n\treturn Tone.TimelineSignal;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Multiply\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\t\n\t/**\n\t * @class Performs a linear scaling on an input signal.\n\t * Scales a NormalRange input to between\n\t * outputMin and outputMax.\n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @param {number} [outputMin=0] The output value when the input is 0. \n\t * @param {number} [outputMax=1]\tThe output value when the input is 1. \n\t * @example\n\t * var scale = new Tone.Scale(50, 100);\n\t * var signal = new Tone.Signal(0.5).connect(scale);\n\t * //the output of scale equals 75\n\t */\n\tTone.Scale = function(outputMin, outputMax){\n\n\t\t/** \n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._outputMin = this.defaultArg(outputMin, 0);\n\n\t\t/** \n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._outputMax = this.defaultArg(outputMax, 1);\n\n\n\t\t/** \n\t\t * @private\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._scale = this.input = new Tone.Multiply(1);\n\t\t\n\t\t/** \n\t\t * @private\n\t\t * @type {Tone.Add}\n\t\t * @private\n\t\t */\n\t\tthis._add = this.output = new Tone.Add(0);\n\n\t\tthis._scale.connect(this._add);\n\t\tthis._setRange();\n\t};\n\n\tTone.extend(Tone.Scale, Tone.SignalBase);\n\n\t/**\n\t * The minimum output value. This number is output when \n\t * the value input value is 0. \n\t * @memberOf Tone.Scale#\n\t * @type {number}\n\t * @name min\n\t */\n\tObject.defineProperty(Tone.Scale.prototype, \"min\", {\n\t\tget : function(){\n\t\t\treturn this._outputMin;\n\t\t},\n\t\tset : function(min){\n\t\t\tthis._outputMin = min;\n\t\t\tthis._setRange();\n\t\t}\n\t});\n\n\t/**\n\t * The maximum output value. This number is output when \n\t * the value input value is 1. \n\t * @memberOf Tone.Scale#\n\t * @type {number}\n\t * @name max\n\t */\n\tObject.defineProperty(Tone.Scale.prototype, \"max\", {\n\t\tget : function(){\n\t\t\treturn this._outputMax;\n\t\t},\n\t\tset : function(max){\n\t\t\tthis._outputMax = max;\n\t\t\tthis._setRange();\n\t\t}\n\t});\n\n\t/**\n\t * set the values\n\t * @private\n\t */\n\tTone.Scale.prototype._setRange = function() {\n\t\tthis._add.value = this._outputMin;\n\t\tthis._scale.value = this._outputMax - this._outputMin;\n\t};\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Scale} this\n\t */\n\tTone.Scale.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._add.dispose();\n\t\tthis._add = null;\n\t\tthis._scale.dispose();\n\t\tthis._scale = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Scale;\n});\n","define([\"Tone/core/Tone\", \"Tone/type/Time\", \"Tone/type/Frequency\", \"Tone/type/TransportTime\", \"Tone/core/Context\"],\nfunction (Tone) {\t\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTYPES\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Units which a value can take on.\n\t * @enum {String}\n\t */\n\tTone.Type = {\n\t\t/** \n\t\t * Default units\n\t\t * @typedef {Default}\n\t\t */\n\t\tDefault : \"number\",\n\t\t/**\n\t\t * Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time).\n\t\t *\n\t\t *
    \n\t\t *
  • Numbers, which will be taken literally as the time (in seconds).
  • \n\t\t *
  • Notation, (\"4n\", \"8t\") describes time in BPM and time signature relative values.
  • \n\t\t *
  • TransportTime, (\"4:3:2\") will also provide tempo and time signature relative times \n\t\t * in the form BARS:QUARTERS:SIXTEENTHS.
  • \n\t\t *
  • Frequency, (\"8hz\") is converted to the length of the cycle in seconds.
  • \n\t\t *
  • Now-Relative, (\"+1\") prefix any of the above with \"+\" and it will be interpreted as \n\t\t * \"the current time plus whatever expression follows\".
  • \n\t\t *
  • Expressions, (\"3:0 + 2 - (1m / 7)\") any of the above can also be combined \n\t\t * into a mathematical expression which will be evaluated to compute the desired time.
  • \n\t\t *
  • No Argument, for methods which accept time, no argument will be interpreted as \n\t\t * \"now\" (i.e. the currentTime).
  • \n\t\t *
\n\t\t * \n\t\t * @typedef {Time}\n\t\t */\n\t\tTime : \"time\",\n\t\t/**\n\t\t * Frequency can be described similar to time, except ultimately the\n\t\t * values are converted to frequency instead of seconds. A number\n\t\t * is taken literally as the value in hertz. Additionally any of the \n\t\t * Time encodings can be used. Note names in the form\n\t\t * of NOTE OCTAVE (i.e. C4) are also accepted and converted to their\n\t\t * frequency value. \n\t\t * @typedef {Frequency}\n\t\t */\n\t\tFrequency : \"frequency\",\n\t\t/**\n\t\t * TransportTime describes a position along the Transport's timeline. It is\n\t\t * similar to Time in that it uses all the same encodings, but TransportTime specifically\n\t\t * pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable. \n\t\t * [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime)\n\t\t * @typedef {TransportTime}\n\t\t */\n\t\tTransportTime : \"transportTime\",\n\t\t/** \n\t\t * Ticks are the basic subunit of the Transport. They are\n\t\t * the smallest unit of time that the Transport supports.\n\t\t * @typedef {Ticks}\n\t\t */\n\t\tTicks : \"ticks\",\n\t\t/** \n\t\t * Normal values are within the range [0, 1].\n\t\t * @typedef {NormalRange}\n\t\t */\n\t\tNormalRange : \"normalRange\",\n\t\t/** \n\t\t * AudioRange values are between [-1, 1].\n\t\t * @typedef {AudioRange}\n\t\t */\n\t\tAudioRange : \"audioRange\",\n\t\t/** \n\t\t * Decibels are a logarithmic unit of measurement which is useful for volume\n\t\t * because of the logarithmic way that we perceive loudness. 0 decibels \n\t\t * means no change in volume. -10db is approximately half as loud and 10db \n\t\t * is twice is loud. \n\t\t * @typedef {Decibels}\n\t\t */\n\t\tDecibels : \"db\",\n\t\t/** \n\t\t * Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up.\n\t\t * @typedef {Interval}\n\t\t */\n\t\tInterval : \"interval\",\n\t\t/** \n\t\t * Beats per minute. \n\t\t * @typedef {BPM}\n\t\t */\n\t\tBPM : \"bpm\",\n\t\t/** \n\t\t * The value must be greater than or equal to 0.\n\t\t * @typedef {Positive}\n\t\t */\n\t\tPositive : \"positive\",\n\t\t/** \n\t\t * A cent is a hundredth of a semitone. \n\t\t * @typedef {Cents}\n\t\t */\n\t\tCents : \"cents\",\n\t\t/** \n\t\t * Angle between 0 and 360. \n\t\t * @typedef {Degrees}\n\t\t */\n\t\tDegrees : \"degrees\",\n\t\t/** \n\t\t * A number representing a midi note.\n\t\t * @typedef {MIDI}\n\t\t */\n\t\tMIDI : \"midi\",\n\t\t/** \n\t\t * A colon-separated representation of time in the form of\n\t\t * Bars:Beats:Sixteenths. \n\t\t * @typedef {BarsBeatsSixteenths}\n\t\t */\n\t\tBarsBeatsSixteenths : \"barsBeatsSixteenths\",\n\t\t/** \n\t\t * Sampling is the reduction of a continuous signal to a discrete signal.\n\t\t * Audio is typically sampled 44100 times per second. \n\t\t * @typedef {Samples}\n\t\t */\n\t\tSamples : \"samples\",\n\t\t/** \n\t\t * Hertz are a frequency representation defined as one cycle per second.\n\t\t * @typedef {Hertz}\n\t\t */\n\t\tHertz : \"hertz\",\n\t\t/** \n\t\t * A frequency represented by a letter name, \n\t\t * accidental and octave. This system is known as\n\t\t * [Scientific Pitch Notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation).\n\t\t * @typedef {Note}\n\t\t */\n\t\tNote : \"note\",\n\t\t/** \n\t\t * One millisecond is a thousandth of a second. \n\t\t * @typedef {Milliseconds}\n\t\t */\n\t\tMilliseconds : \"milliseconds\",\n\t\t/** \n\t\t * Seconds are the time unit of the AudioContext. In the end, \n\t\t * all values need to be evaluated to seconds. \n\t\t * @typedef {Seconds}\n\t\t */\n\t\tSeconds : \"seconds\",\n\t\t/** \n\t\t * A string representing a duration relative to a measure. \n\t\t *
    \n\t\t * \t
  • \"4n\" = quarter note
  • \n\t\t * \t
  • \"2m\" = two measures
  • \n\t\t * \t
  • \"8t\" = eighth-note triplet
  • \n\t\t *
\n\t\t * @typedef {Notation}\n\t\t */\n\t\tNotation : \"notation\",\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// AUGMENT TONE's PROTOTYPE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Convert Time into seconds.\n\t * \n\t * Unlike the method which it overrides, this takes into account \n\t * transporttime and musical notation.\n\t *\n\t * Time : 1.40\n\t * Notation: 4n|1m|2t\n\t * Now Relative: +3n\n\t * Math: 3n+16n or even complicated expressions ((3n*2)/6 + 1)\n\t *\n\t * @param {Time} time \n\t * @return {Seconds} \n\t */\n\tTone.prototype.toSeconds = function(time){\n\t\tif (this.isNumber(time)){\n\t\t\treturn time;\n\t\t} else if (this.isUndef(time)){\n\t\t\treturn this.now();\t\t\t\n\t\t} else if (this.isString(time)){\n\t\t\treturn (new Tone.Time(time)).toSeconds();\n\t\t} else if (time instanceof Tone.TimeBase){\n\t\t\treturn time.toSeconds();\n\t\t}\n\t};\n\n\t/**\n\t * Convert a frequency representation into a number.\n\t * @param {Frequency} freq \n\t * @return {Hertz} the frequency in hertz\n\t */\n\tTone.prototype.toFrequency = function(freq){\n\t\tif (this.isNumber(freq)){\n\t\t\treturn freq;\n\t\t} else if (this.isString(freq) || this.isUndef(freq)){\n\t\t\treturn (new Tone.Frequency(freq)).valueOf();\n\t\t} else if (freq instanceof Tone.TimeBase){\n\t\t\treturn freq.toFrequency();\n\t\t}\n\t};\n\n\t/**\n\t * Convert a time representation into ticks.\n\t * @param {Time} time\n\t * @return {Ticks} the time in ticks\n\t */\n\tTone.prototype.toTicks = function(time){\n\t\tif (this.isNumber(time) || this.isString(time)){\n\t\t\treturn (new Tone.TransportTime(time)).toTicks();\n\t\t} else if (this.isUndef(time)){\n\t\t\treturn Tone.Transport.ticks;\t\t\t\n\t\t} else if (time instanceof Tone.TimeBase){\n\t\t\treturn time.toTicks();\n\t\t}\n\t};\n\n\treturn Tone;\n});","define([\"Tone/core/Tone\", \"Tone/core/Param\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * createGain shim\n\t * @private\n\t */\n\tif (window.GainNode && !AudioContext.prototype.createGain){\n\t\tAudioContext.prototype.createGain = AudioContext.prototype.createGainNode;\n\t}\n\n\t/**\n\t * @class A thin wrapper around the Native Web Audio GainNode.\n\t * The GainNode is a basic building block of the Web Audio\n\t * API and is useful for routing audio and adjusting gains. \n\t * @extends {Tone}\n\t * @param {Number=} gain The initial gain of the GainNode\n\t * @param {Tone.Type=} units The units of the gain parameter. \n\t */\n\tTone.Gain = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"gain\", \"units\"], Tone.Gain.defaults);\n\n\t\t/**\n\t\t * The GainNode\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis.input = this.output = this._gainNode = this.context.createGain();\n\n\t\t/**\n\t\t * The gain parameter of the gain node.\n\t\t * @type {Tone.Param}\n\t\t * @signal\n\t\t */\n\t\tthis.gain = new Tone.Param({\n\t\t\t\"param\" : this._gainNode.gain, \n\t\t\t\"units\" : options.units,\n\t\t\t\"value\" : options.gain,\n\t\t\t\"convert\" : options.convert\n\t\t});\n\t\tthis._readOnly(\"gain\");\n\t};\n\n\tTone.extend(Tone.Gain);\n\n\t/**\n\t * The defaults\n\t * @const\n\t * @type {Object}\n\t */\n\tTone.Gain.defaults = {\n\t\t\"gain\" : 1,\n\t\t\"convert\" : true,\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.Gain} this\n\t */\n\tTone.Gain.prototype.dispose = function(){\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._gainNode.disconnect();\n\t\tthis._gainNode = null;\n\t\tthis._writable(\"gain\");\n\t\tthis.gain.dispose();\n\t\tthis.gain = null;\n\t};\n\n\t//STATIC///////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Create input and outputs for this object.\n\t * @param {Number} input The number of inputs\n\t * @param {Number=} outputs The number of outputs\n\t * @return {Tone} this\n\t * @internal\n\t */\n\tTone.prototype.createInsOuts = function(inputs, outputs){\n\n\t\tif (inputs === 1){\n\t\t\tthis.input = new Tone.Gain();\n\t\t} else if (inputs > 1){\n\t\t\tthis.input = new Array(inputs);\n\t\t}\n\n\t\tif (outputs === 1){\n\t\t\tthis.output = new Tone.Gain();\n\t\t} else if (outputs > 1){\n\t\t\tthis.output = new Array(inputs);\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\n\treturn Tone.Gain;\n});","define([\"Tone/core/Tone\", \"Tone/signal/TimelineSignal\", \"Tone/core/TimelineState\", \n\t\"Tone/core/Emitter\", \"Tone/core/Context\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A sample accurate clock which provides a callback at the given rate. \n\t * While the callback is not sample-accurate (it is still susceptible to\n\t * loose JS timing), the time passed in as the argument to the callback\n\t * is precise. For most applications, it is better to use Tone.Transport\n\t * instead of the Clock by itself since you can synchronize multiple callbacks.\n\t *\n\t * \t@constructor\n\t * @extends {Tone.Emitter}\n\t * \t@param {function} callback The callback to be invoked with the time of the audio event\n\t * \t@param {Frequency} frequency The rate of the callback\n\t * \t@example\n\t * //the callback will be invoked approximately once a second\n\t * //and will print the time exactly once a second apart.\n\t * var clock = new Tone.Clock(function(time){\n\t * \tconsole.log(time);\n\t * }, 1);\n\t */\n\tTone.Clock = function(){\n\n\t\tTone.Emitter.call(this);\n\n\t\tvar options = this.optionsObject(arguments, [\"callback\", \"frequency\"], Tone.Clock.defaults);\n\n\t\t/**\n\t\t * The callback function to invoke at the scheduled tick.\n\t\t * @type {Function}\n\t\t */\n\t\tthis.callback = options.callback;\n\n\t\t/**\n\t\t * The next time the callback is scheduled.\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._nextTick = 0;\n\n\t\t/**\n\t\t * The last state of the clock.\n\t\t * @type {State}\n\t\t * @private\n\t\t */\n\t\tthis._lastState = Tone.State.Stopped;\n\n\t\t/**\n\t\t * The rate the callback function should be invoked. \n\t\t * @type {BPM}\n\t\t * @signal\n\t\t */\n\t\tthis.frequency = new Tone.TimelineSignal(options.frequency, Tone.Type.Frequency);\n\t\tthis._readOnly(\"frequency\");\n\n\t\t/**\n\t\t * The number of times the callback was invoked. Starts counting at 0\n\t\t * and increments after the callback was invoked. \n\t\t * @type {Ticks}\n\t\t * @readOnly\n\t\t */\n\t\tthis.ticks = 0;\n\n\t\t/**\n\t\t * The state timeline\n\t\t * @type {Tone.TimelineState}\n\t\t * @private\n\t\t */\n\t\tthis._state = new Tone.TimelineState(Tone.State.Stopped);\n\n\t\t/**\n\t\t * The loop function bound to its context. \n\t\t * This is necessary to remove the event in the end.\n\t\t * @type {Function}\n\t\t * @private\n\t\t */\n\t\tthis._boundLoop = this._loop.bind(this);\n\n\t\t//bind a callback to the worker thread\n \tthis.context.on(\"tick\", this._boundLoop);\n\t};\n\n\tTone.extend(Tone.Clock, Tone.Emitter);\n\n\t/**\n\t * The defaults\n\t * @const\n\t * @type {Object}\n\t */\n\tTone.Clock.defaults = {\n\t\t\"callback\" : Tone.noOp,\n\t\t\"frequency\" : 1,\n\t\t\"lookAhead\" : \"auto\",\n\t};\n\n\t/**\n\t * Returns the playback state of the source, either \"started\", \"stopped\" or \"paused\".\n\t * @type {Tone.State}\n\t * @readOnly\n\t * @memberOf Tone.Clock#\n\t * @name state\n\t */\n\tObject.defineProperty(Tone.Clock.prototype, \"state\", {\n\t\tget : function(){\n\t\t\treturn this._state.getValueAtTime(this.now());\n\t\t}\n\t});\n\n\t/**\n\t * Start the clock at the given time. Optionally pass in an offset\n\t * of where to start the tick counter from.\n\t * @param {Time} time The time the clock should start\n\t * @param {Ticks=} offset Where the tick counter starts counting from.\n\t * @return {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.start = function(time, offset){\n\t\ttime = this.toSeconds(time);\n\t\tif (this._state.getValueAtTime(time) !== Tone.State.Started){\n\t\t\tthis._state.add({\n\t\t\t\t\"state\" : Tone.State.Started, \n\t\t\t\t\"time\" : time,\n\t\t\t\t\"offset\" : offset\n\t\t\t});\n\t\t}\n\t\treturn this;\t\n\t};\n\n\t/**\n\t * Stop the clock. Stopping the clock resets the tick counter to 0.\n\t * @param {Time} [time=now] The time when the clock should stop.\n\t * @returns {Tone.Clock} this\n\t * @example\n\t * clock.stop();\n\t */\n\tTone.Clock.prototype.stop = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tthis._state.cancel(time);\n\t\tthis._state.setStateAtTime(Tone.State.Stopped, time);\n\t\treturn this;\t\n\t};\n\n\n\t/**\n\t * Pause the clock. Pausing does not reset the tick counter.\n\t * @param {Time} [time=now] The time when the clock should stop.\n\t * @returns {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.pause = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tif (this._state.getValueAtTime(time) === Tone.State.Started){\n\t\t\tthis._state.setStateAtTime(Tone.State.Paused, time);\n\t\t}\n\t\treturn this;\t\n\t};\n\n\t/**\n\t * The scheduling loop.\n\t * @param {Number} time The current page time starting from 0\n\t * when the page was loaded.\n\t * @private\n\t */\n\tTone.Clock.prototype._loop = function(){\n\t\t//get the frequency value to compute the value of the next loop\n\t\tvar now = this.now();\n\t\t//if it's started\n\t\tvar lookAhead = this.context.lookAhead;\n\t\tvar updateInterval = this.context.updateInterval;\n\t\tvar lagCompensation = this.context.lag * 2;\n\t\tvar loopInterval = now + lookAhead + updateInterval + lagCompensation;\n\t\twhile (loopInterval > this._nextTick && this._state){\n\t\t\tvar currentState = this._state.getValueAtTime(this._nextTick);\n\t\t\tif (currentState !== this._lastState){\n\t\t\t\tthis._lastState = currentState;\n\t\t\t\tvar event = this._state.get(this._nextTick);\n\t\t\t\t// emit an event\n\t\t\t\tif (currentState === Tone.State.Started){\n\t\t\t\t\t//correct the time\n\t\t\t\t\tthis._nextTick = event.time;\n\t\t\t\t\tif (!this.isUndef(event.offset)){\n\t\t\t\t\t\tthis.ticks = event.offset;\n\t\t\t\t\t}\n\t\t\t\t\tthis.emit(\"start\", event.time, this.ticks);\n\t\t\t\t} else if (currentState === Tone.State.Stopped){\n\t\t\t\t\tthis.ticks = 0;\n\n\t\t\t\t\tthis.emit(\"stop\", event.time);\n\t\t\t\t} else if (currentState === Tone.State.Paused){\n\t\t\t\t\tthis.emit(\"pause\", event.time);\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar tickTime = this._nextTick;\n\t\t\tif (this.frequency){\n\t\t\t\tthis._nextTick += 1 / this.frequency.getValueAtTime(this._nextTick);\n\t\t\t\tif (currentState === Tone.State.Started){\n\t\t\t\t\tthis.callback(tickTime);\n\t\t\t\t\tthis.ticks++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Returns the scheduled state at the given time.\n\t * @param {Time} time The time to query.\n\t * @return {String} The name of the state input in setStateAtTime.\n\t * @example\n\t * clock.start(\"+0.1\");\n\t * clock.getStateAtTime(\"+0.1\"); //returns \"started\"\n\t */\n\tTone.Clock.prototype.getStateAtTime = function(time){\n\t\ttime = this.toSeconds(time);\n\t\treturn this._state.getValueAtTime(time);\n\t};\n\n\t/**\n\t * Clean up\n\t * @returns {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.dispose = function(){\n\t\tTone.Emitter.prototype.dispose.call(this);\n\t\tthis.context.off(\"tick\", this._boundLoop);\n\t\tthis._writable(\"frequency\");\n\t\tthis.frequency.dispose();\n\t\tthis.frequency = null;\n\t\tthis._boundLoop = null;\n\t\tthis._nextTick = Infinity;\n\t\tthis.callback = null;\n\t\tthis._state.dispose();\n\t\tthis._state = null;\n\t};\n\n\treturn Tone.Clock;\n});","define([\"Tone/core/Tone\", \"Tone/core/Emitter\"], function (Tone) {\n\n\t/**\n\t * shim\n\t * @private\n\t */\n\tif (!window.hasOwnProperty(\"AudioContext\") && window.hasOwnProperty(\"webkitAudioContext\")){\n\t\twindow.AudioContext = window.webkitAudioContext;\n\t}\n\n\t/**\n\t * @class Wrapper around the native AudioContext.\n\t * @extends {Tone.Emitter}\n\t * @param {AudioContext=} context optionally pass in a context\n\t */\n\tTone.Context = function(context){\n\n\t\tTone.Emitter.call(this);\n\n\t\tif (!context){\n\t\t\tcontext = new window.AudioContext();\n\t\t}\n\t\tthis._context = context;\n\t\t// extend all of the methods\n\t\tfor (var prop in this._context){\n\t\t\tthis._defineProperty(this._context, prop);\n\t\t}\n\n\t\t///////////////////////////////////////////////////////////////////////\n\t\t// WORKER\n\t\t///////////////////////////////////////////////////////////////////////\n\n\t\t/**\n\t\t * The default latency hint\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t\tthis._latencyHint = \"interactive\";\n\n\t\t/**\n\t\t * The amount of time events are scheduled\n\t\t * into the future\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._lookAhead = 0.1;\n\n\t\t/**\n\t\t * How often the update look runs\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._updateInterval = this._lookAhead/3;\n\n\t\t/**\n\t\t * A reference to the actual computed update interval\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._computedUpdateInterval = 0;\n\n\t\t/**\n\t\t * The web worker which is used to update Tone.Clock\n\t\t * @private\n\t\t * @type {WebWorker}\n\t\t */\n\t\tthis._worker = this._createWorker();\n\n\t\t/**\n\t\t * An object containing all of the constants AudioBufferSourceNodes\n\t\t * @type {Object}\n\t\t * @private\n\t\t */\n\t\tthis._constants = {};\n\n\t};\n\n\tTone.extend(Tone.Context, Tone.Emitter);\n\tTone.Emitter.mixin(Tone.Context);\n\n\t/**\n\t * Define a property on this Tone.Context. \n\t * This is used to extend the native AudioContext\n\t * @param {AudioContext} context\n\t * @param {String} prop \n\t * @private\n\t */\n\tTone.Context.prototype._defineProperty = function(context, prop){\n\t\tif (this.isUndef(this[prop])){\n\t\t\tObject.defineProperty(this, prop, {\n\t\t\t\tget : function(){\n\t\t\t\t\tif (typeof context[prop] === \"function\"){\n\t\t\t\t\t\treturn context[prop].bind(context);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn context[prop];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tset : function(val){\n\t\t\t\t\tcontext[prop] = val;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * The current audio context time\n\t * @return {Number}\n\t */\n\tTone.Context.prototype.now = function(){\n\t\treturn this._context.currentTime;\n\t};\n\n\t/**\n\t * Generate a web worker\n\t * @return {WebWorker}\n\t * @private\n\t */\n\tTone.Context.prototype._createWorker = function(){\n\t\t\n\t\t//URL Shim\n\t\twindow.URL = window.URL || window.webkitURL;\n\n\t\tvar blob = new Blob([\n\t\t\t//the initial timeout time\n\t\t\t\"var timeoutTime = \"+(this._updateInterval * 1000).toFixed(1)+\";\" +\n\t\t\t//onmessage callback\n\t\t\t\"self.onmessage = function(msg){\" +\n\t\t\t\"\ttimeoutTime = parseInt(msg.data);\" + \n\t\t\t\"};\" + \n\t\t\t//the tick function which posts a message\n\t\t\t//and schedules a new tick\n\t\t\t\"function tick(){\" +\n\t\t\t\"\tsetTimeout(tick, timeoutTime);\" +\n\t\t\t\"\tself.postMessage('tick');\" +\n\t\t\t\"}\" +\n\t\t\t//call tick initially\n\t\t\t\"tick();\"\n\t\t]);\n\t\tvar blobUrl = URL.createObjectURL(blob);\n\t\tvar worker = new Worker(blobUrl);\n\n\t\tworker.addEventListener(\"message\", function(){\n\t\t\t// tick the clock\n\t\t\tthis.emit(\"tick\");\n\t\t}.bind(this));\n\n\t\t//lag compensation\n\t\tworker.addEventListener(\"message\", function(){\n\t\t\tvar now = this.now();\n\t\t\tif (this.isNumber(this._lastUpdate)){\n\t\t\t\tvar diff = now - this._lastUpdate;\n\t\t\t\tthis._computedUpdateInterval = Math.max(diff, this._computedUpdateInterval * 0.97);\n\t\t\t}\n\t\t\tthis._lastUpdate = now;\n\t\t}.bind(this));\n\n\t\treturn worker;\n\t};\n\n\t/**\n\t * Generate a looped buffer at some constant value.\n\t * @param {Number} val\n\t * @return {BufferSourceNode}\n\t */\n\tTone.Context.prototype.getConstant = function(val){\n\t\tif (this._constants[val]){\n\t\t\treturn this._constants[val];\n\t\t} else {\n\t\t\tvar buffer = this._context.createBuffer(1, 128, this._context.sampleRate);\n\t\t\tvar arr = buffer.getChannelData(0);\n\t\t\tfor (var i = 0; i < arr.length; i++){\n\t\t\t\tarr[i] = val;\n\t\t\t}\n\t\t\tvar constant = this._context.createBufferSource();\n\t\t\tconstant.channelCount = 1;\n\t\t\tconstant.channelCountMode = \"explicit\";\n\t\t\tconstant.buffer = buffer;\n\t\t\tconstant.loop = true;\n\t\t\tconstant.start(0);\n\t\t\tthis._constants[val] = constant;\n\t\t\treturn constant;\n\t\t}\n\t};\n\n\t/**\n\t * This is the time that the clock is falling behind\n\t * the scheduled update interval. The Context automatically\n\t * adjusts for the lag and schedules further in advance.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name lag\n\t * @static\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"lag\", {\n\t\tget : function(){\n\t\t\tvar diff = this._computedUpdateInterval - this._updateInterval;\n\t\t\tdiff = Math.max(diff, 0);\n\t\t\treturn diff;\n\t\t}\n\t});\n\n\t/**\n\t * The amount of time in advance that events are scheduled.\n\t * The lookAhead will adjust slightly in response to the \n\t * measured update time to try to avoid clicks.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name lookAhead\n\t * @static\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"lookAhead\", {\n\t\tget : function(){\n\t\t\treturn this._lookAhead;\n\t\t},\n\t\tset : function(lA){\n\t\t\tthis._lookAhead = lA;\n\t\t}\n\t});\n\n\t/**\n\t * How often the Web Worker callback is invoked.\n\t * This number corresponds to how responsive the scheduling\n\t * can be. Context.updateInterval + Context.lookAhead gives you the\n\t * total latency between scheduling an event and hearing it.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name updateInterval\n\t * @static\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"updateInterval\", {\n\t\tget : function(){\n\t\t\treturn this._updateInterval;\n\t\t},\n\t\tset : function(interval){\n\t\t\tthis._updateInterval = Math.max(interval, Tone.prototype.blockTime);\n\t\t\tthis._worker.postMessage(Math.max(interval * 1000, 1));\n\t\t}\n\t});\n\n\t/**\n\t * The type of playback, which affects tradeoffs between audio \n\t * output latency and responsiveness. \n\t * \n\t * In addition to setting the value in seconds, the latencyHint also\n\t * accepts the strings \"interactive\" (prioritizes low latency), \n\t * \"playback\" (prioritizes sustained playback), \"balanced\" (balances\n\t * latency and performance), and \"fastest\" (lowest latency, might glitch more often). \n\t * @type {String|Seconds}\n\t * @memberOf Tone.Context#\n\t * @name latencyHint\n\t * @static\n\t * @example\n\t * //set the lookAhead to 0.3 seconds\n\t * Tone.context.latencyHint = 0.3;\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"latencyHint\", {\n\t\tget : function(){\n\t\t\treturn this._latencyHint;\n\t\t},\n\t\tset : function(hint){\n\t\t\tvar lookAhead = hint;\n\t\t\tthis._latencyHint = hint;\n\t\t\tif (this.isString(hint)){\n\t\t\t\tswitch(hint){\n\t\t\t\t\tcase \"interactive\" :\n\t\t\t\t\t\tlookAhead = 0.1;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"playback\" :\n\t\t\t\t\t\tlookAhead = 0.8;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"balanced\" :\n\t\t\t\t\t\tlookAhead = 0.25;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fastest\" :\n\t\t\t\t\t\tlookAhead = 0.01;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.lookAhead = lookAhead;\n\t\t\tthis.updateInterval = lookAhead/3;\n\t\t}\n\t});\n\n\t/**\n\t * Shim all connect/disconnect and some deprecated methods which are still in\n\t * some older implementations.\n\t * @private\n\t */\n\tfunction shimConnect(){\n\n\t\tvar nativeConnect = AudioNode.prototype.connect;\n\t\tvar nativeDisconnect = AudioNode.prototype.disconnect;\n\n\t\t//replace the old connect method\n\t\tfunction toneConnect(B, outNum, inNum){\n\t\t\tif (B.input){\n\t\t\t\tif (Array.isArray(B.input)){\n\t\t\t\t\tif (Tone.prototype.isUndef(inNum)){\n\t\t\t\t\t\tinNum = 0;\n\t\t\t\t\t}\n\t\t\t\t\tthis.connect(B.input[inNum]);\n\t\t\t\t} else {\n\t\t\t\t\tthis.connect(B.input, outNum, inNum);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tif (B instanceof AudioNode){\n\t\t\t\t\t\tnativeConnect.call(this, B, outNum, inNum);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnativeConnect.call(this, B, outNum);\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new Error(\"error connecting to node: \"+B+\"\\n\"+e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//replace the old disconnect method\n\t\tfunction toneDisconnect(B, outNum, inNum){\n\t\t\tif (B && B.input && Array.isArray(B.input)){\n\t\t\t\tif (Tone.prototype.isUndef(inNum)){\n\t\t\t\t\tinNum = 0;\n\t\t\t\t}\n\t\t\t\tthis.disconnect(B.input[inNum], outNum, inNum);\n\t\t\t} else if (B && B.input){\n\t\t\t\tthis.disconnect(B.input, outNum, inNum);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tnativeDisconnect.apply(this, arguments);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new Error(\"error disconnecting node: \"+B+\"\\n\"+e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (AudioNode.prototype.connect !== toneConnect){\n\t\t\tAudioNode.prototype.connect = toneConnect;\n\t\t\tAudioNode.prototype.disconnect = toneDisconnect;\n\t\t}\n\t}\n\n\t// set the audio context initially\n\tif (Tone.supported){\n\t\tshimConnect();\n\t\tTone.context = new Tone.Context();\n\t} else {\n\t\tconsole.warn(\"This browser does not support Tone.js\");\n\t}\n\n\treturn Tone.Context;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Negate\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Subtract the signal connected to input[1] from the signal connected \n\t * to input[0]. If an argument is provided in the constructor, the \n\t * signals .value will be subtracted from the incoming signal.\n\t *\n\t * @extends {Tone.Signal}\n\t * @constructor\n\t * @param {number=} value The value to subtract from the incoming signal. If the value\n\t * is omitted, it will subtract the second signal from the first.\n\t * @example\n\t * var sub = new Tone.Subtract(1);\n\t * var sig = new Tone.Signal(4).connect(sub);\n\t * //the output of sub is 3. \n\t * @example\n\t * var sub = new Tone.Subtract();\n\t * var sigA = new Tone.Signal(10);\n\t * var sigB = new Tone.Signal(2.5);\n\t * sigA.connect(sub, 0, 0);\n\t * sigB.connect(sub, 0, 1);\n\t * //output of sub is 7.5\n\t */\n\tTone.Subtract = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the summing node\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._sum = this.input[0] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * negate the input of the second input before connecting it\n\t\t * to the summing node.\n\t\t * @type {Tone.Negate}\n\t\t * @private\n\t\t */\n\t\tthis._neg = new Tone.Negate();\n\n\t\t/**\n\t\t * the node where the value is set\n\t\t * @private\n\t\t * @type {Tone.Signal}\n\t\t */\n\t\tthis._param = this.input[1] = new Tone.Signal(value);\n\n\t\tthis._param.chain(this._neg, this._sum);\n\t};\n\n\tTone.extend(Tone.Subtract, Tone.Signal);\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.SignalBase} this\n\t */\n\tTone.Subtract.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._neg.dispose();\n\t\tthis._neg = null;\n\t\tthis._sum.disconnect();\n\t\tthis._sum = null;\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Subtract;\n});","define([\"Tone/core/Tone\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Emitter gives classes which extend it\n\t * the ability to listen for and emit events. \n\t * Inspiration and reference from Jerome Etienne's [MicroEvent](https://github.com/jeromeetienne/microevent.js).\n\t * MIT (c) 2011 Jerome Etienne.\n\t * \n\t * @extends {Tone}\n\t */\n\tTone.Emitter = function(){\n\t\t/**\n\t\t * Contains all of the events.\n\t\t * @private\n\t\t * @type {Object}\n\t\t */\n\t\tthis._events = {};\n\t};\n\n\tTone.extend(Tone.Emitter);\n\n\t/**\n\t * Bind a callback to a specific event.\n\t * @param {String} event The name of the event to listen for.\n\t * @param {Function} callback The callback to invoke when the\n\t * event is emitted\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.on = function(event, callback){\n\t\t//split the event\n\t\tvar events = event.split(/\\W+/);\n\t\tfor (var i = 0; i < events.length; i++){\n\t\t\tvar eventName = events[i];\n\t\t\tif (!this._events.hasOwnProperty(eventName)){\n\t\t\t\tthis._events[eventName] = [];\n\t\t\t}\n\t\t\tthis._events[eventName].push(callback);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Remove the event listener.\n\t * @param {String} event The event to stop listening to.\n\t * @param {Function=} callback The callback which was bound to \n\t * the event with Tone.Emitter.on.\n\t * If no callback is given, all callbacks\n\t * events are removed.\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.off = function(event, callback){\n\t\tvar events = event.split(/\\W+/);\n\t\tfor (var ev = 0; ev < events.length; ev++){\n\t\t\tevent = events[ev];\n\t\t\tif (this._events.hasOwnProperty(event)){\n\t\t\t\tif (Tone.prototype.isUndef(callback)){\n\t\t\t\t\tthis._events[event] = [];\n\t\t\t\t} else {\n\t\t\t\t\tvar eventList = this._events[event];\n\t\t\t\t\tfor (var i = 0; i < eventList.length; i++){\n\t\t\t\t\t\tif (eventList[i] === callback){\n\t\t\t\t\t\t\teventList.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Invoke all of the callbacks bound to the event\n\t * with any arguments passed in. \n\t * @param {String} event The name of the event.\n\t * @param {*...} args The arguments to pass to the functions listening.\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.emit = function(event){\n\t\tif (this._events){\n\t\t\tvar args = Array.apply(null, arguments).slice(1);\n\t\t\tif (this._events.hasOwnProperty(event)){\n\t\t\t\tvar eventList = this._events[event];\n\t\t\t\tfor (var i = 0, len = eventList.length; i < len; i++){\n\t\t\t\t\teventList[i].apply(this, args);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Add Emitter functions (on/off/emit) to the object\n\t * @param {Object|Function} object The object or class to extend.\n\t */\n\tTone.Emitter.mixin = function(object){\n\t\tvar functions = [\"on\", \"off\", \"emit\"];\n\t\tobject._events = {};\n\t\tfor (var i = 0; i < functions.length; i++){\n\t\t\tvar func = functions[i];\n\t\t\tvar emitterFunc = Tone.Emitter.prototype[func];\n\t\t\tobject[func] = emitterFunc;\n\t\t}\n\t};\n\n\t/**\n\t * Clean up\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._events = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Emitter;\n});","define([\"Tone/core/Tone\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Base class for all Signals. Used Internally. \n\t *\n\t * @constructor\n\t * @extends {Tone}\n\t */\n\tTone.SignalBase = function(){};\n\n\tTone.extend(Tone.SignalBase);\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.SignalBase} this\n\t */\n\tTone.SignalBase.prototype.connect = function(node, outputNumber, inputNumber){\n\t\t//zero it out so that the signal can have full control\n\t\tif ((Tone.Signal && Tone.Signal === node.constructor) || \n\t\t\t\t(Tone.Param && Tone.Param === node.constructor) || \n\t\t\t\t(Tone.TimelineSignal && Tone.TimelineSignal === node.constructor)){\n\t\t\t//cancel changes\n\t\t\tnode._param.cancelScheduledValues(0);\n\t\t\t//reset the value\n\t\t\tnode._param.value = 0;\n\t\t\t//mark the value as overridden\n\t\t\tnode.overridden = true;\n\t\t} else if (node instanceof AudioParam){\n\t\t\tnode.cancelScheduledValues(0);\n\t\t\tnode.value = 0;\n\t\t} \n\t\tTone.prototype.connect.call(this, node, outputNumber, inputNumber);\n\t\treturn this;\n\t};\n\n\treturn Tone.SignalBase;\n});","define([\"Tone/core/Tone\", \"Tone/type/TimeBase\"], function (Tone) {\n\n\t/**\n\t * @class Tone.Time is a primitive type for encoding Time values. \n\t * Eventually all time values are evaluated to seconds\n\t * using the `eval` method. Tone.Time can be constructed\n\t * with or without the `new` keyword. Tone.Time can be passed\n\t * into the parameter of any method which takes time as an argument. \n\t * @constructor\n\t * @extends {Tone.TimeBase}\n\t * @param {String|Number} val The time value.\n\t * @param {String=} units The units of the value.\n\t * @example\n\t * var t = Tone.Time(\"4n\");//encodes a quarter note\n\t * t.mult(4); // multiply that value by 4\n\t * t.toNotation(); //returns \"1m\"\n\t */\n\tTone.Time = function(val, units){\n\t\tif (this instanceof Tone.Time){\n\n\t\t\t/**\n\t\t\t * If the current clock time should\n\t\t\t * be added to the output\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t\t\tthis._plusNow = false;\n\t\t\t\n\t\t\tTone.TimeBase.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.Time(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.Time, Tone.TimeBase);\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.Time.prototype._unaryExpressions = Object.create(Tone.TimeBase.prototype._unaryExpressions);\n\n\t/*\n\t * Adds an additional unary expression\n\t * which quantizes values to the next subdivision\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Time.prototype._unaryExpressions.quantize = {\n\t\tregexp : /^@/,\n\t\tmethod : function(rh){\n\t\t\treturn Tone.Transport.nextSubdivision(rh());\n\t\t}\n\t};\n\n\t/*\n\t * Adds an additional unary expression\n\t * which adds the current clock time.\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Time.prototype._unaryExpressions.now = {\n\t\tregexp : /^\\+/,\n\t\tmethod : function(lh){\n\t\t\tthis._plusNow = true;\n\t\t\treturn lh();\n\t\t}\n\t};\n\n\t/**\n\t * Quantize the time by the given subdivision. Optionally add a\n\t * percentage which will move the time value towards the ideal\n\t * quantized value by that percentage. \n\t * @param {Number|Time} val The subdivision to quantize to\n\t * @param {NormalRange} [percent=1] Move the time value\n\t * towards the quantized value by\n\t * a percentage.\n\t * @return {Tone.Time} this\n\t * @example\n\t * Tone.Time(21).quantize(2) //returns 22\n\t * Tone.Time(0.6).quantize(\"4n\", 0.5) //returns 0.55\n\t */\n\tTone.Time.prototype.quantize = function(subdiv, percent){\n\t\tpercent = this.defaultArg(percent, 1);\n\t\tthis._expr = function(expr, subdivision, percent){\n\t\t\texpr = expr();\n\t\t\tsubdivision = subdivision.toSeconds();\n\t\t\tvar multiple = Math.round(expr / subdivision);\n\t\t\tvar ideal = multiple * subdivision;\n\t\t\tvar diff = ideal - expr;\n\t\t\treturn expr + diff * percent;\n\t\t}.bind(this, this._expr, new this.constructor(subdiv), percent);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Adds the clock time to the time expression at the \n\t * moment of evaluation. \n\t * @return {Tone.Time} this\n\t */\n\tTone.Time.prototype.addNow = function(){\n\t\tthis._plusNow = true;\n\t\treturn this;\n\t};\n\n\t/**\n\t * @override\n\t * Override the default value return when no arguments are passed in.\n\t * The default value is 'now'\n\t * @private\n\t */\n\tTone.Time.prototype._defaultExpr = function(){\n\t\tthis._plusNow = true;\n\t\treturn this._noOp;\n\t};\n\n\t/**\n\t * Copies the value of time to this Time\n\t * @param {Tone.Time} time\n\t * @return {Time}\n\t */\n\tTone.Time.prototype.copy = function(time){\n\t\tTone.TimeBase.prototype.copy.call(this, time);\n\t\tthis._plusNow = time._plusNow;\n\t\treturn this;\n\t};\n\n\t//CONVERSIONS//////////////////////////////////////////////////////////////\n\n\t/**\n\t * Convert a Time to Notation. Values will be thresholded to the nearest 128th note. \n\t * @return {Notation} \n\t * @example\n\t * //if the Transport is at 120bpm:\n\t * Tone.Time(2).toNotation();//returns \"1m\"\n\t */\n\tTone.Time.prototype.toNotation = function(){\n\t\tvar time = this.toSeconds();\n\t\tvar testNotations = [\"1m\", \"2n\", \"4n\", \"8n\", \"16n\", \"32n\", \"64n\", \"128n\"];\n\t\tvar retNotation = this._toNotationHelper(time, testNotations);\n\t\t//try the same thing but with tripelets\n\t\tvar testTripletNotations = [\"1m\", \"2n\", \"2t\", \"4n\", \"4t\", \"8n\", \"8t\", \"16n\", \"16t\", \"32n\", \"32t\", \"64n\", \"64t\", \"128n\"];\n\t\tvar retTripletNotation = this._toNotationHelper(time, testTripletNotations);\n\t\t//choose the simpler expression of the two\n\t\tif (retTripletNotation.split(\"+\").length < retNotation.split(\"+\").length){\n\t\t\treturn retTripletNotation;\n\t\t} else {\n\t\t\treturn retNotation;\n\t\t}\n\t};\n\n\t/**\n\t * Helper method for Tone.toNotation\n\t * @param {Number} units \n\t * @param {Array} testNotations\n\t * @return {String}\n\t * @private\n\t */\n\tTone.Time.prototype._toNotationHelper = function(units, testNotations){\n\t\t//the threshold is the last value in the array\n\t\tvar threshold = this._notationToUnits(testNotations[testNotations.length - 1]);\n\t\tvar retNotation = \"\";\n\t\tfor (var i = 0; i < testNotations.length; i++){\n\t\t\tvar notationTime = this._notationToUnits(testNotations[i]);\n\t\t\t//account for floating point errors (i.e. round up if the value is 0.999999)\n\t\t\tvar multiple = units / notationTime;\n\t\t\tvar floatingPointError = 0.000001;\n\t\t\tif (1 - multiple % 1 < floatingPointError){\n\t\t\t\tmultiple += floatingPointError;\n\t\t\t}\n\t\t\tmultiple = Math.floor(multiple);\n\t\t\tif (multiple > 0){\n\t\t\t\tif (multiple === 1){\n\t\t\t\t\tretNotation += testNotations[i];\n\t\t\t\t} else {\n\t\t\t\t\tretNotation += multiple.toString() + \"*\" + testNotations[i];\n\t\t\t\t}\n\t\t\t\tunits -= multiple * notationTime;\n\t\t\t\tif (units < threshold){\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tretNotation += \" + \";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (retNotation === \"\"){\n\t\t\tretNotation = \"0\";\n\t\t}\n\t\treturn retNotation;\n\t};\n\n\t/**\n\t * Convert a notation value to the current units\n\t * @param {Notation} notation \n\t * @return {Number} \n\t * @private\n\t */\n\tTone.Time.prototype._notationToUnits = function(notation){\n\t\tvar primaryExprs = this._primaryExpressions;\n\t\tvar notationExprs = [primaryExprs.n, primaryExprs.t, primaryExprs.m];\n\t\tfor (var i = 0; i < notationExprs.length; i++){\n\t\t\tvar expr = notationExprs[i];\n\t\t\tvar match = notation.match(expr.regexp);\n\t\t\tif (match){\n\t\t\t\treturn expr.method.call(this, match[1]);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Return the time encoded as Bars:Beats:Sixteenths.\n\t * @return {BarsBeatsSixteenths}\n\t */\n\tTone.Time.prototype.toBarsBeatsSixteenths = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.toSeconds() / quarterTime;\n\t\tvar measures = Math.floor(quarters / this._timeSignature());\n\t\tvar sixteenths = (quarters % 1) * 4;\n\t\tquarters = Math.floor(quarters) % this._timeSignature();\n\t\tsixteenths = sixteenths.toString();\n\t\tif (sixteenths.length > 3){\n\t\t\tsixteenths = parseFloat(sixteenths).toFixed(3);\n\t\t}\n\t\tvar progress = [measures, quarters, sixteenths];\n\t\treturn progress.join(\":\");\n\t};\n\n\t/**\n\t * Return the time in ticks.\n\t * @return {Ticks}\n\t */\n\tTone.Time.prototype.toTicks = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.valueOf() / quarterTime;\n\t\treturn Math.floor(quarters * Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Return the time in samples\n\t * @return {Samples} \n\t */\n\tTone.Time.prototype.toSamples = function(){\n\t\treturn this.toSeconds() * this.context.sampleRate;\n\t};\n\n\t/**\n\t * Return the time as a frequency value\n\t * @return {Frequency} \n\t * @example\n\t * Tone.Time(2).toFrequency(); //0.5\n\t */\n\tTone.Time.prototype.toFrequency = function(){\n\t\treturn 1/this.toSeconds();\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.Time.prototype.toSeconds = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the time in milliseconds.\n\t * @return {Milliseconds} \n\t */\n\tTone.Time.prototype.toMilliseconds = function(){\n\t\treturn this.toSeconds() * 1000;\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.Time.prototype.valueOf = function(){\n\t\tvar val = this._expr();\n\t\treturn val + (this._plusNow?this.now():0);\n\t};\n\n\treturn Tone.Time;\n});","define([\"Tone/core/Tone\"], function (Tone) {\n\n\t/**\n\t * @class Tone.TimeBase is a flexible encoding of time\n\t * which can be evaluated to and from a string.\n\t * Parsing code modified from https://code.google.com/p/tapdigit/\n\t * Copyright 2011 2012 Ariya Hidayat, New BSD License\n\t * @extends {Tone}\n\t * @param {Time} val The time value as a number or string\n\t * @param {String=} units Unit values\n\t * @example\n\t * Tone.TimeBase(4, \"n\")\n\t * Tone.TimeBase(2, \"t\")\n\t * Tone.TimeBase(\"2t\").add(\"1m\")\n\t * Tone.TimeBase(\"2t + 1m\");\n\t */\n\tTone.TimeBase = function(val, units){\n\n\t\t//allows it to be constructed with or without 'new'\n\t\tif (this instanceof Tone.TimeBase) {\n\n\t\t\t/**\n\t\t\t * Any expressions parsed from the Time\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t\t\tthis._expr = this._noOp;\n\n\t\t\tif (val instanceof Tone.TimeBase){\n\t\t\t\tthis.copy(val);\n\t\t\t} else if (!this.isUndef(units) || this.isNumber(val)){\n\t\t\t\t//default units\n\t\t\t\tunits = this.defaultArg(units, this._defaultUnits);\n\t\t\t\tvar method = this._primaryExpressions[units].method;\n\t\t\t\tthis._expr = method.bind(this, val);\n\t\t\t} else if (this.isString(val)){\n\t\t\t\tthis.set(val);\n\t\t\t} else if (this.isUndef(val)){\n\t\t\t\t//default expression\n\t\t\t\tthis._expr = this._defaultExpr();\n\t\t\t}\n\t\t} else {\n\n\t\t\treturn new Tone.TimeBase(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.TimeBase);\n\n\t/**\n\t * Repalce the current time value with the value\n\t * given by the expression string.\n\t * @param {String} exprString\n\t * @return {Tone.TimeBase} this\n\t */\n\tTone.TimeBase.prototype.set = function(exprString){\n\t\tthis._expr = this._parseExprString(exprString);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Return a clone of the TimeBase object.\n\t * @return {Tone.TimeBase} The new cloned Tone.TimeBase\n\t */\n\tTone.TimeBase.prototype.clone = function(){\n\t\tvar instance = new this.constructor();\n\t\tinstance.copy(this);\n\t\treturn instance;\n\t};\n\n\t/**\n\t * Copies the value of time to this Time\n\t * @param {Tone.TimeBase} time\n\t * @return {TimeBase}\n\t */\n\tTone.TimeBase.prototype.copy = function(time){\n\t\tvar val = time._expr();\n\t\treturn this.set(val);\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tABSTRACT SYNTAX TREE PARSER\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * All the primary expressions.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._primaryExpressions = {\n\t\t\"n\" : {\n\t\t\tregexp : /^(\\d+)n/i,\n\t\t\tmethod : function(value){\n\t\t\t\tvalue = parseInt(value);\n\t\t\t\tif (value === 1){\n\t\t\t\t\treturn this._beatsToUnits(this._timeSignature());\n\t\t\t\t} else {\n\t\t\t\t\treturn this._beatsToUnits(4 / value);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"t\" : {\n\t\t\tregexp : /^(\\d+)t/i,\n\t\t\tmethod : function(value){\n\t\t\t\tvalue = parseInt(value);\n\t\t\t\treturn this._beatsToUnits(8 / (parseInt(value) * 3));\n\t\t\t}\n\t\t},\n\t\t\"m\" : {\n\t\t\tregexp : /^(\\d+)m/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._beatsToUnits(parseInt(value) * this._timeSignature());\n\t\t\t}\n\t\t},\n\t\t\"i\" : {\n\t\t\tregexp : /^(\\d+)i/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._ticksToUnits(parseInt(value));\n\t\t\t}\n\t\t},\n\t\t\"hz\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?)hz/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._frequencyToUnits(parseFloat(value));\n\t\t\t}\n\t\t},\n\t\t\"tr\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t\t\tmethod : function(m, q, s){\n\t\t\t\tvar total = 0;\n\t\t\t\tif (m && m !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(this._timeSignature() * parseFloat(m));\n\t\t\t\t}\n\t\t\t\tif (q && q !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(parseFloat(q));\n\t\t\t\t}\n\t\t\t\tif (s && s !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(parseFloat(s) / 4);\n\t\t\t\t}\n\t\t\t\treturn total;\n\t\t\t}\n\t\t},\n\t\t\"s\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?s)/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._secondsToUnits(parseFloat(value));\n\t\t\t}\n\t\t},\n\t\t\"samples\" : {\n\t\t\tregexp : /^(\\d+)samples/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn parseInt(value) / this.context.sampleRate;\n\t\t\t}\n\t\t},\n\t\t\"default\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?)/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._primaryExpressions[this._defaultUnits].method.call(this, value);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * All the binary expressions that TimeBase can accept.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._binaryExpressions = {\n\t\t\"+\" : {\n\t\t\tregexp : /^\\+/,\n\t\t\tprecedence : 2,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() + rh();\n\t\t\t}\n\t\t},\n\t\t\"-\" : {\n\t\t\tregexp : /^\\-/,\n\t\t\tprecedence : 2,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() - rh();\n\t\t\t}\n\t\t},\n\t\t\"*\" : {\n\t\t\tregexp : /^\\*/,\n\t\t\tprecedence : 1,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() * rh();\n\t\t\t}\n\t\t},\n\t\t\"/\" : {\n\t\t\tregexp : /^\\//,\n\t\t\tprecedence : 1,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() / rh();\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * All the unary expressions.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._unaryExpressions = {\n\t\t\"neg\" : {\n\t\t\tregexp : /^\\-/,\n\t\t\tmethod : function(lh){\n\t\t\t\treturn -lh();\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Syntactic glue which holds expressions together\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._syntaxGlue = {\n\t\t\"(\" : {\n\t\t\tregexp : /^\\(/\n\t\t},\n\t\t\")\" : {\n\t\t\tregexp : /^\\)/\n\t\t}\n\t};\n\n\t/**\n\t * tokenize the expression based on the Expressions object\n\t * @param {string} expr \n\t * @return {Object} returns two methods on the tokenized list, next and peek\n\t * @private\n\t */\n\tTone.TimeBase.prototype._tokenize = function(expr){\n\t\tvar position = -1;\n\t\tvar tokens = [];\n\n\t\twhile(expr.length > 0){\n\t\t\texpr = expr.trim();\n\t\t\tvar token = getNextToken(expr, this);\n\t\t\ttokens.push(token);\n\t\t\texpr = expr.substr(token.value.length);\n\t\t}\n\n\t\tfunction getNextToken(expr, context){\n\t\t\tvar expressions = [\"_binaryExpressions\", \"_unaryExpressions\", \"_primaryExpressions\", \"_syntaxGlue\"];\n\t\t\tfor (var i = 0; i < expressions.length; i++){\n\t\t\t\tvar group = context[expressions[i]];\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tvar reg = op.regexp;\n\t\t\t\t\tvar match = expr.match(reg);\n\t\t\t\t\tif (match !== null){\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tmethod : op.method,\n\t\t\t\t\t\t\tprecedence : op.precedence,\n\t\t\t\t\t\t\tregexp : op.regexp,\n\t\t\t\t\t\t\tvalue : match[0],\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.TimeBase: Unexpected token \"+expr);\n\t\t}\n\n\t\treturn {\n\t\t\tnext : function(){\n\t\t\t\treturn tokens[++position];\n\t\t\t},\n\t\t\tpeek : function(){\n\t\t\t\treturn tokens[position + 1];\n\t\t\t}\n\t\t};\n\t};\n\n\t/**\n\t * Given a token, find the value within the groupName\n\t * @param {Object} token\n\t * @param {String} groupName\n\t * @param {Number} precedence\n\t * @private\n\t */\n\tTone.TimeBase.prototype._matchGroup = function(token, group, prec) {\n\t\tvar ret = false;\n\t\tif (!this.isUndef(token)){\n\t\t\tfor (var opName in group){\n\t\t\t\tvar op = group[opName];\n\t\t\t\tif (op.regexp.test(token.value)){\n\t\t\t\t\tif (!this.isUndef(prec)){\n\t\t\t\t\t\tif(op.precedence === prec){\t\n\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn op;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * Match a binary expression given the token and the precedence\n\t * @param {Lexer} lexer\n\t * @param {Number} precedence\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseBinary = function(lexer, precedence){\n\t\tif (this.isUndef(precedence)){\n\t\t\tprecedence = 2;\n\t\t}\n\t\tvar expr;\n\t\tif (precedence < 0){\n\t\t\texpr = this._parseUnary(lexer);\n\t\t} else {\n\t\t\texpr = this._parseBinary(lexer, precedence - 1);\n\t\t}\n\t\tvar token = lexer.peek();\n\t\twhile (token && this._matchGroup(token, this._binaryExpressions, precedence)){\n\t\t\ttoken = lexer.next();\n\t\t\texpr = token.method.bind(this, expr, this._parseBinary(lexer, precedence - 1));\n\t\t\ttoken = lexer.peek();\n\t\t}\n\t\treturn expr;\n\t};\n\n\t/**\n\t * Match a unary expression.\n\t * @param {Lexer} lexer\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseUnary = function(lexer){\n\t\tvar token, expr;\n\t\ttoken = lexer.peek();\n\t\tvar op = this._matchGroup(token, this._unaryExpressions);\n\t\tif (op) {\n\t\t\ttoken = lexer.next();\n\t\t\texpr = this._parseUnary(lexer);\n\t\t\treturn op.method.bind(this, expr);\n\t\t}\n\t\treturn this._parsePrimary(lexer);\n\t};\n\n\t/**\n\t * Match a primary expression (a value).\n\t * @param {Lexer} lexer\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parsePrimary = function(lexer){\n\t\tvar token, expr;\n\t\ttoken = lexer.peek();\n\t\tif (this.isUndef(token)) {\n\t\t\tthrow new SyntaxError(\"Tone.TimeBase: Unexpected end of expression\");\n\t\t}\n\t\tif (this._matchGroup(token, this._primaryExpressions)) {\n\t\t\ttoken = lexer.next();\n\t\t\tvar matching = token.value.match(token.regexp);\n\t\t\treturn token.method.bind(this, matching[1], matching[2], matching[3]);\n\t\t}\n\t\tif (token && token.value === \"(\"){\n\t\t\tlexer.next();\n\t\t\texpr = this._parseBinary(lexer);\n\t\t\ttoken = lexer.next();\n\t\t\tif (!(token && token.value === \")\")) {\n\t\t\t\tthrow new SyntaxError(\"Expected )\");\n\t\t\t}\n\t\t\treturn expr;\n\t\t}\n\t\tthrow new SyntaxError(\"Tone.TimeBase: Cannot process token \" + token.value);\n\t};\n\n\t/**\n\t * Recursively parse the string expression into a syntax tree.\n\t * @param {string} expr \n\t * @return {Function} the bound method to be evaluated later\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseExprString = function(exprString){\n\t\tif (!this.isString(exprString)){\n\t\t\texprString = exprString.toString();\n\t\t}\n\t\tvar lexer = this._tokenize(exprString);\n\t\tvar tree = this._parseBinary(lexer);\n\t\treturn tree;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tDEFAULTS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The initial expression value\n\t * @return {Number} The initial value 0\n\t * @private\n\t */\n\tTone.TimeBase.prototype._noOp = function(){\n\t\treturn 0;\n\t};\n\n\t/**\n\t * The default expression value if no arguments are given\n\t * @private\n\t */\n\tTone.TimeBase.prototype._defaultExpr = function(){\n\t\treturn this._noOp;\n\t};\n\n\t/**\n\t * The default units if none are given.\n\t * @private\n\t */\n\tTone.TimeBase.prototype._defaultUnits = \"s\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value of a frequency in the current units\n\t * @param {Frequency} freq\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._frequencyToUnits = function(freq){\n\t\treturn 1/freq;\n\t};\n\n\t/**\n\t * Return the value of the beats in the current units\n\t * @param {Number} beats\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._beatsToUnits = function(beats){\n\t\treturn (60 / Tone.Transport.bpm.value) * beats;\n\t};\n\n\t/**\n\t * Returns the value of a second in the current units\n\t * @param {Seconds} seconds\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._secondsToUnits = function(seconds){\n\t\treturn seconds;\n\t};\n\n\t/**\n\t * Returns the value of a tick in the current time units\n\t * @param {Ticks} ticks\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._ticksToUnits = function(ticks){\n\t\treturn ticks * (this._beatsToUnits(1) / Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Return the time signature.\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._timeSignature = function(){\n\t\treturn Tone.Transport.timeSignature;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tEXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Push an expression onto the expression list\n\t * @param {Time} val\n\t * @param {String} type\n\t * @param {String} units\n\t * @return {Tone.TimeBase} \n\t * @private\n\t */\n\tTone.TimeBase.prototype._pushExpr = function(val, name, units){\n\t\t//create the expression\n\t\tif (!(val instanceof Tone.TimeBase)){\n\t\t\tval = new this.constructor(val, units);\n\t\t}\n\t\tthis._expr = this._binaryExpressions[name].method.bind(this, this._expr, val._expr);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Add to the current value.\n\t * @param {Time} val The value to add\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").add(\"1m\"); //\"3m\"\n\t */\n\tTone.TimeBase.prototype.add = function(val, units){\n\t\treturn this._pushExpr(val, \"+\", units);\n\t};\n\n\t/**\n\t * Subtract the value from the current time.\n\t * @param {Time} val The value to subtract\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").sub(\"1m\"); //\"1m\"\n\t */\n\tTone.TimeBase.prototype.sub = function(val, units){\n\t\treturn this._pushExpr(val, \"-\", units);\n\t};\n\n\t/**\n\t * Multiply the current value by the given time.\n\t * @param {Time} val The value to multiply\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").mult(\"2\"); //\"4m\"\n\t */\n\tTone.TimeBase.prototype.mult = function(val, units){\n\t\treturn this._pushExpr(val, \"*\", units);\n\t};\n\n\t/**\n\t * Divide the current value by the given time.\n\t * @param {Time} val The value to divide by\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").div(2); //\"1m\"\n\t */\n\tTone.TimeBase.prototype.div = function(val, units){\n\t\treturn this._pushExpr(val, \"/\", units);\n\t};\n\n\t/**\n\t * Evaluate the time value. Returns the time\n\t * in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.TimeBase.prototype.valueOf = function(){\n\t\treturn this._expr();\n\t};\n\n\t/**\n\t * Clean up\n\t * @return {Tone.TimeBase} this\n\t */\n\tTone.TimeBase.prototype.dispose = function(){\n\t\tthis._expr = null;\n\t};\n\n\treturn Tone.TimeBase;\n});","define([\"Tone/core/Tone\", \"Tone/type/Type\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Param wraps the native Web Audio's AudioParam to provide\n\t * additional unit conversion functionality. It also\n\t * serves as a base-class for classes which have a single,\n\t * automatable parameter. \n\t * @extends {Tone}\n\t * @param {AudioParam} param The parameter to wrap.\n\t * @param {Tone.Type} units The units of the audio param.\n\t * @param {Boolean} convert If the param should be converted.\n\t */\n\tTone.Param = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"param\", \"units\", \"convert\"], Tone.Param.defaults);\n\n\t\t/**\n\t\t * The native parameter to control\n\t\t * @type {AudioParam}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input = options.param;\n\n\t\t/**\n\t\t * The units of the parameter\n\t\t * @type {Tone.Type}\n\t\t */\n\t\tthis.units = options.units;\n\n\t\t/**\n\t\t * If the value should be converted or not\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.convert = options.convert;\n\n\t\t/**\n\t\t * True if the signal value is being overridden by \n\t\t * a connected signal.\n\t\t * @readOnly\n\t\t * @type {boolean}\n\t\t * @private\n\t\t */\n\t\tthis.overridden = false;\n\n\t\t/**\n\t\t * If there is an LFO, this is where it is held.\n\t\t * @type {Tone.LFO}\n\t\t * @private\n\t\t */\n\t\tthis._lfo = null;\n\n\t\tif (this.isObject(options.lfo)){\n\t\t\tthis.value = options.lfo;\n\t\t} else if (!this.isUndef(options.value)){\n\t\t\tthis.value = options.value;\n\t\t}\n\t};\n\n\tTone.extend(Tone.Param);\n\t\n\t/**\n\t * Defaults\n\t * @type {Object}\n\t * @const\n\t */\n\tTone.Param.defaults = {\n\t\t\"units\" : Tone.Type.Default,\n\t\t\"convert\" : true,\n\t\t\"param\" : undefined\n\t};\n\n\t/**\n\t * The current value of the parameter. \n\t * @memberOf Tone.Param#\n\t * @type {Number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Param.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._toUnits(this._param.value);\n\t\t},\n\t\tset : function(value){\n\t\t\tif (this.isObject(value)){\n\t\t\t\t//throw an error if the LFO needs to be included\n\t\t\t\tif (this.isUndef(Tone.LFO)){\n\t\t\t\t\tthrow new Error(\"Include 'Tone.LFO' to use an LFO as a Param value.\");\n\t\t\t\t}\n\t\t\t\t//remove the old one\n\t\t\t\tif (this._lfo){\n\t\t\t\t\tthis._lfo.dispose();\n\t\t\t\t}\n\t\t\t\tthis._lfo = new Tone.LFO(value).start();\n\t\t\t\tthis._lfo.connect(this.input);\n\t\t\t} else {\n\t\t\t\tvar convertedVal = this._fromUnits(value);\n\t\t\t\tthis._param.cancelScheduledValues(0);\n\t\t\t\tthis._param.value = convertedVal;\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Convert the given value from the type specified by Tone.Param.units\n\t * into the destination value (such as Gain or Frequency).\n\t * @private\n\t * @param {*} val the value to convert\n\t * @return {number} the number which the value should be set to\n\t */\n\tTone.Param.prototype._fromUnits = function(val){\n\t\tif (this.convert || this.isUndef(this.convert)){\n\t\t\tswitch(this.units){\n\t\t\t\tcase Tone.Type.Time: \n\t\t\t\t\treturn this.toSeconds(val);\n\t\t\t\tcase Tone.Type.Frequency: \n\t\t\t\t\treturn this.toFrequency(val);\n\t\t\t\tcase Tone.Type.Decibels: \n\t\t\t\t\treturn this.dbToGain(val);\n\t\t\t\tcase Tone.Type.NormalRange: \n\t\t\t\t\treturn Math.min(Math.max(val, 0), 1);\n\t\t\t\tcase Tone.Type.AudioRange: \n\t\t\t\t\treturn Math.min(Math.max(val, -1), 1);\n\t\t\t\tcase Tone.Type.Positive: \n\t\t\t\t\treturn Math.max(val, 0);\n\t\t\t\tdefault:\n\t\t\t\t\treturn val;\n\t\t\t}\n\t\t} else {\n\t\t\treturn val;\n\t\t}\n\t};\n\n\t/**\n\t * Convert the parameters value into the units specified by Tone.Param.units.\n\t * @private\n\t * @param {number} val the value to convert\n\t * @return {number}\n\t */\n\tTone.Param.prototype._toUnits = function(val){\n\t\tif (this.convert || this.isUndef(this.convert)){\n\t\t\tswitch(this.units){\n\t\t\t\tcase Tone.Type.Decibels: \n\t\t\t\t\treturn this.gainToDb(val);\n\t\t\t\tdefault:\n\t\t\t\t\treturn val;\n\t\t\t}\n\t\t} else {\n\t\t\treturn val;\n\t\t}\n\t};\n\n\t/**\n\t * the minimum output value\n\t * @type {Number}\n\t * @private\n\t */\n\tTone.Param.prototype._minOutput = 0.00001;\n\n\t/**\n\t * Schedules a parameter value change at the given time.\n\t * @param {*}\tvalue The value to set the signal.\n\t * @param {Time} time The time when the change should occur.\n\t * @returns {Tone.Param} this\n\t * @example\n\t * //set the frequency to \"G4\" in exactly 1 second from now. \n\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t */\n\tTone.Param.prototype.setValueAtTime = function(value, time){\n\t\tvalue = this._fromUnits(value);\n\t\ttime = this.toSeconds(time);\n\t\tif (time <= this.now() + this.blockTime){\n\t\t\tthis._param.value = value;\n\t\t} else {\n\t\t\tthis._param.setValueAtTime(value, time);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Creates a schedule point with the current value at the current time.\n\t * This is useful for creating an automation anchor point in order to \n\t * schedule changes from the current value. \n\t *\n\t * @param {number=} now (Optionally) pass the now value in. \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.setRampPoint = function(now){\n\t\tnow = this.defaultArg(now, this.now());\n\t\tvar currentVal = this._param.value;\n\t\t// exponentialRampToValueAt cannot ever ramp from or to 0\n\t\t// More info: https://bugzilla.mozilla.org/show_bug.cgi?id=1125600#c2\n\t\tif (currentVal === 0){\n\t\t\tcurrentVal = this._minOutput;\n\t\t}\n\t\tthis._param.setValueAtTime(currentVal, now);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules a linear continuous change in parameter value from the \n\t * previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.linearRampToValueAtTime = function(value, endTime){\n\t\tvalue = this._fromUnits(value);\n\t\tthis._param.linearRampToValueAtTime(value, this.toSeconds(endTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.exponentialRampToValueAtTime = function(value, endTime){\n\t\tvalue = this._fromUnits(value);\n\t\tvalue = Math.max(this._minOutput, value);\n\t\tthis._param.exponentialRampToValueAtTime(value, this.toSeconds(endTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the current time and current value to the given value over the \n\t * duration of the rampTime.\n\t * \n\t * @param {number} value The value to ramp to.\n\t * @param {Time} rampTime the time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //exponentially ramp to the value 2 over 4 seconds. \n\t * signal.exponentialRampToValue(2, 4);\n\t */\n\tTone.Param.prototype.exponentialRampToValue = function(value, rampTime, startTime){\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis.setRampPoint(startTime);\n\t\tthis.exponentialRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an linear continuous change in parameter value from \n\t * the current time and current value to the given value over the \n\t * duration of the rampTime.\n\t * \n\t * @param {number} value The value to ramp to.\n\t * @param {Time} rampTime the time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //linearly ramp to the value 4 over 3 seconds. \n\t * signal.linearRampToValue(4, 3);\n\t */\n\tTone.Param.prototype.linearRampToValue = function(value, rampTime, startTime){\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis.setRampPoint(startTime);\n\t\tthis.linearRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Start exponentially approaching the target value at the given time with\n\t * a rate having the given time constant.\n\t * @param {number} value \n\t * @param {Time} startTime \n\t * @param {number} timeConstant \n\t * @returns {Tone.Param} this \n\t */\n\tTone.Param.prototype.setTargetAtTime = function(value, startTime, timeConstant){\n\t\tvalue = this._fromUnits(value);\n\t\t// The value will never be able to approach without timeConstant > 0.\n\t\t// http://www.w3.org/TR/webaudio/#dfn-setTargetAtTime, where the equation\n\t\t// is described. 0 results in a division by 0.\n\t\tvalue = Math.max(this._minOutput, value);\n\t\ttimeConstant = Math.max(this._minOutput, timeConstant);\n\t\tthis._param.setTargetAtTime(value, this.toSeconds(startTime), timeConstant);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Sets an array of arbitrary parameter values starting at the given time\n\t * for the given duration.\n\t * \t\n\t * @param {Array} values \n\t * @param {Time} startTime \n\t * @param {Time} duration \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.setValueCurveAtTime = function(values, startTime, duration){\n\t\tfor (var i = 0; i < values.length; i++){\n\t\t\tvalues[i] = this._fromUnits(values[i]);\n\t\t}\n\t\tthis._param.setValueCurveAtTime(values, this.toSeconds(startTime), this.toSeconds(duration));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancels all scheduled parameter changes with times greater than or \n\t * equal to startTime.\n\t * \n\t * @param {Time} startTime\n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.cancelScheduledValues = function(startTime){\n\t\tthis._param.cancelScheduledValues(this.toSeconds(startTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Ramps to the given value over the duration of the rampTime. \n\t * Automatically selects the best ramp type (exponential or linear)\n\t * depending on the `units` of the signal\n\t * \n\t * @param {number} value \n\t * @param {Time} rampTime \tThe time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //ramp to the value either linearly or exponentially \n\t * //depending on the \"units\" value of the signal\n\t * signal.rampTo(0, 10);\n\t * @example\n\t * //schedule it to ramp starting at a specific time\n\t * signal.rampTo(0, 10, 5)\n\t */\n\tTone.Param.prototype.rampTo = function(value, rampTime, startTime){\n\t\trampTime = this.defaultArg(rampTime, 0);\n\t\tif (this.units === Tone.Type.Frequency || this.units === Tone.Type.BPM || this.units === Tone.Type.Decibels){\n\t\t\tthis.exponentialRampToValue(value, rampTime, startTime);\n\t\t} else {\n\t\t\tthis.linearRampToValue(value, rampTime, startTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * The LFO created by the signal instance. If none\n\t * was created, this is null.\n\t * @type {Tone.LFO}\n\t * @readOnly\n\t * @memberOf Tone.Param#\n\t * @name lfo\n\t */\n\tObject.defineProperty(Tone.Param.prototype, \"lfo\", {\n\t\tget : function(){\n\t\t\treturn this._lfo;\n\t\t}\n\t});\n\n\t/**\n\t * Clean up\n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._param = null;\n\t\tif (this._lfo){\n\t\t\tthis._lfo.dispose();\n\t\t\tthis._lfo = null;\n\t\t}\n\t\treturn this;\n\t};\n\n\treturn Tone.Param;\n});","define([\"Tone/core/Tone\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A Timeline class for scheduling and maintaining state\n\t * along a timeline. All events must have a \"time\" property. \n\t * Internally, events are stored in time order for fast \n\t * retrieval.\n\t * @extends {Tone}\n\t * @param {Positive} [memory=Infinity] The number of previous events that are retained.\n\t */\n\tTone.Timeline = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"memory\"], Tone.Timeline.defaults);\n\n\t\t/**\n\t\t * The array of scheduled timeline events\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._timeline = [];\n\n\t\t/**\n\t\t * An array of items to remove from the list. \n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._toRemove = [];\n\n\t\t/**\n\t\t * Flag if the tieline is mid iteration\n\t\t * @private\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis._iterating = false;\n\n\t\t/**\n\t\t * The memory of the timeline, i.e.\n\t\t * how many events in the past it will retain\n\t\t * @type {Positive}\n\t\t */\n\t\tthis.memory = options.memory;\n\t};\n\n\tTone.extend(Tone.Timeline);\n\n\t/**\n\t * the default parameters\n\t * @static\n\t * @const\n\t */\n\tTone.Timeline.defaults = {\n\t\t\"memory\" : Infinity\n\t};\n\n\t/**\n\t * The number of items in the timeline.\n\t * @type {Number}\n\t * @memberOf Tone.Timeline#\n\t * @name length\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.Timeline.prototype, \"length\", {\n\t\tget : function(){\n\t\t\treturn this._timeline.length;\n\t\t}\n\t});\n\n\t/**\n\t * Insert an event object onto the timeline. Events must have a \"time\" attribute.\n\t * @param {Object} event The event object to insert into the \n\t * timeline. \n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.add = function(event){\n\t\t//the event needs to have a time attribute\n\t\tif (this.isUndef(event.time)){\n\t\t\tthrow new Error(\"Tone.Timeline: events must have a time attribute\");\n\t\t}\n\t\tif (this._timeline.length){\n\t\t\tvar index = this._search(event.time);\n\t\t\tthis._timeline.splice(index + 1, 0, event);\n\t\t} else {\n\t\t\tthis._timeline.push(event);\t\t\t\n\t\t}\n\t\t//if the length is more than the memory, remove the previous ones\n\t\tif (this.length > this.memory){\n\t\t\tvar diff = this.length - this.memory;\n\t\t\tthis._timeline.splice(0, diff);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Remove an event from the timeline.\n\t * @param {Object} event The event object to remove from the list.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.remove = function(event){\n\t\tif (this._iterating){\n\t\t\tthis._toRemove.push(event);\n\t\t} else {\n\t\t\tvar index = this._timeline.indexOf(event);\n\t\t\tif (index !== -1){\n\t\t\t\tthis._timeline.splice(index, 1);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Get the nearest event whose time is less than or equal to the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object set after that time.\n\t */\n\tTone.Timeline.prototype.get = function(time){\n\t\tvar index = this._search(time);\n\t\tif (index !== -1){\n\t\t\treturn this._timeline[index];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Return the first event in the timeline without removing it\n\t * @returns {Object} The first event object\n\t */\n\tTone.Timeline.prototype.peek = function(){\n\t\treturn this._timeline[0];\n\t};\n\n\t/**\n\t * Return the first event in the timeline and remove it\n\t * @returns {Object} The first event object\n\t */\n\tTone.Timeline.prototype.shift = function(){\n\t\treturn this._timeline.shift();\n\t};\n\n\t/**\n\t * Get the event which is scheduled after the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object after the given time\n\t */\n\tTone.Timeline.prototype.getAfter = function(time){\n\t\tvar index = this._search(time);\n\t\tif (index + 1 < this._timeline.length){\n\t\t\treturn this._timeline[index + 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Get the event before the event at the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object before the given time\n\t */\n\tTone.Timeline.prototype.getBefore = function(time){\n\t\tvar len = this._timeline.length;\n\t\t//if it's after the last item, return the last item\n\t\tif (len > 0 && this._timeline[len - 1].time < time){\n\t\t\treturn this._timeline[len - 1];\n\t\t}\n\t\tvar index = this._search(time);\n\t\tif (index - 1 >= 0){\n\t\t\treturn this._timeline[index - 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Cancel events after the given time\n\t * @param {Number} time The time to query.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.cancel = function(after){\n\t\tif (this._timeline.length > 1){\n\t\t\tvar index = this._search(after);\n\t\t\tif (index >= 0){\n\t\t\t\tif (this._timeline[index].time === after){\n\t\t\t\t\t//get the first item with that time\n\t\t\t\t\tfor (var i = index; i >= 0; i--){\n\t\t\t\t\t\tif (this._timeline[i].time === after){\n\t\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis._timeline = this._timeline.slice(0, index);\n\t\t\t\t} else {\n\t\t\t\t\tthis._timeline = this._timeline.slice(0, index + 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis._timeline = [];\n\t\t\t}\n\t\t} else if (this._timeline.length === 1){\n\t\t\t//the first item's time\n\t\t\tif (this._timeline[0].time >= after){\n\t\t\t\tthis._timeline = [];\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancel events before or equal to the given time.\n\t * @param {Number} time The time to cancel before.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.cancelBefore = function(time){\n\t\tif (this._timeline.length){\n\t\t\tvar index = this._search(time);\n\t\t\tif (index >= 0){\n\t\t\t\tthis._timeline = this._timeline.slice(index + 1);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Does a binary serach on the timeline array and returns the \n\t * nearest event index whose time is after or equal to the given time.\n\t * If a time is searched before the first index in the timeline, -1 is returned.\n\t * If the time is after the end, the index of the last item is returned.\n\t * @param {Number} time \n\t * @return {Number} the index in the timeline array \n\t * @private\n\t */\n\tTone.Timeline.prototype._search = function(time){\n\t\tvar beginning = 0;\n\t\tvar len = this._timeline.length;\n\t\tvar end = len;\n\t\tif (len > 0 && this._timeline[len - 1].time <= time){\n\t\t\treturn len - 1;\n\t\t}\n\t\twhile (beginning < end){\n\t\t\t// calculate the midpoint for roughly equal partition\n\t\t\tvar midPoint = Math.floor(beginning + (end - beginning) / 2);\n\t\t\tvar event = this._timeline[midPoint];\n\t\t\tvar nextEvent = this._timeline[midPoint + 1];\n\t\t\tif (event.time === time){\n\t\t\t\t//choose the last one that has the same time\n\t\t\t\tfor (var i = midPoint; i < this._timeline.length; i++){\n\t\t\t\t\tvar testEvent = this._timeline[i];\n\t\t\t\t\tif (testEvent.time === time){\n\t\t\t\t\t\tmidPoint = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn midPoint;\n\t\t\t} else if (event.time < time && nextEvent.time > time){\n\t\t\t\treturn midPoint;\n\t\t\t} else if (event.time > time){\n\t\t\t\t//search lower\n\t\t\t\tend = midPoint;\n\t\t\t} else if (event.time < time){\n\t\t\t\t//search upper\n\t\t\t\tbeginning = midPoint + 1;\n\t\t\t} \n\t\t}\n\t\treturn -1;\n\t};\n\n\t/**\n\t * Internal iterator. Applies extra safety checks for \n\t * removing items from the array. \n\t * @param {Function} callback \n\t * @param {Number=} lowerBound \n\t * @param {Number=} upperBound \n\t * @private\n\t */\n\tTone.Timeline.prototype._iterate = function(callback, lowerBound, upperBound){\n\t\tthis._iterating = true;\n\t\tlowerBound = this.defaultArg(lowerBound, 0);\n\t\tupperBound = this.defaultArg(upperBound, this._timeline.length - 1);\n\t\tfor (var i = lowerBound; i <= upperBound; i++){\n\t\t\tcallback(this._timeline[i]);\n\t\t}\n\t\tthis._iterating = false;\n\t\tif (this._toRemove.length > 0){\n\t\t\tfor (var j = 0; j < this._toRemove.length; j++){\n\t\t\t\tvar index = this._timeline.indexOf(this._toRemove[j]);\n\t\t\t\tif (index !== -1){\n\t\t\t\t\tthis._timeline.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._toRemove = [];\n\t\t}\n\t};\n\n\t/**\n\t * Iterate over everything in the array\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEach = function(callback){\n\t\tthis._iterate(callback);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at or before the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachBefore = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar upperBound = this._search(time);\n\t\tif (upperBound !== -1){\n\t\t\tthis._iterate(callback, 0, upperBound);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array after the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachAfter = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar lowerBound = this._search(time);\n\t\tthis._iterate(callback, lowerBound + 1);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at or after the given time. Similar to \n\t * forEachAfter, but includes the item(s) at the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachFrom = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar lowerBound = this._search(time);\n\t\t//work backwards until the event time is less than time\n\t\twhile (lowerBound >= 0 && this._timeline[lowerBound].time >= time){\n\t\t\tlowerBound--;\n\t\t}\n\t\tthis._iterate(callback, lowerBound + 1);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at the given time\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachAtTime = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar upperBound = this._search(time);\n\t\tif (upperBound !== -1){\n\t\t\tthis._iterate(function(event){\n\t\t\t\tif (event.time === time){\n\t\t\t\t\tcallback(event);\n\t\t\t\t} \n\t\t\t}, 0, upperBound);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._timeline = null;\n\t\tthis._toRemove = null;\n\t};\n\n\treturn Tone.Timeline;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Multiply\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Negate the incoming signal. i.e. an input signal of 10 will output -10\n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var neg = new Tone.Negate();\n\t * var sig = new Tone.Signal(-2).connect(neg);\n\t * //output of neg is positive 2. \n\t */\n\tTone.Negate = function(){\n\t\t/**\n\t\t * negation is done by multiplying by -1\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._multiply = this.input = this.output = new Tone.Multiply(-1);\n\t};\n\n\tTone.extend(Tone.Negate, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Negate} this\n\t */\n\tTone.Negate.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._multiply.dispose();\n\t\tthis._multiply = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Negate;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/signal/Multiply\", \"Tone/signal/WaveShaper\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class GreaterThanZero outputs 1 when the input is strictly greater than zero\n\t * \n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var gt0 = new Tone.GreaterThanZero();\n\t * var sig = new Tone.Signal(0.01).connect(gt0);\n\t * //the output of gt0 is 1. \n\t * sig.value = 0;\n\t * //the output of gt0 is 0. \n\t */\n\tTone.GreaterThanZero = function(){\n\t\t\n\t\t/**\n\t\t * @type {Tone.WaveShaper}\n\t\t * @private\n\t\t */\n\t\tthis._thresh = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (val <= 0){\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}, 127);\n\n\t\t/**\n\t\t * scale the first thresholded signal by a large value.\n\t\t * this will help with values which are very close to 0\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._scale = this.input = new Tone.Multiply(10000);\n\n\t\t//connections\n\t\tthis._scale.connect(this._thresh);\n\t};\n\n\tTone.extend(Tone.GreaterThanZero, Tone.SignalBase);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.GreaterThanZero} this\n\t */\n\tTone.GreaterThanZero.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._scale.dispose();\n\t\tthis._scale = null;\n\t\tthis._thresh.dispose();\n\t\tthis._thresh = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.GreaterThanZero;\n});","/**\n * StartAudioContext.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2016 Yotam Mann\n */\n(function (root, factory) {\n\tif (typeof define === \"function\" && define.amd) {\n\t\tdefine([], factory)\n\t } else if (typeof module === \"object\" && module.exports) {\n module.exports = factory()\n\t} else {\n\t\troot.StartAudioContext = factory()\n }\n}(this, function () {\n\n\t//TAP LISTENER/////////////////////////////////////////////////////////////\n\n\t/**\n\t * @class Listens for non-dragging tap ends on the given element\n\t * @param {Element} element\n\t * @internal\n\t */\n\tvar TapListener = function(element, context){\n\n\t\tthis._dragged = false\n\n\t\tthis._element = element\n\n\t\tthis._bindedMove = this._moved.bind(this)\n\t\tthis._bindedEnd = this._ended.bind(this, context)\n\n\t\telement.addEventListener(\"touchstart\", this._bindedEnd)\n\t\telement.addEventListener(\"touchmove\", this._bindedMove)\n\t\telement.addEventListener(\"touchend\", this._bindedEnd)\n\t\telement.addEventListener(\"mouseup\", this._bindedEnd)\n\t}\n\n\t/**\n\t * drag move event\n\t */\n\tTapListener.prototype._moved = function(e){\n\t\tthis._dragged = true\n\t};\n\n\t/**\n\t * tap ended listener\n\t */\n\tTapListener.prototype._ended = function(context){\n\t\tif (!this._dragged){\n\t\t\tstartContext(context)\n\t\t}\n\t\tthis._dragged = false\n\t};\n\n\t/**\n\t * remove all the bound events\n\t */\n\tTapListener.prototype.dispose = function(){\n\t\tthis._element.removeEventListener(\"touchstart\", this._bindedEnd)\n\t\tthis._element.removeEventListener(\"touchmove\", this._bindedMove)\n\t\tthis._element.removeEventListener(\"touchend\", this._bindedEnd)\n\t\tthis._element.removeEventListener(\"mouseup\", this._bindedEnd)\n\t\tthis._bindedMove = null\n\t\tthis._bindedEnd = null\n\t\tthis._element = null\n\t};\n\n\t//END TAP LISTENER/////////////////////////////////////////////////////////\n\n\t/**\n\t * Plays a silent sound and also invoke the \"resume\" method\n\t * @param {AudioContext} context\n\t * @private\n\t */\n\tfunction startContext(context){\n\t\t// this accomplishes the iOS specific requirement\n\t\tvar buffer = context.createBuffer(1, 1, context.sampleRate)\n\t\tvar source = context.createBufferSource()\n\t\tsource.buffer = buffer\n\t\tsource.connect(context.destination)\n\t\tsource.start(0)\n\n\t\t// resume the audio context\n\t\tif (context.resume){\n\t\t\tcontext.resume()\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if the audio context is started\n\t * @param {AudioContext} context\n\t * @return {Boolean}\n\t * @private\n\t */\n\tfunction isStarted(context){\n\t\t return context.state === \"running\"\n\t}\n\n\t/**\n\t * Invokes the callback as soon as the AudioContext\n\t * is started\n\t * @param {AudioContext} context\n\t * @param {Function} callback\n\t */\n\tfunction onStarted(context, callback){\n\n\t\tfunction checkLoop(){\n\t\t\tif (isStarted(context)){\n\t\t\t\tcallback()\n\t\t\t} else {\n\t\t\t\trequestAnimationFrame(checkLoop)\n\t\t\t\tif (context.resume){\n\t\t\t\t\tcontext.resume()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isStarted(context)){\n\t\t\tcallback()\n\t\t} else {\n\t\t\tcheckLoop()\n\t\t}\n\t}\n\n\t/**\n\t * Add a tap listener to the audio context\n\t * @param {Array|Element|String|jQuery} element\n\t * @param {Array} tapListeners\n\t */\n\tfunction bindTapListener(element, tapListeners, context){\n\t\tif (Array.isArray(element) || (NodeList && element instanceof NodeList)){\n\t\t\tfor (var i = 0; i < element.length; i++){\n\t\t\t\tbindTapListener(element[i], tapListeners, context)\n\t\t\t}\n\t\t} else if (typeof element === \"string\"){\n\t\t\tbindTapListener(document.querySelectorAll(element), tapListeners, context)\n\t\t} else if (element.jquery && typeof element.toArray === \"function\"){\n\t\t\tbindTapListener(element.toArray(), tapListeners, context)\n\t\t} else if (Element && element instanceof Element){\n\t\t\t//if it's an element, create a TapListener\n\t\t\tvar tap = new TapListener(element, context)\n\t\t\ttapListeners.push(tap)\n\t\t} \n\t}\n\n\t/**\n\t * @param {AudioContext} context The AudioContext to start.\n\t * @param {Array|String|Element|jQuery=} elements For iOS, the list of elements\n\t * to bind tap event listeners\n\t * which will start the AudioContext. If\n\t * no elements are given, it will bind\n\t * to the document.body.\n\t * @param {Function=} callback The callback to invoke when the AudioContext is started.\n\t * @return {Promise} The promise is invoked when the AudioContext\n\t * is started.\n\t */\n\tfunction StartAudioContext(context, elements, callback){\n\n\t\t//the promise is invoked when the AudioContext is started\n\t\tvar promise = new Promise(function(success) {\n\t\t\tonStarted(context, success)\n\t\t})\n\n\t\t// The TapListeners bound to the elements\n\t\tvar tapListeners = []\n\n\t\t// add all the tap listeners\n\t\tif (!elements){\n\t\t\telements = document.body\n\t\t}\n\t\tbindTapListener(elements, tapListeners, context)\n\n\t\t//dispose all these tap listeners when the context is started\n\t\tpromise.then(function(){\n\t\t\tfor (var i = 0; i < tapListeners.length; i++){\n\t\t\t\ttapListeners[i].dispose()\n\t\t\t}\n\t\t\ttapListeners = null\n\n\t\t\tif (callback){\n\t\t\t\tcallback()\n\t\t\t}\n\t\t})\n\n\t\treturn promise\n\t}\n\n\treturn StartAudioContext\n}))","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/signal/Expr\", \n\t\"Tone/signal/EqualPowerGain\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Crossfade provides equal power fading between two inputs. \n\t * More on crossfading technique [here](https://en.wikipedia.org/wiki/Fade_(audio_engineering)#Crossfading).\n\t *\n\t * @constructor\n\t * @extends {Tone}\n\t * @param {NormalRange} [initialFade=0.5]\n\t * @example\n\t * var crossFade = new Tone.CrossFade(0.5);\n\t * //connect effect A to crossfade from\n\t * //effect output 0 to crossfade input 0\n\t * effectA.connect(crossFade, 0, 0);\n\t * //connect effect B to crossfade from\n\t * //effect output 0 to crossfade input 1\n\t * effectB.connect(crossFade, 0, 1);\n\t * crossFade.fade.value = 0;\n\t * // ^ only effectA is output\n\t * crossFade.fade.value = 1;\n\t * // ^ only effectB is output\n\t * crossFade.fade.value = 0.5;\n\t * // ^ the two signals are mixed equally. \n\t */\t\t\n\tTone.CrossFade = function(initialFade){\n\n\t\tthis.createInsOuts(2, 1);\n\n\t\t/**\n\t\t * Alias for input[0]. \n\t\t * @type {Tone.Gain}\n\t\t */\n\t\tthis.a = this.input[0] = new Tone.Gain();\n\n\t\t/**\n\t\t * Alias for input[1]. \n\t\t * @type {Tone.Gain}\n\t\t */\n\t\tthis.b = this.input[1] = new Tone.Gain();\n\n\t\t/**\n\t\t * \tThe mix between the two inputs. A fade value of 0\n\t\t * \twill output 100% input[0] and \n\t\t * \ta value of 1 will output 100% input[1]. \n\t\t * @type {NormalRange}\n\t\t * @signal\n\t\t */\n\t\tthis.fade = new Tone.Signal(this.defaultArg(initialFade, 0.5), Tone.Type.NormalRange);\n\n\t\t/**\n\t\t * equal power gain cross fade\n\t\t * @private\n\t\t * @type {Tone.EqualPowerGain}\n\t\t */\n\t\tthis._equalPowerA = new Tone.EqualPowerGain();\n\n\t\t/**\n\t\t * equal power gain cross fade\n\t\t * @private\n\t\t * @type {Tone.EqualPowerGain}\n\t\t */\n\t\tthis._equalPowerB = new Tone.EqualPowerGain();\n\t\t\n\t\t/**\n\t\t * invert the incoming signal\n\t\t * @private\n\t\t * @type {Tone}\n\t\t */\n\t\tthis._invert = new Tone.Expr(\"1 - $0\");\n\n\t\t//connections\n\t\tthis.a.connect(this.output);\n\t\tthis.b.connect(this.output);\n\t\tthis.fade.chain(this._equalPowerB, this.b.gain);\n\t\tthis.fade.chain(this._invert, this._equalPowerA, this.a.gain);\n\t\tthis._readOnly(\"fade\");\n\t};\n\n\tTone.extend(Tone.CrossFade);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.CrossFade} this\n\t */\n\tTone.CrossFade.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._writable(\"fade\");\n\t\tthis._equalPowerA.dispose();\n\t\tthis._equalPowerA = null;\n\t\tthis._equalPowerB.dispose();\n\t\tthis._equalPowerB = null;\n\t\tthis.fade.dispose();\n\t\tthis.fade = null;\n\t\tthis._invert.dispose();\n\t\tthis._invert = null;\n\t\tthis.a.dispose();\n\t\tthis.a = null;\n\t\tthis.b.dispose();\n\t\tthis.b = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.CrossFade;\n});\n","!function(){var e,t=[];function r(e){var r=this,n={},i=-1;this.parameters.forEach(function(e,o){var s=t[++i]||(t[i]=new Float32Array(r.bufferSize));s.fill(e.value),n[o]=s}),this.processor.realm.exec(\"self.sampleRate=sampleRate=\"+this.context.sampleRate+\";self.currentTime=currentTime=\"+this.context.currentTime);var s=o(e.inputBuffer),a=o(e.outputBuffer);this.instance.process([s],[a],n)}function o(e){for(var t=[],r=0;r= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar RecorderProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(RecorderProcessor, _AudioWorkletProcesso);\\n\\n function RecorderProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, RecorderProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(RecorderProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.numOutputChannels = options.outputChannelCount || 2;\\n _this.numInputChannels = processorOptions.numInputChannels || 2;\\n _this.bufferSize = processorOptions.bufferSize || 1024;\\n _this.recording = false;\\n\\n _this.clear();\\n\\n _this.port.onmessage = function (event) {\\n var data = event.data;\\n\\n if (data.name === 'start') {\\n _this.record(data.duration);\\n } else if (data.name === 'stop') {\\n _this.stop();\\n }\\n };\\n\\n return _this;\\n }\\n\\n _createClass(RecorderProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs) {\\n if (!this.recording) {\\n return true;\\n } else if (this.sampleLimit && this.recordedSamples >= this.sampleLimit) {\\n this.stop();\\n return true;\\n }\\n\\n var input = inputs[0];\\n this.inputRingBuffer.push(input);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n\\n for (var channel = 0; channel < this.numOutputChannels; ++channel) {\\n var inputChannelCopy = this.inputRingBufferArraySequence[channel].slice();\\n\\n if (channel === 0) {\\n this.leftBuffers.push(inputChannelCopy);\\n\\n if (this.numInputChannels === 1) {\\n this.rightBuffers.push(inputChannelCopy);\\n }\\n } else if (channel === 1 && this.numInputChannels > 1) {\\n this.rightBuffers.push(inputChannelCopy);\\n }\\n }\\n\\n this.recordedSamples += this.bufferSize;\\n }\\n\\n return true;\\n }\\n }, {\\n key: \\\"record\\\",\\n value: function record(duration) {\\n if (duration) {\\n this.sampleLimit = Math.round(duration * sampleRate);\\n }\\n\\n this.recording = true;\\n }\\n }, {\\n key: \\\"stop\\\",\\n value: function stop() {\\n this.recording = false;\\n var buffers = this.getBuffers();\\n var leftBuffer = buffers[0].buffer;\\n var rightBuffer = buffers[1].buffer;\\n this.port.postMessage({\\n name: 'buffers',\\n leftBuffer: leftBuffer,\\n rightBuffer: rightBuffer\\n }, [leftBuffer, rightBuffer]);\\n this.clear();\\n }\\n }, {\\n key: \\\"getBuffers\\\",\\n value: function getBuffers() {\\n var buffers = [];\\n buffers.push(this.mergeBuffers(this.leftBuffers));\\n buffers.push(this.mergeBuffers(this.rightBuffers));\\n return buffers;\\n }\\n }, {\\n key: \\\"mergeBuffers\\\",\\n value: function mergeBuffers(channelBuffer) {\\n var result = new Float32Array(this.recordedSamples);\\n var offset = 0;\\n var lng = channelBuffer.length;\\n\\n for (var i = 0; i < lng; i++) {\\n var buffer = channelBuffer[i];\\n result.set(buffer, offset);\\n offset += buffer.length;\\n }\\n\\n return result;\\n }\\n }, {\\n key: \\\"clear\\\",\\n value: function clear() {\\n var _this2 = this;\\n\\n this.leftBuffers = [];\\n this.rightBuffers = [];\\n this.inputRingBuffer = new RingBuffer(this.bufferSize, this.numInputChannels);\\n this.inputRingBufferArraySequence = new Array(this.numInputChannels).fill(null).map(function () {\\n return new Float32Array(_this2.bufferSize);\\n });\\n this.recordedSamples = 0;\\n this.sampleLimit = null;\\n }\\n }]);\\n\\n return RecorderProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.recorderProcessor, RecorderProcessor);\";","export default \"function _typeof(obj) { if (typeof Symbol === \\\"function\\\" && typeof Symbol.iterator === \\\"symbol\\\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \\\"function\\\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \\\"symbol\\\" : typeof obj; }; } return _typeof(obj); }\\n\\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \\\"object\\\" || typeof call === \\\"function\\\")) { return call; } return _assertThisInitialized(self); }\\n\\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\"); } return self; }\\n\\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \\\"function\\\" && superClass !== null) { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\\n\\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \\\"function\\\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \\\"function\\\") { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } if (typeof _cache !== \\\"undefined\\\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\\n\\nfunction isNativeReflectConstruct() { if (typeof Reflect === \\\"undefined\\\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \\\"function\\\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\\n\\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\\n\\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\\\"[native code]\\\") !== -1; }\\n\\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\\n\\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\\n\\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\\"Cannot call a class as a function\\\"); } }\\n\\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\\\"value\\\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\\n\\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\\n\\n// import dependencies via preval.require so that they're available as values at compile time\\nvar processorNames = {\\n \\\"recorderProcessor\\\": \\\"recorder-processor\\\",\\n \\\"soundFileProcessor\\\": \\\"sound-file-processor\\\",\\n \\\"amplitudeProcessor\\\": \\\"amplitude-processor\\\"\\n};\\nvar RingBuffer = {\\n \\\"default\\\":\\n /*#__PURE__*/\\n function () {\\n /**\\n * @constructor\\n * @param {number} length Buffer length in frames.\\n * @param {number} channelCount Buffer channel count.\\n */\\n function RingBuffer(length, channelCount) {\\n _classCallCheck(this, RingBuffer);\\n\\n this._readIndex = 0;\\n this._writeIndex = 0;\\n this._framesAvailable = 0;\\n this._channelCount = channelCount;\\n this._length = length;\\n this._channelData = [];\\n\\n for (var i = 0; i < this._channelCount; ++i) {\\n this._channelData[i] = new Float32Array(length);\\n }\\n }\\n /**\\n * Getter for Available frames in buffer.\\n *\\n * @return {number} Available frames in buffer.\\n */\\n\\n\\n _createClass(RingBuffer, [{\\n key: \\\"push\\\",\\n\\n /**\\n * Push a sequence of Float32Arrays to buffer.\\n *\\n * @param {array} arraySequence A sequence of Float32Arrays.\\n */\\n value: function push(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // Transfer data from the |arraySequence| storage to the internal buffer.\\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\\n\\n for (var i = 0; i < sourceLength; ++i) {\\n var writeIndex = (this._writeIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\\n }\\n }\\n\\n this._writeIndex += sourceLength;\\n\\n if (this._writeIndex >= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar SoundFileProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(SoundFileProcessor, _AudioWorkletProcesso);\\n\\n function SoundFileProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, SoundFileProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SoundFileProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.bufferSize = processorOptions.bufferSize || 256;\\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, 1);\\n _this.inputRingBufferArraySequence = [new Float32Array(_this.bufferSize)];\\n return _this;\\n }\\n\\n _createClass(SoundFileProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs) {\\n var input = inputs[0]; // we only care about the first input channel, because that contains the position data\\n\\n this.inputRingBuffer.push([input[0]]);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n var inputChannel = this.inputRingBufferArraySequence[0];\\n var position = inputChannel[inputChannel.length - 1] || 0;\\n this.port.postMessage({\\n name: 'position',\\n position: position\\n });\\n }\\n\\n return true;\\n }\\n }]);\\n\\n return SoundFileProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.soundFileProcessor, SoundFileProcessor);\";","export default \"function _typeof(obj) { if (typeof Symbol === \\\"function\\\" && typeof Symbol.iterator === \\\"symbol\\\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \\\"function\\\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \\\"symbol\\\" : typeof obj; }; } return _typeof(obj); }\\n\\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \\\"object\\\" || typeof call === \\\"function\\\")) { return call; } return _assertThisInitialized(self); }\\n\\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\"); } return self; }\\n\\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \\\"function\\\" && superClass !== null) { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\\n\\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \\\"function\\\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \\\"function\\\") { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } if (typeof _cache !== \\\"undefined\\\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\\n\\nfunction isNativeReflectConstruct() { if (typeof Reflect === \\\"undefined\\\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \\\"function\\\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\\n\\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\\n\\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\\\"[native code]\\\") !== -1; }\\n\\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\\n\\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\\n\\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\\"Cannot call a class as a function\\\"); } }\\n\\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\\\"value\\\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\\n\\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\\n\\n// import dependencies via preval.require so that they're available as values at compile time\\nvar processorNames = {\\n \\\"recorderProcessor\\\": \\\"recorder-processor\\\",\\n \\\"soundFileProcessor\\\": \\\"sound-file-processor\\\",\\n \\\"amplitudeProcessor\\\": \\\"amplitude-processor\\\"\\n};\\nvar RingBuffer = {\\n \\\"default\\\":\\n /*#__PURE__*/\\n function () {\\n /**\\n * @constructor\\n * @param {number} length Buffer length in frames.\\n * @param {number} channelCount Buffer channel count.\\n */\\n function RingBuffer(length, channelCount) {\\n _classCallCheck(this, RingBuffer);\\n\\n this._readIndex = 0;\\n this._writeIndex = 0;\\n this._framesAvailable = 0;\\n this._channelCount = channelCount;\\n this._length = length;\\n this._channelData = [];\\n\\n for (var i = 0; i < this._channelCount; ++i) {\\n this._channelData[i] = new Float32Array(length);\\n }\\n }\\n /**\\n * Getter for Available frames in buffer.\\n *\\n * @return {number} Available frames in buffer.\\n */\\n\\n\\n _createClass(RingBuffer, [{\\n key: \\\"push\\\",\\n\\n /**\\n * Push a sequence of Float32Arrays to buffer.\\n *\\n * @param {array} arraySequence A sequence of Float32Arrays.\\n */\\n value: function push(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // Transfer data from the |arraySequence| storage to the internal buffer.\\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\\n\\n for (var i = 0; i < sourceLength; ++i) {\\n var writeIndex = (this._writeIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\\n }\\n }\\n\\n this._writeIndex += sourceLength;\\n\\n if (this._writeIndex >= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar AmplitudeProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(AmplitudeProcessor, _AudioWorkletProcesso);\\n\\n function AmplitudeProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, AmplitudeProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(AmplitudeProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.numOutputChannels = options.outputChannelCount || 1;\\n _this.numInputChannels = processorOptions.numInputChannels || 2;\\n _this.normalize = processorOptions.normalize || false;\\n _this.smoothing = processorOptions.smoothing || 0;\\n _this.bufferSize = processorOptions.bufferSize || 2048;\\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, _this.numInputChannels);\\n _this.outputRingBuffer = new RingBuffer(_this.bufferSize, _this.numOutputChannels);\\n _this.inputRingBufferArraySequence = new Array(_this.numInputChannels).fill(null).map(function () {\\n return new Float32Array(_this.bufferSize);\\n });\\n _this.stereoVol = [0, 0];\\n _this.stereoVolNorm = [0, 0];\\n _this.volMax = 0.001;\\n\\n _this.port.onmessage = function (event) {\\n var data = event.data;\\n\\n if (data.name === 'toggleNormalize') {\\n _this.normalize = data.normalize;\\n } else if (data.name === 'smoothing') {\\n _this.smoothing = Math.max(0, Math.min(1, data.smoothing));\\n }\\n };\\n\\n return _this;\\n } // TO DO make this stereo / dependent on # of audio channels\\n\\n\\n _createClass(AmplitudeProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs, outputs) {\\n var input = inputs[0];\\n var output = outputs[0];\\n var smoothing = this.smoothing;\\n this.inputRingBuffer.push(input);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n\\n for (var channel = 0; channel < this.numInputChannels; ++channel) {\\n var inputBuffer = this.inputRingBufferArraySequence[channel];\\n var bufLength = inputBuffer.length;\\n var sum = 0;\\n\\n for (var i = 0; i < bufLength; i++) {\\n var x = inputBuffer[i];\\n\\n if (this.normalize) {\\n sum += Math.max(Math.min(x / this.volMax, 1), -1) * Math.max(Math.min(x / this.volMax, 1), -1);\\n } else {\\n sum += x * x;\\n }\\n } // ... then take the square root of the sum.\\n\\n\\n var rms = Math.sqrt(sum / bufLength);\\n this.stereoVol[channel] = Math.max(rms, this.stereoVol[channel] * smoothing);\\n this.volMax = Math.max(this.stereoVol[channel], this.volMax);\\n } // calculate stero normalized volume and add volume from all channels together\\n\\n\\n var volSum = 0;\\n\\n for (var index = 0; index < this.stereoVol.length; index++) {\\n this.stereoVolNorm[index] = Math.max(Math.min(this.stereoVol[index] / this.volMax, 1), 0);\\n volSum += this.stereoVol[index];\\n } // volume is average of channels\\n\\n\\n var volume = volSum / this.stereoVol.length; // normalized value\\n\\n var volNorm = Math.max(Math.min(volume / this.volMax, 1), 0);\\n this.port.postMessage({\\n name: 'amplitude',\\n volume: volume,\\n volNorm: volNorm,\\n stereoVol: this.stereoVol,\\n stereoVolNorm: this.stereoVolNorm\\n }); // pass input through to output\\n\\n this.outputRingBuffer.push(this.inputRingBufferArraySequence);\\n } // pull 128 frames out of the ring buffer\\n // if the ring buffer does not have enough frames, the output will be silent\\n\\n\\n this.outputRingBuffer.pull(output);\\n return true;\\n }\\n }]);\\n\\n return AmplitudeProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.amplitudeProcessor, AmplitudeProcessor);\";","define([\"Tone/core/Tone\", \"Tone/type/TimeBase\"], function (Tone) {\n\n\t/**\n\t * @class Tone.Frequency is a primitive type for encoding Frequency values. \n\t * Eventually all time values are evaluated to hertz\n\t * using the `eval` method. \n\t * @constructor\n\t * @extends {Tone.TimeBase}\n\t * @param {String|Number} val The time value.\n\t * @param {String=} units The units of the value.\n\t * @example\n\t * Tone.Frequency(\"C3\") // 261\n\t * Tone.Frequency(38, \"midi\") //\n\t * Tone.Frequency(\"C3\").transpose(4);\n\t */\n\tTone.Frequency = function(val, units){\n\t\tif (this instanceof Tone.Frequency){\n\t\t\t\n\t\t\tTone.TimeBase.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.Frequency(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.Frequency, Tone.TimeBase);\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tAUGMENT BASE EXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.Frequency.prototype._primaryExpressions = Object.create(Tone.TimeBase.prototype._primaryExpressions);\n\n\t/*\n\t * midi type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.midi = {\n\t\tregexp : /^(\\d+(?:\\.\\d+)?midi)/,\n\t\tmethod : function(value){\n\t\t\treturn this.midiToFrequency(value);\n\t\t}\t\n\t};\n\n\t/*\n\t * note type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.note = {\n\t\tregexp : /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,\n\t\tmethod : function(pitch, octave){\n\t\t\tvar index = noteToScaleIndex[pitch.toLowerCase()];\n\t\t\tvar noteNumber = index + (parseInt(octave) + 1) * 12;\n\t\t\treturn this.midiToFrequency(noteNumber);\n\t\t}\t\n\t};\n\n\t/*\n\t * BeatsBarsSixteenths type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.tr = {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t\t\tmethod : function(m, q, s){\n\t\t\tvar total = 1;\n\t\t\tif (m && m !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(this._timeSignature() * parseFloat(m));\n\t\t\t}\n\t\t\tif (q && q !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(parseFloat(q));\n\t\t\t}\n\t\t\tif (s && s !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(parseFloat(s) / 4);\n\t\t\t}\n\t\t\treturn total;\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tEXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Transposes the frequency by the given number of semitones.\n\t * @param {Interval} interval\n\t * @return {Tone.Frequency} this\n\t * @example\n\t * Tone.Frequency(\"A4\").transpose(3); //\"C5\"\n\t */\n\tTone.Frequency.prototype.transpose = function(interval){\n\t\tthis._expr = function(expr, interval){\n\t\t\tvar val = expr();\n\t\t\treturn val * this.intervalToFrequencyRatio(interval);\n\t\t}.bind(this, this._expr, interval);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Takes an array of semitone intervals and returns\n\t * an array of frequencies transposed by those intervals.\n\t * @param {Array} intervals\n\t * @return {Tone.Frequency} this\n\t * @example\n\t * Tone.Frequency(\"A4\").harmonize([0, 3, 7]); //[\"A4\", \"C5\", \"E5\"]\n\t */\n\tTone.Frequency.prototype.harmonize = function(intervals){\n\t\tthis._expr = function(expr, intervals){\n\t\t\tvar val = expr();\n\t\t\tvar ret = [];\n\t\t\tfor (var i = 0; i < intervals.length; i++){\n\t\t\t\tret[i] = val * this.intervalToFrequencyRatio(intervals[i]);\n\t\t\t}\n\t\t\treturn ret;\n\t\t}.bind(this, this._expr, intervals);\n\t\treturn this;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Return the value of the frequency as a MIDI note\n\t * @return {MIDI}\n\t * @example\n\t * Tone.Frequency(\"C4\").toMidi(); //60\n\t */\n\tTone.Frequency.prototype.toMidi = function(){\n\t\treturn this.frequencyToMidi(this.valueOf());\n\t};\n\n\t/**\n\t * Return the value of the frequency in Scientific Pitch Notation\n\t * @return {Note}\n\t * @example\n\t * Tone.Frequency(69, \"midi\").toNote(); //\"A4\"\n\t */\n\tTone.Frequency.prototype.toNote = function(){\n\t\tvar freq = this.valueOf();\n\t\tvar log = Math.log(freq / Tone.Frequency.A4) / Math.LN2;\n\t\tvar noteNumber = Math.round(12 * log) + 57;\n\t\tvar octave = Math.floor(noteNumber/12);\n\t\tif(octave < 0){\n\t\t\tnoteNumber += -12 * octave;\n\t\t}\n\t\tvar noteName = scaleIndexToNote[noteNumber % 12];\n\t\treturn noteName + octave.toString();\n\t};\n\n\t/**\n\t * Return the duration of one cycle in seconds.\n\t * @return {Seconds}\n\t */\n\tTone.Frequency.prototype.toSeconds = function(){\n\t\treturn 1 / this.valueOf();\n\t};\n\n\t/**\n\t * Return the value in Hertz\n\t * @return {Frequency}\n\t */\n\tTone.Frequency.prototype.toFrequency = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the duration of one cycle in ticks\n\t * @return {Ticks}\n\t */\n\tTone.Frequency.prototype.toTicks = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.valueOf() / quarterTime;\n\t\treturn Math.floor(quarters * Tone.Transport.PPQ);\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS HELPERS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value of a frequency in the current units\n\t * @param {Frequency} freq\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._frequencyToUnits = function(freq){\n\t\treturn freq;\n\t};\n\n\t/**\n\t * Returns the value of a tick in the current time units\n\t * @param {Ticks} ticks\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._ticksToUnits = function(ticks){\n\t\treturn 1 / ((ticks * 60) / (Tone.Transport.bpm.value * Tone.Transport.PPQ));\n\t};\n\n\t/**\n\t * Return the value of the beats in the current units\n\t * @param {Number} beats\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._beatsToUnits = function(beats){\n\t\treturn 1 / Tone.TimeBase.prototype._beatsToUnits.call(this, beats);\n\t};\n\n\t/**\n\t * Returns the value of a second in the current units\n\t * @param {Seconds} seconds\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._secondsToUnits = function(seconds){\n\t\treturn 1 / seconds;\n\t};\n\n\t/**\n\t * The default units if none are given.\n\t * @private\n\t */\n\tTone.Frequency.prototype._defaultUnits = \"hz\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tFREQUENCY CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Note to scale index\n\t * @type {Object}\n\t */\n\tvar noteToScaleIndex = {\n\t\t\"cbb\" : -2, \"cb\" : -1, \"c\" : 0, \"c#\" : 1, \"cx\" : 2, \n\t\t\"dbb\" : 0, \"db\" : 1, \"d\" : 2, \"d#\" : 3, \"dx\" : 4,\n\t\t\"ebb\" : 2, \"eb\" : 3, \"e\" : 4, \"e#\" : 5, \"ex\" : 6, \n\t\t\"fbb\" : 3, \"fb\" : 4, \"f\" : 5, \"f#\" : 6, \"fx\" : 7,\n\t\t\"gbb\" : 5, \"gb\" : 6, \"g\" : 7, \"g#\" : 8, \"gx\" : 9,\n\t\t\"abb\" : 7, \"ab\" : 8, \"a\" : 9, \"a#\" : 10, \"ax\" : 11,\n\t\t\"bbb\" : 9, \"bb\" : 10, \"b\" : 11, \"b#\" : 12, \"bx\" : 13,\n\t};\n\n\t/**\n\t * scale index to note (sharps)\n\t * @type {Array}\n\t */\n\tvar scaleIndexToNote = [\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"A#\", \"B\"];\n\n\t/**\n\t * The [concert pitch](https://en.wikipedia.org/wiki/Concert_pitch)\n\t * A4's values in Hertz. \n\t * @type {Frequency}\n\t * @static\n\t */\n\tTone.Frequency.A4 = 440;\n\n\t/**\n\t * Convert a MIDI note to frequency value. \n\t * @param {MIDI} midi The midi number to convert.\n\t * @return {Frequency} the corresponding frequency value\n\t * @example\n\t * tone.midiToFrequency(69); // returns 440\n\t */\n\tTone.Frequency.prototype.midiToFrequency = function(midi){\n\t\treturn Tone.Frequency.A4 * Math.pow(2, (midi - 69) / 12);\n\t};\n\n\t/**\n\t * Convert a frequency value to a MIDI note.\n\t * @param {Frequency} frequency The value to frequency value to convert.\n\t * @returns {MIDI}\n\t * @example\n\t * tone.midiToFrequency(440); // returns 69\n\t */\n\tTone.Frequency.prototype.frequencyToMidi = function(frequency){\n\t\treturn 69 + 12 * Math.log(frequency / Tone.Frequency.A4) / Math.LN2;\n\t};\n\n\treturn Tone.Frequency;\n});","define([\"Tone/core/Tone\", \"Tone/type/Time\"], function (Tone) {\n\n\t/**\n\t * @class Tone.TransportTime is a the time along the Transport's\n\t * timeline. It is similar to Tone.Time, but instead of evaluating\n\t * against the AudioContext's clock, it is evaluated against\n\t * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime).\n\t * @constructor\n\t * @param {Time} val The time value as a number or string\n\t * @param {String=} units Unit values\n\t * @extends {Tone.Time}\n\t */\n\tTone.TransportTime = function(val, units){\n\t\tif (this instanceof Tone.TransportTime){\n\t\t\t\n\t\t\tTone.Time.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.TransportTime(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.TransportTime, Tone.Time);\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.TransportTime.prototype._unaryExpressions = Object.create(Tone.Time.prototype._unaryExpressions);\n\n\t/**\n\t * Adds an additional unary expression\n\t * which quantizes values to the next subdivision\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.TransportTime.prototype._unaryExpressions.quantize = {\n\t\tregexp : /^@/,\n\t\tmethod : function(rh){\n\t\t\tvar subdivision = this._secondsToTicks(rh());\n\t\t\tvar multiple = Math.ceil(Tone.Transport.ticks / subdivision);\n\t\t\treturn this._ticksToUnits(multiple * subdivision);\n\t\t}\n\t};\n\n\t/**\n\t * Convert seconds into ticks\n\t * @param {Seconds} seconds\n\t * @return {Ticks}\n\t * @private\n\t */\n\tTone.TransportTime.prototype._secondsToTicks = function(seconds){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = seconds / quarterTime;\n\t\treturn Math.round(quarters * Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Evaluate the time expression. Returns values in ticks\n\t * @return {Ticks}\n\t */\n\tTone.TransportTime.prototype.valueOf = function(){\n\t\tvar val = this._secondsToTicks(this._expr());\n\t\treturn val + (this._plusNow ? Tone.Transport.ticks : 0);\n\t};\n\n\t/**\n\t * Return the time in ticks.\n\t * @return {Ticks}\n\t */\n\tTone.TransportTime.prototype.toTicks = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds}\n\t */\n\tTone.TransportTime.prototype.toSeconds = function(){\n\t\tvar val = this._expr();\n\t\treturn val + (this._plusNow ? Tone.Transport.seconds : 0);\n\t};\n\n\t/**\n\t * Return the time as a frequency value\n\t * @return {Frequency} \n\t */\n\tTone.TransportTime.prototype.toFrequency = function(){\n\t\treturn 1/this.toSeconds();\n\t};\n\n\treturn Tone.TransportTime;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Subtract\", \"Tone/signal/Multiply\", \n\t\"Tone/signal/GreaterThan\", \"Tone/signal/GreaterThanZero\", \"Tone/signal/Abs\", \"Tone/signal/Negate\", \n\t\"Tone/signal/Modulo\", \"Tone/signal/Pow\", \"Tone/signal/AudioToGain\"], \n\tfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Evaluate an expression at audio rate.

\n\t * Parsing code modified from https://code.google.com/p/tapdigit/\n\t * Copyright 2011 2012 Ariya Hidayat, New BSD License\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {string} expr the expression to generate\n\t * @example\n\t * //adds the signals from input[0] and input[1].\n\t * var expr = new Tone.Expr(\"$0 + $1\");\n\t */\n\tTone.Expr = function(){\n\n\t\tvar expr = this._replacements(Array.prototype.slice.call(arguments));\n\t\tvar inputCount = this._parseInputs(expr);\n\n\t\t/**\n\t\t * hold onto all of the nodes for disposal\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._nodes = [];\n\n\t\t/**\n\t\t * The inputs. The length is determined by the expression. \n\t\t * @type {Array}\n\t\t */\n\t\tthis.input = new Array(inputCount);\n\n\t\t//create a gain for each input\n\t\tfor (var i = 0; i < inputCount; i++){\n\t\t\tthis.input[i] = this.context.createGain();\n\t\t}\n\n\t\t//parse the syntax tree\n\t\tvar tree = this._parseTree(expr);\n\t\t//evaluate the results\n\t\tvar result;\n\t\ttry {\n\t\t\tresult = this._eval(tree);\n\t\t} catch (e){\n\t\t\tthis._disposeNodes();\n\t\t\tthrow new Error(\"Tone.Expr: Could evaluate expression: \"+expr);\n\t\t}\n\n\t\t/**\n\t\t * The output node is the result of the expression\n\t\t * @type {Tone}\n\t\t */\n\t\tthis.output = result;\n\t};\n\n\tTone.extend(Tone.Expr, Tone.SignalBase);\n\n\t//some helpers to cut down the amount of code\n\tfunction applyBinary(Constructor, args, self){\n\t\tvar op = new Constructor();\n\t\tself._eval(args[0]).connect(op, 0, 0);\n\t\tself._eval(args[1]).connect(op, 0, 1);\n\t\treturn op;\n\t}\n\tfunction applyUnary(Constructor, args, self){\n\t\tvar op = new Constructor();\n\t\tself._eval(args[0]).connect(op, 0, 0);\n\t\treturn op;\n\t}\n\tfunction getNumber(arg){\n\t\treturn arg ? parseFloat(arg) : undefined;\n\t}\n\tfunction literalNumber(arg){\n\t\treturn arg && arg.args ? parseFloat(arg.args) : undefined;\n\t}\n\n\t/*\n\t * the Expressions that Tone.Expr can parse.\n\t *\n\t * each expression belongs to a group and contains a regexp \n\t * for selecting the operator as well as that operators method\n\t * \n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Expr._Expressions = {\n\t\t//values\n\t\t\"value\" : {\n\t\t\t\"signal\" : {\n\t\t\t\tregexp : /^\\d+\\.\\d+|^\\d+/,\n\t\t\t\tmethod : function(arg){\n\t\t\t\t\tvar sig = new Tone.Signal(getNumber(arg));\n\t\t\t\t\treturn sig;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"input\" : {\n\t\t\t\tregexp : /^\\$\\d/,\n\t\t\t\tmethod : function(arg, self){\n\t\t\t\t\treturn self.input[getNumber(arg.substr(1))];\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t//syntactic glue\n\t\t\"glue\" : {\n\t\t\t\"(\" : {\n\t\t\t\tregexp : /^\\(/,\n\t\t\t},\n\t\t\t\")\" : {\n\t\t\t\tregexp : /^\\)/,\n\t\t\t},\n\t\t\t\",\" : {\n\t\t\t\tregexp : /^,/,\n\t\t\t}\n\t\t},\n\t\t//functions\n\t\t\"func\" : {\n\t\t\t\"abs\" : {\n\t\t\t\tregexp : /^abs/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.Abs)\n\t\t\t},\n\t\t\t\"mod\" : {\n\t\t\t\tregexp : /^mod/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar modulus = literalNumber(args[1]);\n\t\t\t\t\tvar op = new Tone.Modulo(modulus);\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"pow\" : {\n\t\t\t\tregexp : /^pow/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar exp = literalNumber(args[1]);\n\t\t\t\t\tvar op = new Tone.Pow(exp);\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"a2g\" : {\n\t\t\t\tregexp : /^a2g/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar op = new Tone.AudioToGain();\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t//binary expressions\n\t\t\"binary\" : {\n\t\t\t\"+\" : {\n\t\t\t\tregexp : /^\\+/,\n\t\t\t\tprecedence : 1,\n\t\t\t\tmethod : applyBinary.bind(this, Tone.Add)\n\t\t\t},\n\t\t\t\"-\" : {\n\t\t\t\tregexp : /^\\-/,\n\t\t\t\tprecedence : 1,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\t//both unary and binary op\n\t\t\t\t\tif (args.length === 1){\n\t\t\t\t\t\treturn applyUnary(Tone.Negate, args, self);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn applyBinary(Tone.Subtract, args, self);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"*\" : {\n\t\t\t\tregexp : /^\\*/,\n\t\t\t\tprecedence : 0,\n\t\t\t\tmethod : applyBinary.bind(this, Tone.Multiply)\n\t\t\t}\n\t\t},\n\t\t//unary expressions\n\t\t\"unary\" : {\n\t\t\t\"-\" : {\n\t\t\t\tregexp : /^\\-/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.Negate)\n\t\t\t},\n\t\t\t\"!\" : {\n\t\t\t\tregexp : /^\\!/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.NOT)\n\t\t\t},\n\t\t},\n\t};\n\t\t\n\t/**\n\t * @param {string} expr the expression string\n\t * @return {number} the input count\n\t * @private\n\t */\n\tTone.Expr.prototype._parseInputs = function(expr){\n\t\tvar inputArray = expr.match(/\\$\\d/g);\n\t\tvar inputMax = 0;\n\t\tif (inputArray !== null){\n\t\t\tfor (var i = 0; i < inputArray.length; i++){\n\t\t\t\tvar inputNum = parseInt(inputArray[i].substr(1)) + 1;\n\t\t\t\tinputMax = Math.max(inputMax, inputNum);\n\t\t\t}\n\t\t}\n\t\treturn inputMax;\n\t};\n\n\t/**\n\t * @param {Array} args \tan array of arguments\n\t * @return {string} the results of the replacements being replaced\n\t * @private\n\t */\n\tTone.Expr.prototype._replacements = function(args){\n\t\tvar expr = args.shift();\n\t\tfor (var i = 0; i < args.length; i++){\n\t\t\texpr = expr.replace(/\\%/i, args[i]);\n\t\t}\n\t\treturn expr;\n\t};\n\n\t/**\n\t * tokenize the expression based on the Expressions object\n\t * @param {string} expr \n\t * @return {Object} returns two methods on the tokenized list, next and peek\n\t * @private\n\t */\n\tTone.Expr.prototype._tokenize = function(expr){\n\t\tvar position = -1;\n\t\tvar tokens = [];\n\n\t\twhile(expr.length > 0){\n\t\t\texpr = expr.trim();\n\t\t\tvar token = getNextToken(expr);\n\t\t\ttokens.push(token);\n\t\t\texpr = expr.substr(token.value.length);\n\t\t}\n\n\t\tfunction getNextToken(expr){\n\t\t\tfor (var type in Tone.Expr._Expressions){\n\t\t\t\tvar group = Tone.Expr._Expressions[type];\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tvar reg = op.regexp;\n\t\t\t\t\tvar match = expr.match(reg);\n\t\t\t\t\tif (match !== null){\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype : type,\n\t\t\t\t\t\t\tvalue : match[0],\n\t\t\t\t\t\t\tmethod : op.method\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.Expr: Unexpected token \"+expr);\n\t\t}\n\n\t\treturn {\n\t\t\tnext : function(){\n\t\t\t\treturn tokens[++position];\n\t\t\t},\n\t\t\tpeek : function(){\n\t\t\t\treturn tokens[position + 1];\n\t\t\t}\n\t\t};\n\t};\n\n\t/**\n\t * recursively parse the string expression into a syntax tree\n\t * \n\t * @param {string} expr \n\t * @return {Object}\n\t * @private\n\t */\n\tTone.Expr.prototype._parseTree = function(expr){\n\t\tvar lexer = this._tokenize(expr);\n\t\tvar isUndef = this.isUndef.bind(this);\n\n\t\tfunction matchSyntax(token, syn) {\n\t\t\treturn !isUndef(token) && \n\t\t\t\ttoken.type === \"glue\" &&\n\t\t\t\ttoken.value === syn;\n\t\t}\n\n\t\tfunction matchGroup(token, groupName, prec) {\n\t\t\tvar ret = false;\n\t\t\tvar group = Tone.Expr._Expressions[groupName];\n\t\t\tif (!isUndef(token)){\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tif (op.regexp.test(token.value)){\n\t\t\t\t\t\tif (!isUndef(prec)){\n\t\t\t\t\t\t\tif(op.precedence === prec){\t\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tfunction parseExpression(precedence) {\n\t\t\tif (isUndef(precedence)){\n\t\t\t\tprecedence = 5;\n\t\t\t}\n\t\t\tvar expr;\n\t\t\tif (precedence < 0){\n\t\t\t\texpr = parseUnary();\n\t\t\t} else {\n\t\t\t\texpr = parseExpression(precedence-1);\n\t\t\t}\n\t\t\tvar token = lexer.peek();\n\t\t\twhile (matchGroup(token, \"binary\", precedence)) {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\texpr = {\n\t\t\t\t\toperator: token.value,\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : [\n\t\t\t\t\t\texpr,\n\t\t\t\t\t\tparseExpression(precedence-1)\n\t\t\t\t\t]\n\t\t\t\t};\n\t\t\t\ttoken = lexer.peek();\n\t\t\t}\n\t\t\treturn expr;\n\t\t}\n\n\t\tfunction parseUnary() {\n\t\t\tvar token, expr;\n\t\t\ttoken = lexer.peek();\n\t\t\tif (matchGroup(token, \"unary\")) {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\texpr = parseUnary();\n\t\t\t\treturn {\n\t\t\t\t\toperator: token.value,\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : [expr]\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn parsePrimary();\n\t\t}\n\n\t\tfunction parsePrimary() {\n\t\t\tvar token, expr;\n\t\t\ttoken = lexer.peek();\n\t\t\tif (isUndef(token)) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Unexpected termination of expression\");\n\t\t\t}\n\t\t\tif (token.type === \"func\") {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\treturn parseFunctionCall(token);\n\t\t\t}\n\t\t\tif (token.type === \"value\") {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\treturn {\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : token.value\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (matchSyntax(token, \"(\")) {\n\t\t\t\tlexer.next();\n\t\t\t\texpr = parseExpression();\n\t\t\t\ttoken = lexer.next();\n\t\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\t\tthrow new SyntaxError(\"Expected )\");\n\t\t\t\t}\n\t\t\t\treturn expr;\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.Expr: Parse error, cannot process token \" + token.value);\n\t\t}\n\n\t\tfunction parseFunctionCall(func) {\n\t\t\tvar token, args = [];\n\t\t\ttoken = lexer.next();\n\t\t\tif (!matchSyntax(token, \"(\")) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Expected ( in a function call \\\"\" + func.value + \"\\\"\");\n\t\t\t}\n\t\t\ttoken = lexer.peek();\n\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\targs = parseArgumentList();\n\t\t\t}\n\t\t\ttoken = lexer.next();\n\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Expected ) in a function call \\\"\" + func.value + \"\\\"\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tmethod : func.method,\n\t\t\t\targs : args,\n\t\t\t\tname : name\n\t\t\t};\n\t\t}\n\n\t\tfunction parseArgumentList() {\n\t\t\tvar token, expr, args = [];\n\t\t\twhile (true) {\n\t\t\t\texpr = parseExpression();\n\t\t\t\tif (isUndef(expr)) {\n\t\t\t\t\t// TODO maybe throw exception?\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\targs.push(expr);\n\t\t\t\ttoken = lexer.peek();\n\t\t\t\tif (!matchSyntax(token, \",\")) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tlexer.next();\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\n\t\treturn parseExpression();\n\t};\n\n\t/**\n\t * recursively evaluate the expression tree\n\t * @param {Object} tree \n\t * @return {AudioNode} the resulting audio node from the expression\n\t * @private\n\t */\n\tTone.Expr.prototype._eval = function(tree){\n\t\tif (!this.isUndef(tree)){\n\t\t\tvar node = tree.method(tree.args, this);\n\t\t\tthis._nodes.push(node);\n\t\t\treturn node;\n\t\t} \n\t};\n\n\t/**\n\t * dispose all the nodes\n\t * @private\n\t */\n\tTone.Expr.prototype._disposeNodes = function(){\n\t\tfor (var i = 0; i < this._nodes.length; i++){\n\t\t\tvar node = this._nodes[i];\n\t\t\tif (this.isFunction(node.dispose)) {\n\t\t\t\tnode.dispose();\n\t\t\t} else if (this.isFunction(node.disconnect)) {\n\t\t\t\tnode.disconnect();\n\t\t\t}\n\t\t\tnode = null;\n\t\t\tthis._nodes[i] = null;\n\t\t}\n\t\tthis._nodes = null;\n\t};\n\n\t/**\n\t * clean up\n\t */\n\tTone.Expr.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._disposeNodes();\n\t};\n\n\treturn Tone.Expr;\n});","define([\"Tone/core/Tone\", \"Tone/signal/GreaterThanZero\", \"Tone/signal/Subtract\", \"Tone/signal/Signal\"], \n\tfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Output 1 if the signal is greater than the value, otherwise outputs 0.\n\t * can compare two signals or a signal and a number. \n\t * \n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number} [value=0] the value to compare to the incoming signal\n\t * @example\n\t * var gt = new Tone.GreaterThan(2);\n\t * var sig = new Tone.Signal(4).connect(gt);\n\t * //output of gt is equal 1. \n\t */\n\tTone.GreaterThan = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\t\t\n\t\t/**\n\t\t * subtract the amount from the incoming signal\n\t\t * @type {Tone.Subtract}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input[0] = new Tone.Subtract(value);\n\t\tthis.input[1] = this._param.input[1];\n\n\t\t/**\n\t\t * compare that amount to zero\n\t\t * @type {Tone.GreaterThanZero}\n\t\t * @private\n\t\t */\n\t\tthis._gtz = this.output = new Tone.GreaterThanZero();\n\n\t\t//connect\n\t\tthis._param.connect(this._gtz);\n\t};\n\n\tTone.extend(Tone.GreaterThan, Tone.Signal);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.GreaterThan} this\n\t */\n\tTone.GreaterThan.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\tthis._gtz.dispose();\n\t\tthis._gtz = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.GreaterThan;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/SignalBase\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Return the absolute value of an incoming signal. \n\t * \n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var signal = new Tone.Signal(-1);\n\t * var abs = new Tone.Abs();\n\t * signal.connect(abs);\n\t * //the output of abs is 1. \n\t */\n\tTone.Abs = function(){\n\t\t/**\n\t\t * @type {Tone.LessThan}\n\t\t * @private\n\t\t */\n\t\tthis._abs = this.input = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (val === 0){\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn Math.abs(val);\n\t\t\t}\n\t\t}, 127);\n\t};\n\n\tTone.extend(Tone.Abs, Tone.SignalBase);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.Abs} this\n\t */\n\tTone.Abs.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._abs.dispose();\n\t\tthis._abs = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Abs;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/Multiply\", \"Tone/signal/Subtract\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Signal-rate modulo operator. Only works in AudioRange [-1, 1] and for modulus\n\t * values in the NormalRange. \n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @param {NormalRange} modulus The modulus to apply.\n\t * @example\n\t * var mod = new Tone.Modulo(0.2)\n\t * var sig = new Tone.Signal(0.5).connect(mod);\n\t * //mod outputs 0.1\n\t */\n\tTone.Modulo = function(modulus){\n\n\t\tthis.createInsOuts(1, 0);\n\n\t\t/**\n\t\t * A waveshaper gets the integer multiple of \n\t\t * the input signal and the modulus.\n\t\t * @private\n\t\t * @type {Tone.WaveShaper}\n\t\t */\n\t\tthis._shaper = new Tone.WaveShaper(Math.pow(2, 16));\n\n\t\t/**\n\t\t * the integer multiple is multiplied by the modulus\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._multiply = new Tone.Multiply();\n\n\t\t/**\n\t\t * and subtracted from the input signal\n\t\t * @type {Tone.Subtract}\n\t\t * @private\n\t\t */\n\t\tthis._subtract = this.output = new Tone.Subtract();\n\n\t\t/**\n\t\t * the modulus signal\n\t\t * @type {Tone.Signal}\n\t\t * @private\n\t\t */\n\t\tthis._modSignal = new Tone.Signal(modulus);\n\n\t\t//connections\n\t\tthis.input.fan(this._shaper, this._subtract);\n\t\tthis._modSignal.connect(this._multiply, 0, 0);\n\t\tthis._shaper.connect(this._multiply, 0, 1);\n\t\tthis._multiply.connect(this._subtract, 0, 1);\n\t\tthis._setWaveShaper(modulus);\n\t};\n\n\tTone.extend(Tone.Modulo, Tone.SignalBase);\n\n\t/**\n\t * @param {number} mod the modulus to apply\n\t * @private\n\t */\n\tTone.Modulo.prototype._setWaveShaper = function(mod){\n\t\tthis._shaper.setMap(function(val){\n\t\t\tvar multiple = Math.floor((val + 0.0001) / mod);\n\t\t\treturn multiple;\n\t\t});\n\t};\n\n\t/**\n\t * The modulus value.\n\t * @memberOf Tone.Modulo#\n\t * @type {NormalRange}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Modulo.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._modSignal.value;\n\t\t},\n\t\tset : function(mod){\n\t\t\tthis._modSignal.value = mod;\n\t\t\tthis._setWaveShaper(mod);\n\t\t}\n\t});\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Modulo} this\n\t */\n\tTone.Modulo.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._shaper.dispose();\n\t\tthis._shaper = null;\n\t\tthis._multiply.dispose();\n\t\tthis._multiply = null;\n\t\tthis._subtract.dispose();\n\t\tthis._subtract = null;\n\t\tthis._modSignal.dispose();\n\t\tthis._modSignal = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Modulo;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Pow applies an exponent to the incoming signal. The incoming signal\n\t * must be AudioRange.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {Positive} exp The exponent to apply to the incoming signal, must be at least 2. \n\t * @example\n\t * var pow = new Tone.Pow(2);\n\t * var sig = new Tone.Signal(0.5).connect(pow);\n\t * //output of pow is 0.25. \n\t */\n\tTone.Pow = function(exp){\n\n\t\t/**\n\t\t * the exponent\n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._exp = this.defaultArg(exp, 1);\n\n\t\t/**\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._expScaler = this.input = this.output = new Tone.WaveShaper(this._expFunc(this._exp), 8192);\n\t};\n\n\tTone.extend(Tone.Pow, Tone.SignalBase);\n\n\t/**\n\t * The value of the exponent.\n\t * @memberOf Tone.Pow#\n\t * @type {number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Pow.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._exp;\n\t\t},\n\t\tset : function(exp){\n\t\t\tthis._exp = exp;\n\t\t\tthis._expScaler.setMap(this._expFunc(this._exp));\n\t\t}\n\t});\n\n\n\t/**\n\t * the function which maps the waveshaper\n\t * @param {number} exp\n\t * @return {function}\n\t * @private\n\t */\n\tTone.Pow.prototype._expFunc = function(exp){\n\t\treturn function(val){\n\t\t\treturn Math.pow(Math.abs(val), exp);\n\t\t};\n\t};\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Pow} this\n\t */\n\tTone.Pow.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._expScaler.dispose();\n\t\tthis._expScaler = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Pow;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1]. \n\t * See Tone.GainToAudio.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @example\n\t * var a2g = new Tone.AudioToGain();\n\t */\n\tTone.AudioToGain = function(){\n\n\t\t/**\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._norm = this.input = this.output = new Tone.WaveShaper(function(x){\n\t\t\treturn (x + 1) / 2;\n\t\t});\n\t};\n\n\tTone.extend(Tone.AudioToGain, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.AudioToGain} this\n\t */\n\tTone.AudioToGain.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._norm.dispose();\n\t\tthis._norm = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.AudioToGain;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Convert an incoming signal between 0, 1 to an equal power gain scale.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @example\n\t * var eqPowGain = new Tone.EqualPowerGain();\n\t */\n\tTone.EqualPowerGain = function(){\n\n\t\t/**\n\t\t * @type {Tone.WaveShaper}\n\t\t * @private\n\t\t */\n\t\tthis._eqPower = this.input = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (Math.abs(val) < 0.001){\n\t\t\t\t//should output 0 when input is 0\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn this.equalPowerScale(val);\n\t\t\t}\n\t\t}.bind(this), 4096);\n\t};\n\n\tTone.extend(Tone.EqualPowerGain, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.EqualPowerGain} this\n\t */\n\tTone.EqualPowerGain.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._eqPower.dispose();\n\t\tthis._eqPower = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.EqualPowerGain;\n});","define([\"Tone/core/Tone\", \"Tone/core/Timeline\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A Timeline State. Provides the methods: setStateAtTime(\"state\", time)\n\t * and getValueAtTime(time).\n\t *\n\t * @extends {Tone.Timeline}\n\t * @param {String} initial The initial state of the TimelineState. \n\t * Defaults to undefined\n\t */\n\tTone.TimelineState = function(initial){\n\n\t\tTone.Timeline.call(this);\n\n\t\t/**\n\t\t * The initial state\n\t\t * @private\n\t\t * @type {String}\n\t\t */\n\t\tthis._initial = initial;\n\t};\n\n\tTone.extend(Tone.TimelineState, Tone.Timeline);\n\n\t/**\n\t * Returns the scheduled state scheduled before or at\n\t * the given time.\n\t * @param {Number} time The time to query.\n\t * @return {String} The name of the state input in setStateAtTime.\n\t */\n\tTone.TimelineState.prototype.getValueAtTime = function(time){\n\t\tvar event = this.get(time);\n\t\tif (event !== null){\n\t\t\treturn event.state;\n\t\t} else {\n\t\t\treturn this._initial;\n\t\t}\n\t};\n\n\t/**\n\t * Returns the scheduled state scheduled before or at\n\t * the given time.\n\t * @param {String} state The name of the state to set.\n\t * @param {Number} time The time to query.\n\t */\n\tTone.TimelineState.prototype.setStateAtTime = function(state, time){\n\t\tthis.add({\n\t\t\t\"state\" : state,\n\t\t\t\"time\" : time\n\t\t});\n\t};\n\n\treturn Tone.TimelineState;\n});","import audiocontext from './audiocontext.js';\n\n// P5Sound contains the final sound output bus.\nclass Main {\n constructor() {\n this.input = audiocontext.createGain();\n this.output = audiocontext.createGain();\n\n //put a hard limiter on the output\n this.limiter = audiocontext.createDynamicsCompressor();\n this.limiter.threshold.value = -3;\n this.limiter.ratio.value = 20;\n this.limiter.knee.value = 1;\n\n this.audiocontext = audiocontext;\n\n this.output.disconnect();\n\n // connect input to limiter\n this.input.connect(this.limiter);\n\n // connect limiter to output\n this.limiter.connect(this.output);\n\n // meter is just for global Amplitude / FFT analysis\n this.meter = audiocontext.createGain();\n this.fftMeter = audiocontext.createGain();\n this.output.connect(this.meter);\n this.output.connect(this.fftMeter);\n\n // connect output to destination\n this.output.connect(this.audiocontext.destination);\n\n // an array of all sounds in the sketch\n this.soundArray = [];\n // an array of all musical parts in the sketch\n this.parts = [];\n\n // file extensions to search for\n this.extensions = [];\n }\n}\n\n// create a single instance of the p5Sound main output for use within this sketch\nconst p5sound = new Main();\n\n/**\n * Returns a number representing the output volume for sound\n * in this sketch.\n *\n * @method getOutputVolume\n * @return {Number} Output volume for sound in this sketch.\n * Should be between 0.0 (silence) and 1.0.\n */\np5.prototype.getOutputVolume = function () {\n return p5sound.output.gain.value;\n};\n\n/**\n *

Scale the output of all sound in this sketch

\n * Scaled between 0.0 (silence) and 1.0 (full volume).\n * 1.0 is the maximum amplitude of a digital sound, so multiplying\n * by greater than 1.0 may cause digital distortion. To\n * fade, provide a rampTime parameter. For more\n * complex fades, see the Envelope class.\n *\n * Alternately, you can pass in a signal source such as an\n * oscillator to modulate the amplitude with an audio signal.\n *\n *

How This Works: When you load the p5.sound module, it\n * creates a single instance of p5sound. All sound objects in this\n * module output to p5sound before reaching your computer's output.\n * So if you change the amplitude of p5sound, it impacts all of the\n * sound in this module.

\n *\n *

If no value is provided, returns a Web Audio API Gain Node

\n *\n * @method outputVolume\n * @param {Number|Object} volume Volume (amplitude) between 0.0\n * and 1.0 or modulating signal/oscillator\n * @param {Number} [rampTime] Fade for t seconds\n * @param {Number} [timeFromNow] Schedule this event to happen at\n * t seconds in the future\n */\np5.prototype.outputVolume = function (vol, rampTime = 0, tFromNow = 0) {\n if (typeof vol === 'number') {\n var now = p5sound.audiocontext.currentTime;\n var currentVol = p5sound.output.gain.value;\n p5sound.output.gain.cancelScheduledValues(now + tFromNow);\n p5sound.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n p5sound.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(p5sound.output.gain);\n } else {\n // return the Gain Node\n return p5sound.output.gain;\n }\n};\n\n/**\n * `p5.soundOut` is the p5.sound final output bus. It sends output to\n * the destination of this window's web audio context. It contains\n * Web Audio API nodes including a dyanmicsCompressor (.limiter),\n * and Gain Nodes for .input and .output.\n *\n * @property {Object} soundOut\n */\np5.prototype.soundOut = p5.soundOut = p5sound;\n\n// a silent connection to the DesinationNode\n// which will ensure that anything connected to it\n// will not be garbage collected\np5.soundOut._silentNode = p5sound.audiocontext.createGain();\np5.soundOut._silentNode.gain.value = 0;\np5.soundOut._silentNode.connect(p5sound.audiocontext.destination);\n\nexport default p5sound;\n","import p5sound from './main';\nimport processorNames from './audioWorklet/processorNames';\n/**\n * @for p5\n */\n\n/**\n * Returns a number representing the sample rate, in samples per second,\n * of all sound objects in this audio context. It is determined by the\n * sampling rate of your operating system's sound card, and it is not\n * currently possile to change.\n * It is often 44100, or twice the range of human hearing.\n *\n * @method sampleRate\n * @return {Number} samplerate samples per second\n */\nfunction sampleRate() {\n return p5sound.audiocontext.sampleRate;\n}\n\n/**\n * Returns the closest MIDI note value for\n * a given frequency.\n *\n * @method freqToMidi\n * @param {Number} frequency A freqeuncy, for example, the \"A\"\n * above Middle C is 440Hz\n * @return {Number} MIDI note value\n */\nfunction freqToMidi(f) {\n var mathlog2 = Math.log(f / 440) / Math.log(2);\n var m = Math.round(12 * mathlog2) + 69;\n return m;\n}\n\n/**\n * Returns the frequency value of a MIDI note value.\n * General MIDI treats notes as integers where middle C\n * is 60, C# is 61, D is 62 etc. Useful for generating\n * musical frequencies with oscillators.\n *\n * @method midiToFreq\n * @param {Number} midiNote The number of a MIDI note\n * @return {Number} Frequency value of the given MIDI note\n * @example\n *
\n * let midiNotes = [60, 64, 67, 72];\n * let noteIndex = 0;\n * let midiVal, freq;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startSound);\n * osc = new p5.TriOsc();\n * env = new p5.Envelope();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 10, 20);\n * if (midiVal) {\n * text('MIDI: ' + midiVal, 10, 40);\n * text('Freq: ' + freq, 10, 60);\n * }\n * }\n *\n * function startSound() {\n * // see also: userStartAudio();\n * osc.start();\n *\n * midiVal = midiNotes[noteIndex % midiNotes.length];\n * freq = midiToFreq(midiVal);\n * osc.freq(freq);\n * env.ramp(osc, 0, 1.0, 0);\n *\n * noteIndex++;\n * }\n *
\n */\nfunction midiToFreq(m) {\n return 440 * Math.pow(2, (m - 69) / 12.0);\n}\n\n// This method converts ANSI notes specified as a string \"C4\", \"Eb3\" to a frequency\nfunction noteToFreq(note) {\n if (typeof note !== 'string') {\n return note;\n }\n var wholeNotes = { A: 21, B: 23, C: 24, D: 26, E: 28, F: 29, G: 31 };\n var value = wholeNotes[note[0].toUpperCase()];\n var octave = ~~note.slice(-1);\n value += 12 * (octave - 1);\n\n switch (note[1]) {\n case '#':\n value += 1;\n break;\n case 'b':\n value -= 1;\n break;\n default:\n break;\n }\n return midiToFreq(value);\n}\n\n/**\n * List the SoundFile formats that you will include. LoadSound\n * will search your directory for these extensions, and will pick\n * a format that is compatable with the client's web browser.\n * Here is a free online file\n * converter.\n *\n * @method soundFormats\n * @param {String} [...formats] i.e. 'mp3', 'wav', 'ogg'\n * @example\n *
\n * function preload() {\n * // set the global sound formats\n * soundFormats('mp3', 'ogg');\n *\n * // load either beatbox.mp3, or .ogg, depending on browser\n * mySound = loadSound('assets/beatbox.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * text('sound loaded! tap to play', 10, 20, width - 20);\n * cnv.mousePressed(function() {\n * mySound.play();\n * });\n * }\n *
\n */\n\nfunction soundFormats() {\n // reset extensions array\n p5sound.extensions = [];\n // add extensions\n for (var i = 0; i < arguments.length; i++) {\n arguments[i] = arguments[i].toLowerCase();\n if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(arguments[i]) > -1) {\n p5sound.extensions.push(arguments[i]);\n } else {\n throw arguments[i] + ' is not a valid sound format!';\n }\n }\n}\n\nfunction disposeSound() {\n for (var i = 0; i < p5sound.soundArray.length; i++) {\n p5sound.soundArray[i].dispose();\n }\n}\n\nfunction _checkFileFormats(paths) {\n var path;\n // if path is a single string, check to see if extension is provided\n if (typeof paths === 'string') {\n path = paths;\n // see if extension is provided\n var extTest = path.split('.').pop();\n // if an extension is provided...\n if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(extTest) > -1) {\n if (!p5.prototype.isFileSupported(extTest)) {\n var pathSplit = path.split('.');\n var pathCore = pathSplit[pathSplit.length - 1];\n for (let i = 0; i < p5sound.extensions.length; i++) {\n const extension = p5sound.extensions[i];\n const supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n pathCore = '';\n if (pathSplit.length === 2) {\n pathCore += pathSplit[0];\n }\n for (let i = 1; i <= pathSplit.length - 2; i++) {\n var p = pathSplit[i];\n pathCore += '.' + p;\n }\n path = pathCore += '.';\n path = path += extension;\n break;\n }\n }\n }\n }\n // if no extension is provided...\n else {\n for (let i = 0; i < p5sound.extensions.length; i++) {\n const extension = p5sound.extensions[i];\n const supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n path = path + '.' + extension;\n break;\n }\n }\n }\n } // end 'if string'\n\n // path can either be a single string, or an array\n else if (typeof paths === 'object') {\n for (var i = 0; i < paths.length; i++) {\n var extension = paths[i].split('.').pop();\n var supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n // console.log('.'+extension + ' is ' + supported +\n // ' supported by your browser.');\n path = paths[i];\n break;\n }\n }\n }\n return path;\n}\n\n/**\n * Used by Osc and Envelope to chain signal math\n */\nfunction _mathChain(o, math, thisChain, nextChain, type) {\n // if this type of math already exists in the chain, replace it\n for (var i in o.mathOps) {\n if (o.mathOps[i] instanceof type) {\n o.mathOps[i].dispose();\n thisChain = i;\n if (thisChain < o.mathOps.length - 1) {\n nextChain = o.mathOps[i + 1];\n }\n }\n }\n o.mathOps[thisChain - 1].disconnect();\n o.mathOps[thisChain - 1].connect(math);\n math.connect(nextChain);\n o.mathOps[thisChain] = math;\n return o;\n}\n\n// helper methods to convert audio file as .wav format,\n// will use as saving .wav file and saving blob object\n// Thank you to Matt Diamond's RecorderJS (MIT License)\n// https://github.com/mattdiamond/Recorderjs\nfunction convertToWav(audioBuffer) {\n var leftChannel, rightChannel;\n leftChannel = audioBuffer.getChannelData(0);\n\n // handle mono files\n if (audioBuffer.numberOfChannels > 1) {\n rightChannel = audioBuffer.getChannelData(1);\n } else {\n rightChannel = leftChannel;\n }\n\n var interleaved = interleave(leftChannel, rightChannel);\n\n // create the buffer and view to create the .WAV file\n var buffer = new window.ArrayBuffer(44 + interleaved.length * 2);\n var view = new window.DataView(buffer);\n\n // write the WAV container,\n // check spec at: https://web.archive.org/web/20171215131933/http://tiny.systems/software/soundProgrammer/WavFormatDocs.pdf\n\n // RIFF chunk descriptor\n writeUTFBytes(view, 0, 'RIFF');\n view.setUint32(4, 36 + interleaved.length * 2, true);\n writeUTFBytes(view, 8, 'WAVE');\n // FMT sub-chunk\n writeUTFBytes(view, 12, 'fmt ');\n view.setUint32(16, 16, true);\n view.setUint16(20, 1, true);\n // stereo (2 channels)\n view.setUint16(22, 2, true);\n view.setUint32(24, p5sound.audiocontext.sampleRate, true);\n view.setUint32(28, p5sound.audiocontext.sampleRate * 4, true);\n view.setUint16(32, 4, true);\n view.setUint16(34, 16, true);\n // data sub-chunk\n writeUTFBytes(view, 36, 'data');\n view.setUint32(40, interleaved.length * 2, true);\n\n // write the PCM samples\n var lng = interleaved.length;\n var index = 44;\n var volume = 1;\n for (var i = 0; i < lng; i++) {\n view.setInt16(index, interleaved[i] * (0x7fff * volume), true);\n index += 2;\n }\n\n return view;\n}\n\n// helper methods to save waves\nfunction interleave(leftChannel, rightChannel) {\n var length = leftChannel.length + rightChannel.length;\n var result = new Float32Array(length);\n\n var inputIndex = 0;\n\n for (var index = 0; index < length; ) {\n result[index++] = leftChannel[inputIndex];\n result[index++] = rightChannel[inputIndex];\n inputIndex++;\n }\n return result;\n}\n\nfunction writeUTFBytes(view, offset, string) {\n var lng = string.length;\n for (var i = 0; i < lng; i++) {\n view.setUint8(offset + i, string.charCodeAt(i));\n }\n}\n\nfunction safeBufferSize(idealBufferSize) {\n let bufferSize = idealBufferSize;\n\n // if the AudioWorkletNode is actually a ScriptProcessorNode created via polyfill,\n // make sure that our chosen buffer size isn't smaller than the buffer size automatically\n // selected by the polyfill\n // reference: https://github.com/GoogleChromeLabs/audioworklet-polyfill/issues/13#issuecomment-425014930\n let tempAudioWorkletNode = new AudioWorkletNode(\n p5sound.audiocontext,\n processorNames.soundFileProcessor\n );\n if (tempAudioWorkletNode instanceof ScriptProcessorNode) {\n bufferSize = tempAudioWorkletNode.bufferSize;\n }\n tempAudioWorkletNode.disconnect();\n tempAudioWorkletNode = null;\n\n return bufferSize;\n}\n\n/**\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\n * to download the file to their device.\n * For uploading audio to a server, use\n * `p5.SoundFile.saveBlob`.\n *\n * @for p5\n * @method saveSound\n * @param {p5.SoundFile} soundFile p5.SoundFile that you wish to save\n * @param {String} fileName name of the resulting .wav file.\n */\n// add to p5.prototype as this is used by the p5 `save()` method.\nfunction saveSound(soundFile, fileName) {\n const dataView = convertToWav(soundFile.buffer);\n p5.prototype.writeFile([dataView], fileName, 'wav');\n}\n\nexport {\n sampleRate,\n freqToMidi,\n midiToFreq,\n noteToFreq,\n soundFormats,\n disposeSound,\n _checkFileFormats,\n _mathChain,\n convertToWav,\n interleave,\n writeUTFBytes,\n safeBufferSize,\n saveSound,\n};\n","/*\n Helper function to generate an error\n with a custom stack trace that points to the sketch\n and removes other parts of the stack trace.\n\n @private\n @class customError\n @constructor\n @param {String} name custom error name\n @param {String} errorTrace custom error trace\n @param {String} failedPath path to the file that failed to load\n @property {String} name custom error name\n @property {String} message custom error message\n @property {String} stack trace the error back to a line in the user's sketch.\n Note: this edits out stack trace within p5.js and p5.sound.\n @property {String} originalStack unedited, original stack trace\n @property {String} failedPath path to the file that failed to load\n @return {Error} returns a custom Error object\n */\nvar CustomError = function (name, errorTrace, failedPath) {\n var err = new Error();\n var tempStack, splitStack;\n\n err.name = name;\n err.originalStack = err.stack + errorTrace;\n tempStack = err.stack + errorTrace;\n err.failedPath = failedPath;\n\n // only print the part of the stack trace that refers to the user code:\n splitStack = tempStack.split('\\n').filter(function (ln) {\n return !ln.match(/(p5.|native code|globalInit)/g);\n });\n err.stack = splitStack.join('\\n');\n\n return err; // TODO: is this really a constructor?\n};\nexport default CustomError;\n","import p5sound from '../main.js';\nconst moduleSources = [\n require('raw-loader!./recorderProcessor').default,\n require('raw-loader!./soundFileProcessor').default,\n require('raw-loader!./amplitudeProcessor').default,\n];\nconst ac = p5sound.audiocontext;\nlet initializedAudioWorklets = false;\n\nfunction loadAudioWorkletModules() {\n return Promise.all(\n moduleSources.map(function (moduleSrc) {\n const blob = new Blob([moduleSrc], { type: 'application/javascript' });\n const objectURL = URL.createObjectURL(blob);\n return ac.audioWorklet.addModule(objectURL);\n })\n );\n}\n\np5.prototype.registerMethod('init', function () {\n if (initializedAudioWorklets) return;\n // ensure that a preload function exists so that p5 will wait for preloads to finish\n if (!this.preload && !window.preload) {\n this.preload = function () {};\n }\n\n // use p5's preload system to load necessary AudioWorklet modules before setup()\n this._incrementPreload();\n const onWorkletModulesLoad = function () {\n initializedAudioWorklets = true;\n this._decrementPreload();\n }.bind(this);\n loadAudioWorkletModules().then(onWorkletModulesLoad);\n});\n","import p5sound from './main';\nvar ac = p5sound.audiocontext;\nvar panner;\n// Stereo panner\n// if there is a stereo panner node use it\nif (typeof ac.createStereoPanner !== 'undefined') {\n class Panner {\n constructor(input, output) {\n this.stereoPanner = this.input = ac.createStereoPanner();\n input.connect(this.stereoPanner);\n this.stereoPanner.connect(output);\n }\n\n pan(val, tFromNow) {\n var time = tFromNow || 0;\n var t = ac.currentTime + time;\n\n this.stereoPanner.pan.linearRampToValueAtTime(val, t);\n }\n\n //not implemented because stereopanner\n //node does not require this and will automatically\n //convert single channel or multichannel to stereo.\n //tested with single and stereo, not with (>2) multichannel\n inputChannels() {}\n\n connect(obj) {\n this.stereoPanner.connect(obj);\n }\n\n disconnect() {\n if (this.stereoPanner) {\n this.stereoPanner.disconnect();\n }\n }\n }\n\n panner = Panner;\n} else {\n // if there is no createStereoPanner object\n // such as in safari 7.1.7 at the time of writing this\n // use this method to create the effect\n class Panner {\n constructor(input, output, numInputChannels) {\n this.input = ac.createGain();\n input.connect(this.input);\n\n this.left = ac.createGain();\n this.right = ac.createGain();\n this.left.channelInterpretation = 'discrete';\n this.right.channelInterpretation = 'discrete';\n\n // if input is stereo\n if (numInputChannels > 1) {\n this.splitter = ac.createChannelSplitter(2);\n this.input.connect(this.splitter);\n\n this.splitter.connect(this.left, 1);\n this.splitter.connect(this.right, 0);\n } else {\n this.input.connect(this.left);\n this.input.connect(this.right);\n }\n\n this.output = ac.createChannelMerger(2);\n this.left.connect(this.output, 0, 1);\n this.right.connect(this.output, 0, 0);\n this.output.connect(output);\n }\n\n // -1 is left, +1 is right\n pan(val, tFromNow) {\n var time = tFromNow || 0;\n var t = ac.currentTime + time;\n var v = (val + 1) / 2;\n var rightVal = Math.cos((v * Math.PI) / 2);\n var leftVal = Math.sin((v * Math.PI) / 2);\n this.left.gain.linearRampToValueAtTime(leftVal, t);\n this.right.gain.linearRampToValueAtTime(rightVal, t);\n }\n\n inputChannels(numChannels) {\n if (numChannels === 1) {\n this.input.disconnect();\n this.input.connect(this.left);\n this.input.connect(this.right);\n } else if (numChannels === 2) {\n if (typeof this.splitter === 'undefined') {\n this.splitter = ac.createChannelSplitter(2);\n }\n this.input.disconnect();\n this.input.connect(this.splitter);\n this.splitter.connect(this.left, 1);\n this.splitter.connect(this.right, 0);\n }\n }\n\n connect(obj) {\n this.output.connect(obj);\n }\n\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n }\n panner = Panner;\n}\n\nexport default panner;\n","import CustomError from './errorHandler';\nimport p5sound from './main';\nimport { midiToFreq, convertToWav, safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\nimport Panner from './panner';\n\nconst ac = p5sound.audiocontext;\n\nvar _createCounterBuffer = function (buffer) {\n const len = buffer.length;\n const audioBuf = ac.createBuffer(1, buffer.length, ac.sampleRate);\n const arrayBuffer = audioBuf.getChannelData(0);\n for (var index = 0; index < len; index++) {\n arrayBuffer[index] = index;\n }\n return audioBuf;\n};\n\n/*** SCHEDULE EVENTS ***/\n\n// Cue inspired by JavaScript setTimeout, and the\n// Tone.js Transport Timeline Event, MIT License Yotam Mann 2015 tonejs.org\nclass Cue {\n constructor(callback, time, id, val) {\n this.callback = callback;\n this.time = time;\n this.id = id;\n this.val = val;\n }\n}\n\n// event handler to remove references to the bufferSourceNode when it is done playing\nfunction _clearOnEnd(e) {\n const thisBufferSourceNode = e.target;\n const soundFile = this;\n\n // delete this.bufferSourceNode from the sources array when it is done playing:\n thisBufferSourceNode._playing = false;\n thisBufferSourceNode.removeEventListener('ended', soundFile._clearOnEnd);\n\n // call the onended callback\n soundFile._onended(soundFile);\n\n // delete bufferSourceNode(s) in soundFile.bufferSourceNodes\n // iterate in reverse order because the index changes by splice\n soundFile.bufferSourceNodes\n .map((_, i) => i)\n .reverse()\n .forEach(function (i) {\n const n = soundFile.bufferSourceNodes[i];\n\n if (n._playing === false) {\n soundFile.bufferSourceNodes.splice(i, 1);\n }\n });\n\n if (soundFile.bufferSourceNodes.length === 0) {\n soundFile._playing = false;\n }\n}\n\n/**\n *

SoundFile object with a path to a file.

\n *\n *

The p5.SoundFile may not be available immediately because\n * it loads the file information asynchronously.

\n *\n *

To do something with the sound as soon as it loads\n * pass the name of a function as the second parameter.

\n *\n *

Only one file path is required. However, audio file formats\n * (i.e. mp3, ogg, wav and m4a/aac) are not supported by all\n * web browsers. If you want to ensure compatability, instead of a single\n * file path, you may include an Array of filepaths, and the browser will\n * choose a format that works.

\n *\n * @class p5.SoundFile\n * @constructor\n * @param {String|Array} path path to a sound file (String). Optionally,\n * you may include multiple file formats in\n * an array. Alternately, accepts an object\n * from the HTML5 File API, or a p5.File.\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if file fails to\n * load. This function will receive an error or\n * XMLHttpRequest object with information\n * about what went wrong.\n * @param {Function} [whileLoadingCallback] Name of a function to call while file\n * is loading. That function will\n * receive progress of the request to\n * load the sound file\n * (between 0 and 1) as its first\n * parameter. This progress\n * does not account for the additional\n * time needed to decode the audio data.\n *\n * @example\n *
\n * let mySound;\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * mySound = loadSound('assets/doorbell');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap here to play', 10, 20);\n * }\n *\n * function canvasPressed() {\n * // playing a sound file on a user gesture\n * // is equivalent to `userStartAudio()`\n * mySound.play();\n * }\n *
\n */\nclass SoundFile {\n constructor(paths, onload, onerror, whileLoading) {\n if (typeof paths !== 'undefined') {\n if (typeof paths === 'string' || typeof paths[0] === 'string') {\n var path = p5.prototype._checkFileFormats(paths);\n this.url = path;\n } else if (typeof paths === 'object') {\n if (\n !(window.File && window.FileReader && window.FileList && window.Blob)\n ) {\n // The File API isn't supported in this browser\n throw 'Unable to load file because the File API is not supported';\n }\n }\n\n // if type is a p5.File...get the actual file\n if (paths.file) {\n paths = paths.file;\n }\n\n this.file = paths;\n }\n\n // private _onended callback, set by the method: onended(callback)\n this._onended = function () {};\n\n this._looping = false;\n this._playing = false;\n this._paused = false;\n this._pauseTime = 0;\n\n // cues for scheduling events with addCue() removeCue()\n this._cues = [];\n this._cueIDCounter = 0;\n\n // position of the most recently played sample\n this._lastPos = 0;\n this._counterNode = null;\n this._workletNode = null;\n\n // array of sources so that they can all be stopped!\n this.bufferSourceNodes = [];\n\n // current source\n this.bufferSourceNode = null;\n\n this.buffer = null;\n this.playbackRate = 1;\n\n this.input = p5sound.audiocontext.createGain();\n this.output = p5sound.audiocontext.createGain();\n\n this.reversed = false;\n\n // start and end of playback / loop\n this.startTime = 0;\n this.endTime = null;\n this.pauseTime = 0;\n\n // \"restart\" would stop playback before retriggering\n this.mode = 'sustain';\n\n // time that playback was started, in millis\n this.startMillis = null;\n\n // stereo panning\n this.panPosition = 0.0;\n this.panner = new Panner(this.output, p5sound.input, 2);\n\n // it is possible to instantiate a soundfile with no path\n if (this.url || this.file) {\n this.load(onload, onerror);\n }\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n\n if (typeof whileLoading === 'function') {\n this._whileLoading = whileLoading;\n } else {\n this._whileLoading = function () {};\n }\n\n this._clearOnEnd = _clearOnEnd.bind(this);\n\n // same as setVolume, to match Processing Sound\n this.amp = this.setVolume;\n\n // these are the same thing\n this.fade = this.setVolume;\n }\n\n /**\n * This is a helper function that the p5.SoundFile calls to load\n * itself. Accepts a callback (the name of another function)\n * as an optional parameter.\n *\n * @private\n * @for p5.SoundFile\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if there is an error\n */\n load(callback, errorCallback) {\n var self = this;\n var errorTrace = new Error().stack;\n\n if (this.url !== undefined && this.url !== '') {\n var request = new XMLHttpRequest();\n request.addEventListener(\n 'progress',\n function (evt) {\n self._updateProgress(evt);\n },\n false\n );\n request.open('GET', this.url, true);\n request.responseType = 'arraybuffer';\n\n request.onload = function () {\n if (request.status === 200) {\n // on sucess loading file:\n if (!self.panner) return;\n ac.decodeAudioData(\n request.response,\n // success decoding buffer:\n function (buff) {\n if (!self.panner) return;\n self.buffer = buff;\n self.panner.inputChannels(buff.numberOfChannels);\n if (callback) {\n callback(self);\n }\n },\n // error decoding buffer. \"e\" is undefined in Chrome 11/22/2015\n function () {\n if (!self.panner) return;\n var err = new CustomError(\n 'decodeAudioData',\n errorTrace,\n self.url\n );\n var msg = 'AudioContext error at decodeAudioData for ' + self.url;\n if (errorCallback) {\n err.msg = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n );\n }\n // if request status != 200, it failed\n else {\n if (!self.panner) return;\n var err = new CustomError('loadSound', errorTrace, self.url);\n var msg =\n 'Unable to load ' +\n self.url +\n '. The request status was: ' +\n request.status +\n ' (' +\n request.statusText +\n ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n };\n\n // if there is another error, aside from 404...\n request.onerror = function () {\n var err = new CustomError('loadSound', errorTrace, self.url);\n var msg =\n 'There was no response from the server at ' +\n self.url +\n '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n };\n\n request.send();\n } else if (this.file !== undefined) {\n var reader = new FileReader();\n reader.onload = function () {\n if (!self.panner) return;\n ac.decodeAudioData(reader.result, function (buff) {\n if (!self.panner) return;\n self.buffer = buff;\n self.panner.inputChannels(buff.numberOfChannels);\n if (callback) {\n callback(self);\n }\n });\n };\n reader.onerror = function (e) {\n if (!self.panner) return;\n if (onerror) {\n onerror(e);\n }\n };\n reader.readAsArrayBuffer(this.file);\n }\n }\n\n // TO DO: use this method to create a loading bar that shows progress during file upload/decode.\n _updateProgress(evt) {\n if (evt.lengthComputable) {\n var percentComplete = (evt.loaded / evt.total) * 0.99;\n this._whileLoading(percentComplete, evt);\n // ...\n } else {\n // Unable to compute progress information since the total size is unknown\n this._whileLoading('size unknown');\n }\n }\n\n /**\n * Returns true if the sound file finished loading successfully.\n *\n * @method isLoaded\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isLoaded() {\n if (this.buffer) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Play the p5.SoundFile\n *\n * @method play\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule playback to start (in seconds from now).\n * @param {Number} [rate] (optional) playback rate\n * @param {Number} [amp] (optional) amplitude (volume)\n * of playback\n * @param {Number} [cueStart] (optional) cue start time in seconds\n * @param {Number} [duration] (optional) duration of playback in seconds\n */\n play(startTime, rate, amp, _cueStart, duration) {\n if (!this.output) {\n console.warn('SoundFile.play() called after dispose');\n return;\n }\n\n var now = p5sound.audiocontext.currentTime;\n var cueStart, cueEnd;\n var time = startTime || 0;\n if (time < 0) {\n time = 0;\n }\n\n time = time + now;\n\n if (typeof rate !== 'undefined') {\n this.rate(rate);\n }\n\n if (typeof amp !== 'undefined') {\n this.setVolume(amp);\n }\n\n // TO DO: if already playing, create array of buffers for easy stop()\n if (this.buffer) {\n // reset the pause time (if it was paused)\n this._pauseTime = 0;\n\n // handle restart playmode\n if (this.mode === 'restart' && this.buffer && this.bufferSourceNode) {\n this.bufferSourceNode.stop(time);\n this._counterNode.stop(time);\n }\n\n //dont create another instance if already playing\n if (this.mode === 'untildone' && this.isPlaying()) {\n return;\n }\n // make a new source and counter. They are automatically assigned playbackRate and buffer\n this.bufferSourceNode = this._initSourceNode();\n\n // garbage collect counterNode and create a new one\n delete this._counterNode;\n this._counterNode = this._initCounterNode();\n\n if (_cueStart) {\n if (_cueStart >= 0 && _cueStart < this.buffer.duration) {\n // this.startTime = cueStart;\n cueStart = _cueStart;\n } else {\n throw 'start time out of range';\n }\n } else {\n cueStart = 0;\n }\n\n if (duration) {\n // if duration is greater than buffer.duration, just play entire file anyway rather than throw an error\n duration =\n duration <= this.buffer.duration - cueStart\n ? duration\n : this.buffer.duration;\n }\n\n // if it was paused, play at the pause position\n if (this._paused) {\n this.bufferSourceNode.start(time, this.pauseTime, duration);\n this._counterNode.start(time, this.pauseTime, duration);\n } else {\n this.bufferSourceNode.start(time, cueStart, duration);\n this._counterNode.start(time, cueStart, duration);\n }\n\n this._playing = true;\n this._paused = false;\n\n // add source to sources array, which is used in stopAll()\n this.bufferSourceNodes.push(this.bufferSourceNode);\n this.bufferSourceNode._arrayIndex = this.bufferSourceNodes.length - 1;\n\n this.bufferSourceNode.addEventListener('ended', this._clearOnEnd);\n }\n // If soundFile hasn't loaded the buffer yet, throw an error\n else {\n throw 'not ready to play file, buffer has yet to load. Try preload()';\n }\n\n // if looping, will restart at original time\n this.bufferSourceNode.loop = this._looping;\n this._counterNode.loop = this._looping;\n\n if (this._looping === true) {\n cueEnd = duration ? duration : cueStart - 0.000000000000001;\n this.bufferSourceNode.loopStart = cueStart;\n this.bufferSourceNode.loopEnd = cueEnd;\n this._counterNode.loopStart = cueStart;\n this._counterNode.loopEnd = cueEnd;\n }\n }\n\n /**\n * p5.SoundFile has two play modes: restart and\n * sustain. Play Mode determines what happens to a\n * p5.SoundFile if it is triggered while in the middle of playback.\n * In sustain mode, playback will continue simultaneous to the\n * new playback. In restart mode, play() will stop playback\n * and start over. With untilDone, a sound will play only if it's\n * not already playing. Sustain is the default mode.\n *\n * @method playMode\n * @for p5.SoundFile\n * @param {String} str 'restart' or 'sustain' or 'untilDone'\n * @example\n *
\n * let mySound;\n * function preload(){\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * noFill();\n * rect(0, height/2, width - 1, height/2 - 1);\n * rect(0, 0, width - 1, height/2);\n * textAlign(CENTER, CENTER);\n * fill(20);\n * text('restart', width/2, 1 * height/4);\n * text('sustain', width/2, 3 * height/4);\n * }\n * function canvasPressed() {\n * if (mouseX < height/2) {\n * mySound.playMode('restart');\n * } else {\n * mySound.playMode('sustain');\n * }\n * mySound.play();\n * }\n *\n *
\n */\n playMode(str) {\n var s = str.toLowerCase();\n\n // if restart, stop all other sounds from playing\n if (s === 'restart' && this.buffer && this.bufferSourceNode) {\n for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {\n var now = p5sound.audiocontext.currentTime;\n this.bufferSourceNodes[i].stop(now);\n }\n }\n\n // set play mode to effect future playback\n if (s === 'restart' || s === 'sustain' || s === 'untildone') {\n this.mode = s;\n } else {\n throw 'Invalid play mode. Must be either \"restart\" or \"sustain\"';\n }\n }\n\n /**\n * Pauses a file that is currently playing. If the file is not\n * playing, then nothing will happen.\n *\n * After pausing, .play() will resume from the paused\n * position.\n * If p5.SoundFile had been set to loop before it was paused,\n * it will continue to loop after it is unpaused with .play().\n *\n * @method pause\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * seconds from now\n * @example\n *
\n * let soundFile;\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play, release to pause', 10, 20, width - 20);\n * }\n * function canvasPressed() {\n * soundFile.loop();\n * background(0, 200, 50);\n * }\n * function mouseReleased() {\n * soundFile.pause();\n * background(220);\n * }\n * \n *
\n */\n pause(startTime) {\n var now = p5sound.audiocontext.currentTime;\n var time = startTime || 0;\n var pTime = time + now;\n\n if (this.isPlaying() && this.buffer && this.bufferSourceNode) {\n this._paused = true;\n this._playing = false;\n\n this.pauseTime = this.currentTime();\n this.bufferSourceNode.stop(pTime);\n this._counterNode.stop(pTime);\n\n this._pauseTime = this.currentTime();\n // TO DO: make sure play() still starts from orig start position\n } else {\n this._pauseTime = 0;\n }\n }\n\n /**\n * Loop the p5.SoundFile. Accepts optional parameters to set the\n * playback rate, playback volume, loopStart, loopEnd.\n *\n * @method loop\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * seconds from now\n * @param {Number} [rate] (optional) playback rate\n * @param {Number} [amp] (optional) playback volume\n * @param {Number} [cueLoopStart] (optional) startTime in seconds\n * @param {Number} [duration] (optional) loop duration in seconds\n * @example\n *
\n * let soundFile;\n * let loopStart = 0.5;\n * let loopDuration = 0.2;\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play, release to pause', 10, 20, width - 20);\n * }\n * function canvasPressed() {\n * soundFile.loop();\n * background(0, 200, 50);\n * }\n * function mouseReleased() {\n * soundFile.pause();\n * background(220);\n * }\n * \n *
\n */\n loop(startTime, rate, amp, loopStart, duration) {\n this._looping = true;\n this.play(startTime, rate, amp, loopStart, duration);\n }\n\n /**\n * Set a p5.SoundFile's looping flag to true or false. If the sound\n * is currently playing, this change will take effect when it\n * reaches the end of the current playback.\n *\n * @method setLoop\n * @for p5.SoundFile\n * @param {Boolean} Boolean set looping to true or false\n */\n setLoop(bool) {\n if (bool === true) {\n this._looping = true;\n } else if (bool === false) {\n this._looping = false;\n } else {\n throw 'Error: setLoop accepts either true or false';\n }\n if (this.bufferSourceNode) {\n this.bufferSourceNode.loop = this._looping;\n this._counterNode.loop = this._looping;\n }\n }\n\n /**\n * Returns 'true' if a p5.SoundFile is currently looping and playing, 'false' if not.\n *\n * @method isLooping\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isLooping() {\n if (!this.bufferSourceNode) {\n return false;\n }\n if (this._looping === true && this.isPlaying() === true) {\n return true;\n }\n return false;\n }\n\n /**\n * Returns true if a p5.SoundFile is playing, false if not (i.e.\n * paused or stopped).\n *\n * @method isPlaying\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isPlaying() {\n return this._playing;\n }\n\n /**\n * Returns true if a p5.SoundFile is paused, false if not (i.e.\n * playing or stopped).\n *\n * @method isPaused\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isPaused() {\n return this._paused;\n }\n\n /**\n * Stop soundfile playback.\n *\n * @method stop\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * in seconds from now\n */\n stop(timeFromNow) {\n var time = timeFromNow || 0;\n\n if (this.mode === 'sustain' || this.mode === 'untildone') {\n this.stopAll(time);\n this._playing = false;\n this.pauseTime = 0;\n this._paused = false;\n } else if (this.buffer && this.bufferSourceNode) {\n var now = p5sound.audiocontext.currentTime;\n var t = time || 0;\n this.pauseTime = 0;\n this.bufferSourceNode.stop(now + t);\n this._counterNode.stop(now + t);\n this._playing = false;\n this._paused = false;\n }\n }\n\n /**\n * Stop playback on all of this soundfile's sources.\n * @private\n */\n stopAll(_time) {\n var now = p5sound.audiocontext.currentTime;\n var time = _time || 0;\n if (this.buffer && this.bufferSourceNode) {\n for (var i in this.bufferSourceNodes) {\n const bufferSourceNode = this.bufferSourceNodes[i];\n if (bufferSourceNode) {\n try {\n bufferSourceNode.stop(now + time);\n } catch (e) {\n // this was throwing errors only on Safari\n }\n }\n }\n this._counterNode.stop(now + time);\n }\n }\n\n getVolume() {\n return this.output.gain.value;\n }\n\n /**\n * Set the stereo panning of a p5.sound object to\n * a floating point number between -1.0 (left) and 1.0 (right).\n * Default is 0.0 (center).\n *\n * @method pan\n * @for p5.SoundFile\n * @param {Number} [panValue] Set the stereo panner\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @example\n *
\n * let ballX = 0;\n * let soundFile;\n *\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/beatbox.mp3');\n * }\n *\n * function draw() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * ballX = constrain(mouseX, 0, width);\n * ellipse(ballX, height/2, 20, 20);\n * }\n *\n * function canvasPressed(){\n * // map the ball's x location to a panning degree\n * // between -1.0 (left) and 1.0 (right)\n * let panning = map(ballX, 0., width,-1.0, 1.0);\n * soundFile.pan(panning);\n * soundFile.play();\n * }\n *
\n */\n pan(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n }\n\n /**\n * Returns the current stereo pan position (-1.0 to 1.0)\n *\n * @method getPan\n * @for p5.SoundFile\n * @return {Number} Returns the stereo pan setting of the Oscillator\n * as a number between -1.0 (left) and 1.0 (right).\n * 0.0 is center and default.\n */\n getPan() {\n return this.panPosition;\n }\n\n /**\n * Set the playback rate of a sound file. Will change the speed and the pitch.\n * Values less than zero will reverse the audio buffer.\n *\n * @method rate\n * @for p5.SoundFile\n * @param {Number} [playbackRate] Set the playback rate. 1.0 is normal,\n * .5 is half-speed, 2.0 is twice as fast.\n * Values less than zero play backwards.\n * @example\n *
\n * let mySound;\n *\n * function preload() {\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * }\n * function canvasPressed() {\n * mySound.loop();\n * }\n * function mouseReleased() {\n * mySound.pause();\n * }\n * function draw() {\n * background(220);\n *\n * // Set the rate to a range between 0.1 and 4\n * // Changing the rate also alters the pitch\n * let playbackRate = map(mouseY, 0.1, height, 2, 0);\n * playbackRate = constrain(playbackRate, 0.01, 4);\n * mySound.rate(playbackRate);\n *\n * line(0, mouseY, width, mouseY);\n * text('rate: ' + round(playbackRate * 100) + '%', 10, 20);\n * }\n *\n * \n *
\n *\n */\n rate(playbackRate) {\n var reverse = false;\n if (typeof playbackRate === 'undefined') {\n return this.playbackRate;\n }\n\n this.playbackRate = playbackRate;\n\n if (playbackRate === 0) {\n playbackRate = 0.0000000000001;\n } else if (playbackRate < 0 && !this.reversed) {\n playbackRate = Math.abs(playbackRate);\n reverse = true;\n } else if (playbackRate > 0 && this.reversed) {\n reverse = true;\n }\n\n if (this.bufferSourceNode) {\n var now = p5sound.audiocontext.currentTime;\n this.bufferSourceNode.playbackRate.cancelScheduledValues(now);\n this.bufferSourceNode.playbackRate.linearRampToValueAtTime(\n Math.abs(playbackRate),\n now\n );\n this._counterNode.playbackRate.cancelScheduledValues(now);\n this._counterNode.playbackRate.linearRampToValueAtTime(\n Math.abs(playbackRate),\n now\n );\n }\n\n if (reverse) {\n this.reverseBuffer();\n }\n return this.playbackRate;\n }\n\n // TO DO: document this\n setPitch(num) {\n var newPlaybackRate = midiToFreq(num) / midiToFreq(60);\n this.rate(newPlaybackRate);\n }\n\n getPlaybackRate() {\n return this.playbackRate;\n }\n\n /**\n * Multiply the output volume (amplitude) of a sound file\n * between 0.0 (silence) and 1.0 (full volume).\n * 1.0 is the maximum amplitude of a digital sound, so multiplying\n * by greater than 1.0 may cause digital distortion. To\n * fade, provide a rampTime parameter. For more\n * complex fades, see the Envelope class.\n *\n * Alternately, you can pass in a signal source such as an\n * oscillator to modulate the amplitude with an audio signal.\n *\n * @method setVolume\n * @for p5.SoundFile\n * @param {Number|Object} volume Volume (amplitude) between 0.0\n * and 1.0 or modulating signal/oscillator\n * @param {Number} [rampTime] Fade for t seconds\n * @param {Number} [timeFromNow] Schedule this event to happen at\n * t seconds in the future\n */\n setVolume(vol, _rampTime, _tFromNow) {\n if (typeof vol === 'number') {\n var rampTime = _rampTime || 0;\n var tFromNow = _tFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now + tFromNow);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(this.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n }\n /**\n * Returns the duration of a sound file in seconds.\n *\n * @method duration\n * @for p5.SoundFile\n * @return {Number} The duration of the soundFile in seconds.\n */\n duration() {\n // Return Duration\n if (this.buffer) {\n return this.buffer.duration;\n } else {\n return 0;\n }\n }\n\n /**\n * Return the current position of the p5.SoundFile playhead, in seconds.\n * Time is relative to the normal buffer direction, so if `reverseBuffer`\n * has been called, currentTime will count backwards.\n *\n * @method currentTime\n * @for p5.SoundFile\n * @return {Number} currentTime of the soundFile in seconds.\n */\n currentTime() {\n return this.reversed\n ? Math.abs(this._lastPos - this.buffer.length) / ac.sampleRate\n : this._lastPos / ac.sampleRate;\n }\n\n /**\n * Move the playhead of a soundfile that is currently playing to a\n * new position and a new duration, in seconds.\n * If none are given, will reset the file to play entire duration\n * from start to finish. To set the position of a soundfile that is\n * not currently playing, use the `play` or `loop` methods.\n *\n * @method jump\n * @for p5.SoundFile\n * @param {Number} cueTime cueTime of the soundFile in seconds.\n * @param {Number} duration duration in seconds.\n */\n jump(cueTime, duration) {\n if (cueTime < 0 || cueTime > this.buffer.duration) {\n throw 'jump time out of range';\n }\n if (duration > this.buffer.duration - cueTime) {\n throw 'end time out of range';\n }\n\n var cTime = cueTime || 0;\n var dur = duration || undefined;\n if (this.isPlaying()) {\n this.stop(0);\n this.play(0, this.playbackRate, this.output.gain.value, cTime, dur);\n }\n }\n\n /**\n * Return the number of channels in a sound file.\n * For example, Mono = 1, Stereo = 2.\n *\n * @method channels\n * @for p5.SoundFile\n * @return {Number} [channels]\n */\n channels() {\n return this.buffer.numberOfChannels;\n }\n\n /**\n * Return the sample rate of the sound file.\n *\n * @method sampleRate\n * @for p5.SoundFile\n * @return {Number} [sampleRate]\n */\n sampleRate() {\n return this.buffer.sampleRate;\n }\n\n /**\n * Return the number of samples in a sound file.\n * Equal to sampleRate * duration.\n *\n * @method frames\n * @for p5.SoundFile\n * @return {Number} [sampleCount]\n */\n frames() {\n return this.buffer.length;\n }\n\n /**\n * Returns an array of amplitude peaks in a p5.SoundFile that can be\n * used to draw a static waveform. Scans through the p5.SoundFile's\n * audio buffer to find the greatest amplitudes. Accepts one\n * parameter, 'length', which determines size of the array.\n * Larger arrays result in more precise waveform visualizations.\n *\n * Inspired by Wavesurfer.js.\n *\n * @method getPeaks\n * @for p5.SoundFile\n * @params {Number} [length] length is the size of the returned array.\n * Larger length results in more precision.\n * Defaults to 5*width of the browser window.\n * @returns {Float32Array} Array of peaks.\n */\n getPeaks(length) {\n if (this.buffer) {\n // set length to window's width if no length is provided\n if (!length) {\n length = window.width * 5;\n }\n if (this.buffer) {\n var buffer = this.buffer;\n var sampleSize = buffer.length / length;\n var sampleStep = ~~(sampleSize / 10) || 1;\n var channels = buffer.numberOfChannels;\n var peaks = new Float32Array(Math.round(length));\n\n for (var c = 0; c < channels; c++) {\n var chan = buffer.getChannelData(c);\n for (var i = 0; i < length; i++) {\n var start = ~~(i * sampleSize);\n var end = ~~(start + sampleSize);\n var max = 0;\n for (var j = start; j < end; j += sampleStep) {\n var value = chan[j];\n if (value > max) {\n max = value;\n // faster than Math.abs\n } else if (-value > max) {\n max = value;\n }\n }\n if (c === 0 || Math.abs(max) > peaks[i]) {\n peaks[i] = max;\n }\n }\n }\n\n return peaks;\n }\n } else {\n throw 'Cannot load peaks yet, buffer is not loaded';\n }\n }\n\n /**\n * Reverses the p5.SoundFile's buffer source.\n * Playback must be handled separately (see example).\n *\n * @method reverseBuffer\n * @for p5.SoundFile\n * @example\n *
\n * let drum;\n * function preload() {\n * drum = loadSound('assets/drum.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function canvasPressed() {\n * drum.stop();\n * drum.reverseBuffer();\n * drum.play();\n * }\n * \n *
\n */\n reverseBuffer() {\n if (this.buffer) {\n var currentPos = this._lastPos / ac.sampleRate;\n var curVol = this.getVolume();\n this.setVolume(0, 0.001);\n\n const numChannels = this.buffer.numberOfChannels;\n for (var i = 0; i < numChannels; i++) {\n this.buffer.getChannelData(i).reverse();\n }\n // set reversed flag\n this.reversed = !this.reversed;\n\n if (this.isPlaying() && currentPos) {\n this.jump(this.duration() - currentPos);\n }\n this.setVolume(curVol, 0.001);\n } else {\n throw 'SoundFile is not done loading';\n }\n }\n\n /**\n * Schedule an event to be called when the soundfile\n * reaches the end of a buffer. If the soundfile is\n * playing through once, this will be called when it\n * ends. If it is looping, it will be called when\n * stop is called.\n *\n * @method onended\n * @for p5.SoundFile\n * @param {Function} callback function to call when the\n * soundfile has ended.\n */\n onended(callback) {\n this._onended = callback;\n return this;\n }\n\n add() {\n // TO DO\n }\n\n dispose() {\n var now = p5sound.audiocontext.currentTime;\n\n // remove reference to soundfile\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.stop(now);\n if (this.buffer && this.bufferSourceNode) {\n for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {\n if (this.bufferSourceNodes[i] !== null) {\n this.bufferSourceNodes[i].disconnect();\n try {\n this.bufferSourceNodes[i].stop(now);\n } catch (e) {\n console.warn('no buffer source node to dispose');\n }\n this.bufferSourceNodes[i] = null;\n }\n }\n if (this.isPlaying()) {\n try {\n this._counterNode.stop(now);\n } catch (e) {\n console.log(e);\n }\n this._counterNode = null;\n }\n }\n if (this.output) {\n this.output.disconnect();\n this.output = null;\n }\n if (this.panner) {\n this.panner.disconnect();\n this.panner = null;\n }\n }\n\n /**\n * Connects the output of a p5sound object to input of another\n * p5.sound object. For example, you may connect a p5.SoundFile to an\n * FFT or an Effect. If no parameter is given, it will connect to\n * the main output. Most p5sound objects connect to the master\n * output when they are created.\n *\n * @method connect\n * @for p5.SoundFile\n * @param {Object} [object] Audio object that accepts an input\n */\n connect(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n } else {\n if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n } else {\n this.panner.connect(unit);\n }\n }\n }\n\n /**\n * Disconnects the output of this p5sound object.\n *\n * @method disconnect\n * @for p5.SoundFile\n */\n disconnect() {\n if (this.panner) {\n this.panner.disconnect();\n }\n }\n\n /**\n */\n getLevel() {\n console.warn(\n 'p5.SoundFile.getLevel has been removed from the library. Use p5.Amplitude instead'\n );\n }\n\n /**\n * Reset the source for this SoundFile to a\n * new path (URL).\n *\n * @method setPath\n * @for p5.SoundFile\n * @param {String} path path to audio file\n * @param {Function} callback Callback\n */\n setPath(p, callback) {\n var path = p5.prototype._checkFileFormats(p);\n this.url = path;\n this.load(callback);\n }\n\n /**\n * Replace the current Audio Buffer with a new Buffer.\n *\n * @method setBuffer\n * @for p5.SoundFile\n * @param {Array} buf Array of Float32 Array(s). 2 Float32 Arrays\n * will create a stereo source. 1 will create\n * a mono source.\n */\n setBuffer(buf) {\n var numChannels = buf.length;\n var size = buf[0].length;\n var newBuffer = ac.createBuffer(numChannels, size, ac.sampleRate);\n\n if (!(buf[0] instanceof Float32Array)) {\n buf[0] = new Float32Array(buf[0]);\n }\n\n for (var channelNum = 0; channelNum < numChannels; channelNum++) {\n var channel = newBuffer.getChannelData(channelNum);\n channel.set(buf[channelNum]);\n }\n\n this.buffer = newBuffer;\n\n // set numbers of channels on input to the panner\n this.panner.inputChannels(numChannels);\n }\n\n // initialize counterNode, set its initial buffer and playbackRate\n _initCounterNode() {\n var self = this;\n var now = ac.currentTime;\n var cNode = ac.createBufferSource();\n\n const workletBufferSize = safeBufferSize(256);\n\n // dispose of worklet node if it already exists\n if (self._workletNode) {\n self._workletNode.disconnect();\n delete self._workletNode;\n }\n self._workletNode = new AudioWorkletNode(\n ac,\n processorNames.soundFileProcessor,\n {\n processorOptions: { bufferSize: workletBufferSize },\n }\n );\n self._workletNode.port.onmessage = (event) => {\n if (event.data.name === 'position') {\n // event.data.position should only be 0 when paused\n if (event.data.position === 0) {\n return;\n }\n this._lastPos = event.data.position;\n\n // do any callbacks that have been scheduled\n this._onTimeUpdate(self._lastPos);\n }\n };\n\n // create counter buffer of the same length as self.buffer\n cNode.buffer = _createCounterBuffer(self.buffer);\n\n cNode.playbackRate.setValueAtTime(self.playbackRate, now);\n\n cNode.connect(self._workletNode);\n self._workletNode.connect(p5.soundOut._silentNode);\n\n return cNode;\n }\n\n // initialize sourceNode, set its initial buffer and playbackRate\n _initSourceNode() {\n var bufferSourceNode = ac.createBufferSource();\n bufferSourceNode.buffer = this.buffer;\n bufferSourceNode.playbackRate.value = this.playbackRate;\n bufferSourceNode.connect(this.output);\n return bufferSourceNode;\n }\n\n processPeaks(callback, _initThreshold, _minThreshold, _minPeaks) {\n console.warn('processPeaks is deprecated');\n }\n\n /**\n * Schedule events to trigger every time a MediaElement\n * (audio/video) reaches a playback cue point.\n *\n * Accepts a callback function, a time (in seconds) at which to trigger\n * the callback, and an optional parameter for the callback.\n *\n * Time will be passed as the first parameter to the callback function,\n * and param will be the second parameter.\n *\n *\n * @method addCue\n * @for p5.SoundFile\n * @param {Number} time Time in seconds, relative to this media\n * element's playback. For example, to trigger\n * an event every time playback reaches two\n * seconds, pass in the number 2. This will be\n * passed as the first parameter to\n * the callback function.\n * @param {Function} callback Name of a function that will be\n * called at the given time. The callback will\n * receive time and (optionally) param as its\n * two parameters.\n * @param {Object} [value] An object to be passed as the\n * second parameter to the\n * callback function.\n * @return {Number} id ID of this cue,\n * useful for removeCue(id)\n * @example\n *
\n * let mySound;\n * function preload() {\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play', 10, 20);\n *\n * // schedule calls to changeText\n * mySound.addCue(0, changeText, \"hello\" );\n * mySound.addCue(0.5, changeText, \"hello,\" );\n * mySound.addCue(1, changeText, \"hello, p5!\");\n * mySound.addCue(1.5, changeText, \"hello, p5!!\");\n * mySound.addCue(2, changeText, \"hello, p5!!!!!\");\n * }\n *\n * function changeText(val) {\n * background(220);\n * text(val, 10, 20);\n * }\n *\n * function canvasPressed() {\n * mySound.play();\n * }\n *
\n */\n addCue(time, callback, val) {\n var id = this._cueIDCounter++;\n\n var cue = new Cue(callback, time, id, val);\n this._cues.push(cue);\n\n // if (!this.elt.ontimeupdate) {\n // this.elt.ontimeupdate = this._onTimeUpdate.bind(this);\n // }\n\n return id;\n }\n\n /**\n * Remove a callback based on its ID. The ID is returned by the\n * addCue method.\n *\n * @method removeCue\n * @for p5.SoundFile\n * @param {Number} id ID of the cue, as returned by addCue\n */\n removeCue(id) {\n var cueLength = this._cues.length;\n for (var i = 0; i < cueLength; i++) {\n var cue = this._cues[i];\n if (cue.id === id) {\n this._cues.splice(i, 1);\n break;\n }\n }\n\n if (this._cues.length === 0) {\n // TO DO: remove callback\n // this.elt.ontimeupdate = null\n }\n }\n\n /**\n * Remove all of the callbacks that had originally been scheduled\n * via the addCue method.\n *\n * @method clearCues\n */\n clearCues() {\n this._cues = [];\n // this.elt.ontimeupdate = null;\n }\n\n // private method that checks for cues to be fired if events\n // have been scheduled using addCue(callback, time).\n _onTimeUpdate(position) {\n var playbackTime = position / this.buffer.sampleRate;\n var cueLength = this._cues.length;\n\n for (var i = 0; i < cueLength; i++) {\n var cue = this._cues[i];\n var callbackTime = cue.time;\n var val = cue.val;\n var leftLimit = this._prevUpdateTime || 0;\n var rightLimit = playbackTime;\n if (leftLimit <= callbackTime && callbackTime <= rightLimit) {\n // pass the scheduled callbackTime as parameter to the callback\n cue.callback(val);\n }\n }\n\n this._prevUpdateTime = playbackTime;\n }\n\n /**\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\n * to download the file to their device. To upload a file to a server, see\n * getBlob\n *\n * @method save\n * @for p5.SoundFile\n * @param {String} [fileName] name of the resulting .wav file.\n * @example\n *
\n * let mySound;\n * function preload() {\n * mySound = loadSound('assets/doorbell.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to download', 10, 20);\n * }\n *\n * function canvasPressed() {\n * mySound.save('my cool filename');\n * }\n *
\n */\n save(fileName) {\n p5.prototype.saveSound(this, fileName, 'wav');\n }\n\n /**\n * This method is useful for sending a SoundFile to a server. It returns the\n * .wav-encoded audio data as a \"Blob\".\n * A Blob is a file-like data object that can be uploaded to a server\n * with an http request. We'll\n * use the `httpDo` options object to send a POST request with some\n * specific options: we encode the request as `multipart/form-data`,\n * and attach the blob as one of the form values using `FormData`.\n *\n *\n * @method getBlob\n * @for p5.SoundFile\n * @returns {Blob} A file-like data object\n * @example\n *
\n * function preload() {\n * mySound = loadSound('assets/doorbell.mp3');\n * }\n *\n * function setup() {\n * noCanvas();\n * let soundBlob = mySound.getBlob();\n *\n * // Now we can send the blob to a server...\n * let serverUrl = 'https://jsonplaceholder.typicode.com/posts';\n * let httpRequestOptions = {\n * method: 'POST',\n * body: new FormData().append('soundBlob', soundBlob),\n * headers: new Headers({\n * 'Content-Type': 'multipart/form-data'\n * })\n * };\n * httpDo(serverUrl, httpRequestOptions);\n *\n * // We can also create an `ObjectURL` pointing to the Blob\n * let blobUrl = URL.createObjectURL(soundBlob);\n *\n * // The `
\n */\n getBlob() {\n const dataView = convertToWav(this.buffer);\n return new Blob([dataView], { type: 'audio/wav' });\n }\n}\n\n/**\n * loadSound() returns a new p5.SoundFile from a specified\n * path. If called during preload(), the p5.SoundFile will be ready\n * to play in time for setup() and draw(). If called outside of\n * preload, the p5.SoundFile will not be ready immediately, so\n * loadSound accepts a callback as the second parameter. Using a\n * \n * local server is recommended when loading external files.\n *\n * @method loadSound\n * @for p5\n * @param {String|Array} path Path to the sound file, or an array with\n * paths to soundfiles in multiple formats\n * i.e. ['sound.ogg', 'sound.mp3'].\n * Alternately, accepts an object: either\n * from the HTML5 File API, or a p5.File.\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if there is\n * an error loading the file.\n * @param {Function} [whileLoading] Name of a function to call while file is loading.\n * This function will receive the percentage loaded\n * so far, from 0.0 to 1.0.\n * @return {SoundFile} Returns a p5.SoundFile\n * @example\n *
\n * let mySound;\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * mySound = loadSound('assets/doorbell');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap here to play', 10, 20);\n * }\n *\n * function canvasPressed() {\n * // playing a sound file on a user gesture\n * // is equivalent to `userStartAudio()`\n * mySound.play();\n * }\n *
\n */\nfunction loadSound(path, callback, onerror, whileLoading) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n window.alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n\n var self = this;\n var s = new SoundFile(\n path,\n function () {\n if (typeof callback === 'function') {\n callback.apply(self, arguments);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n },\n onerror,\n whileLoading\n );\n\n return s;\n}\n\nexport default SoundFile;\nexport { loadSound };\n","import p5sound from './main';\nimport { safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\n\n/**\n * Amplitude measures volume between 0.0 and 1.0.\n * Listens to all p5sound by default, or use setInput()\n * to listen to a specific sound source. Accepts an optional\n * smoothing value, which defaults to 0.\n *\n * @class p5.Amplitude\n * @constructor\n * @param {Number} [smoothing] between 0.0 and .999 to smooth\n * amplitude readings (defaults to 0)\n * @example\n *
\n * let sound, amplitude;\n *\n * function preload(){\n * sound = loadSound('assets/beat.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100,100);\n * cnv.mouseClicked(togglePlay);\n * amplitude = new p5.Amplitude();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 20, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function togglePlay() {\n * if (sound.isPlaying() ){\n * sound.pause();\n * } else {\n * sound.loop();\n *\t\tamplitude = new p5.Amplitude();\n *\t\tamplitude.setInput(sound);\n * }\n * }\n *\n *
\n */\nclass Amplitude {\n constructor(smoothing) {\n // Set to 2048 for now. In future iterations, this should be inherited or parsed from p5sound's default\n this.bufferSize = safeBufferSize(2048);\n\n // set audio context\n this.audiocontext = p5sound.audiocontext;\n this._workletNode = new AudioWorkletNode(\n this.audiocontext,\n processorNames.amplitudeProcessor,\n {\n outputChannelCount: [1],\n\n parameterData: { smoothing: smoothing || 0 },\n processorOptions: {\n normalize: false,\n smoothing: smoothing || 0,\n numInputChannels: 2,\n bufferSize: this.bufferSize,\n },\n }\n );\n\n this._workletNode.port.onmessage = function (event) {\n if (event.data.name === 'amplitude') {\n this.volume = event.data.volume;\n this.volNorm = event.data.volNorm;\n this.stereoVol = event.data.stereoVol;\n this.stereoVolNorm = event.data.stereoVolNorm;\n }\n }.bind(this);\n\n // for connections\n this.input = this._workletNode;\n\n this.output = this.audiocontext.createGain();\n\n // the variables to return\n this.volume = 0;\n this.volNorm = 0;\n this.stereoVol = [0, 0];\n this.stereoVolNorm = [0, 0];\n\n this.normalize = false;\n\n this._workletNode.connect(this.output);\n this.output.gain.value = 0;\n\n // this may only be necessary because of a Chrome bug\n this.output.connect(this.audiocontext.destination);\n\n // connect to p5sound main output by default, unless set by input()\n p5sound.meter.connect(this._workletNode);\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connects to the p5sound instance (main output) by default.\n * Optionally, you can pass in a specific source (i.e. a soundfile).\n *\n * @method setInput\n * @for p5.Amplitude\n * @param {soundObject|undefined} [snd] set the sound source\n * (optional, defaults to\n * main output)\n * @param {Number|undefined} [smoothing] a range between 0.0 and 1.0\n * to smooth amplitude readings\n * @example\n *
\n * function preload(){\n * sound1 = loadSound('assets/beat.mp3');\n * sound2 = loadSound('assets/drum.mp3');\n * }\n * function setup(){\n * cnv = createCanvas(100, 100);\n * cnv.mouseClicked(toggleSound);\n *\n * amplitude = new p5.Amplitude();\n * amplitude.setInput(sound2);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 20, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function toggleSound(){\n * if (sound1.isPlaying() && sound2.isPlaying()) {\n * sound1.stop();\n * sound2.stop();\n * } else {\n * sound1.play();\n * sound2.play();\n * }\n * }\n *
\n */\n setInput(source, smoothing) {\n p5sound.meter.disconnect();\n\n if (smoothing) {\n this._workletNode.parameters.get('smoothing').value = smoothing;\n }\n\n // connect to the master out of p5s instance if no snd is provided\n if (source == null) {\n console.log(\n 'Amplitude input source is not ready! Connecting to main output instead'\n );\n p5sound.meter.connect(this._workletNode);\n }\n\n // connect to the sound if it is available\n else if (source) {\n source.connect(this._workletNode);\n this._workletNode.disconnect();\n this._workletNode.connect(this.output);\n }\n\n // otherwise, connect to the master out of p5s instance (default)\n else {\n p5sound.meter.connect(this._workletNode);\n }\n }\n\n connect(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n } else {\n this.output.connect(unit);\n }\n } else {\n this.output.connect(this.panner.connect(p5sound.input));\n }\n }\n\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Returns a single Amplitude reading at the moment it is called.\n * For continuous readings, run in the draw loop.\n *\n * @method getLevel\n * @for p5.Amplitude\n * @param {Number} [channel] Optionally return only channel 0 (left) or 1 (right)\n * @return {Number} Amplitude as a number between 0.0 and 1.0\n * @example\n *
\n * function preload(){\n * sound = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mouseClicked(toggleSound);\n * amplitude = new p5.Amplitude();\n * }\n *\n * function draw() {\n * background(220, 150);\n * textAlign(CENTER);\n * text('tap to play', width/2, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function toggleSound(){\n * if (sound.isPlaying()) {\n * sound.stop();\n * } else {\n * sound.play();\n * }\n * }\n *
\n */\n getLevel(channel) {\n if (typeof channel !== 'undefined') {\n if (this.normalize) {\n return this.stereoVolNorm[channel];\n } else {\n return this.stereoVol[channel];\n }\n } else if (this.normalize) {\n return this.volNorm;\n } else {\n return this.volume;\n }\n }\n\n /**\n * Determines whether the results of Amplitude.process() will be\n * Normalized. To normalize, Amplitude finds the difference the\n * loudest reading it has processed and the maximum amplitude of\n * 1.0. Amplitude adds this difference to all values to produce\n * results that will reliably map between 0.0 and 1.0. However,\n * if a louder moment occurs, the amount that Normalize adds to\n * all the values will change. Accepts an optional boolean parameter\n * (true or false). Normalizing is off by default.\n *\n * @method toggleNormalize\n * @for p5.Amplitude\n * @param {boolean} [boolean] set normalize to true (1) or false (0)\n */\n toggleNormalize(bool) {\n if (typeof bool === 'boolean') {\n this.normalize = bool;\n } else {\n this.normalize = !this.normalize;\n }\n this._workletNode.port.postMessage({\n name: 'toggleNormalize',\n normalize: this.normalize,\n });\n }\n /**\n * Smooth Amplitude analysis by averaging with the last analysis\n * frame. Off by default.\n *\n * @method smooth\n * @for p5.Amplitude\n * @param {Number} set smoothing from 0.0 <= 1\n */\n smooth(s) {\n if (s >= 0 && s < 1) {\n this._workletNode.port.postMessage({ name: 'smoothing', smoothing: s });\n } else {\n console.log('Error: smoothing must be between 0 and 1');\n }\n }\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n\n this._workletNode.disconnect();\n delete this._workletNode;\n }\n}\n\nexport default Amplitude;\n","import p5sound from './main';\n\n/**\n *

FFT (Fast Fourier Transform) is an analysis algorithm that\n * isolates individual\n * \n * audio frequencies within a waveform.

\n *\n *

Once instantiated, a p5.FFT object can return an array based on\n * two types of analyses:
• FFT.waveform() computes\n * amplitude values along the time domain. The array indices correspond\n * to samples across a brief moment in time. Each value represents\n * amplitude of the waveform at that sample of time.
\n * • FFT.analyze() computes amplitude values along the\n * frequency domain. The array indices correspond to frequencies (i.e.\n * pitches), from the lowest to the highest that humans can hear. Each\n * value represents amplitude at that slice of the frequency spectrum.\n * Use with getEnergy() to measure amplitude at specific\n * frequencies, or within a range of frequencies.

\n *\n *

FFT analyzes a very short snapshot of sound called a sample\n * buffer. It returns an array of amplitude measurements, referred\n * to as bins. The array is 1024 bins long by default.\n * You can change the bin array length, but it must be a power of 2\n * between 16 and 1024 in order for the FFT algorithm to function\n * correctly. The actual size of the FFT buffer is twice the\n * number of bins, so given a standard sample rate, the buffer is\n * 2048/44100 seconds long.

\n *\n *\n * @class p5.FFT\n * @constructor\n * @param {Number} [smoothing] Smooth results of Freq Spectrum.\n * 0.0 < smoothing < 1.0.\n * Defaults to 0.8.\n * @param {Number} [bins] Length of resulting array.\n * Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @example\n *
\n * function preload(){\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup(){\n * let cnv = createCanvas(100,100);\n * cnv.mouseClicked(togglePlay);\n * fft = new p5.FFT();\n * sound.amp(0.2);\n * }\n *\n * function draw(){\n * background(220);\n *\n * let spectrum = fft.analyze();\n * noStroke();\n * fill(255, 0, 255);\n * for (let i = 0; i< spectrum.length; i++){\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width / spectrum.length, h )\n * }\n *\n * let waveform = fft.waveform();\n * noFill();\n * beginShape();\n * stroke(20);\n * for (let i = 0; i < waveform.length; i++){\n * let x = map(i, 0, waveform.length, 0, width);\n * let y = map( waveform[i], -1, 1, 0, height);\n * vertex(x,y);\n * }\n * endShape();\n *\n * text('tap to play', 20, 20);\n * }\n *\n * function togglePlay() {\n * if (sound.isPlaying()) {\n * sound.pause();\n * } else {\n * sound.loop();\n * }\n * }\n *
\n */\nclass FFT {\n constructor(smoothing, bins) {\n this.input = this.analyser = p5sound.audiocontext.createAnalyser();\n\n Object.defineProperties(this, {\n bins: {\n get: function () {\n return this.analyser.fftSize / 2;\n },\n set: function (b) {\n this.analyser.fftSize = b * 2;\n },\n configurable: true,\n enumerable: true,\n },\n smoothing: {\n get: function () {\n return this.analyser.smoothingTimeConstant;\n },\n set: function (s) {\n this.analyser.smoothingTimeConstant = s;\n },\n configurable: true,\n enumerable: true,\n },\n });\n\n // set default smoothing and bins\n this.smooth(smoothing);\n this.bins = bins || 1024;\n\n // default connections to p5sound fftMeter\n p5sound.fftMeter.connect(this.analyser);\n\n this.freqDomain = new Uint8Array(this.analyser.frequencyBinCount);\n this.timeDomain = new Uint8Array(this.analyser.frequencyBinCount);\n\n // predefined frequency ranges, these will be tweakable\n this.bass = [20, 140];\n this.lowMid = [140, 400];\n this.mid = [400, 2600];\n this.highMid = [2600, 5200];\n this.treble = [5200, 14000];\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Set the input source for the FFT analysis. If no source is\n * provided, FFT will analyze all sound in the sketch.\n *\n * @method setInput\n * @for p5.FFT\n * @param {Object} [source] p5.sound object (or web audio API source node)\n */\n setInput(source) {\n if (!source) {\n p5sound.fftMeter.connect(this.analyser);\n } else {\n if (source.output) {\n source.output.connect(this.analyser);\n } else if (source.connect) {\n source.connect(this.analyser);\n }\n p5sound.fftMeter.disconnect();\n }\n }\n\n /**\n * Returns an array of amplitude values (between -1.0 and +1.0) that represent\n * a snapshot of amplitude readings in a single buffer. Length will be\n * equal to bins (defaults to 1024). Can be used to draw the waveform\n * of a sound.\n *\n * @method waveform\n * @for p5.FFT\n * @param {Number} [bins] Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @param {String} [precision] If any value is provided, will return results\n * in a Float32 Array which is more precise\n * than a regular array.\n * @return {Array} Array Array of amplitude values (-1 to 1)\n * over time. Array length = bins.\n *\n */\n waveform() {\n var bins, mode;\n var normalArray = new Array();\n\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'number') {\n bins = arguments[i];\n this.analyser.fftSize = bins * 2;\n }\n if (typeof arguments[i] === 'string') {\n mode = arguments[i];\n }\n }\n\n // getFloatFrequencyData doesnt work in Safari as of 5/2015\n if (mode && !p5.prototype._isSafari()) {\n timeToFloat(this, this.timeDomain);\n this.analyser.getFloatTimeDomainData(this.timeDomain);\n return this.timeDomain;\n } else {\n timeToInt(this, this.timeDomain);\n this.analyser.getByteTimeDomainData(this.timeDomain);\n for (var j = 0; j < this.timeDomain.length; j++) {\n var scaled = p5.prototype.map(this.timeDomain[j], 0, 255, -1, 1);\n normalArray.push(scaled);\n }\n return normalArray;\n }\n }\n\n /**\n * Returns an array of amplitude values (between 0 and 255)\n * across the frequency spectrum. Length is equal to FFT bins\n * (1024 by default). The array indices correspond to frequencies\n * (i.e. pitches), from the lowest to the highest that humans can\n * hear. Each value represents amplitude at that slice of the\n * frequency spectrum. Must be called prior to using\n * getEnergy().\n *\n * @method analyze\n * @for p5.FFT\n * @param {Number} [bins] Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @param {Number} [scale] If \"dB,\" returns decibel\n * float measurements between\n * -140 and 0 (max).\n * Otherwise returns integers from 0-255.\n * @return {Array} spectrum Array of energy (amplitude/volume)\n * values across the frequency spectrum.\n * Lowest energy (silence) = 0, highest\n * possible is 255.\n * @example\n *
\n * let osc, fft;\n *\n * function setup(){\n * let cnv = createCanvas(100,100);\n * cnv.mousePressed(startSound);\n * osc = new p5.Oscillator();\n * osc.amp(0);\n * fft = new p5.FFT();\n * }\n *\n * function draw(){\n * background(220);\n *\n * let freq = map(mouseX, 0, windowWidth, 20, 10000);\n * freq = constrain(freq, 1, 20000);\n * osc.freq(freq);\n *\n * let spectrum = fft.analyze();\n * noStroke();\n * fill(255, 0, 255);\n * for (let i = 0; i< spectrum.length; i++){\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width / spectrum.length, h );\n * }\n *\n * stroke(255);\n * if (!osc.started) {\n * text('tap here and drag to change frequency', 10, 20, width - 20);\n * } else {\n * text(round(freq)+'Hz', 10, 20);\n * }\n * }\n *\n * function startSound() {\n * osc.start();\n * osc.amp(0.5, 0.2);\n * }\n *\n * function mouseReleased() {\n * osc.amp(0, 0.2);\n * }\n *
\n *\n *\n */\n analyze() {\n var mode;\n\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'number') {\n this.bins = arguments[i];\n this.analyser.fftSize = this.bins * 2;\n }\n if (typeof arguments[i] === 'string') {\n mode = arguments[i];\n }\n }\n\n if (mode && mode.toLowerCase() === 'db') {\n freqToFloat(this);\n this.analyser.getFloatFrequencyData(this.freqDomain);\n return this.freqDomain;\n } else {\n freqToInt(this, this.freqDomain);\n this.analyser.getByteFrequencyData(this.freqDomain);\n var normalArray = Array.apply([], this.freqDomain);\n\n return normalArray;\n }\n }\n\n /**\n * Returns the amount of energy (volume) at a specific\n * \n * frequency, or the average amount of energy between two\n * frequencies. Accepts Number(s) corresponding\n * to frequency (in Hz), or a \"string\" corresponding to predefined\n * frequency ranges (\"bass\", \"lowMid\", \"mid\", \"highMid\", \"treble\").\n * Returns a range between 0 (no energy/volume at that frequency) and\n * 255 (maximum energy).\n * NOTE: analyze() must be called prior to getEnergy(). analyze()\n * tells the FFT to analyze frequency data, and getEnergy() uses\n * the results to determine the value at a specific frequency or\n * range of frequencies.

\n *\n * @method getEnergy\n * @for p5.FFT\n * @param {Number|String} frequency1 Will return a value representing\n * energy at this frequency. Alternately,\n * the strings \"bass\", \"lowMid\" \"mid\",\n * \"highMid\", and \"treble\" will return\n * predefined frequency ranges.\n * @param {Number} [frequency2] If a second frequency is given,\n * will return average amount of\n * energy that exists between the\n * two frequencies.\n * @return {Number} Energy Energy (volume/amplitude) from\n * 0 and 255.\n *\n */\n getEnergy(frequency1, frequency2) {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n\n if (frequency1 === 'bass') {\n frequency1 = this.bass[0];\n frequency2 = this.bass[1];\n } else if (frequency1 === 'lowMid') {\n frequency1 = this.lowMid[0];\n frequency2 = this.lowMid[1];\n } else if (frequency1 === 'mid') {\n frequency1 = this.mid[0];\n frequency2 = this.mid[1];\n } else if (frequency1 === 'highMid') {\n frequency1 = this.highMid[0];\n frequency2 = this.highMid[1];\n } else if (frequency1 === 'treble') {\n frequency1 = this.treble[0];\n frequency2 = this.treble[1];\n }\n\n if (typeof frequency1 !== 'number') {\n throw 'invalid input for getEnergy()';\n } else if (!frequency2) {\n // if only one parameter:\n var index = Math.round((frequency1 / nyquist) * this.freqDomain.length);\n return this.freqDomain[index];\n } else if (frequency1 && frequency2) {\n // if two parameters:\n // if second is higher than first\n if (frequency1 > frequency2) {\n var swap = frequency2;\n frequency2 = frequency1;\n frequency1 = swap;\n }\n var lowIndex = Math.round(\n (frequency1 / nyquist) * this.freqDomain.length\n );\n var highIndex = Math.round(\n (frequency2 / nyquist) * this.freqDomain.length\n );\n\n var total = 0;\n var numFrequencies = 0;\n // add up all of the values for the frequencies\n for (var i = lowIndex; i <= highIndex; i++) {\n total += this.freqDomain[i];\n numFrequencies += 1;\n }\n // divide by total number of frequencies\n var toReturn = total / numFrequencies;\n return toReturn;\n } else {\n throw 'invalid input for getEnergy()';\n }\n }\n\n // compatability with v.012, changed to getEnergy in v.0121. Will be deprecated...\n getFreq(freq1, freq2) {\n console.log('getFreq() is deprecated. Please use getEnergy() instead.');\n var x = this.getEnergy(freq1, freq2);\n return x;\n }\n\n /**\n * Returns the\n * \n * spectral centroid of the input signal.\n * NOTE: analyze() must be called prior to getCentroid(). Analyze()\n * tells the FFT to analyze frequency data, and getCentroid() uses\n * the results determine the spectral centroid.

\n *\n * @method getCentroid\n * @for p5.FFT\n * @return {Number} Spectral Centroid Frequency of the spectral centroid in Hz.\n *\n *\n * @example\n *
\n * function setup(){\n * cnv = createCanvas(100,100);\n * cnv.mousePressed(userStartAudio);\n * sound = new p5.AudioIn();\n * sound.start();\n * fft = new p5.FFT();\n * sound.connect(fft);\n *}\n *\n *function draw() {\n * if (getAudioContext().state !== 'running') {\n * background(220);\n * text('tap here and enable mic to begin', 10, 20, width - 20);\n * return;\n * }\n * let centroidplot = 0.0;\n * let spectralCentroid = 0;\n *\n * background(0);\n * stroke(0,255,0);\n * let spectrum = fft.analyze();\n * fill(0,255,0); // spectrum is green\n *\n * //draw the spectrum\n * for (let i = 0; i < spectrum.length; i++){\n * let x = map(log(i), 0, log(spectrum.length), 0, width);\n * let h = map(spectrum[i], 0, 255, 0, height);\n * let rectangle_width = (log(i+1)-log(i))*(width/log(spectrum.length));\n * rect(x, height, rectangle_width, -h )\n * }\n * let nyquist = 22050;\n *\n * // get the centroid\n * spectralCentroid = fft.getCentroid();\n *\n * // the mean_freq_index calculation is for the display.\n * let mean_freq_index = spectralCentroid/(nyquist/spectrum.length);\n *\n * centroidplot = map(log(mean_freq_index), 0, log(spectrum.length), 0, width);\n *\n * stroke(255,0,0); // the line showing where the centroid is will be red\n *\n * rect(centroidplot, 0, width / spectrum.length, height)\n * noStroke();\n * fill(255,255,255); // text is white\n * text('centroid: ', 10, 20);\n * text(round(spectralCentroid)+' Hz', 10, 40);\n *}\n *
\n */\n getCentroid() {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n var cumulative_sum = 0;\n var centroid_normalization = 0;\n\n for (var i = 0; i < this.freqDomain.length; i++) {\n cumulative_sum += i * this.freqDomain[i];\n centroid_normalization += this.freqDomain[i];\n }\n\n var mean_freq_index = 0;\n\n if (centroid_normalization !== 0) {\n mean_freq_index = cumulative_sum / centroid_normalization;\n }\n\n var spec_centroid_freq =\n mean_freq_index * (nyquist / this.freqDomain.length);\n return spec_centroid_freq;\n }\n\n /**\n * Smooth FFT analysis by averaging with the last analysis frame.\n *\n * @method smooth\n * @param {Number} smoothing 0.0 < smoothing < 1.0.\n * Defaults to 0.8.\n */\n smooth(s) {\n if (typeof s !== 'undefined') {\n this.smoothing = s;\n }\n return this.smoothing;\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.analyser) {\n this.analyser.disconnect();\n delete this.analyser;\n }\n }\n\n /**\n * Returns an array of average amplitude values for a given number\n * of frequency bands split equally. N defaults to 16.\n * NOTE: analyze() must be called prior to linAverages(). Analyze()\n * tells the FFT to analyze frequency data, and linAverages() uses\n * the results to group them into a smaller set of averages.

\n *\n * @method linAverages\n * @for p5.FFT\n * @param {Number} N Number of returned frequency groups\n * @return {Array} linearAverages Array of average amplitude values for each group\n */\n\n linAverages(_N) {\n var N = _N || 16; // This prevents undefined, null or 0 values of N\n\n var spectrum = this.freqDomain;\n var spectrumLength = spectrum.length;\n var spectrumStep = Math.floor(spectrumLength / N);\n\n var linearAverages = new Array(N);\n // Keep a second index for the current average group and place the values accordingly\n // with only one loop in the spectrum data\n var groupIndex = 0;\n\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\n linearAverages[groupIndex] =\n linearAverages[groupIndex] !== undefined\n ? (linearAverages[groupIndex] + spectrum[specIndex]) / 2\n : spectrum[specIndex];\n\n // Increase the group index when the last element of the group is processed\n if (specIndex % spectrumStep === spectrumStep - 1) {\n groupIndex++;\n }\n }\n\n return linearAverages;\n }\n\n /**\n * Returns an array of average amplitude values of the spectrum, for a given\n * set of \n * Octave Bands\n * NOTE: analyze() must be called prior to logAverages(). Analyze()\n * tells the FFT to analyze frequency data, and logAverages() uses\n * the results to group them into a smaller set of averages.

\n *\n * @method logAverages\n * @for p5.FFT\n * @param {Array} octaveBands Array of Octave Bands objects for grouping\n * @return {Array} logAverages Array of average amplitude values for each group\n */\n logAverages(octaveBands) {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n var spectrum = this.freqDomain;\n var spectrumLength = spectrum.length;\n\n var logAverages = new Array(octaveBands.length);\n // Keep a second index for the current average group and place the values accordingly\n // With only one loop in the spectrum data\n var octaveIndex = 0;\n\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\n var specIndexFrequency = Math.round(\n (specIndex * nyquist) / this.freqDomain.length\n );\n\n // Increase the group index if the current frequency exceeds the limits of the band\n if (specIndexFrequency > octaveBands[octaveIndex].hi) {\n octaveIndex++;\n }\n\n logAverages[octaveIndex] =\n logAverages[octaveIndex] !== undefined\n ? (logAverages[octaveIndex] + spectrum[specIndex]) / 2\n : spectrum[specIndex];\n }\n\n return logAverages;\n }\n\n /**\n * Calculates and Returns the 1/N\n * Octave Bands\n * N defaults to 3 and minimum central frequency to 15.625Hz.\n * (1/3 Octave Bands ~= 31 Frequency Bands)\n * Setting fCtr0 to a central value of a higher octave will ignore the lower bands\n * and produce less frequency groups.\n *\n * @method getOctaveBands\n * @for p5.FFT\n * @param {Number} N Specifies the 1/N type of generated octave bands\n * @param {Number} fCtr0 Minimum central frequency for the lowest band\n * @return {Array} octaveBands Array of octave band objects with their bounds\n */\n getOctaveBands(_N, _fCtr0) {\n var N = _N || 3; // Default to 1/3 Octave Bands\n var fCtr0 = _fCtr0 || 15.625; // Minimum central frequency, defaults to 15.625Hz\n\n var octaveBands = [];\n var lastFrequencyBand = {\n lo: fCtr0 / Math.pow(2, 1 / (2 * N)),\n ctr: fCtr0,\n hi: fCtr0 * Math.pow(2, 1 / (2 * N)),\n };\n octaveBands.push(lastFrequencyBand);\n\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n while (lastFrequencyBand.hi < nyquist) {\n var newFrequencyBand = {};\n newFrequencyBand.lo = lastFrequencyBand.hi;\n newFrequencyBand.ctr = lastFrequencyBand.ctr * Math.pow(2, 1 / N);\n newFrequencyBand.hi = newFrequencyBand.ctr * Math.pow(2, 1 / (2 * N));\n\n octaveBands.push(newFrequencyBand);\n lastFrequencyBand = newFrequencyBand;\n }\n\n return octaveBands;\n }\n}\n\n// helper methods to convert type from float (dB) to int (0-255)\nfunction freqToFloat(fft) {\n if (fft.freqDomain instanceof Float32Array === false) {\n fft.freqDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction freqToInt(fft) {\n if (fft.freqDomain instanceof Uint8Array === false) {\n fft.freqDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction timeToFloat(fft) {\n if (fft.timeDomain instanceof Float32Array === false) {\n fft.timeDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction timeToInt(fft) {\n if (fft.timeDomain instanceof Uint8Array === false) {\n fft.timeDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n}\n\nexport default FFT;\n","import p5sound from './main';\nimport Add from 'Tone/signal/Add';\nimport Mult from 'Tone/signal/Multiply';\nimport Scale from 'Tone/signal/Scale';\nimport Panner from './panner';\n// ========================== //\n// SIGNAL MATH FOR MODULATION //\n// ========================== //\n\n// return sigChain(this, scale, thisChain, nextChain, Scale);\nfunction sigChain(o, mathObj, thisChain, nextChain, type) {\n var chainSource = o.oscillator;\n // if this type of math already exists in the chain, replace it\n for (var i in o.mathOps) {\n if (o.mathOps[i] instanceof type) {\n chainSource.disconnect();\n o.mathOps[i].dispose();\n thisChain = i;\n // assume nextChain is output gain node unless...\n if (thisChain < o.mathOps.length - 2) {\n nextChain = o.mathOps[i + 1];\n }\n }\n }\n if (thisChain === o.mathOps.length - 1) {\n o.mathOps.push(nextChain);\n }\n // assume source is the oscillator unless i > 0\n if (i > 0) {\n chainSource = o.mathOps[i - 1];\n }\n chainSource.disconnect();\n chainSource.connect(mathObj);\n mathObj.connect(nextChain);\n o.mathOps[thisChain] = mathObj;\n return o;\n}\n\n/**\n *

Creates a signal that oscillates between -1.0 and 1.0.\n * By default, the oscillation takes the form of a sinusoidal\n * shape ('sine'). Additional types include 'triangle',\n * 'sawtooth' and 'square'. The frequency defaults to\n * 440 oscillations per second (440Hz, equal to the pitch of an\n * 'A' note).

\n *\n *

Set the type of oscillation with setType(), or by instantiating a\n * specific oscillator: p5.SinOsc, p5.TriOsc, p5.SqrOsc, or p5.SawOsc.\n *

\n *\n * @class p5.Oscillator\n * @constructor\n * @param {Number} [freq] frequency defaults to 440Hz\n * @param {String} [type] type of oscillator. Options:\n * 'sine' (default), 'triangle',\n * 'sawtooth', 'square'\n * @example\n *
\n * let osc, playing, freq, amp;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playOscillator);\n * osc = new p5.Oscillator('sine');\n * }\n *\n * function draw() {\n * background(220)\n * freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\n * amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\n *\n * text('tap to play', 20, 20);\n * text('freq: ' + freq, 20, 40);\n * text('amp: ' + amp, 20, 60);\n *\n * if (playing) {\n * // smooth the transitions by 0.1 seconds\n * osc.freq(freq, 0.1);\n * osc.amp(amp, 0.1);\n * }\n * }\n *\n * function playOscillator() {\n * // starting an oscillator on a user gesture will enable audio\n * // in browsers that have a strict autoplay policy.\n * // See also: userStartAudio();\n * osc.start();\n * playing = true;\n * }\n *\n * function mouseReleased() {\n * // ramp amplitude to 0 over 0.5 seconds\n * osc.amp(0, 0.5);\n * playing = false;\n * }\n *
\n */\nclass Oscillator {\n constructor(freq, type) {\n if (typeof freq === 'string') {\n let f = type;\n type = freq;\n freq = f;\n }\n if (typeof type === 'number') {\n let f = type;\n type = freq;\n freq = f;\n }\n this.started = false;\n\n // components\n this.phaseAmount = undefined;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.f = freq || 440.0; // frequency\n this.oscillator.type = type || 'sine';\n this.oscillator.frequency.setValueAtTime(\n this.f,\n p5sound.audiocontext.currentTime\n );\n\n // connections\n this.output = p5sound.audiocontext.createGain();\n\n this._freqMods = []; // modulators connected to this oscillator's frequency\n\n // set default output gain to 0.5\n this.output.gain.value = 0.5;\n this.output.gain.setValueAtTime(0.5, p5sound.audiocontext.currentTime);\n\n this.oscillator.connect(this.output);\n // stereo panning\n this.panPosition = 0.0;\n this.connection = p5sound.input; // connect to p5sound by default\n this.panner = new Panner(this.output, this.connection, 1);\n\n //array of math operation signal chaining\n this.mathOps = [this.output];\n\n // add to the soundArray so we can dispose of the osc later\n p5sound.soundArray.push(this);\n\n // these methods are now the same thing\n this.fade = this.amp;\n }\n\n /**\n * Start an oscillator.\n *\n * Starting an oscillator on a user gesture will enable audio in browsers\n * that have a strict autoplay policy, including Chrome and most mobile\n * devices. See also: `userStartAudio()`.\n *\n * @method start\n * @for p5.Oscillator\n * @param {Number} [time] startTime in seconds from now.\n * @param {Number} [frequency] frequency in Hz.\n */\n start(time, f) {\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n }\n if (!this.started) {\n var freq = f || this.f;\n var type = this.oscillator.type;\n\n // set old osc free to be garbage collected (memory)\n if (this.oscillator) {\n this.oscillator.disconnect();\n delete this.oscillator;\n }\n\n // var detune = this.oscillator.frequency.value;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.oscillator.frequency.value = Math.abs(freq);\n this.oscillator.type = type;\n // this.oscillator.detune.value = detune;\n this.oscillator.connect(this.output);\n time = time || 0;\n this.oscillator.start(time + p5sound.audiocontext.currentTime);\n this.freqNode = this.oscillator.frequency;\n\n // if other oscillators are already connected to this osc's freq\n for (var i in this._freqMods) {\n if (typeof this._freqMods[i].connect !== 'undefined') {\n this._freqMods[i].connect(this.oscillator.frequency);\n }\n }\n\n this.started = true;\n }\n }\n\n /**\n * Stop an oscillator. Accepts an optional parameter\n * to determine how long (in seconds from now) until the\n * oscillator stops.\n *\n * @method stop\n * @for p5.Oscillator\n * @param {Number} secondsFromNow Time, in seconds from now.\n */\n stop(time) {\n if (this.started) {\n var t = time || 0;\n var now = p5sound.audiocontext.currentTime;\n this.oscillator.stop(t + now);\n this.started = false;\n }\n }\n\n /**\n * Set the amplitude between 0 and 1.0. Or, pass in an object\n * such as an oscillator to modulate amplitude with an audio signal.\n *\n * @method amp\n * @for p5.Oscillator\n * @param {Number|Object} vol between 0 and 1.0\n * or a modulating signal/oscillator\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {AudioParam} gain If no value is provided,\n * returns the Web Audio API\n * AudioParam that controls\n * this oscillator's\n * gain/amplitude/volume)\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n if (typeof vol === 'number') {\n var now = p5sound.audiocontext.currentTime;\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(this.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n }\n\n /**\n * Returns the value of output gain\n *\n * @method getAmp\n * @for p5.Oscillator\n *\n * @returns {number} Amplitude value between 0.0 and 1.0\n */\n\n getAmp() {\n return this.output.gain.value;\n }\n\n /**\n * Set frequency of an oscillator to a value. Or, pass in an object\n * such as an oscillator to modulate the frequency with an audio signal.\n *\n * @method freq\n * @for p5.Oscillator\n * @param {Number|Object} Frequency Frequency in Hz\n * or modulating signal/oscillator\n * @param {Number} [rampTime] Ramp time (in seconds)\n * @param {Number} [timeFromNow] Schedule this event to happen\n * at x seconds from now\n * @return {AudioParam} Frequency If no value is provided,\n * returns the Web Audio API\n * AudioParam that controls\n * this oscillator's frequency\n * @example\n *
\n * let osc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playOscillator);\n * osc = new p5.Oscillator(300);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playOscillator() {\n * osc.start();\n * osc.amp(0.5);\n * // start at 700Hz\n * osc.freq(700);\n * // ramp to 60Hz over 0.7 seconds\n * osc.freq(60, 0.7);\n * osc.amp(0, 0.1, 0.7);\n * }\n *
\n */\n freq(val, rampTime = 0, tFromNow = 0) {\n if (typeof val === 'number' && !isNaN(val)) {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n\n if (rampTime === 0) {\n this.oscillator.frequency.setValueAtTime(val, tFromNow + now);\n } else {\n if (val > 0) {\n this.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n } else {\n this.oscillator.frequency.linearRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n }\n }\n\n // reset phase if oscillator has a phase\n if (this.phaseAmount) {\n this.phase(this.phaseAmount);\n }\n } else if (val) {\n if (val.output) {\n val = val.output;\n }\n val.connect(this.oscillator.frequency);\n\n // keep track of what is modulating this param\n // so it can be re-connected if\n this._freqMods.push(val);\n } else {\n // return the Frequency Node\n return this.oscillator.frequency;\n }\n }\n /**\n * Returns the value of frequency of oscillator\n *\n * @method getFreq\n * @for p5.Oscillator\n * @returns {number} Frequency of oscillator in Hertz\n */\n\n getFreq() {\n return this.oscillator.frequency.value;\n }\n\n /**\n * Set type to 'sine', 'triangle', 'sawtooth' or 'square'.\n *\n * @method setType\n * @for p5.Oscillator\n * @param {String} type 'sine', 'triangle', 'sawtooth' or 'square'.\n */\n setType(type) {\n this.oscillator.type = type;\n }\n /**\n * Returns current type of oscillator eg. 'sine', 'triangle', 'sawtooth' or 'square'.\n *\n * @method getType\n * @for p5.Oscillator\n * @returns {String} type of oscillator eg . 'sine', 'triangle', 'sawtooth' or 'square'.\n */\n\n getType() {\n return this.oscillator.type;\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.Oscillator\n * @param {Object} unit A p5.sound or Web Audio object\n */\n connect(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n } else if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n this.connection = unit.input;\n } else {\n this.panner.connect(unit);\n this.connection = unit;\n }\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.Oscillator\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n if (this.panner) {\n this.panner.disconnect();\n if (this.output) {\n this.output.connect(this.panner);\n }\n }\n this.oscMods = [];\n }\n\n /**\n * Pan between Left (-1) and Right (1)\n *\n * @method pan\n * @for p5.Oscillator\n * @param {Number} panning Number between -1 and 1\n * @param {Number} timeFromNow schedule this event to happen\n * seconds from now\n */\n pan(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n }\n\n /**\n * Returns the current value of panPosition , between Left (-1) and Right (1)\n *\n * @method getPan\n * @for p5.Oscillator\n *\n * @returns {number} panPosition of oscillator , between Left (-1) and Right (1)\n */\n\n getPan() {\n return this.panPosition;\n }\n\n // get rid of the oscillator\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.oscillator) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.disconnect();\n this.panner = null;\n this.oscillator = null;\n }\n // if it is a Pulse\n if (this.osc2) {\n this.osc2.dispose();\n }\n }\n\n /**\n * Set the phase of an oscillator between 0.0 and 1.0.\n * In this implementation, phase is a delay time\n * based on the oscillator's current frequency.\n *\n * @method phase\n * @for p5.Oscillator\n * @param {Number} phase float between 0.0 and 1.0\n */\n phase(p) {\n var delayAmt = p5.prototype.map(p, 0, 1.0, 0, 1 / this.f);\n var now = p5sound.audiocontext.currentTime;\n\n this.phaseAmount = p;\n\n if (!this.dNode) {\n // create a delay node\n this.dNode = p5sound.audiocontext.createDelay();\n // put the delay node in between output and panner\n this.oscillator.disconnect();\n this.oscillator.connect(this.dNode);\n this.dNode.connect(this.output);\n }\n\n // set delay time to match phase:\n this.dNode.delayTime.setValueAtTime(delayAmt, now);\n }\n\n /**\n * Add a value to the p5.Oscillator's output amplitude,\n * and return the oscillator. Calling this method again\n * will override the initial add() with a new value.\n *\n * @method add\n * @for p5.Oscillator\n * @param {Number} number Constant number to add\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with scaled output\n *\n */\n add(num) {\n var add = new Add(num);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, add, thisChain, nextChain, Add);\n }\n /**\n * Multiply the p5.Oscillator's output amplitude\n * by a fixed value (i.e. turn it up!). Calling this method\n * again will override the initial mult() with a new value.\n *\n * @method mult\n * @for p5.Oscillator\n * @param {Number} number Constant number to multiply\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with multiplied output\n */\n mult(num) {\n var mult = new Mult(num);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, mult, thisChain, nextChain, Mult);\n }\n\n /**\n * Scale this oscillator's amplitude values to a given\n * range, and return the oscillator. Calling this method\n * again will override the initial scale() with new values.\n *\n * @method scale\n * @for p5.Oscillator\n * @param {Number} inMin input range minumum\n * @param {Number} inMax input range maximum\n * @param {Number} outMin input range minumum\n * @param {Number} outMax input range maximum\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with scaled output\n */\n scale(inMin, inMax, outMin, outMax) {\n var mapOutMin, mapOutMax;\n if (arguments.length === 4) {\n mapOutMin = p5.prototype.map(outMin, inMin, inMax, 0, 1) - 0.5; //find a way to get rid of p5.prototype ?\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5; //find a way to get rid of p5.prototype ?\n } else {\n mapOutMin = arguments[0];\n mapOutMax = arguments[1];\n }\n var scale = new Scale(mapOutMin, mapOutMax);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, scale, thisChain, nextChain, Scale);\n\n // this.output.disconnect();\n // this.output.connect(scale)\n }\n}\n\n// ============================== //\n// SinOsc, TriOsc, SqrOsc, SawOsc //\n// ============================== //\n\n/**\n * Constructor: new p5.SinOsc().\n * This creates a Sine Wave Oscillator and is\n * equivalent to new p5.Oscillator('sine')\n * or creating a p5.Oscillator and then calling\n * its method setType('sine').\n * See p5.Oscillator for methods.\n *\n * @class p5.SinOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SinOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'sine');\n }\n}\n\n/**\n * Constructor: new p5.TriOsc().\n * This creates a Triangle Wave Oscillator and is\n * equivalent to new p5.Oscillator('triangle')\n * or creating a p5.Oscillator and then calling\n * its method setType('triangle').\n * See p5.Oscillator for methods.\n *\n * @class p5.TriOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass TriOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'triangle');\n }\n}\n\n/**\n * Constructor: new p5.SawOsc().\n * This creates a SawTooth Wave Oscillator and is\n * equivalent to new p5.Oscillator('sawtooth')\n * or creating a p5.Oscillator and then calling\n * its method setType('sawtooth').\n * See p5.Oscillator for methods.\n *\n * @class p5.SawOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SawOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'sawtooth');\n }\n}\n\n/**\n * Constructor: new p5.SqrOsc().\n * This creates a Square Wave Oscillator and is\n * equivalent to new p5.Oscillator('square')\n * or creating a p5.Oscillator and then calling\n * its method setType('square').\n * See p5.Oscillator for methods.\n *\n * @class p5.SqrOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SqrOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'square');\n }\n}\n\nexport default Oscillator;\nexport { SinOsc, TriOsc, SawOsc, SqrOsc };\n","import p5sound from './main';\nimport Add from 'Tone/signal/Add';\nimport Mult from 'Tone/signal/Multiply';\nimport Scale from 'Tone/signal/Scale';\nimport TimelineSignal from 'Tone/signal/TimelineSignal.js';\n\n/**\n *

Envelopes are pre-defined amplitude distribution over time.\n * Typically, envelopes are used to control the output volume\n * of an object, a series of fades referred to as Attack, Decay,\n * Sustain and Release (\n * ADSR\n * ). Envelopes can also control other Web Audio Parameters—for example, a p5.Envelope can\n * control an Oscillator's frequency like this: osc.freq(env).

\n *

Use setRange to change the attack/release level.\n * Use setADSR to change attackTime, decayTime, sustainPercent and releaseTime.

\n *

Use the play method to play the entire envelope,\n * the ramp method for a pingable trigger,\n * or triggerAttack/\n * triggerRelease to trigger noteOn/noteOff.

\n *\n * @class p5.Envelope\n * @constructor\n * @example\n *
\n * let t1 = 0.1; // attack time in seconds\n * let l1 = 0.7; // attack level 0.0 to 1.0\n * let t2 = 0.3; // decay time in seconds\n * let l2 = 0.1; // decay level 0.0 to 1.0\n *\n * let env;\n * let triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * text('tap to play', 20, 20);\n * cnv.mousePressed(playSound);\n *\n * env = new p5.Envelope(t1, l1, t2, l2);\n * triOsc = new p5.Oscillator('triangle');\n * }\n *\n * function playSound() {\n * // starting the oscillator ensures that audio is enabled.\n * triOsc.start();\n * env.play(triOsc);\n * }\n *
\n */\np5.Envelope = function (t1, l1, t2, l2, t3, l3) {\n /**\n * Time until envelope reaches attackLevel\n * @property attackTime\n */\n this.aTime = t1 || 0.1;\n /**\n * Level once attack is complete.\n * @property attackLevel\n */\n this.aLevel = l1 || 1;\n /**\n * Time until envelope reaches decayLevel.\n * @property decayTime\n */\n this.dTime = t2 || 0.5;\n /**\n * Level after decay. The envelope will sustain here until it is released.\n * @property decayLevel\n */\n this.dLevel = l2 || 0;\n /**\n * Duration of the release portion of the envelope.\n * @property releaseTime\n */\n this.rTime = t3 || 0;\n /**\n * Level at the end of the release.\n * @property releaseLevel\n */\n this.rLevel = l3 || 0;\n\n this._rampHighPercentage = 0.98;\n\n this._rampLowPercentage = 0.02;\n\n this.output = p5sound.audiocontext.createGain();\n\n this.control = new TimelineSignal();\n\n this._init(); // this makes sure the envelope starts at zero\n\n this.control.connect(this.output); // connect to the output\n\n this.connection = null; // store connection\n\n //array of math operation signal chaining\n this.mathOps = [this.control];\n\n //whether envelope should be linear or exponential curve\n this.isExponential = false;\n\n // oscillator or buffer source to clear on env complete\n // to save resources if/when it is retriggered\n this.sourceToClear = null;\n\n // set to true if attack is set, then false on release\n this.wasTriggered = false;\n\n // add to the soundArray so we can dispose of the env later\n p5sound.soundArray.push(this);\n};\n\n// this init function just smooths the starting value to zero and gives a start point for the timeline\n// - it was necessary to remove glitches at the beginning.\np5.Envelope.prototype._init = function () {\n var now = p5sound.audiocontext.currentTime;\n var t = now;\n this.control.setTargetAtTime(0.00001, t, 0.001);\n //also, compute the correct time constants\n this._setRampAD(this.aTime, this.dTime);\n};\n\n/**\n * Reset the envelope with a series of time/value pairs.\n *\n * @method set\n * @for p5.Envelope\n * @param {Number} attackTime Time (in seconds) before level\n * reaches attackLevel\n * @param {Number} attackLevel Typically an amplitude between\n * 0.0 and 1.0\n * @param {Number} decayTime Time\n * @param {Number} decayLevel Amplitude (In a standard ADSR envelope,\n * decayLevel = sustainLevel)\n * @param {Number} releaseTime Release Time (in seconds)\n * @param {Number} releaseLevel Amplitude\n * @example\n *
\n * let attackTime;\n * let l1 = 0.7; // attack level 0.0 to 1.0\n * let t2 = 0.3; // decay time in seconds\n * let l2 = 0.1; // decay level 0.0 to 1.0\n * let l3 = 0.2; // release time in seconds\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n *\n * attackTime = map(mouseX, 0, width, 0.0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 20);\n * }\n *\n * // mouseClick triggers envelope if over canvas\n * function playSound() {\n * env.set(attackTime, l1, t2, l2, l3);\n *\n * triOsc.start();\n * env.play(triOsc);\n * }\n *
\n *\n */\np5.Envelope.prototype.set = function (t1, l1, t2, l2, t3, l3) {\n this.aTime = t1;\n this.aLevel = l1;\n this.dTime = t2 || 0;\n this.dLevel = l2 || 0;\n this.rTime = t3 || 0;\n this.rLevel = l3 || 0;\n\n // set time constants for ramp\n this._setRampAD(t1, t2);\n};\n\n/**\n * Set values like a traditional\n * \n * ADSR envelope\n * .\n *\n * @method setADSR\n * @for p5.Envelope\n * @param {Number} attackTime Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackTime = map(mouseX, 0, width, 0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 40);\n * }\n *\n * function playEnv() {\n * triOsc.start();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.setADSR = function (aTime, dTime, sPercent, rTime) {\n this.aTime = aTime;\n this.dTime = dTime || 0;\n\n // lerp\n this.sPercent = sPercent || 0;\n this.dLevel =\n typeof sPercent !== 'undefined'\n ? sPercent * (this.aLevel - this.rLevel) + this.rLevel\n : 0;\n\n this.rTime = rTime || 0;\n\n // also set time constants for ramp\n this._setRampAD(aTime, dTime);\n};\n\n/**\n * Set max (attackLevel) and min (releaseLevel) of envelope.\n *\n * @method setRange\n * @for p5.Envelope\n * @param {Number} aLevel attack level (defaults to 1)\n * @param {Number} rLevel release level (defaults to 0)\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackLevel = map(mouseY, height, 0, 0, 1.0);\n * text('attack level: ' + attackLevel, 5, height - 20);\n * }\n *\n * function playEnv() {\n * triOsc.start();\n * env.setRange(attackLevel, releaseLevel);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.setRange = function (aLevel, rLevel) {\n this.aLevel = aLevel || 1;\n this.rLevel = rLevel || 0;\n\n // not sure if this belongs here:\n\n // {Number} [dLevel] decay/sustain level (optional)\n // if (typeof(dLevel) !== 'undefined') {\n // this.dLevel = dLevel\n // } else if (this.sPercent) {\n // this.dLevel = this.sPercent ? this.sPercent * (this.aLevel - this.rLevel) + this.rLevel : 0;\n // }\n};\n\n// private (undocumented) method called when ADSR is set to set time constants for ramp\n//\n// Set the \n// time constants for simple exponential ramps.\n// The larger the time constant value, the slower the\n// transition will be.\n//\n// method _setRampAD\n// param {Number} attackTimeConstant attack time constant\n// param {Number} decayTimeConstant decay time constant\n//\np5.Envelope.prototype._setRampAD = function (t1, t2) {\n this._rampAttackTime = this.checkExpInput(t1);\n this._rampDecayTime = this.checkExpInput(t2);\n\n var TCDenominator = 1.0;\n /// Aatish Bhatia's calculation for time constant for rise(to adjust 1/1-e calculation to any percentage)\n TCDenominator = Math.log(\n 1.0 / this.checkExpInput(1.0 - this._rampHighPercentage)\n );\n this._rampAttackTC = t1 / this.checkExpInput(TCDenominator);\n TCDenominator = Math.log(1.0 / this._rampLowPercentage);\n this._rampDecayTC = t2 / this.checkExpInput(TCDenominator);\n};\n\n// private method\np5.Envelope.prototype.setRampPercentages = function (p1, p2) {\n //set the percentages that the simple exponential ramps go to\n this._rampHighPercentage = this.checkExpInput(p1);\n this._rampLowPercentage = this.checkExpInput(p2);\n var TCDenominator = 1.0;\n //now re-compute the time constants based on those percentages\n /// Aatish Bhatia's calculation for time constant for rise(to adjust 1/1-e calculation to any percentage)\n TCDenominator = Math.log(\n 1.0 / this.checkExpInput(1.0 - this._rampHighPercentage)\n );\n this._rampAttackTC = this._rampAttackTime / this.checkExpInput(TCDenominator);\n TCDenominator = Math.log(1.0 / this._rampLowPercentage);\n this._rampDecayTC = this._rampDecayTime / this.checkExpInput(TCDenominator);\n};\n\n/**\n * Assign a parameter to be controlled by this envelope.\n * If a p5.Sound object is given, then the p5.Envelope will control its\n * output gain. If multiple inputs are provided, the env will\n * control all of them.\n *\n * @method setInput\n * @for p5.Envelope\n * @param {Object} [...inputs] A p5.sound object or\n * Web Audio Param.\n */\np5.Envelope.prototype.setInput = function () {\n for (var i = 0; i < arguments.length; i++) {\n this.connect(arguments[i]);\n }\n};\n\n/**\n * Set whether the envelope ramp is linear (default) or exponential.\n * Exponential ramps can be useful because we perceive amplitude\n * and frequency logarithmically.\n *\n * @method setExp\n * @for p5.Envelope\n * @param {Boolean} isExp true is exponential, false is linear\n */\np5.Envelope.prototype.setExp = function (isExp) {\n this.isExponential = isExp;\n};\n\n//helper method to protect against zero values being sent to exponential functions\np5.Envelope.prototype.checkExpInput = function (value) {\n if (value <= 0) {\n value = 0.00000001;\n }\n return value;\n};\n\n/**\n *

Play tells the envelope to start acting on a given input.\n * If the input is a p5.sound object (i.e. AudioIn, Oscillator,\n * SoundFile), then Envelope will control its output volume.\n * Envelopes can also be used to control any \n * Web Audio Audio Param.

\n *\n * @method play\n * @for p5.Envelope\n * @param {Object} unit A p5.sound object or\n * Web Audio Param.\n * @param {Number} [startTime] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * triOsc.start();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackTime = map(mouseX, 0, width, 0, 1.0);\n * attackLevel = map(mouseY, height, 0, 0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 40);\n * text('attack level: ' + attackLevel, 5, height - 20);\n * }\n *\n * function playEnv() {\n * // ensure that audio is enabled\n * userStartAudio();\n *\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(attackLevel, releaseLevel);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.play = function (unit, secondsFromNow, susTime) {\n var tFromNow = secondsFromNow || 0;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n this.triggerAttack(unit, tFromNow);\n\n this.triggerRelease(unit, tFromNow + this.aTime + this.dTime + ~~susTime);\n};\n\n/**\n * Trigger the Attack, and Decay portion of the Envelope.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go. Input can be\n * any p5.sound object, or a \n * Web Audio Param.\n *\n * @method triggerAttack\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow time from now (in seconds)\n * @example\n *
\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.3;\n * let releaseTime = 0.4;\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * textSize(10);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(1.0, 0.0);\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.freq(220);\n *\n * cnv.mousePressed(envAttack);\n * }\n *\n * function envAttack() {\n * background(0, 255, 255);\n * text('release to release', width/2, height/2);\n *\n * // ensures audio is enabled. See also: `userStartAudio`\n * triOsc.start();\n *\n * env.triggerAttack(triOsc);\n * }\n *\n * function mouseReleased() {\n * background(220);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env.triggerRelease(triOsc);\n * }\n *
\n */\np5.Envelope.prototype.triggerAttack = function (unit, secondsFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n this.lastAttack = t;\n this.wasTriggered = true;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n // get and set value (with linear ramp) to anchor automation\n var valToSet = this.control.getValueAtTime(t);\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n } else {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // after each ramp completes, cancel scheduled values\n // (so they can be overridden in case env has been re-triggered)\n // then, set current value (with linearRamp to avoid click)\n // then, schedule the next automation...\n\n // attack\n t += this.aTime;\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.aLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.aLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // decay to decay level (if using ADSR, then decay level == sustain level)\n t += this.dTime;\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.dLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.dLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n};\n\n/**\n * Trigger the Release of the Envelope. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @method triggerRelease\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow time to trigger the release\n * @example\n *
\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.3;\n * let releaseTime = 0.4;\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * textSize(10);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(1.0, 0.0);\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.freq(220);\n *\n * cnv.mousePressed(envAttack);\n * }\n *\n * function envAttack() {\n * background(0, 255, 255);\n * text('release to release', width/2, height/2);\n *\n * // ensures audio is enabled. See also: `userStartAudio`\n * triOsc.start();\n *\n * env.triggerAttack(triOsc);\n * }\n *\n * function mouseReleased() {\n * background(220);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env.triggerRelease(triOsc);\n * }\n *
\n */\np5.Envelope.prototype.triggerRelease = function (unit, secondsFromNow) {\n // only trigger a release if an attack was triggered\n if (!this.wasTriggered) {\n // this currently causes a bit of trouble:\n // if a later release has been scheduled (via the play function)\n // a new earlier release won't interrupt it, because\n // this.wasTriggered has already been set to false.\n // If we want new earlier releases to override, then we need to\n // keep track of the last release time, and if the new release time is\n // earlier, then use it.\n return;\n }\n\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n // get and set value (with linear or exponential ramp) to anchor automation\n var valToSet = this.control.getValueAtTime(t);\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n } else {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // release\n t += this.rTime;\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.rLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.rLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n this.wasTriggered = false;\n};\n\n/**\n * Exponentially ramp to a value using the first two\n * values from setADSR(attackTime, decayTime)\n * as \n * time constants for simple exponential ramps.\n * If the value is higher than current value, it uses attackTime,\n * while a decrease uses decayTime.\n *\n * @method ramp\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow When to trigger the ramp\n * @param {Number} v Target value\n * @param {Number} [v2] Second target value\n * @example\n *
\n * let env, osc, amp;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let attackLevel = 1;\n * let decayLevel = 0;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * fill(0,255,0);\n * noStroke();\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime);\n * osc = new p5.Oscillator();\n * osc.amp(env);\n * amp = new p5.Amplitude();\n *\n * cnv.mousePressed(triggerRamp);\n * }\n *\n * function triggerRamp() {\n * // ensures audio is enabled. See also: `userStartAudio`\n * osc.start();\n *\n * env.ramp(osc, 0, attackLevel, decayLevel);\n * }\n *\n * function draw() {\n * background(20);\n * text('tap to play', 10, 20);\n * let h = map(amp.getLevel(), 0, 0.4, 0, height);;\n * rect(0, height, width, -h);\n * }\n *
\n */\np5.Envelope.prototype.ramp = function (unit, secondsFromNow, v1, v2) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n var destination1 = this.checkExpInput(v1);\n var destination2 =\n typeof v2 !== 'undefined' ? this.checkExpInput(v2) : undefined;\n\n // connect env to unit if not already connected\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n //get current value\n var currentVal = this.checkExpInput(this.control.getValueAtTime(t));\n // this.control.cancelScheduledValues(t);\n\n //if it's going up\n if (destination1 > currentVal) {\n this.control.setTargetAtTime(destination1, t, this._rampAttackTC);\n t += this._rampAttackTime;\n }\n\n //if it's going down\n else if (destination1 < currentVal) {\n this.control.setTargetAtTime(destination1, t, this._rampDecayTC);\n t += this._rampDecayTime;\n }\n\n // Now the second part of envelope begins\n if (destination2 === undefined) return;\n\n //if it's going up\n if (destination2 > destination1) {\n this.control.setTargetAtTime(destination2, t, this._rampAttackTC);\n }\n\n //if it's going down\n else if (destination2 < destination1) {\n this.control.setTargetAtTime(destination2, t, this._rampDecayTC);\n }\n};\n\np5.Envelope.prototype.connect = function (unit) {\n this.connection = unit;\n\n // assume we're talking about output gain\n // unless given a different audio param\n if (\n unit instanceof p5.Oscillator ||\n unit instanceof p5.SoundFile ||\n unit instanceof p5.AudioIn ||\n unit instanceof p5.Reverb ||\n unit instanceof p5.Noise ||\n unit instanceof p5.Filter ||\n unit instanceof p5.Delay\n ) {\n unit = unit.output.gain;\n }\n if (unit instanceof AudioParam) {\n //set the initial value\n unit.setValueAtTime(0, p5sound.audiocontext.currentTime);\n }\n\n this.output.connect(unit);\n};\n\np5.Envelope.prototype.disconnect = function () {\n if (this.output) {\n this.output.disconnect();\n }\n};\n\n// Signal Math\n\n/**\n * Add a value to the p5.Oscillator's output amplitude,\n * and return the oscillator. Calling this method\n * again will override the initial add() with new values.\n *\n * @method add\n * @for p5.Envelope\n * @param {Number} number Constant number to add\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.add = function (num) {\n var add = new Add(num);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, add, thisChain, nextChain, Add);\n};\n\n/**\n * Multiply the p5.Envelope's output amplitude\n * by a fixed value. Calling this method\n * again will override the initial mult() with new values.\n *\n * @method mult\n * @for p5.Envelope\n * @param {Number} number Constant number to multiply\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.mult = function (num) {\n var mult = new Mult(num);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, mult, thisChain, nextChain, Mult);\n};\n\n/**\n * Scale this envelope's amplitude values to a given\n * range, and return the envelope. Calling this method\n * again will override the initial scale() with new values.\n *\n * @method scale\n * @for p5.Envelope\n * @param {Number} inMin input range minumum\n * @param {Number} inMax input range maximum\n * @param {Number} outMin input range minumum\n * @param {Number} outMax input range maximum\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.scale = function (inMin, inMax, outMin, outMax) {\n var scale = new Scale(inMin, inMax, outMin, outMax);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, scale, thisChain, nextChain, Scale);\n};\n\n// get rid of the oscillator\np5.Envelope.prototype.dispose = function () {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.disconnect();\n if (this.control) {\n this.control.dispose();\n this.control = null;\n }\n for (var i = 1; i < this.mathOps.length; i++) {\n this.mathOps[i].dispose();\n }\n};\n\n// Different name for backwards compatibility, replicates p5.Envelope class\np5.Env = function (t1, l1, t2, l2, t3, l3) {\n console.warn(\n 'WARNING: p5.Env is now deprecated and may be removed in future versions. ' +\n 'Please use the new p5.Envelope instead.'\n );\n p5.Envelope.call(this, t1, l1, t2, l2, t3, l3);\n};\np5.Env.prototype = Object.create(p5.Envelope.prototype);\n\nconst Envelope = p5.Envelope;\nexport default Envelope;\n","import p5sound from './main';\nimport Oscillator from './oscillator';\n\n// generate noise buffers\nconst _whiteNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var whiteBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = whiteBuffer.getChannelData(0);\n for (var i = 0; i < bufferSize; i++) {\n noiseData[i] = Math.random() * 2 - 1;\n }\n whiteBuffer.type = 'white';\n return whiteBuffer;\n})();\n\nconst _pinkNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var pinkBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = pinkBuffer.getChannelData(0);\n var b0, b1, b2, b3, b4, b5, b6;\n b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0.0;\n for (var i = 0; i < bufferSize; i++) {\n var white = Math.random() * 2 - 1;\n b0 = 0.99886 * b0 + white * 0.0555179;\n b1 = 0.99332 * b1 + white * 0.0750759;\n b2 = 0.969 * b2 + white * 0.153852;\n b3 = 0.8665 * b3 + white * 0.3104856;\n b4 = 0.55 * b4 + white * 0.5329522;\n b5 = -0.7616 * b5 - white * 0.016898;\n noiseData[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362;\n noiseData[i] *= 0.11; // (roughly) compensate for gain\n b6 = white * 0.115926;\n }\n pinkBuffer.type = 'pink';\n return pinkBuffer;\n})();\n\nconst _brownNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var brownBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = brownBuffer.getChannelData(0);\n var lastOut = 0.0;\n for (var i = 0; i < bufferSize; i++) {\n var white = Math.random() * 2 - 1;\n noiseData[i] = (lastOut + 0.02 * white) / 1.02;\n lastOut = noiseData[i];\n noiseData[i] *= 3.5;\n }\n brownBuffer.type = 'brown';\n return brownBuffer;\n})();\n\n/**\n * Noise is a type of oscillator that generates a buffer with random values.\n *\n * @class p5.Noise\n * @extends p5.Oscillator\n * @constructor\n * @param {String} type Type of noise can be 'white' (default),\n * 'brown' or 'pink'.\n */\nclass Noise extends Oscillator {\n constructor(type) {\n super();\n var assignType;\n delete this.f;\n delete this.freq;\n delete this.oscillator;\n\n if (type === 'brown') {\n assignType = _brownNoiseBuffer;\n } else if (type === 'pink') {\n assignType = _pinkNoiseBuffer;\n } else {\n assignType = _whiteNoiseBuffer;\n }\n this.buffer = assignType;\n }\n\n /**\n * Set type of noise to 'white', 'pink' or 'brown'.\n * White is the default.\n *\n * @method setType\n * @param {String} [type] 'white', 'pink' or 'brown'\n */\n setType(type) {\n switch (type) {\n case 'white':\n this.buffer = _whiteNoiseBuffer;\n break;\n case 'pink':\n this.buffer = _pinkNoiseBuffer;\n break;\n case 'brown':\n this.buffer = _brownNoiseBuffer;\n break;\n default:\n this.buffer = _whiteNoiseBuffer;\n }\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.start(now + 0.01);\n }\n }\n\n getType() {\n return this.buffer.type;\n }\n start() {\n if (this.started) {\n this.stop();\n }\n this.noise = p5sound.audiocontext.createBufferSource();\n this.noise.buffer = this.buffer;\n this.noise.loop = true;\n this.noise.connect(this.output);\n var now = p5sound.audiocontext.currentTime;\n this.noise.start(now);\n this.started = true;\n }\n\n stop() {\n var now = p5sound.audiocontext.currentTime;\n if (this.noise) {\n this.noise.stop(now);\n this.started = false;\n }\n }\n\n dispose() {\n var now = p5sound.audiocontext.currentTime;\n\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.noise) {\n this.noise.disconnect();\n this.stop(now);\n }\n if (this.output) {\n this.output.disconnect();\n }\n if (this.panner) {\n this.panner.disconnect();\n }\n this.output = null;\n this.panner = null;\n this.buffer = null;\n this.noise = null;\n }\n}\n\nexport default Noise;\n","import Signal from 'Tone/signal/Signal';\nimport Multiply from 'Tone/signal/Multiply';\n\nimport p5sound from './main';\nimport Oscillator, { SawOsc } from './oscillator';\n\n/**\n * Creates a Pulse object, an oscillator that implements\n * Pulse Width Modulation.\n * The pulse is created with two oscillators.\n * Accepts a parameter for frequency, and to set the\n * width between the pulses. See \n * p5.Oscillator for a full list of methods.\n *\n * @class p5.Pulse\n * @extends p5.Oscillator\n * @constructor\n * @param {Number} [freq] Frequency in oscillations per second (Hz)\n * @param {Number} [w] Width between the pulses (0 to 1.0,\n * defaults to 0)\n * @example\n *
\n * let pulse;\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startPulse);\n * background(220);\n *\n * pulse = new p5.Pulse();\n * pulse.amp(0.5);\n * pulse.freq(220);\n * }\n * function startPulse() {\n * pulse.start();\n * pulse.amp(0.5, 0.02);\n * }\n * function mouseReleased() {\n * pulse.amp(0, 0.2);\n * }\n * function draw() {\n * background(220);\n * text('tap to play', 5, 20, width - 20);\n * let w = map(mouseX, 0, width, 0, 1);\n * w = constrain(w, 0, 1);\n * pulse.width(w);\n * text('pulse width: ' + w, 5, height - 20);\n * }\n *
\n */\nclass Pulse extends Oscillator {\n constructor(freq, w) {\n super(freq, 'sawtooth');\n\n // width of PWM, should be betw 0 to 1.0\n this.w = w || 0;\n\n // create a second oscillator with inverse frequency\n this.osc2 = new SawOsc(freq);\n\n // create a delay node\n this.dNode = p5sound.audiocontext.createDelay();\n\n // dc offset\n this.dcOffset = createDCOffset();\n this.dcGain = p5sound.audiocontext.createGain();\n this.dcOffset.connect(this.dcGain);\n this.dcGain.connect(this.output);\n // set delay time based on PWM width\n this.f = freq || 440;\n var mW = this.w / this.oscillator.frequency.value;\n this.dNode.delayTime.value = mW;\n this.dcGain.gain.value = 1.7 * (0.5 - this.w);\n\n // disconnect osc2 and connect it to delay, which is connected to output\n this.osc2.disconnect();\n this.osc2.panner.disconnect();\n this.osc2.amp(-1); // inverted amplitude\n this.osc2.output.connect(this.dNode);\n this.dNode.connect(this.output);\n\n this.output.gain.value = 1;\n this.output.connect(this.panner);\n }\n\n /**\n * Set the width of a Pulse object (an oscillator that implements\n * Pulse Width Modulation).\n *\n * @method width\n * @param {Number} [width] Width between the pulses (0 to 1.0,\n * defaults to 0)\n */\n width(w) {\n if (typeof w === 'number') {\n if (w <= 1.0 && w >= 0.0) {\n this.w = w;\n // set delay time based on PWM width\n\n // var mW = map(this.w, 0, 1.0, 0, 1/this.f);\n var mW = this.w / this.oscillator.frequency.value;\n this.dNode.delayTime.value = mW;\n }\n\n this.dcGain.gain.value = 1.7 * (0.5 - this.w);\n } else {\n w.connect(this.dNode.delayTime);\n let sig = new Signal(-0.5); //repalce it with tones Signals Method\n w.connect(sig);\n let mult1 = new Multiply(-1);\n let mult2 = new Multiply(1.7);\n sig = sig.connect(mult1).connect(mult2);\n sig.connect(this.dcGain.gain);\n }\n }\n\n start(f, time) {\n var now = p5sound.audiocontext.currentTime;\n var t = time || 0;\n if (!this.started) {\n var freq = f || this.f;\n var type = this.oscillator.type;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.oscillator.frequency.setValueAtTime(freq, now);\n this.oscillator.type = type;\n this.oscillator.connect(this.output);\n this.oscillator.start(t + now);\n\n // set up osc2\n this.osc2.oscillator = p5sound.audiocontext.createOscillator();\n this.osc2.oscillator.frequency.setValueAtTime(freq, t + now);\n this.osc2.oscillator.type = type;\n this.osc2.oscillator.connect(this.osc2.output);\n this.osc2.start(t + now);\n this.freqNode = [\n this.oscillator.frequency,\n this.osc2.oscillator.frequency,\n ];\n\n // start dcOffset, too\n this.dcOffset = createDCOffset();\n this.dcOffset.connect(this.dcGain);\n this.dcOffset.start(t + now);\n\n // if LFO connections depend on these oscillators\n if (this.mods !== undefined && this.mods.frequency !== undefined) {\n this.mods.frequency.connect(this.freqNode[0]);\n this.mods.frequency.connect(this.freqNode[1]);\n }\n this.started = true;\n this.osc2.started = true;\n }\n }\n\n stop(time) {\n if (this.started) {\n var t = time || 0;\n var now = p5sound.audiocontext.currentTime;\n this.oscillator.stop(t + now);\n if (this.osc2.oscillator) {\n this.osc2.oscillator.stop(t + now);\n }\n this.dcOffset.stop(t + now);\n this.started = false;\n this.osc2.started = false;\n }\n }\n\n freq(val, rampTime = 0, tFromNow = 0) {\n if (typeof val === 'number') {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n var currentFreq = this.oscillator.frequency.value;\n this.oscillator.frequency.cancelScheduledValues(now);\n this.oscillator.frequency.setValueAtTime(currentFreq, now + tFromNow);\n this.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n this.osc2.oscillator.frequency.cancelScheduledValues(now);\n this.osc2.oscillator.frequency.setValueAtTime(\n currentFreq,\n now + tFromNow\n );\n this.osc2.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n\n if (this.freqMod) {\n this.freqMod.output.disconnect();\n this.freqMod = null;\n }\n } else if (val.output) {\n val.output.disconnect();\n val.output.connect(this.oscillator.frequency);\n val.output.connect(this.osc2.oscillator.frequency);\n this.freqMod = val;\n }\n }\n}\n\n// inspiration: http://webaudiodemos.appspot.com/oscilloscope/\nfunction createDCOffset() {\n var ac = p5sound.audiocontext;\n var buffer = ac.createBuffer(1, 2048, ac.sampleRate);\n var data = buffer.getChannelData(0);\n for (var i = 0; i < 2048; i++) data[i] = 1.0;\n var bufferSource = ac.createBufferSource();\n bufferSource.buffer = buffer;\n bufferSource.loop = true;\n return bufferSource;\n}\n\nexport default Pulse;\n","import p5sound from './main';\nimport Amplitude from './amplitude';\n\n// an array of input sources\np5sound.inputSources = [];\n\n/**\n *

Get audio from an input, i.e. your computer's microphone.

\n *\n *

Turn the mic on/off with the start() and stop() methods. When the mic\n * is on, its volume can be measured with getLevel or by connecting an\n * FFT object.

\n *\n *

If you want to hear the AudioIn, use the .connect() method.\n * AudioIn does not connect to p5.sound output by default to prevent\n * feedback.

\n *\n *

Note: This uses the getUserMedia/\n * Stream API, which is not supported by certain browsers. Access in Chrome browser\n * is limited to localhost and https, but access over http may be limited.

\n *\n * @class p5.AudioIn\n * @constructor\n * @param {Function} [errorCallback] A function to call if there is an error\n * accessing the AudioIn. For example,\n * Safari and iOS devices do not\n * currently allow microphone access.\n * @example\n *
\n * let mic;\n *\n * function setup(){\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(userStartAudio);\n * textAlign(CENTER);\n * mic = new p5.AudioIn();\n * mic.start();\n * }\n *\n * function draw(){\n * background(0);\n * fill(255);\n * text('tap to start', width/2, 20);\n *\n * micLevel = mic.getLevel();\n * let y = height - micLevel * height;\n * ellipse(width/2, y, 10, 10);\n * }\n *
\n */\nclass AudioIn {\n constructor(errorCallback) {\n // set up audio input\n /**\n * @property {GainNode} input\n */\n this.input = p5sound.audiocontext.createGain();\n /**\n * @property {GainNode} output\n */\n this.output = p5sound.audiocontext.createGain();\n\n /**\n * @property {MediaStream|null} stream\n */\n this.stream = null;\n /**\n * @property {MediaStreamAudioSourceNode|null} mediaStream\n */\n this.mediaStream = null;\n /**\n * @property {Number|null} currentSource\n */\n this.currentSource = null;\n\n /**\n * Client must allow browser to access their microphone / audioin source.\n * Default: false. Will become true when the client enables access.\n *\n * @property {Boolean} enabled\n */\n this.enabled = false;\n\n /**\n * Input amplitude, connect to it by default but not to master out\n *\n * @property {p5.Amplitude} amplitude\n */\n this.amplitude = new Amplitude();\n this.output.connect(this.amplitude.input);\n\n if (\n !window.MediaStreamTrack ||\n !window.navigator.mediaDevices ||\n !window.navigator.mediaDevices.getUserMedia\n ) {\n errorCallback\n ? errorCallback()\n : window.alert(\n 'This browser does not support MediaStreamTrack and mediaDevices'\n );\n }\n\n // add to soundArray so we can dispose on close\n p5sound.soundArray.push(this);\n }\n /**\n * Start processing audio input. This enables the use of other\n * AudioIn methods like getLevel(). Note that by default, AudioIn\n * is not connected to p5.sound's output. So you won't hear\n * anything unless you use the connect() method.
\n *\n * Certain browsers limit access to the user's microphone. For example,\n * Chrome only allows access from localhost and over https. For this reason,\n * you may want to include an errorCallback—a function that is called in case\n * the browser won't provide mic access.\n *\n * @method start\n * @for p5.AudioIn\n * @param {Function} [successCallback] Name of a function to call on\n * success.\n * @param {Function} [errorCallback] Name of a function to call if\n * there was an error. For example,\n * some browsers do not support\n * getUserMedia.\n */\n start(successCallback, errorCallback) {\n var self = this;\n\n if (this.stream) {\n this.stop();\n }\n\n // set the audio source\n var audioSource = p5sound.inputSources[self.currentSource];\n var constraints = {\n audio: {\n sampleRate: p5sound.audiocontext.sampleRate,\n echoCancellation: false,\n },\n };\n\n // if developers determine which source to use\n if (p5sound.inputSources[this.currentSource]) {\n constraints.audio.deviceId = audioSource.deviceId;\n }\n\n window.navigator.mediaDevices\n .getUserMedia(constraints)\n .then(function (stream) {\n self.stream = stream;\n self.enabled = true;\n // Wrap a MediaStreamSourceNode around the live input\n self.mediaStream = p5sound.audiocontext.createMediaStreamSource(stream);\n self.mediaStream.connect(self.output);\n // only send to the Amplitude reader, so we can see it but not hear it.\n self.amplitude.setInput(self.output);\n if (successCallback) successCallback();\n })\n .catch(function (err) {\n if (errorCallback) errorCallback(err);\n else console.error(err);\n });\n }\n\n /**\n * Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().\n * If re-starting, the user may be prompted for permission access.\n *\n * @method stop\n * @for p5.AudioIn\n */\n stop() {\n if (this.stream) {\n this.stream.getTracks().forEach(function (track) {\n track.stop();\n });\n\n this.mediaStream.disconnect();\n\n delete this.mediaStream;\n delete this.stream;\n }\n }\n\n /**\n * Connect to an audio unit. If no parameter is provided, will\n * connect to the main output (i.e. your speakers).
\n *\n * @method connect\n * @for p5.AudioIn\n * @param {Object} [unit] An object that accepts audio input,\n * such as an FFT\n */\n connect(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n } else if (unit.hasOwnProperty('analyser')) {\n this.output.connect(unit.analyser);\n } else {\n this.output.connect(unit);\n }\n } else {\n this.output.connect(p5sound.input);\n }\n }\n\n /**\n * Disconnect the AudioIn from all audio units. For example, if\n * connect() had been called, disconnect() will stop sending\n * signal to your speakers.
\n *\n * @method disconnect\n * @for p5.AudioIn\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n // stay connected to amplitude even if not outputting to p5\n this.output.connect(this.amplitude.input);\n }\n }\n\n /**\n * Read the Amplitude (volume level) of an AudioIn. The AudioIn\n * class contains its own instance of the Amplitude class to help\n * make it easy to get a microphone's volume level. Accepts an\n * optional smoothing value (0.0 < 1.0). NOTE: AudioIn must\n * .start() before using .getLevel().
\n *\n * @method getLevel\n * @for p5.AudioIn\n * @param {Number} [smoothing] Smoothing is 0.0 by default.\n * Smooths values based on previous values.\n * @return {Number} Volume level (between 0.0 and 1.0)\n */\n getLevel(smoothing) {\n if (smoothing) {\n this.amplitude.smoothing = smoothing;\n }\n return this.amplitude.getLevel();\n }\n\n /**\n * Set amplitude (volume) of a mic input between 0 and 1.0.
\n *\n * @method amp\n * @for p5.AudioIn\n * @param {Number} vol between 0 and 1.0\n * @param {Number} [time] ramp time (optional)\n */\n amp(vol, t) {\n if (t) {\n var rampTime = t || 0;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\n this.output.gain.setValueAtTime(\n currentVol,\n p5sound.audiocontext.currentTime\n );\n this.output.gain.linearRampToValueAtTime(\n vol,\n rampTime + p5sound.audiocontext.currentTime\n );\n } else {\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\n this.output.gain.setValueAtTime(vol, p5sound.audiocontext.currentTime);\n }\n }\n\n /**\n * Returns a list of available input sources. This is a wrapper\n * for \n * MediaDevices.enumerateDevices() - Web APIs | MDN\n * and it returns a Promise.\n * @method getSources\n * @for p5.AudioIn\n * @param {Function} [successCallback] This callback function handles the sources when they\n * have been enumerated. The callback function\n * receives the deviceList array as its only argument\n * @param {Function} [errorCallback] This optional callback receives the error\n * message as its argument.\n * @returns {Promise} Returns a Promise that can be used in place of the callbacks, similar\n * to the enumerateDevices() method\n * @example\n *
\n * let audioIn;\n *\n * function setup(){\n * text('getting sources...', 0, 20);\n * audioIn = new p5.AudioIn();\n * audioIn.getSources(gotSources);\n * }\n *\n * function gotSources(deviceList) {\n * if (deviceList.length > 0) {\n * //set the source to the first item in the deviceList array\n * audioIn.setSource(0);\n * let currentSource = deviceList[audioIn.currentSource];\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\n * }\n * }\n *
\n */\n getSources(onSuccess, onError) {\n return new Promise(function (resolve, reject) {\n window.navigator.mediaDevices\n .enumerateDevices()\n .then(function (devices) {\n p5sound.inputSources = devices.filter(function (device) {\n return device.kind === 'audioinput';\n });\n resolve(p5sound.inputSources);\n if (onSuccess) {\n onSuccess(p5sound.inputSources);\n }\n })\n .catch(function (error) {\n reject(error);\n if (onError) {\n onError(error);\n } else {\n console.error(\n 'This browser does not support MediaStreamTrack.getSources()'\n );\n }\n });\n });\n }\n\n /**\n * Set the input source. Accepts a number representing a\n * position in the array returned by getSources().\n * This is only available in browsers that support\n * \n * navigator.mediaDevices.enumerateDevices()\n *\n * @method setSource\n * @for p5.AudioIn\n * @param {number} num position of input source in the array\n * @example\n *
\n * let audioIn;\n *\n * function setup(){\n * text('getting sources...', 0, 20);\n * audioIn = new p5.AudioIn();\n * audioIn.getSources(gotSources);\n * }\n *\n * function gotSources(deviceList) {\n * if (deviceList.length > 0) {\n * //set the source to the first item in the deviceList array\n * audioIn.setSource(0);\n * let currentSource = deviceList[audioIn.currentSource];\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\n * }\n * }\n *
\n */\n setSource(num) {\n if (p5sound.inputSources.length > 0 && num < p5sound.inputSources.length) {\n // set the current source\n this.currentSource = num;\n console.log('set source to ', p5sound.inputSources[this.currentSource]);\n } else {\n console.log('unable to set input source');\n }\n\n // restart stream if currently active\n if (this.stream && this.stream.active) {\n this.start();\n }\n }\n\n // private method\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.stop();\n\n if (this.output) {\n this.output.disconnect();\n }\n if (this.amplitude) {\n this.amplitude.disconnect();\n }\n delete this.amplitude;\n delete this.output;\n }\n}\n\nexport default AudioIn;\n","import p5sound from './main';\nimport CrossFade from 'Tone/component/CrossFade.js';\n\n/**\n * Effect is a base class for audio effects in p5.
\n * This module handles the nodes and methods that are\n * common and useful for current and future effects.\n *\n *\n * This class is extended by p5.Distortion,\n * p5.Compressor,\n * p5.Delay,\n * p5.Filter,\n * p5.Reverb.\n *\n * @class p5.Effect\n * @constructor\n *\n * @param {Object} [ac] Reference to the audio context of the p5 object\n * @param {AudioNode} [input] Gain Node effect wrapper\n * @param {AudioNode} [output] Gain Node effect wrapper\n * @param {Object} [_drywet] Tone.JS CrossFade node (defaults to value: 1)\n * @param {AudioNode} [wet] Effects that extend this class should connect\n * to the wet signal to this gain node, so that dry and wet\n * signals are mixed properly.\n */\nclass Effect {\n constructor() {\n this.ac = p5sound.audiocontext;\n\n this.input = this.ac.createGain();\n this.output = this.ac.createGain();\n\n /**\n *\tThe p5.Effect class is built\n * \tusing Tone.js CrossFade\n * \t@private\n */\n\n this._drywet = new CrossFade(1);\n\n /**\n *\tIn classes that extend\n *\tp5.Effect, connect effect nodes\n *\tto the wet parameter\n */\n this.wet = this.ac.createGain();\n\n this.input.connect(this._drywet.a);\n this.wet.connect(this._drywet.b);\n this._drywet.connect(this.output);\n\n this.connect();\n\n //Add to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Set the output volume of the filter.\n *\n * @method amp\n * @for p5.Effect\n * @param {Number} [vol] amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts until rampTime\n * @param {Number} [tFromNow] schedule this event to happen in tFromNow seconds\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n const now = p5sound.audiocontext.currentTime;\n const startTime = now + tFromNow;\n const endTime = startTime + rampTime + 0.001;\n const currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now);\n this.output.gain.linearRampToValueAtTime(currentVol, startTime + 0.001);\n this.output.gain.linearRampToValueAtTime(vol, endTime);\n }\n\n /**\n * Link effects together in a chain\n * Example usage: filter.chain(reverb, delay, panner);\n * May be used with an open-ended number of arguments\n *\n * @method chain\n * @for p5.Effect\n * @param {Object} [arguments] Chain together multiple sound objects\n */\n chain() {\n if (arguments.length > 0) {\n this.connect(arguments[0]);\n for (var i = 1; i < arguments.length; i += 1) {\n arguments[i - 1].connect(arguments[i]);\n }\n }\n return this;\n }\n\n /**\n * Adjust the dry/wet value.\n *\n * @method drywet\n * @for p5.Effect\n * @param {Number} [fade] The desired drywet value (0 - 1.0)\n */\n drywet(fade) {\n if (typeof fade !== 'undefined') {\n this._drywet.fade.value = fade;\n }\n return this._drywet.fade.value;\n }\n\n /**\n * Send output to a p5.js-sound, Web Audio Node, or use signal to\n * control an AudioParam\n *\n * @method connect\n * @for p5.Effect\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5.soundOut.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all output.\n * @method disconnect\n * @for p5.Effect\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n dispose() {\n // remove refernce form soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n\n if (this._drywet) {\n this._drywet.disconnect();\n delete this._drywet;\n }\n\n if (this.wet) {\n this.wet.disconnect();\n delete this.wet;\n }\n\n this.ac = undefined;\n }\n}\n\nexport default Effect;\n","import Effect from './effect';\n\n/**\n *

A p5.Filter uses a Web Audio Biquad Filter to filter\n * the frequency response of an input source. Subclasses\n * include:

\n * p5.LowPass:\n * Allows frequencies below the cutoff frequency to pass through,\n * and attenuates frequencies above the cutoff.
\n * p5.HighPass:\n * The opposite of a lowpass filter.
\n * p5.BandPass:\n * Allows a range of frequencies to pass through and attenuates\n * the frequencies below and above this frequency range.
\n *\n * The .res() method controls either width of the\n * bandpass, or resonance of the low/highpass cutoff frequency.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Filter\n * @extends p5.Effect\n * @constructor\n * @param {String} [type] 'lowpass' (default), 'highpass', 'bandpass'\n * @example\n *
\n * let fft, noise, filter;\n *\n * function setup() {\n * let cnv = createCanvas(100,100);\n * cnv.mousePressed(makeNoise);\n * fill(255, 0, 255);\n *\n * filter = new p5.BandPass();\n * noise = new p5.Noise();\n * noise.disconnect();\n * noise.connect(filter);\n *\n * fft = new p5.FFT();\n * }\n *\n * function draw() {\n * background(220);\n *\n * // set the BandPass frequency based on mouseX\n * let freq = map(mouseX, 0, width, 20, 10000);\n * freq = constrain(freq, 0, 22050);\n * filter.freq(freq);\n * // give the filter a narrow band (lower res = wider bandpass)\n * filter.res(50);\n *\n * // draw filtered spectrum\n * let spectrum = fft.analyze();\n * noStroke();\n * for (let i = 0; i < spectrum.length; i++) {\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width/spectrum.length, h);\n * }\n * if (!noise.started) {\n * text('tap here and drag to change frequency', 10, 20, width - 20);\n * } else {\n * text('Frequency: ' + round(freq)+'Hz', 20, 20, width - 20);\n * }\n * }\n *\n * function makeNoise() {\n * // see also: `userStartAudio()`\n * noise.start();\n * noise.amp(0.5, 0.2);\n * }\n *\n * function mouseReleased() {\n * noise.amp(0, 0.2);\n * }\n *\n *
\n */\nclass Filter extends Effect {\n constructor(type) {\n super();\n //add extend Effect by adding a Biquad Filter\n\n /**\n * The p5.Filter is built with a\n * \n * Web Audio BiquadFilter Node.\n *\n * @property {DelayNode} biquadFilter\n */\n\n this.biquad = this.ac.createBiquadFilter();\n\n this.input.connect(this.biquad);\n\n this.biquad.connect(this.wet);\n\n if (type) {\n this.setType(type);\n }\n\n //Properties useful for the toggle method.\n this._on = true;\n this._untoggledType = this.biquad.type;\n }\n\n /**\n * Filter an audio signal according to a set\n * of filter parameters.\n *\n * @method process\n * @param {Object} Signal An object that outputs audio\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\n * @param {Number} [res] Resonance/Width of the filter frequency\n * from 0.001 to 1000\n */\n process(src, freq, res, time) {\n src.connect(this.input);\n this.set(freq, res, time);\n }\n\n /**\n * Set the frequency and the resonance of the filter.\n *\n * @method set\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\n * @param {Number} [res] Resonance (Q) from 0.001 to 1000\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n set(freq, res, time) {\n if (freq) {\n this.freq(freq, time);\n }\n if (res) {\n this.res(res, time);\n }\n }\n\n /**\n * Set the filter frequency, in Hz, from 10 to 22050 (the range of\n * human hearing, although in reality most people hear in a narrower\n * range).\n *\n * @method freq\n * @param {Number} freq Filter Frequency\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {Number} value Returns the current frequency value\n */\n freq(freq, time) {\n var t = time || 0;\n if (freq <= 0) {\n freq = 1;\n }\n if (typeof freq === 'number') {\n this.biquad.frequency.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.biquad.frequency.exponentialRampToValueAtTime(\n freq,\n this.ac.currentTime + 0.02 + t\n );\n } else if (freq) {\n freq.connect(this.biquad.frequency);\n }\n return this.biquad.frequency.value;\n }\n\n /**\n * Controls either width of a bandpass frequency,\n * or the resonance of a low/highpass cutoff frequency.\n *\n * @method res\n * @param {Number} res Resonance/Width of filter freq\n * from 0.001 to 1000\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {Number} value Returns the current res value\n */\n res(res, time) {\n var t = time || 0;\n if (typeof res === 'number') {\n this.biquad.Q.value = res;\n this.biquad.Q.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.biquad.Q.linearRampToValueAtTime(\n res,\n this.ac.currentTime + 0.02 + t\n );\n } else if (res) {\n res.connect(this.biquad.Q);\n }\n return this.biquad.Q.value;\n }\n\n /**\n * Controls the gain attribute of a Biquad Filter.\n * This is distinctly different from .amp() which is inherited from p5.Effect\n * .amp() controls the volume via the output gain node\n * p5.Filter.gain() controls the gain parameter of a Biquad Filter node.\n *\n * @method gain\n * @param {Number} gain\n * @return {Number} Returns the current or updated gain value\n */\n gain(gain, time) {\n var t = time || 0;\n if (typeof gain === 'number') {\n this.biquad.gain.value = gain;\n this.biquad.gain.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.biquad.gain.linearRampToValueAtTime(\n gain,\n this.ac.currentTime + 0.02 + t\n );\n } else if (gain) {\n gain.connect(this.biquad.gain);\n }\n return this.biquad.gain.value;\n }\n\n /**\n * Toggle function. Switches between the specified type and allpass\n *\n * @method toggle\n * @return {boolean} [Toggle value]\n */\n toggle() {\n this._on = !this._on;\n\n if (this._on === true) {\n this.biquad.type = this._untoggledType;\n } else if (this._on === false) {\n this.biquad.type = 'allpass';\n }\n\n return this._on;\n }\n\n /**\n * Set the type of a p5.Filter. Possible types include:\n * \"lowpass\" (default), \"highpass\", \"bandpass\",\n * \"lowshelf\", \"highshelf\", \"peaking\", \"notch\",\n * \"allpass\".\n *\n * @method setType\n * @param {String} t\n */\n setType(t) {\n this.biquad.type = t;\n this._untoggledType = this.biquad.type;\n }\n\n dispose() {\n // remove reference from soundArray\n super.dispose();\n if (this.biquad) {\n this.biquad.disconnect();\n delete this.biquad;\n }\n }\n}\n\n/**\n * Constructor: new p5.LowPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('lowpass').\n * See p5.Filter for methods.\n *\n * @class p5.LowPass\n * @constructor\n * @extends p5.Filter\n */\nclass LowPass extends Filter {\n constructor() {\n super('lowpass');\n }\n}\n\n/**\n * Constructor: new p5.HighPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('highpass').\n * See p5.Filter for methods.\n *\n * @class p5.HighPass\n * @constructor\n * @extends p5.Filter\n */\nclass HighPass extends Filter {\n constructor() {\n super('highpass');\n }\n}\n\n/**\n * Constructor: new p5.BandPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('bandpass').\n * See p5.Filter for methods.\n *\n * @class p5.BandPass\n * @constructor\n * @extends p5.Filter\n */\nclass BandPass extends Filter {\n constructor() {\n super('bandpass');\n }\n}\nexport default Filter;\nexport { LowPass, HighPass, BandPass };\n","import Filter from './filter';\nimport p5sound from './main';\n\n/**\n * EQFilter extends p5.Filter with constraints\n * necessary for the p5.EQ\n *\n * @private\n */\nclass EQFilter extends Filter {\n constructor(freq, res) {\n super('peaking');\n\n this.disconnect();\n this.set(freq, res);\n this.biquad.gain.value = 0;\n delete this.input;\n delete this.output;\n delete this._drywet;\n delete this.wet;\n }\n\n amp() {\n console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');\n }\n\n drywet() {\n console.warn('`drywet()` is not available for p5.EQ bands.');\n }\n\n connect(unit) {\n var u = unit || p5.soundOut.input;\n if (this.biquad) {\n this.biquad.connect(u.input ? u.input : u);\n } else {\n this.output.connect(u.input ? u.input : u);\n }\n }\n disconnect() {\n if (this.biquad) {\n this.biquad.disconnect();\n }\n }\n\n dispose() {\n // remove reference form soundArray\n const index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n this.disconnect();\n delete this.biquad;\n }\n}\n\nexport default EQFilter;\n","import Effect from './effect';\nimport EQFilter from './eqFilter';\n\n/**\n * p5.EQ is an audio effect that performs the function of a multiband\n * audio equalizer. Equalization is used to adjust the balance of\n * frequency compoenents of an audio signal. This process is commonly used\n * in sound production and recording to change the waveform before it reaches\n * a sound output device. EQ can also be used as an audio effect to create\n * interesting distortions by filtering out parts of the spectrum. p5.EQ is\n * built using a chain of Web Audio Biquad Filter Nodes and can be\n * instantiated with 3 or 8 bands. Bands can be added or removed from\n * the EQ by directly modifying p5.EQ.bands (the array that stores filters).\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.EQ\n * @constructor\n * @extends p5.Effect\n * @param {Number} [_eqsize] Constructor will accept 3 or 8, defaults to 3\n * @return {Object} p5.EQ object\n *\n * @example\n *
\n * let eq, soundFile\n * let eqBandIndex = 0;\n * let eqBandNames = ['lows', 'mids', 'highs'];\n *\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * soundFile = loadSound('assets/beat');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(toggleSound);\n *\n * eq = new p5.EQ(eqBandNames.length);\n * soundFile.disconnect();\n * eq.process(soundFile);\n * }\n *\n * function draw() {\n * background(30);\n * noStroke();\n * fill(255);\n * textAlign(CENTER);\n * text('filtering ', 50, 25);\n *\n * fill(255, 40, 255);\n * textSize(26);\n * text(eqBandNames[eqBandIndex], 50, 55);\n *\n * fill(255);\n * textSize(9);\n *\n * if (!soundFile.isPlaying()) {\n * text('tap to play', 50, 80);\n * } else {\n * text('tap to filter next band', 50, 80)\n * }\n * }\n *\n * function toggleSound() {\n * if (!soundFile.isPlaying()) {\n * soundFile.play();\n * } else {\n * eqBandIndex = (eqBandIndex + 1) % eq.bands.length;\n * }\n *\n * for (let i = 0; i < eq.bands.length; i++) {\n * eq.bands[i].gain(0);\n * }\n * // filter the band we want to filter\n * eq.bands[eqBandIndex].gain(-40);\n * }\n *
\n */\nclass EQ extends Effect {\n constructor(_eqsize) {\n super();\n\n //p5.EQ can be of size (3) or (8), defaults to 3\n _eqsize = _eqsize === 3 || _eqsize === 8 ? _eqsize : 3;\n\n var factor;\n _eqsize === 3 ? (factor = Math.pow(2, 3)) : (factor = 2);\n\n /**\n * The p5.EQ is built with abstracted p5.Filter objects.\n * To modify any bands, use methods of the \n * p5.Filter API, especially `gain` and `freq`.\n * Bands are stored in an array, with indices 0 - 3, or 0 - 7\n * @property {Array} bands\n *\n */\n this.bands = [];\n\n var freq, res;\n for (var i = 0; i < _eqsize; i++) {\n if (i === _eqsize - 1) {\n freq = 21000;\n res = 0.01;\n } else if (i === 0) {\n freq = 100;\n res = 0.1;\n } else if (i === 1) {\n freq = _eqsize === 3 ? 360 * factor : 360;\n res = 1;\n } else {\n freq = this.bands[i - 1].freq() * factor;\n res = 1;\n }\n this.bands[i] = this._newBand(freq, res);\n\n if (i > 0) {\n this.bands[i - 1].connect(this.bands[i].biquad);\n } else {\n this.input.connect(this.bands[i].biquad);\n }\n }\n this.bands[_eqsize - 1].connect(this.output);\n }\n\n /**\n * Process an input by connecting it to the EQ\n * @method process\n * @param {Object} src Audio source\n */\n process(src) {\n src.connect(this.input);\n }\n\n // /**\n // * Set the frequency and gain of each band in the EQ. This method should be\n // * called with 3 or 8 frequency and gain pairs, depending on the size of the EQ.\n // * ex. eq.set(freq0, gain0, freq1, gain1, freq2, gain2);\n // *\n // * @method set\n // * @for p5.EQ\n // * @param {Number} [freq0] Frequency value for band with index 0\n // * @param {Number} [gain0] Gain value for band with index 0\n // * @param {Number} [freq1] Frequency value for band with index 1\n // * @param {Number} [gain1] Gain value for band with index 1\n // * @param {Number} [freq2] Frequency value for band with index 2\n // * @param {Number} [gain2] Gain value for band with index 2\n // * @param {Number} [freq3] Frequency value for band with index 3\n // * @param {Number} [gain3] Gain value for band with index 3\n // * @param {Number} [freq4] Frequency value for band with index 4\n // * @param {Number} [gain4] Gain value for band with index 4\n // * @param {Number} [freq5] Frequency value for band with index 5\n // * @param {Number} [gain5] Gain value for band with index 5\n // * @param {Number} [freq6] Frequency value for band with index 6\n // * @param {Number} [gain6] Gain value for band with index 6\n // * @param {Number} [freq7] Frequency value for band with index 7\n // * @param {Number} [gain7] Gain value for band with index 7\n // */\n set() {\n if (arguments.length === this.bands.length * 2) {\n for (var i = 0; i < arguments.length; i += 2) {\n this.bands[i / 2].freq(arguments[i]);\n this.bands[i / 2].gain(arguments[i + 1]);\n }\n } else {\n console.error(\n 'Argument mismatch. .set() should be called with ' +\n this.bands.length * 2 +\n ' arguments. (one frequency and gain value pair for each band of the eq)'\n );\n }\n }\n\n /**\n * Add a new band. Creates a p5.Filter and strips away everything but\n * the raw biquad filter. This method returns an abstracted p5.Filter,\n * which can be added to p5.EQ.bands, in order to create new EQ bands.\n * @private\n * @for p5.EQ\n * @method _newBand\n * @param {Number} freq\n * @param {Number} res\n * @return {Object} Abstracted Filter\n */\n _newBand(freq, res) {\n return new EQFilter(freq, res);\n }\n\n dispose() {\n super.dispose();\n\n if (this.bands) {\n while (this.bands.length > 0) {\n delete this.bands.pop().dispose();\n }\n delete this.bands;\n }\n }\n}\nexport default EQ;\n","import p5sound from './main';\n\n// /**\n// * listener is a class that can construct both a Spatial Panner\n// * and a Spatial Listener. The panner is based on the\n// * Web Audio Spatial Panner Node\n// * https://www.w3.org/TR/webaudio/#the-listenernode-interface\n// * This panner is a spatial processing node that allows audio to be positioned\n// * and oriented in 3D space.\n// *\n// * The Listener modifies the properties of the Audio Context Listener.\n// * Both objects types use the same methods. The default is a spatial panner.\n// *\n// * p5.Panner3D - Constructs a Spatial Panner
\n// * p5.Listener3D - Constructs a Spatial Listener
\n// *\n// * @class listener\n// * @constructor\n// * @return {Object} p5.Listener3D Object\n// *\n// * @param {Web Audio Node} listener Web Audio Spatial Panning Node\n// * @param {AudioParam} listener.panningModel \"equal power\" or \"HRTF\"\n// * @param {AudioParam} listener.distanceModel \"linear\", \"inverse\", or \"exponential\"\n// * @param {String} [type] [Specify construction of a spatial panner or listener]\n// */\n\nclass Listener3D {\n constructor(type) {\n this.ac = p5sound.audiocontext;\n this.listener = this.ac.listener;\n }\n\n // /**\n // * Connect an audio sorce\n // * @param {Object} src Input source\n // */\n process(src) {\n src.connect(this.input);\n }\n // /**\n // * Set the X,Y,Z position of the Panner\n // * @param {[Number]} xVal\n // * @param {[Number]} yVal\n // * @param {[Number]} zVal\n // * @param {[Number]} time\n // * @return {[Array]} [Updated x, y, z values as an array]\n // */\n position(xVal, yVal, zVal, time) {\n this.positionX(xVal, time);\n this.positionY(yVal, time);\n this.positionZ(zVal, time);\n return [\n this.listener.positionX.value,\n this.listener.positionY.value,\n this.listener.positionZ.value,\n ];\n }\n\n // /**\n // * Getter and setter methods for position coordinates\n // * @return {Number} [updated coordinate value]\n // */\n positionX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.positionX.value = xVal;\n this.listener.positionX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.positionX);\n }\n return this.listener.positionX.value;\n }\n positionY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.positionY.value = yVal;\n this.listener.positionY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.positionY);\n }\n return this.listener.positionY.value;\n }\n positionZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.positionZ.value = zVal;\n this.listener.positionZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.positionZ);\n }\n return this.listener.positionZ.value;\n }\n\n // cannot define method when class definition is commented\n // /**\n // * Overrides the listener orient() method because Listener has slightly\n // * different params. In human terms, Forward vectors are the direction the\n // * nose is pointing. Up vectors are the direction of the top of the head.\n // *\n // * @method orient\n // * @param {Number} xValF Forward vector X direction\n // * @param {Number} yValF Forward vector Y direction\n // * @param {Number} zValF Forward vector Z direction\n // * @param {Number} xValU Up vector X direction\n // * @param {Number} yValU Up vector Y direction\n // * @param {Number} zValU Up vector Z direction\n // * @param {Number} time\n // * @return {Array} All orienation params\n // */\n orient(xValF, yValF, zValF, xValU, yValU, zValU, time) {\n if (arguments.length === 3 || arguments.length === 4) {\n time = arguments[3];\n this.orientForward(xValF, yValF, zValF, time);\n } else if (arguments.length === 6 || arguments === 7) {\n this.orientForward(xValF, yValF, zValF);\n this.orientUp(xValU, yValU, zValU, time);\n }\n\n return [\n this.listener.forwardX.value,\n this.listener.forwardY.value,\n this.listener.forwardZ.value,\n this.listener.upX.value,\n this.listener.upY.value,\n this.listener.upZ.value,\n ];\n }\n\n orientForward(xValF, yValF, zValF, time) {\n this.forwardX(xValF, time);\n this.forwardY(yValF, time);\n this.forwardZ(zValF, time);\n\n return [\n this.listener.forwardX,\n this.listener.forwardY,\n this.listener.forwardZ,\n ];\n }\n\n orientUp(xValU, yValU, zValU, time) {\n this.upX(xValU, time);\n this.upY(yValU, time);\n this.upZ(zValU, time);\n\n return [this.listener.upX, this.listener.upY, this.listener.upZ];\n }\n // /**\n // * Getter and setter methods for orient coordinates\n // * @return {Number} [updated coordinate value]\n // */\n forwardX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.forwardX.value = xVal;\n this.listener.forwardX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.forwardX);\n }\n return this.listener.forwardX.value;\n }\n forwardY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.forwardY.value = yVal;\n this.listener.forwardY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.forwardY);\n }\n return this.listener.forwardY.value;\n }\n forwardZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.forwardZ.value = zVal;\n this.listener.forwardZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.forwardZ);\n }\n return this.listener.forwardZ.value;\n }\n upX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.upX.value = xVal;\n this.listener.upX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.upX);\n }\n return this.listener.upX.value;\n }\n upY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.upY.value = yVal;\n this.listener.upY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.upY);\n }\n return this.listener.upY.value;\n }\n upZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.upZ.value = zVal;\n this.listener.upZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.upZ);\n }\n return this.listener.upZ.value;\n }\n}\n\nexport default Listener3D;\n","import Effect from './effect';\n\n/**\n * Panner3D is based on the \n * Web Audio Spatial Panner Node.\n * This panner is a spatial processing node that allows audio to be positioned\n * and oriented in 3D space.\n *\n * The position is relative to an \n * Audio Context Listener, which can be accessed\n * by p5.soundOut.audiocontext.listener\n *\n *\n * @class p5.Panner3D\n * @constructor\n */\n\nclass Panner3D extends Effect {\n constructor() {\n super();\n /**\n * \n * Web Audio Spatial Panner Node\n *\n * Properties include
\n * [Panning Model](https://www.w3.org/TR/webaudio/#idl-def-PanningModelType)\n * : \"equal power\" or \"HRTF\"
\n * [DistanceModel](https://www.w3.org/TR/webaudio/#idl-def-DistanceModelType)\n * : \"linear\", \"inverse\", or \"exponential\"\n *\n * @property {AudioNode} panner\n *\n */\n this.panner = this.ac.createPanner();\n this.panner.panningModel = 'HRTF';\n this.panner.distanceModel = 'linear';\n this.panner.connect(this.output);\n this.input.connect(this.panner);\n }\n\n /**\n * Connect an audio sorce\n *\n * @method process\n * @for p5.Panner3D\n * @param {Object} src Input source\n */\n process(src) {\n src.connect(this.input);\n }\n /**\n * Set the X,Y,Z position of the Panner\n * @method set\n * @for p5.Panner3D\n * @param {Number} xVal\n * @param {Number} yVal\n * @param {Number} zVal\n * @param {Number} time\n * @return {Array} Updated x, y, z values as an array\n */\n set(xVal, yVal, zVal, time) {\n this.positionX(xVal, time);\n this.positionY(yVal, time);\n this.positionZ(zVal, time);\n return [\n this.panner.positionX.value,\n this.panner.positionY.value,\n this.panner.positionZ.value,\n ];\n }\n\n /**\n * Getter and setter methods for position coordinates\n * @method positionX\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for position coordinates\n * @method positionY\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for position coordinates\n * @method positionZ\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n positionX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.positionX.value = xVal;\n this.panner.positionX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.panner.positionX);\n }\n return this.panner.positionX.value;\n }\n positionY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.positionY.value = yVal;\n this.panner.positionY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.panner.positionY);\n }\n return this.panner.positionY.value;\n }\n positionZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.positionZ.value = zVal;\n this.panner.positionZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.panner.positionZ);\n }\n return this.panner.positionZ.value;\n }\n\n /**\n * Set the X,Y,Z position of the Panner\n * @method orient\n * @for p5.Panner3D\n * @param {Number} xVal\n * @param {Number} yVal\n * @param {Number} zVal\n * @param {Number} time\n * @return {Array} Updated x, y, z values as an array\n */\n orient(xVal, yVal, zVal, time) {\n this.orientX(xVal, time);\n this.orientY(yVal, time);\n this.orientZ(zVal, time);\n return [\n this.panner.orientationX.value,\n this.panner.orientationY.value,\n this.panner.orientationZ.value,\n ];\n }\n\n /**\n * Getter and setter methods for orient coordinates\n * @method orientX\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for orient coordinates\n * @method orientY\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for orient coordinates\n * @method orientZ\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n orientX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.orientationX.value = xVal;\n this.panner.orientationX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.panner.orientationX);\n }\n return this.panner.orientationX.value;\n }\n orientY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.orientationY.value = yVal;\n this.panner.orientationY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.panner.orientationY);\n }\n return this.panner.orientationY.value;\n }\n orientZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.orientationZ.value = zVal;\n this.panner.orientationZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.panner.orientationZ);\n }\n return this.panner.orientationZ.value;\n }\n\n /**\n * Set the rolloff factor and max distance\n * @method setFalloff\n * @for p5.Panner3D\n * @param {Number} [maxDistance]\n * @param {Number} [rolloffFactor]\n */\n setFalloff(maxDistance, rolloffFactor) {\n this.maxDist(maxDistance);\n this.rolloff(rolloffFactor);\n }\n /**\n * Maxium distance between the source and the listener\n * @method maxDist\n * @for p5.Panner3D\n * @param {Number} maxDistance\n * @return {Number} updated value\n */\n maxDist(maxDistance) {\n if (typeof maxDistance === 'number') {\n this.panner.maxDistance = maxDistance;\n }\n return this.panner.maxDistance;\n }\n\n /**\n * How quickly the volume is reduced as the source moves away from the listener\n * @method rollof\n * @for p5.Panner3D\n * @param {Number} rolloffFactor\n * @return {Number} updated value\n */\n rolloff(rolloffFactor) {\n if (typeof rolloffFactor === 'number') {\n this.panner.rolloffFactor = rolloffFactor;\n }\n return this.panner.rolloffFactor;\n }\n\n dispose() {\n super.dispose();\n if (this.panner) {\n this.panner.disconnect();\n delete this.panner;\n }\n }\n}\n\nexport default Panner3D;\n","import Filter from './filter';\nimport Effect from './effect';\n\n/**\n * Delay is an echo effect. It processes an existing sound source,\n * and outputs a delayed version of that sound. The p5.Delay can\n * produce different effects depending on the delayTime, feedback,\n * filter, and type. In the example below, a feedback of 0.5 (the\n * default value) will produce a looping delay that decreases in\n * volume by 50% each repeat. A filter will cut out the high\n * frequencies so that the delay does not sound as piercing as the\n * original source.\n *\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n * @class p5.Delay\n * @extends p5.Effect\n * @constructor\n * @example\n *
\n * let osc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * osc = new p5.Oscillator('square');\n * osc.amp(0.5);\n * delay = new p5.Delay();\n *\n * // delay.process() accepts 4 parameters:\n * // source, delayTime (in seconds), feedback, filter frequency\n * delay.process(osc, 0.12, .7, 2300);\n *\n * cnv.mousePressed(oscStart);\n * }\n *\n * function oscStart() {\n * osc.start();\n * }\n *\n * function mouseReleased() {\n * osc.stop();\n * }\n *
\n */\nclass Delay extends Effect {\n constructor() {\n super();\n\n this._split = this.ac.createChannelSplitter(2);\n this._merge = this.ac.createChannelMerger(2);\n\n this._leftGain = this.ac.createGain();\n this._rightGain = this.ac.createGain();\n /**\n * The p5.Delay is built with two\n * \n * Web Audio Delay Nodes, one for each stereo channel.\n *\n * @for p5.Delay\n * @property {DelayNode} leftDelay\n */\n this.leftDelay = this.ac.createDelay();\n /**\n * The p5.Delay is built with two\n * \n * Web Audio Delay Nodes, one for each stereo channel.\n * @for p5.Delay\n * @property {DelayNode} rightDelay\n */\n this.rightDelay = this.ac.createDelay();\n\n this._leftFilter = new Filter();\n this._rightFilter = new Filter();\n this._leftFilter.disconnect();\n this._rightFilter.disconnect();\n\n this._leftFilter.biquad.frequency.setValueAtTime(1200, this.ac.currentTime);\n this._rightFilter.biquad.frequency.setValueAtTime(\n 1200,\n this.ac.currentTime\n );\n this._leftFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\n this._rightFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\n\n // graph routing\n this.input.connect(this._split);\n this.leftDelay.connect(this._leftGain);\n this.rightDelay.connect(this._rightGain);\n this._leftGain.connect(this._leftFilter.input);\n this._rightGain.connect(this._rightFilter.input);\n this._merge.connect(this.wet);\n\n this._leftFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\n this._rightFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\n\n // default routing\n this.setType(0);\n\n this._maxDelay = this.leftDelay.delayTime.maxValue;\n\n // set initial feedback to 0.5\n this.feedback(0.5);\n }\n /**\n * Add delay to an audio signal according to a set\n * of delay parameters.\n *\n * @method process\n * @for p5.Delay\n * @param {Object} Signal An object that outputs audio\n * @param {Number} [delayTime] Time (in seconds) of the delay/echo.\n * Some browsers limit delayTime to\n * 1 second.\n * @param {Number} [feedback] sends the delay back through itself\n * in a loop that decreases in volume\n * each time.\n * @param {Number} [lowPass] Cutoff frequency. Only frequencies\n * below the lowPass will be part of the\n * delay.\n */\n process(src, _delayTime, _feedback, _filter) {\n var feedback = _feedback || 0;\n var delayTime = _delayTime || 0;\n if (feedback >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n }\n if (delayTime >= this._maxDelay) {\n throw new Error(\n 'Delay Time exceeds maximum delay time of ' +\n this._maxDelay +\n ' second.'\n );\n }\n\n src.connect(this.input);\n this.leftDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\n this.rightDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\n this._leftGain.gain.value = feedback;\n this._rightGain.gain.value = feedback;\n\n if (_filter) {\n this._leftFilter.freq(_filter);\n this._rightFilter.freq(_filter);\n }\n }\n\n /**\n * Set the delay (echo) time, in seconds. Usually this value will be\n * a floating point number between 0.0 and 1.0.\n *\n * @method delayTime\n * @for p5.Delay\n * @param {Number} delayTime Time (in seconds) of the delay\n */\n delayTime(t) {\n // if t is an audio node...\n if (typeof t !== 'number') {\n t.connect(this.leftDelay.delayTime);\n t.connect(this.rightDelay.delayTime);\n } else {\n this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\n this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\n this.leftDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\n this.rightDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\n }\n }\n\n /**\n * Feedback occurs when Delay sends its signal back through its input\n * in a loop. The feedback amount determines how much signal to send each\n * time through the loop. A feedback greater than 1.0 is not desirable because\n * it will increase the overall output each time through the loop,\n * creating an infinite feedback loop. The default value is 0.5\n *\n * @method feedback\n * @for p5.Delay\n * @param {Number|Object} feedback 0.0 to 1.0, or an object such as an\n * Oscillator that can be used to\n * modulate this param\n * @returns {Number} Feedback value\n *\n */\n feedback(f) {\n // if f is an audio node...\n if (f && typeof f !== 'number') {\n f.connect(this._leftGain.gain);\n f.connect(this._rightGain.gain);\n } else if (f >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n } else if (typeof f === 'number') {\n this._leftGain.gain.value = f;\n this._rightGain.gain.value = f;\n }\n\n // return value of feedback\n return this._leftGain.gain.value;\n }\n\n /**\n * Set a lowpass filter frequency for the delay. A lowpass filter\n * will cut off any frequencies higher than the filter frequency.\n *\n * @method filter\n * @for p5.Delay\n * @param {Number|Object} cutoffFreq A lowpass filter will cut off any\n * frequencies higher than the filter frequency.\n * @param {Number|Object} res Resonance of the filter frequency\n * cutoff, or an object (i.e. a p5.Oscillator)\n * that can be used to modulate this parameter.\n * High numbers (i.e. 15) will produce a resonance,\n * low numbers (i.e. .2) will produce a slope.\n */\n filter(freq, q) {\n this._leftFilter.set(freq, q);\n this._rightFilter.set(freq, q);\n }\n\n /**\n * Choose a preset type of delay. 'pingPong' bounces the signal\n * from the left to the right channel to produce a stereo effect.\n * Any other parameter will revert to the default delay setting.\n *\n * @method setType\n * @for p5.Delay\n * @param {String|Number} type 'pingPong' (1) or 'default' (0)\n */\n setType(t) {\n if (t === 1) {\n t = 'pingPong';\n }\n this._split.disconnect();\n this._leftFilter.disconnect();\n this._rightFilter.disconnect();\n this._split.connect(this.leftDelay, 0);\n this._split.connect(this.rightDelay, 1);\n switch (t) {\n case 'pingPong':\n this._rightFilter.setType(this._leftFilter.biquad.type);\n this._leftFilter.output.connect(this._merge, 0, 0);\n this._rightFilter.output.connect(this._merge, 0, 1);\n this._leftFilter.output.connect(this.rightDelay);\n this._rightFilter.output.connect(this.leftDelay);\n break;\n default:\n this._leftFilter.output.connect(this._merge, 0, 0);\n this._rightFilter.output.connect(this._merge, 0, 1);\n this._leftFilter.output.connect(this.leftDelay);\n this._rightFilter.output.connect(this.rightDelay);\n }\n }\n\n // DocBlocks for methods inherited from p5.Effect\n /**\n * Set the output level of the delay effect.\n *\n * @method amp\n * @for p5.Delay\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Delay\n * @param {Object} unit\n */\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Delay\n */\n\n dispose() {\n super.dispose();\n\n this._split.disconnect();\n this._leftFilter.dispose();\n this._rightFilter.dispose();\n this._merge.disconnect();\n this._leftGain.disconnect();\n this._rightGain.disconnect();\n this.leftDelay.disconnect();\n this.rightDelay.disconnect();\n\n this._split = undefined;\n this._leftFilter = undefined;\n this._rightFilter = undefined;\n this._merge = undefined;\n this._leftGain = undefined;\n this._rightGain = undefined;\n this.leftDelay = undefined;\n this.rightDelay = undefined;\n }\n}\n\nexport default Delay;\n","import { getAudioContext } from './audiocontext';\nimport CustomError from './errorHandler';\nimport Effect from './effect';\n\n/**\n * Reverb adds depth to a sound through a large number of decaying\n * echoes. It creates the perception that sound is occurring in a\n * physical space. The p5.Reverb has paramters for Time (how long does the\n * reverb last) and decayRate (how much the sound decays with each echo)\n * that can be set with the .set() or .process() methods. The p5.Convolver\n * extends p5.Reverb allowing you to recreate the sound of actual physical\n * spaces through convolution.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Reverb\n * @extends p5.Effect\n * @constructor\n * @example\n *
\n * let soundFile, reverb;\n * function preload() {\n * soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n *\n * reverb = new p5.Reverb();\n * soundFile.disconnect(); // so we'll only hear reverb...\n *\n * // connect soundFile to reverb, process w/\n * // 3 second reverbTime, decayRate of 2%\n * reverb.process(soundFile, 3, 2);\n * }\n *\n * function draw() {\n * let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);\n * // 1 = all reverb, 0 = no reverb\n * reverb.drywet(dryWet);\n *\n * background(220);\n * text('tap to play', 10, 20);\n * text('dry/wet: ' + round(dryWet * 100) + '%', 10, height - 20);\n * }\n *\n * function playSound() {\n * soundFile.play();\n * }\n *
\n */\n\nclass Reverb extends Effect {\n constructor() {\n super();\n this._initConvolverNode();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n\n // default params\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n _initConvolverNode() {\n this.convolverNode = this.ac.createConvolver();\n this.input.connect(this.convolverNode);\n this.convolverNode.connect(this.wet);\n }\n\n _teardownConvolverNode() {\n if (this.convolverNode) {\n this.convolverNode.disconnect();\n delete this.convolverNode;\n }\n }\n\n _setBuffer(audioBuffer) {\n this._teardownConvolverNode();\n this._initConvolverNode();\n this.convolverNode.buffer = audioBuffer;\n }\n /**\n * Connect a source to the reverb, and assign reverb parameters.\n *\n * @method process\n * @for p5.Reverb\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n * @param {Number} [seconds] Duration of the reverb, in seconds.\n * Min: 0, Max: 10. Defaults to 3.\n * @param {Number} [decayRate] Percentage of decay with each echo.\n * Min: 0, Max: 100. Defaults to 2.\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\n */\n process(src, seconds, decayRate, reverse) {\n src.connect(this.input);\n var rebuild = false;\n if (seconds) {\n this._seconds = seconds;\n rebuild = true;\n }\n if (decayRate) {\n this._decay = decayRate;\n }\n if (reverse) {\n this._reverse = reverse;\n }\n if (rebuild) {\n this._buildImpulse();\n }\n }\n\n /**\n * Set the reverb settings. Similar to .process(), but without\n * assigning a new input.\n *\n * @method set\n * @for p5.Reverb\n * @param {Number} [seconds] Duration of the reverb, in seconds.\n * Min: 0, Max: 10. Defaults to 3.\n * @param {Number} [decayRate] Percentage of decay with each echo.\n * Min: 0, Max: 100. Defaults to 2.\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\n */\n set(seconds, decayRate, reverse) {\n var rebuild = false;\n if (seconds) {\n this._seconds = seconds;\n rebuild = true;\n }\n if (decayRate) {\n this._decay = decayRate;\n }\n if (reverse) {\n this._reverse = reverse;\n }\n if (rebuild) {\n this._buildImpulse();\n }\n }\n\n // DocBlocks for methods inherited from p5.Effect\n /**\n * Set the output level of the reverb effect.\n *\n * @method amp\n * @for p5.Reverb\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Reverb\n * @param {Object} unit\n */\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Reverb\n */\n\n /**\n * Inspired by Simple Reverb by Jordan Santell\n * https://github.com/web-audio-components/simple-reverb/blob/master/index.js\n *\n * Utility function for building an impulse response\n * based on the module parameters.\n *\n * @private\n */\n _buildImpulse() {\n var rate = this.ac.sampleRate;\n var length = rate * this._seconds;\n var decay = this._decay;\n var impulse = this.ac.createBuffer(2, length, rate);\n var impulseL = impulse.getChannelData(0);\n var impulseR = impulse.getChannelData(1);\n var n, i;\n for (i = 0; i < length; i++) {\n n = this._reverse ? length - i : i;\n impulseL[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\n impulseR[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\n }\n this._setBuffer(impulse);\n }\n\n dispose() {\n super.dispose();\n this._teardownConvolverNode();\n }\n}\n\n// =======================================================================\n// *** p5.Convolver ***\n// =======================================================================\n\n/**\n *

p5.Convolver extends p5.Reverb. It can emulate the sound of real\n * physical spaces through a process called \n * convolution.

\n *\n *

Convolution multiplies any audio input by an \"impulse response\"\n * to simulate the dispersion of sound over time. The impulse response is\n * generated from an audio file that you provide. One way to\n * generate an impulse response is to pop a balloon in a reverberant space\n * and record the echo. Convolution can also be used to experiment with\n * sound.

\n *\n *

Use the method createConvolution(path) to instantiate a\n * p5.Convolver with a path to your impulse response audio file.

\n *\n * @class p5.Convolver\n * @extends p5.Effect\n * @constructor\n * @param {String} path path to a sound file\n * @param {Function} [callback] function to call when loading succeeds\n * @param {Function} [errorCallback] function to call if loading fails.\n * This function will receive an error or\n * XMLHttpRequest object with information\n * about what went wrong.\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from main output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *
\n */\nclass Convolver extends Reverb {\n constructor(path, callback, errorCallback) {\n super();\n /**\n * Internally, the p5.Convolver uses the a\n * \n * Web Audio Convolver Node.\n *\n * @property {ConvolverNode} convolverNode\n */\n this._initConvolverNode();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n\n if (path) {\n this.impulses = [];\n this._loadBuffer(path, callback, errorCallback);\n } else {\n // parameters\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n /**\n * If you load multiple impulse files using the .addImpulse method,\n * they will be stored as Objects in this Array. Toggle between them\n * with the toggleImpulse(id) method.\n *\n * @property {Array} impulses\n * @for p5.Convolver\n */\n this.impulses = [];\n this.set = null;\n }\n\n /**\n * Private method to load a buffer as an Impulse Response,\n * assign it to the convolverNode, and add to the Array of .impulses.\n *\n * @param {String} path\n * @param {Function} callback\n * @param {Function} errorCallback\n * @private\n */\n _loadBuffer(_path, callback, errorCallback) {\n var path = p5.prototype._checkFileFormats(_path);\n var self = this;\n var errorTrace = new Error().stack;\n var ac = getAudioContext();\n\n var request = new XMLHttpRequest();\n request.open('GET', path, true);\n request.responseType = 'arraybuffer';\n\n request.onload = function () {\n if (request.status === 200) {\n // on success loading file:\n ac.decodeAudioData(\n request.response,\n function (buff) {\n var buffer = {};\n var chunks = path.split('/');\n buffer.name = chunks[chunks.length - 1];\n buffer.audioBuffer = buff;\n self.impulses.push(buffer);\n self._setBuffer(buffer.audioBuffer);\n if (callback) {\n callback(buffer);\n }\n },\n // error decoding buffer. \"e\" is undefined in Chrome 11/22/2015\n function () {\n var err = new CustomError('decodeAudioData', errorTrace, self.url);\n var msg = 'AudioContext error at decodeAudioData for ' + self.url;\n if (errorCallback) {\n err.msg = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n );\n }\n // if request status != 200, it failed\n else {\n var err = new CustomError('loadConvolver', errorTrace, self.url);\n var msg =\n 'Unable to load ' +\n self.url +\n '. The request status was: ' +\n request.status +\n ' (' +\n request.statusText +\n ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n };\n\n // if there is another error, aside from 404...\n request.onerror = function () {\n var err = new CustomError('loadConvolver', errorTrace, self.url);\n var msg =\n 'There was no response from the server at ' +\n self.url +\n '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n };\n request.send();\n }\n\n /**\n * Connect a source to the convolver.\n *\n * @method process\n * @for p5.Convolver\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from main output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *\n *
\n */\n process(src) {\n src.connect(this.input);\n }\n\n /**\n * Load and assign a new Impulse Response to the p5.Convolver.\n * The impulse is added to the .impulses array. Previous\n * impulses can be accessed with the .toggleImpulse(id)\n * method.\n *\n * @method addImpulse\n * @for p5.Convolver\n * @param {String} path path to a sound file\n * @param {Function} callback function (optional)\n * @param {Function} errorCallback function (optional)\n */\n addImpulse(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n this._loadBuffer(path, callback, errorCallback);\n }\n\n /**\n * Similar to .addImpulse, except that the .impulses\n * Array is reset to save memory. A new .impulses\n * array is created with this impulse as the only item.\n *\n * @method resetImpulse\n * @for p5.Convolver\n * @param {String} path path to a sound file\n * @param {Function} callback function (optional)\n * @param {Function} errorCallback function (optional)\n */\n resetImpulse(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n this.impulses = [];\n this._loadBuffer(path, callback, errorCallback);\n }\n\n /**\n * If you have used .addImpulse() to add multiple impulses\n * to a p5.Convolver, then you can use this method to toggle between\n * the items in the .impulses Array. Accepts a parameter\n * to identify which impulse you wish to use, identified either by its\n * original filename (String) or by its position in the .impulses\n * Array (Number).
\n * You can access the objects in the .impulses Array directly. Each\n * Object has two attributes: an .audioBuffer (type:\n * Web Audio \n * AudioBuffer) and a .name, a String that corresponds\n * with the original filename.\n *\n * @method toggleImpulse\n * @for p5.Convolver\n * @param {String|Number} id Identify the impulse by its original filename\n * (String), or by its position in the\n * .impulses Array (Number).\n */\n toggleImpulse(id) {\n if (typeof id === 'number' && id < this.impulses.length) {\n this._setBuffer(this.impulses[id].audioBuffer);\n }\n if (typeof id === 'string') {\n for (var i = 0; i < this.impulses.length; i++) {\n if (this.impulses[i].name === id) {\n this._setBuffer(this.impulses[i].audioBuffer);\n break;\n }\n }\n }\n }\n\n dispose() {\n super.dispose();\n\n // remove all the Impulse Response buffers\n for (var i in this.impulses) {\n if (this.impulses[i]) {\n this.impulses[i] = null;\n }\n }\n }\n}\n\n/**\n * Create a p5.Convolver. Accepts a path to a soundfile\n * that will be used to generate an impulse response.\n *\n * @method createConvolver\n * @for p5\n * @param {String} path path to a sound file\n * @param {Function} [callback] function to call if loading is successful.\n * The object will be passed in as the argument\n * to the callback function.\n * @param {Function} [errorCallback] function to call if loading is not successful.\n * A custom error will be passed in as the argument\n * to the callback function.\n * @return {p5.Convolver}\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from main output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *
\n */\nfunction createConvolver(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n var self = this;\n var cReverb = new Convolver(\n path,\n function (buffer) {\n if (typeof callback === 'function') {\n callback(buffer);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n },\n errorCallback\n );\n cReverb.impulses = [];\n return cReverb;\n}\n\nexport { Reverb, Convolver, createConvolver };\n","import p5sound from './main';\n// requires the Tone.js library's Clock (MIT license, Yotam Mann)\n// https://github.com/TONEnoTONE/Tone.js/\nimport Clock from 'Tone/core/Clock';\n\nclass Metro {\n constructor() {\n this.clock = new Clock({\n callback: this.ontick.bind(this),\n });\n this.syncedParts = [];\n this.bpm = 120; // gets overridden by p5.Part\n this._init();\n\n this.prevTick = 0;\n this.tatumTime = 0;\n\n this.tickCallback = function () {};\n }\n\n ontick(tickTime) {\n var elapsedTime = tickTime - this.prevTick;\n var secondsFromNow = tickTime - p5sound.audiocontext.currentTime;\n if (elapsedTime - this.tatumTime <= -0.02) {\n return;\n } else {\n // console.log('ok', this.syncedParts[0].phrases[0].name);\n this.prevTick = tickTime;\n\n // for all of the active things on the metro:\n var self = this;\n this.syncedParts.forEach(function (thisPart) {\n if (!thisPart.isPlaying) return;\n thisPart.incrementStep(secondsFromNow);\n // each synced source keeps track of its own beat number\n thisPart.phrases.forEach(function (thisPhrase) {\n var phraseArray = thisPhrase.sequence;\n var bNum = self.metroTicks % phraseArray.length;\n if (\n phraseArray[bNum] !== 0 &&\n (self.metroTicks < phraseArray.length || !thisPhrase.looping)\n ) {\n thisPhrase.callback(secondsFromNow, phraseArray[bNum]);\n }\n });\n });\n this.metroTicks += 1;\n this.tickCallback(secondsFromNow);\n }\n }\n\n setBPM(bpm, rampTime = 0) {\n var beatTime = 60 / (bpm * this.tatums);\n var now = p5sound.audiocontext.currentTime;\n this.tatumTime = beatTime;\n\n this.clock.frequency.setValueAtTime(this.clock.frequency.value, now);\n this.clock.frequency.linearRampToValueAtTime(bpm, now + rampTime);\n this.bpm = bpm;\n }\n\n getBPM() {\n return (this.clock.getRate() / this.tatums) * 60;\n }\n\n _init() {\n this.metroTicks = 0;\n // this.setBPM(120);\n }\n\n // clear existing synced parts, add only this one\n resetSync(part) {\n this.syncedParts = [part];\n }\n\n // push a new synced part to the array\n pushSync(part) {\n this.syncedParts.push(part);\n }\n\n start(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.start(now + t);\n this.setBPM(this.bpm);\n }\n\n stop(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.stop(now + t);\n }\n\n beatLength(tatums) {\n this.tatums = 1 / tatums / 4; // lowest possible division of a beat\n }\n}\nexport default Metro;\n","import p5sound from './main';\nimport Metro from './metro';\n\nvar BPM = 120;\n\n/**\n * Set the global tempo, in beats per minute, for all\n * p5.Parts. This method will impact all active p5.Parts.\n *\n * @method setBPM\n * @for p5\n * @param {Number} BPM Beats Per Minute\n * @param {Number} rampTime Seconds from now\n */\np5.prototype.setBPM = function (bpm, rampTime) {\n BPM = bpm;\n for (var i in p5sound.parts) {\n if (p5sound.parts[i]) {\n p5sound.parts[i].setBPM(bpm, rampTime);\n }\n }\n};\n\n/**\n *

A phrase is a pattern of musical events over time, i.e.\n * a series of notes and rests.

\n *\n *

Phrases must be added to a p5.Part for playback, and\n * each part can play multiple phrases at the same time.\n * For example, one Phrase might be a kick drum, another\n * could be a snare, and another could be the bassline.

\n *\n *

The first parameter is a name so that the phrase can be\n * modified or deleted later. The callback is a a function that\n * this phrase will call at every step—for example it might be\n * called playNote(value){}. The array determines\n * which value is passed into the callback at each step of the\n * phrase. It can be numbers, an object with multiple numbers,\n * or a zero (0) indicates a rest so the callback won't be called).

\n *\n * @class p5.Phrase\n * @constructor\n * @param {String} name Name so that you can access the Phrase.\n * @param {Function} callback The name of a function that this phrase\n * will call. Typically it will play a sound,\n * and accept two parameters: a time at which\n * to play the sound (in seconds from now),\n * and a value from the sequence array. The\n * time should be passed into the play() or\n * start() method to ensure precision.\n * @param {Array} sequence Array of values to pass into the callback\n * at each step of the phrase.\n * @example\n *
\n * let mySound, myPhrase, myPart;\n * let pattern = [1,0,0,2,0,2,0,0];\n *\n * function preload() {\n * mySound = loadSound('assets/beatbox.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playMyPart);\n * background(220);\n * text('tap to play', width/2, height/2);\n * textAlign(CENTER, CENTER);\n *\n * myPhrase = new p5.Phrase('bbox', onEachStep, pattern);\n * myPart = new p5.Part();\n * myPart.addPhrase(myPhrase);\n * myPart.setBPM(60);\n * }\n *\n * function onEachStep(time, playbackRate) {\n * mySound.rate(playbackRate);\n * mySound.play(time);\n * }\n *\n * function playMyPart() {\n * userStartAudio();\n * myPart.start();\n * }\n *
\n */\nclass Phrase {\n constructor(name, callback, sequence) {\n this.phraseStep = 0;\n this.name = name;\n this.callback = callback;\n /**\n * Array of values to pass into the callback\n * at each step of the phrase. Depending on the callback\n * function's requirements, these values may be numbers,\n * strings, or an object with multiple parameters.\n * Zero (0) indicates a rest.\n *\n * @property {Array} sequence\n */\n this.sequence = sequence;\n }\n}\n\n/**\n *

A p5.Part plays back one or more p5.Phrases. Instantiate a part\n * with steps and tatums. By default, each step represents a 1/16th note.

\n *\n *

See p5.Phrase for more about musical timing.

\n *\n * @class p5.Part\n * @constructor\n * @param {Number} [steps] Steps in the part\n * @param {Number} [tatums] Divisions of a beat, e.g. use 1/4, or 0.25 for a quater note (default is 1/16, a sixteenth note)\n * @example\n *
\n * let box, drum, myPart;\n * let boxPat = [1,0,0,2,0,2,0,0];\n * let drumPat = [0,1,1,0,2,0,1,0];\n *\n * function preload() {\n * box = loadSound('assets/beatbox.mp3');\n * drum = loadSound('assets/drum.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playMyPart);\n * background(220);\n * textAlign(CENTER, CENTER);\n * text('tap to play', width/2, height/2);\n *\n * let boxPhrase = new p5.Phrase('box', playBox, boxPat);\n * let drumPhrase = new p5.Phrase('drum', playDrum, drumPat);\n * myPart = new p5.Part();\n * myPart.addPhrase(boxPhrase);\n * myPart.addPhrase(drumPhrase);\n * myPart.setBPM(60);\n * }\n *\n * function playBox(time, playbackRate) {\n * box.rate(playbackRate);\n * box.play(time);\n * }\n *\n * function playDrum(time, playbackRate) {\n * drum.rate(playbackRate);\n * drum.play(time);\n * }\n *\n * function playMyPart() {\n * userStartAudio();\n *\n * myPart.start();\n * }\n *
\n */\nclass Part {\n constructor(steps, bLength) {\n this.length = steps || 0; // how many beats\n this.partStep = 0;\n this.phrases = [];\n this.isPlaying = false;\n this.noLoop();\n this.tatums = bLength || 0.0625; // defaults to quarter note\n\n this.metro = new Metro();\n this.metro._init();\n this.metro.beatLength(this.tatums);\n this.metro.setBPM(BPM);\n p5sound.parts.push(this);\n this.callback = function () {};\n }\n\n /**\n * Set the tempo of this part, in Beats Per Minute.\n *\n * @method setBPM\n * @for p5.Part\n * @param {Number} BPM Beats Per Minute\n * @param {Number} [rampTime] Seconds from now\n */\n setBPM(tempo, rampTime) {\n this.metro.setBPM(tempo, rampTime);\n }\n\n /**\n * Returns the tempo, in Beats Per Minute, of this part.\n *\n * @method getBPM\n * @for p5.Part\n * @return {Number}\n */\n getBPM() {\n return this.metro.getBPM();\n }\n\n /**\n * Start playback of this part. It will play\n * through all of its phrases at a speed\n * determined by setBPM.\n *\n * @method start\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n start(time) {\n if (!this.isPlaying) {\n this.isPlaying = true;\n this.metro.resetSync(this);\n var t = time || 0;\n this.metro.start(t);\n }\n }\n\n /**\n * Loop playback of this part. It will begin\n * looping through all of its phrases at a speed\n * determined by setBPM.\n *\n * @method loop\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n loop(time) {\n this.looping = true;\n // rest onended function\n this.onended = function () {\n this.partStep = 0;\n };\n var t = time || 0;\n this.start(t);\n }\n\n /**\n * Tell the part to stop looping.\n *\n * @method noLoop\n * @for p5.Part\n */\n noLoop() {\n this.looping = false;\n // rest onended function\n this.onended = function () {\n this.stop();\n };\n }\n\n /**\n * Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.\n *\n * @method stop\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n stop(time) {\n this.partStep = 0;\n this.pause(time);\n }\n\n /**\n * Pause the part. Playback will resume\n * from the current step.\n *\n * @method pause\n * @for p5.Part\n * @param {Number} time seconds from now\n */\n pause(time) {\n this.isPlaying = false;\n var t = time || 0;\n this.metro.stop(t);\n }\n\n /**\n * Add a p5.Phrase to this Part.\n *\n * @method addPhrase\n * @for p5.Part\n * @param {p5.Phrase} phrase reference to a p5.Phrase\n */\n addPhrase(name, callback, array) {\n var p;\n if (arguments.length === 3) {\n p = new Phrase(name, callback, array);\n } else if (arguments[0] instanceof Phrase) {\n p = arguments[0];\n } else {\n throw 'invalid input. addPhrase accepts name, callback, array or a p5.Phrase';\n }\n this.phrases.push(p);\n // reset the length if phrase is longer than part's existing length\n if (p.sequence.length > this.length) {\n this.length = p.sequence.length;\n }\n }\n\n /**\n * Remove a phrase from this part, based on the name it was\n * given when it was created.\n *\n * @method removePhrase\n * @for p5.Part\n * @param {String} phraseName\n */\n removePhrase(name) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n this.phrases.splice(i, 1);\n }\n }\n }\n\n /**\n * Get a phrase from this part, based on the name it was\n * given when it was created. Now you can modify its array.\n *\n * @method getPhrase\n * @for p5.Part\n * @param {String} phraseName\n */\n getPhrase(name) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n return this.phrases[i];\n }\n }\n }\n\n /**\n * Find all sequences with the specified name, and replace their patterns with the specified array.\n *\n * @method replaceSequence\n * @for p5.Part\n * @param {String} phraseName\n * @param {Array} sequence Array of values to pass into the callback\n * at each step of the phrase.\n */\n replaceSequence(name, array) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n this.phrases[i].sequence = array;\n }\n }\n }\n\n incrementStep(time) {\n if (this.partStep < this.length - 1) {\n this.callback(time);\n this.partStep += 1;\n } else {\n if (!this.looping && this.partStep === this.length - 1) {\n // this.callback(time);\n this.onended();\n }\n }\n }\n\n /**\n * Set the function that will be called at every step. This will clear the previous function.\n *\n * @method onStep\n * @for p5.Part\n * @param {Function} callback The name of the callback\n * you want to fire\n * on every beat/tatum.\n */\n onStep(callback) {\n this.callback = callback;\n }\n}\n\n// ===============\n// p5.Score\n// ===============\n\n/**\n * A Score consists of a series of Parts. The parts will\n * be played back in order. For example, you could have an\n * A part, a B part, and a C part, and play them back in this order\n * new p5.Score(a, a, b, a, c)\n *\n * @class p5.Score\n * @constructor\n * @param {p5.Part} [...parts] One or multiple parts, to be played in sequence.\n */\nclass Score {\n constructor() {\n // for all of the arguments\n this.parts = [];\n this.currentPart = new Array(arguments.length);;\n\n var thisScore = this;\n for (var i in arguments) {\n this.parts[i] = arguments[i];\n this.parts[i].nextPart = this.parts[i + 1];\n this.parts[i].onended = function () {\n thisScore.resetPart(i);\n playNextPart(thisScore);\n }; \n }\n this.looping = false;\n }\n\n onended() {\n if (this.looping) {\n // this.resetParts();\n this.parts[0].start();\n } else {\n this.parts[this.parts.length - 1].onended = function () {\n this.stop();\n this.resetParts();\n };\n }\n this.currentPart = 0;\n }\n\n /**\n * Start playback of the score.\n *\n * @method start\n * @for p5.Score\n */\n start() {\n this.parts[this.currentPart].start();\n this.scoreStep = 0;\n }\n\n /**\n * Stop playback of the score.\n *\n * @method stop\n * @for p5.Score\n */\n stop() {\n this.parts[this.currentPart].stop();\n this.currentPart = 0;\n this.scoreStep = 0;\n }\n\n /**\n * Pause playback of the score.\n *\n * @method pause\n * @for p5.Score\n */\n pause() {\n this.parts[this.currentPart].stop();\n }\n\n /**\n * Loop playback of the score.\n *\n * @method loop\n * @for p5.Score\n */\n loop() {\n this.looping = true;\n this.start();\n }\n\n /**\n * Stop looping playback of the score. If it\n * is currently playing, this will go into effect\n * after the current round of playback completes.\n *\n * @method noLoop\n * @for p5.Score\n */\n noLoop() {\n this.looping = false;\n }\n\n resetParts() {\n var self = this;\n this.parts.forEach(function (part) {\n self.resetParts[part];\n });\n }\n\n resetPart(i) {\n this.parts[i].stop();\n this.parts[i].partStep = 0;\n for (var p in this.parts[i].phrases) {\n if (this.parts[i]) {\n this.parts[i].phrases[p].phraseStep = 0;\n }\n }\n }\n\n /**\n * Set the tempo for all parts in the score\n *\n * @method setBPM\n * @for p5.Score\n * @param {Number} BPM Beats Per Minute\n * @param {Number} rampTime Seconds from now\n */\n setBPM(bpm, rampTime) {\n for (var i in this.parts) {\n if (this.parts[i]) {\n this.parts[i].setBPM(bpm, rampTime);\n }\n }\n }\n}\n\nfunction playNextPart(aScore) {\n aScore.currentPart++;\n if (aScore.currentPart >= aScore.parts.length) {\n aScore.scoreStep = 0;\n aScore.onended();\n } else {\n aScore.scoreStep = 0;\n aScore.parts[aScore.currentPart - 1].stop();\n aScore.parts[aScore.currentPart].start();\n }\n}\n\nexport { Phrase, Part, Score };\n","import p5sound from './main';\nimport Clock from 'Tone/core/Clock';\n\n/**\n * SoundLoop\n *\n * @class p5.SoundLoop\n * @constructor\n *\n * @param {Function} callback this function will be called on each iteration of theloop\n * @param {Number|String} [interval] amount of time (if a number) or beats (if a string, following Tone.Time convention) for each iteration of the loop. Defaults to 1 second.\n *\n * @example\n *
\n * let synth, soundLoop;\n * let notePattern = [60, 62, 64, 67, 69, 72];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * colorMode(HSB);\n * background(0, 0, 86);\n * text('tap to start/stop', 10, 20);\n *\n * //the looper's callback is passed the timeFromNow\n * //this value should be used as a reference point from\n * //which to schedule sounds\n * let intervalInSeconds = 0.2;\n * soundLoop = new p5.SoundLoop(onSoundLoop, intervalInSeconds);\n *\n * synth = new p5.MonoSynth();\n * }\n *\n * function canvasPressed() {\n * // ensure audio is enabled\n * userStartAudio();\n *\n * if (soundLoop.isPlaying) {\n * soundLoop.stop();\n * } else {\n * // start the loop\n * soundLoop.start();\n * }\n * }\n *\n * function onSoundLoop(timeFromNow) {\n * let noteIndex = (soundLoop.iterations - 1) % notePattern.length;\n * let note = midiToFreq(notePattern[noteIndex]);\n * synth.play(note, 0.5, timeFromNow);\n * background(noteIndex * 360 / notePattern.length, 50, 100);\n * }\n *
\n */\nclass SoundLoop {\n constructor(callback, interval) {\n /**\n * Getters and Setters, setting any paramter will result in a change in the clock's\n * frequency, that will be reflected after the next callback\n * beats per minute (defaults to 60)\n * @property {Number} bpm\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'bpm', {\n get: function () {\n return this._bpm;\n },\n set: function (bpm) {\n if (!this.musicalTimeMode) {\n console.warn(\n 'Changing the BPM in \"seconds\" mode has no effect. ' +\n 'BPM is only relevant in musicalTimeMode ' +\n 'when the interval is specified as a string ' +\n '(\"2n\", \"4n\", \"1m\"...etc)'\n );\n }\n this._bpm = bpm;\n this._update();\n },\n });\n\n /**\n * number of quarter notes in a measure (defaults to 4)\n * @property {Number} timeSignature\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'timeSignature', {\n get: function () {\n return this._timeSignature;\n },\n set: function (timeSig) {\n if (!this.musicalTimeMode) {\n console.warn(\n 'Changing the timeSignature in \"seconds\" mode has no effect. ' +\n 'BPM is only relevant in musicalTimeMode ' +\n 'when the interval is specified as a string ' +\n '(\"2n\", \"4n\", \"1m\"...etc)'\n );\n }\n this._timeSignature = timeSig;\n this._update();\n },\n });\n\n /**\n * length of the loops interval\n * @property {Number|String} interval\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'interval', {\n get: function () {\n return this._interval;\n },\n set: function (interval) {\n this.musicalTimeMode = typeof interval === 'number' ? false : true;\n this._interval = interval;\n this._update();\n },\n });\n\n /**\n * how many times the callback has been called so far\n * @property {Number} iterations\n * @for p5.SoundLoop\n * @readonly\n */\n Object.defineProperty(this, 'iterations', {\n get: function () {\n return this.clock.ticks;\n },\n });\n\n this.callback = callback;\n /**\n * musicalTimeMode uses Tone.Time convention\n * true if string, false if number\n * @property {Boolean} musicalTimeMode\n */\n this.musicalTimeMode = typeof this._interval === 'number' ? false : true;\n\n this._interval = interval || 1;\n\n /**\n * musicalTimeMode variables\n * modify these only when the interval is specified in musicalTime format as a string\n */\n this._timeSignature = 4;\n this._bpm = 60;\n\n this.isPlaying = false;\n\n /**\n * Set a limit to the number of loops to play. defaults to Infinity\n * @property {Number} maxIterations\n */\n this.maxIterations = Infinity;\n var self = this;\n\n this.clock = new Clock({\n callback: function (time) {\n var timeFromNow = time - p5sound.audiocontext.currentTime;\n /**\n * Do not initiate the callback if timeFromNow is < 0\n * This ususually occurs for a few milliseconds when the page\n * is not fully loaded\n *\n * The callback should only be called until maxIterations is reached\n */\n if (timeFromNow > 0 && self.iterations <= self.maxIterations) {\n self.callback(timeFromNow);\n }\n },\n frequency: this._calcFreq(),\n });\n }\n\n /**\n * Start the loop\n * @method start\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a starting time\n */\n start(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (!this.isPlaying) {\n this.clock.start(now + t);\n this.isPlaying = true;\n }\n }\n\n /**\n * Stop the loop\n * @method stop\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a stopping time\n */\n stop(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (this.isPlaying) {\n this.clock.stop(now + t);\n this.isPlaying = false;\n }\n }\n\n /**\n * Pause the loop\n * @method pause\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a pausing time\n */\n pause(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (this.isPlaying) {\n this.clock.pause(now + t);\n this.isPlaying = false;\n }\n }\n\n /**\n * Synchronize loops. Use this method to start two or more loops in synchronization\n * or to start a loop in synchronization with a loop that is already playing\n * This method will schedule the implicit loop in sync with the explicit master loop\n * i.e. loopToStart.syncedStart(loopToSyncWith)\n *\n * @method syncedStart\n * @for p5.SoundLoop\n * @param {Object} otherLoop a p5.SoundLoop to sync with\n * @param {Number} [timeFromNow] Start the loops in sync after timeFromNow seconds\n */\n syncedStart(otherLoop, timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n\n if (!otherLoop.isPlaying) {\n otherLoop.clock.start(now + t);\n otherLoop.isPlaying = true;\n this.clock.start(now + t);\n this.isPlaying = true;\n } else if (otherLoop.isPlaying) {\n var time = otherLoop.clock._nextTick - p5sound.audiocontext.currentTime;\n this.clock.start(now + time);\n this.isPlaying = true;\n }\n }\n /**\n * Updates frequency value, reflected in next callback\n * @private\n * @for p5.SoundLoop\n * @method _update\n */\n _update() {\n this.clock.frequency.value = this._calcFreq();\n }\n\n /**\n * Calculate the frequency of the clock's callback based on bpm, interval, and timesignature\n * @private\n * @for p5.SoundLoop\n * @method _calcFreq\n * @return {Number} new clock frequency value\n */\n _calcFreq() {\n //Seconds mode, bpm / timesignature has no effect\n if (typeof this._interval === 'number') {\n this.musicalTimeMode = false;\n return 1 / this._interval;\n }\n //Musical timing mode, calculate interval based bpm, interval,and time signature\n else if (typeof this._interval === 'string') {\n this.musicalTimeMode = true;\n return (\n (this._bpm / 60 / this._convertNotation(this._interval)) *\n (this._timeSignature / 4)\n );\n }\n }\n\n /**\n * Convert notation from musical time format to seconds\n * Uses Tone.Time convention\n * @private\n * @for p5.SoundLoop\n * @method _convertNotation\n * @param {String} value value to be converted\n * @return {Number} converted value in seconds\n */\n _convertNotation(value) {\n var type = value.slice(-1);\n value = Number(value.slice(0, -1));\n switch (type) {\n case 'm':\n return this._measure(value);\n case 'n':\n return this._note(value);\n default:\n console.warn(\n 'Specified interval is not formatted correctly. See Tone.js ' +\n 'timing reference for more info: https://github.com/Tonejs/Tone.js/wiki/Time'\n );\n }\n }\n\n /**\n * Helper conversion methods of measure and note\n * @private\n * @for p5.SoundLoop\n * @method _measure\n */\n _measure(value) {\n return value * this._timeSignature;\n }\n\n /**\n * @private\n * @method _note\n * @for p5.SoundLoop\n */\n _note(value) {\n return this._timeSignature / value;\n }\n}\n\nexport default SoundLoop;\n","import Effect from './effect';\n\n/**\n * Compressor is an audio effect class that performs dynamics compression\n * on an audio input source. This is a very commonly used technique in music\n * and sound production. Compression creates an overall louder, richer,\n * and fuller sound by lowering the volume of louds and raising that of softs.\n * Compression can be used to avoid clipping (sound distortion due to\n * peaks in volume) and is especially useful when many sounds are played\n * at once. Compression can be used on indivudal sound sources in addition\n * to the main output.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Compressor\n * @constructor\n * @extends p5.Effect\n *\n *\n */\nclass Compressor extends Effect {\n constructor() {\n super();\n /**\n *\n * The p5.Compressor is built with a Web Audio Dynamics Compressor Node\n * \n * @property {AudioNode} compressor\n */\n\n this.compressor = this.ac.createDynamicsCompressor();\n\n this.input.connect(this.compressor);\n this.compressor.connect(this.wet);\n }\n\n /**\n * Performs the same function as .connect, but also accepts\n * optional parameters to set compressor's audioParams\n * @method process\n * @for p5.Compressor\n *\n * @param {Object} src Sound source to be connected\n *\n * @param {Number} [attack] The amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} [knee] A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} [threshold] The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} [release] The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n */\n process(src, attack, knee, ratio, threshold, release) {\n src.connect(this.input);\n this.set(attack, knee, ratio, threshold, release);\n }\n\n /**\n * Set the paramters of a compressor.\n * @method set\n * @for p5.Compressor\n * @param {Number} attack The amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} knee A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} ratio The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} threshold The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n */\n set(attack, knee, ratio, threshold, release) {\n if (typeof attack !== 'undefined') {\n this.attack(attack);\n }\n if (typeof knee !== 'undefined') {\n this.knee(knee);\n }\n if (typeof ratio !== 'undefined') {\n this.ratio(ratio);\n }\n if (typeof threshold !== 'undefined') {\n this.threshold(threshold);\n }\n if (typeof release !== 'undefined') {\n this.release(release);\n }\n }\n\n /**\n * Get current attack or set value w/ time ramp\n *\n *\n * @method attack\n * @for p5.Compressor\n * @param {Number} [attack] Attack is the amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n attack(attack, time) {\n var t = time || 0;\n if (typeof attack === 'number') {\n this.compressor.attack.value = attack;\n this.compressor.attack.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.attack.linearRampToValueAtTime(\n attack,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof attack !== 'undefined') {\n attack.connect(this.compressor.attack);\n }\n return this.compressor.attack.value;\n }\n\n /**\n * Get current knee or set value w/ time ramp\n *\n * @method knee\n * @for p5.Compressor\n * @param {Number} [knee] A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n knee(knee, time) {\n var t = time || 0;\n if (typeof knee === 'number') {\n this.compressor.knee.value = knee;\n this.compressor.knee.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.knee.linearRampToValueAtTime(\n knee,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof knee !== 'undefined') {\n knee.connect(this.compressor.knee);\n }\n return this.compressor.knee.value;\n }\n\n /**\n * Get current ratio or set value w/ time ramp\n * @method ratio\n * @for p5.Compressor\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n ratio(ratio, time) {\n var t = time || 0;\n if (typeof ratio === 'number') {\n this.compressor.ratio.value = ratio;\n this.compressor.ratio.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.ratio.linearRampToValueAtTime(\n ratio,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof ratio !== 'undefined') {\n ratio.connect(this.compressor.ratio);\n }\n return this.compressor.ratio.value;\n }\n\n /**\n * Get current threshold or set value w/ time ramp\n * @method threshold\n * @for p5.Compressor\n * @param {Number} threshold The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n threshold(threshold, time) {\n var t = time || 0;\n if (typeof threshold === 'number') {\n this.compressor.threshold.value = threshold;\n this.compressor.threshold.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.threshold.linearRampToValueAtTime(\n threshold,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof threshold !== 'undefined') {\n threshold.connect(this.compressor.threshold);\n }\n return this.compressor.threshold.value;\n }\n\n /**\n * Get current release or set value w/ time ramp\n * @method release\n * @for p5.Compressor\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n *\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n release(release, time) {\n var t = time || 0;\n if (typeof release === 'number') {\n this.compressor.release.value = release;\n this.compressor.release.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.release.linearRampToValueAtTime(\n release,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof number !== 'undefined') {\n release.connect(this.compressor.release);\n }\n return this.compressor.release.value;\n }\n\n /**\n * Return the current reduction value\n *\n * @method reduction\n * @for p5.Compressor\n * @return {Number} Value of the amount of gain reduction that is applied to the signal\n */\n reduction() {\n return this.compressor.reduction.value;\n }\n\n dispose() {\n super.dispose();\n if (this.compressor) {\n this.compressor.disconnect();\n delete this.compressor;\n }\n }\n}\n\nexport default Compressor;\n","/**\n *

PeakDetect works in conjunction with p5.FFT to\n * look for onsets in some or all of the frequency spectrum.\n *

\n *

\n * To use p5.PeakDetect, call update in the draw loop\n * and pass in a p5.FFT object.\n *

\n *

\n * You can listen for a specific part of the frequency spectrum by\n * setting the range between freq1 and freq2.\n *

\n *\n *

threshold is the threshold for detecting a peak,\n * scaled between 0 and 1. It is logarithmic, so 0.1 is half as loud\n * as 1.0.

\n *\n *

\n * The update method is meant to be run in the draw loop, and\n * frames determines how many loops must pass before\n * another peak can be detected.\n * For example, if the frameRate() = 60, you could detect the beat of a\n * 120 beat-per-minute song with this equation:\n * framesPerPeak = 60 / (estimatedBPM / 60 );\n *

\n *\n *

\n * Based on example contribtued by @b2renger, and a simple beat detection\n * explanation by Felix Turner.\n *

\n *\n * @class p5.PeakDetect\n * @constructor\n * @param {Number} [freq1] lowFrequency - defaults to 20Hz\n * @param {Number} [freq2] highFrequency - defaults to 20000 Hz\n * @param {Number} [threshold] Threshold for detecting a beat between 0 and 1\n * scaled logarithmically where 0.1 is 1/2 the loudness\n * of 1.0. Defaults to 0.35.\n * @param {Number} [framesPerPeak] Defaults to 20.\n * @example\n *
\n *\n * var cnv, soundFile, fft, peakDetect;\n * var ellipseWidth = 10;\n *\n * function preload() {\n * soundFile = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * background(0);\n * noStroke();\n * fill(255);\n * textAlign(CENTER);\n *\n * // p5.PeakDetect requires a p5.FFT\n * fft = new p5.FFT();\n * peakDetect = new p5.PeakDetect();\n * }\n *\n * function draw() {\n * background(0);\n * text('click to play/pause', width/2, height/2);\n *\n * // peakDetect accepts an fft post-analysis\n * fft.analyze();\n * peakDetect.update(fft);\n *\n * if ( peakDetect.isDetected ) {\n * ellipseWidth = 50;\n * } else {\n * ellipseWidth *= 0.95;\n * }\n *\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n * }\n *\n * // toggle play/stop when canvas is clicked\n * function mouseClicked() {\n * if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n * if (soundFile.isPlaying() ) {\n * soundFile.stop();\n * } else {\n * soundFile.play();\n * }\n * }\n * }\n *
\n */\nclass PeakDetect {\n // framesPerPeak determines how often to look for a beat.\n // If a beat is provided, try to look for a beat based on bpm\n constructor(freq1, freq2, threshold, _framesPerPeak) {\n this.framesPerPeak = _framesPerPeak || 20;\n this.framesSinceLastPeak = 0;\n this.decayRate = 0.95;\n\n this.threshold = threshold || 0.35;\n this.cutoff = 0;\n\n // how much to increase the cutoff\n // TO DO: document this / figure out how to make it accessible\n this.cutoffMult = 1.5;\n\n this.energy = 0;\n this.penergy = 0;\n\n // TO DO: document this property / figure out how to make it accessible\n this.currentValue = 0;\n\n /**\n * isDetected is set to true when a peak is detected.\n *\n * @attribute isDetected {Boolean}\n * @default false\n */\n this.isDetected = false;\n\n this.f1 = freq1 || 40;\n this.f2 = freq2 || 20000;\n\n // function to call when a peak is detected\n this._onPeak = function () {};\n }\n\n /**\n * The update method is run in the draw loop.\n *\n * Accepts an FFT object. You must call .analyze()\n * on the FFT object prior to updating the peakDetect\n * because it relies on a completed FFT analysis.\n *\n * @method update\n * @param {p5.FFT} fftObject A p5.FFT object\n */\n update(fftObject) {\n var nrg = (this.energy = fftObject.getEnergy(this.f1, this.f2) / 255);\n if (nrg > this.cutoff && nrg > this.threshold && nrg - this.penergy > 0) {\n // trigger callback\n this._onPeak();\n this.isDetected = true;\n\n // debounce\n this.cutoff = nrg * this.cutoffMult;\n this.framesSinceLastPeak = 0;\n } else {\n this.isDetected = false;\n if (this.framesSinceLastPeak <= this.framesPerPeak) {\n this.framesSinceLastPeak++;\n } else {\n this.cutoff *= this.decayRate;\n this.cutoff = Math.max(this.cutoff, this.threshold);\n }\n }\n\n this.currentValue = nrg;\n this.penergy = nrg;\n }\n\n /**\n * onPeak accepts two arguments: a function to call when\n * a peak is detected. The value of the peak,\n * between 0.0 and 1.0, is passed to the callback.\n *\n * @method onPeak\n * @param {Function} callback Name of a function that will\n * be called when a peak is\n * detected.\n * @param {Object} [val] Optional value to pass\n * into the function when\n * a peak is detected.\n * @example\n *
\n * var cnv, soundFile, fft, peakDetect;\n * var ellipseWidth = 0;\n *\n * function preload() {\n * soundFile = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * cnv = createCanvas(100,100);\n * textAlign(CENTER);\n *\n * fft = new p5.FFT();\n * peakDetect = new p5.PeakDetect();\n *\n * setupSound();\n *\n * // when a beat is detected, call triggerBeat()\n * peakDetect.onPeak(triggerBeat);\n * }\n *\n * function draw() {\n * background(0);\n * fill(255);\n * text('click to play', width/2, height/2);\n *\n * fft.analyze();\n * peakDetect.update(fft);\n *\n * ellipseWidth *= 0.95;\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n * }\n *\n * // this function is called by peakDetect.onPeak\n * function triggerBeat() {\n * ellipseWidth = 50;\n * }\n *\n * // mouseclick starts/stops sound\n * function setupSound() {\n * cnv.mouseClicked( function() {\n * if (soundFile.isPlaying() ) {\n * soundFile.stop();\n * } else {\n * soundFile.play();\n * }\n * });\n * }\n *
\n */\n onPeak(callback, val) {\n var self = this;\n\n self._onPeak = function () {\n callback(self.energy, val);\n };\n }\n}\n\nexport default PeakDetect;\n","// inspiration: recorder.js, Tone.js & typedarray.org\n\nimport p5sound from './main';\nimport { safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\n\nconst ac = p5sound.audiocontext;\n\n/**\n *

Record sounds for playback and/or to save as a .wav file.\n * The p5.SoundRecorder records all sound output from your sketch,\n * or can be assigned a specific source with setInput().

\n *

The record() method accepts a p5.SoundFile as a parameter.\n * When playback is stopped (either after the given amount of time,\n * or with the stop() method), the p5.SoundRecorder will send its\n * recording to that p5.SoundFile for playback.

\n *\n * @class p5.SoundRecorder\n * @constructor\n * @example\n *
\n * let mic, recorder, soundFile;\n * let state = 0;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * textAlign(CENTER, CENTER);\n *\n * // create an audio in\n * mic = new p5.AudioIn();\n *\n * // prompts user to enable their browser mic\n * mic.start();\n *\n * // create a sound recorder\n * recorder = new p5.SoundRecorder();\n *\n * // connect the mic to the recorder\n * recorder.setInput(mic);\n *\n * // this sound file will be used to\n * // playback & save the recording\n * soundFile = new p5.SoundFile();\n *\n * text('tap to record', width/2, height/2);\n * }\n *\n * function canvasPressed() {\n * // ensure audio is enabled\n * userStartAudio();\n *\n * // make sure user enabled the mic\n * if (state === 0 && mic.enabled) {\n *\n * // record to our p5.SoundFile\n * recorder.record(soundFile);\n *\n * background(255,0,0);\n * text('Recording!', width/2, height/2);\n * state++;\n * }\n * else if (state === 1) {\n * background(0,255,0);\n *\n * // stop recorder and\n * // send result to soundFile\n * recorder.stop();\n *\n * text('Done! Tap to play and download', width/2, height/2, width - 20);\n * state++;\n * }\n *\n * else if (state === 2) {\n * soundFile.play(); // play the result!\n * save(soundFile, 'mySound.wav');\n * state++;\n * }\n * }\n *
\n */\nclass SoundRecorder {\n constructor() {\n this.input = ac.createGain();\n this.output = ac.createGain();\n\n this._inputChannels = 2;\n this._outputChannels = 2; // stereo output, even if input is mono\n\n const workletBufferSize = safeBufferSize(1024);\n\n this._workletNode = new AudioWorkletNode(\n ac,\n processorNames.recorderProcessor,\n {\n outputChannelCount: [this._outputChannels],\n processorOptions: {\n numInputChannels: this._inputChannels,\n bufferSize: workletBufferSize,\n },\n }\n );\n\n this._workletNode.port.onmessage = function (event) {\n if (event.data.name === 'buffers') {\n const buffers = [\n new Float32Array(event.data.leftBuffer),\n new Float32Array(event.data.rightBuffer),\n ];\n this._callback(buffers);\n }\n }.bind(this);\n\n /**\n * callback invoked when the recording is over\n * @private\n * @type Function(Float32Array)\n */\n this._callback = function () {};\n\n // connections\n this._workletNode.connect(p5.soundOut._silentNode);\n this.setInput();\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connect a specific device to the p5.SoundRecorder.\n * If no parameter is given, p5.SoundRecorer will record\n * all audible p5.sound from your sketch.\n *\n * @method setInput\n * @for p5.SoundRecorder\n * @param {Object} [unit] p5.sound object or a web audio unit\n * that outputs sound\n */\n setInput(unit) {\n this.input.disconnect();\n this.input = null;\n this.input = ac.createGain();\n this.input.connect(this._workletNode);\n this.input.connect(this.output);\n if (unit) {\n unit.connect(this.input);\n } else {\n p5.soundOut.output.connect(this.input);\n }\n }\n\n /**\n * Start recording. To access the recording, provide\n * a p5.SoundFile as the first parameter. The p5.SoundRecorder\n * will send its recording to that p5.SoundFile for playback once\n * recording is complete. Optional parameters include duration\n * (in seconds) of the recording, and a callback function that\n * will be called once the complete recording has been\n * transfered to the p5.SoundFile.\n *\n * @method record\n * @for p5.SoundRecorder\n * @param {p5.SoundFile} soundFile p5.SoundFile\n * @param {Number} [duration] Time (in seconds)\n * @param {Function} [callback] The name of a function that will be\n * called once the recording completes\n */\n record(sFile, duration, callback) {\n this._workletNode.port.postMessage({ name: 'start', duration: duration });\n\n if (sFile && callback) {\n this._callback = function (buffer) {\n sFile.setBuffer(buffer);\n callback();\n };\n } else if (sFile) {\n this._callback = function (buffer) {\n sFile.setBuffer(buffer);\n };\n }\n }\n\n /**\n * Stop the recording. Once the recording is stopped,\n * the results will be sent to the p5.SoundFile that\n * was given on .record(), and if a callback function\n * was provided on record, that function will be called.\n *\n * @method stop\n * @for p5.SoundRecorder\n */\n stop() {\n this._workletNode.port.postMessage({ name: 'stop' });\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this._callback = function () {};\n if (this.input) {\n this.input.disconnect();\n }\n this.input = null;\n this._workletNode = null;\n }\n}\n\nexport default SoundRecorder;\n","import Effect from './effect.js';\n\n/*\n * Adapted from [Kevin Ennis on StackOverflow](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n */\nfunction makeDistortionCurve(amount) {\n var k = typeof amount === 'number' ? amount : 50;\n var numSamples = 44100;\n var curve = new Float32Array(numSamples);\n var deg = Math.PI / 180;\n var i = 0;\n var x;\n for (; i < numSamples; ++i) {\n x = (i * 2) / numSamples - 1;\n curve[i] = ((3 + k) * x * 20 * deg) / (Math.PI + k * Math.abs(x));\n }\n return curve;\n}\n\n/**\n * A Distortion effect created with a Waveshaper Node,\n * with an approach adapted from\n * [Kevin Ennis](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Distortion\n * @extends p5.Effect\n * @constructor\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n *\n */\nclass Distortion extends Effect {\n constructor(amount, oversample) {\n super();\n if (typeof amount === 'undefined') {\n amount = 0.25;\n }\n if (typeof amount !== 'number') {\n throw new Error('amount must be a number');\n }\n if (typeof oversample === 'undefined') {\n oversample = '2x';\n }\n if (typeof oversample !== 'string') {\n throw new Error('oversample must be a String');\n }\n\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\n\n /**\n * The p5.Distortion is built with a\n * \n * Web Audio WaveShaper Node.\n *\n * @property {AudioNode} WaveShaperNode\n */\n this.waveShaperNode = this.ac.createWaveShaper();\n\n this.amount = curveAmount;\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\n this.waveShaperNode.oversample = oversample;\n\n this.input.connect(this.waveShaperNode);\n\n this.waveShaperNode.connect(this.wet);\n }\n\n /**\n * Process a sound source, optionally specify amount and oversample values.\n *\n * @method process\n * @for p5.Distortion\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n */\n process(src, amount, oversample) {\n src.connect(this.input);\n this.set(amount, oversample);\n }\n\n /**\n * Set the amount and oversample of the waveshaper distortion.\n *\n * @method set\n * @for p5.Distortion\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n */\n set(amount, oversample) {\n if (amount) {\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\n this.amount = curveAmount;\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\n }\n if (oversample) {\n this.waveShaperNode.oversample = oversample;\n }\n }\n\n /**\n * Return the distortion amount, typically between 0-1.\n *\n * @method getAmount\n * @for p5.Distortion\n * @return {Number} Unbounded distortion amount.\n * Normal values range from 0-1.\n */\n getAmount() {\n return this.amount;\n }\n\n /**\n * Return the oversampling.\n *\n * @method getOversample\n * @for p5.Distortion\n * @return {String} Oversample can either be 'none', '2x', or '4x'.\n */\n getOversample() {\n return this.waveShaperNode.oversample;\n }\n\n dispose() {\n super.dispose();\n if (this.waveShaperNode) {\n this.waveShaperNode.disconnect();\n this.waveShaperNode = null;\n }\n }\n}\n\nexport default Distortion;\n","import p5sound from './main';\n\n/**\n * A gain node is usefull to set the relative volume of sound.\n * It's typically used to build mixers.\n *\n * @class p5.Gain\n * @constructor\n * @example\n *
\n *\n * // load two soundfile and crossfade beetween them\n * let sound1,sound2;\n * let sound1Gain, sound2Gain, mixGain;\n * function preload(){\n * soundFormats('ogg', 'mp3');\n * sound1 = loadSound('assets/Damscray_-_Dancing_Tiger_01');\n * sound2 = loadSound('assets/beat');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startSound);\n * // create a 'mix' gain bus to which we will connect both soundfiles\n * mixGain = new p5.Gain();\n * mixGain.connect();\n * sound1.disconnect(); // diconnect from p5 output\n * sound1Gain = new p5.Gain(); // setup a gain node\n * sound1Gain.setInput(sound1); // connect the first sound to its input\n * sound1Gain.connect(mixGain); // connect its output to the final mix bus\n * sound2.disconnect();\n * sound2Gain = new p5.Gain();\n * sound2Gain.setInput(sound2);\n * sound2Gain.connect(mixGain);\n * }\n * function startSound() {\n * sound1.loop();\n * sound2.loop();\n * loop();\n * }\n * function mouseReleased() {\n * sound1.stop();\n * sound2.stop();\n * }\n * function draw(){\n * background(220);\n * textAlign(CENTER);\n * textSize(11);\n * fill(0);\n * if (!sound1.isPlaying()) {\n * text('tap and drag to play', width/2, height/2);\n * return;\n * }\n * // map the horizontal position of the mouse to values useable for volume * control of sound1\n * var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);\n * var sound2Volume = 1-sound1Volume;\n * sound1Gain.amp(sound1Volume);\n * sound2Gain.amp(sound2Volume);\n * // map the vertical position of the mouse to values useable for 'output * volume control'\n * var outputVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\n * mixGain.amp(outputVolume);\n * text('output', width/2, height - outputVolume * height * 0.9)\n * fill(255, 0, 255);\n * textAlign(LEFT);\n * text('sound1', 5, height - sound1Volume * height * 0.9);\n * textAlign(RIGHT);\n * text('sound2', width - 5, height - sound2Volume * height * 0.9);\n * }\n *
\n */\n\nclass Gain {\n constructor() {\n this.ac = p5sound.audiocontext;\n\n this.input = this.ac.createGain();\n this.output = this.ac.createGain();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n this.input.connect(this.output);\n\n // add to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connect a source to the gain node.\n *\n * @method setInput\n * @for p5.Gain\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n */\n\n setInput(src) {\n src.connect(this.input);\n }\n\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Gain\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5.soundOut.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Gain\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Set the output level of the gain node.\n *\n * @method amp\n * @for p5.Gain\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n var now = p5sound.audiocontext.currentTime;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n }\n}\n\nexport default Gain;\n","import p5sound from './main';\n\n/**\n * Base class for monophonic synthesizers. Any extensions of this class\n * should follow the API and implement the methods below in order to\n * remain compatible with p5.PolySynth();\n *\n * @class p5.AudioVoice\n * @constructor\n */\nclass AudioVoice {\n constructor() {\n this.ac = p5sound.audiocontext;\n this.output = this.ac.createGain();\n this.connect();\n p5sound.soundArray.push(this);\n }\n play(note, velocity, secondsFromNow, sustime) {}\n\n triggerAttack(note, velocity, secondsFromNow) {}\n\n triggerRelease(secondsFromNow) {}\n\n amp(vol, rampTime) {}\n\n /**\n * Connect to p5 objects or Web Audio Nodes\n * @method connect\n * @for p5.AudioVoice\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect from soundOut\n * @method disconnect\n * @for p5.AudioVoice\n */\n disconnect() {\n this.output.disconnect();\n }\n\n dispose() {\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n }\n}\n\nexport default AudioVoice;\n","import AudioVoice from './audioVoice';\nimport Envelope from './envelope';\nimport p5sound from './main';\nimport Oscillator from './oscillator';\nimport { noteToFreq } from './helpers';\n\nvar DEFAULT_SUSTAIN = 0.15;\n\n/**\n * A MonoSynth is used as a single voice for sound synthesis.\n * This is a class to be used in conjunction with the PolySynth\n * class. Custom synthetisers should be built inheriting from\n * this class.\n *\n * @class p5.MonoSynth\n * @constructor\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * let note = random(['Fb4', 'G4']);\n * // note velocity (volume, from 0 to 1)\n * let velocity = random();\n * // time from now (in seconds)\n * let time = 0;\n * // note duration (in seconds)\n * let dur = 1/6;\n *\n * monoSynth.play(note, velocity, time, dur);\n * }\n *
\n **/\n\nclass MonoSynth extends AudioVoice {\n constructor() {\n super();\n this.oscillator = new Oscillator();\n\n this.env = new Envelope(); //to be changed\n this.env.setRange(1, 0);\n this.env.setExp(true);\n\n //set params\n this.setADSR(0.02, 0.25, 0.05, 0.35);\n\n // oscillator --> env --> this.output (gain) --> p5.soundOut\n this.oscillator.disconnect();\n this.oscillator.connect(this.output);\n\n this.env.disconnect();\n this.env.setInput(this.output.gain);\n\n // reset oscillator gain to 1.0\n this.oscillator.output.gain.value = 1.0;\n\n this.oscillator.start();\n this.connect();\n\n p5sound.soundArray.push(this);\n\n /**\n * Getters and Setters\n * @property {Number} attack\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} decay\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} sustain\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} release\n * @for p5.MonoSynth\n */\n Object.defineProperties(this, {\n attack: {\n get: function () {\n return this.env.aTime;\n },\n set: function (attack) {\n this.env.setADSR(\n attack,\n this.env.dTime,\n this.env.sPercent,\n this.env.rTime\n );\n },\n },\n decay: {\n get: function () {\n return this.env.dTime;\n },\n set: function (decay) {\n this.env.setADSR(\n this.env.aTime,\n decay,\n this.env.sPercent,\n this.env.rTime\n );\n },\n },\n sustain: {\n get: function () {\n return this.env.sPercent;\n },\n set: function (sustain) {\n this.env.setADSR(\n this.env.aTime,\n this.env.dTime,\n sustain,\n this.env.rTime\n );\n },\n },\n release: {\n get: function () {\n return this.env.rTime;\n },\n set: function (release) {\n this.env.setADSR(\n this.env.aTime,\n this.env.dTime,\n this.env.sPercent,\n release\n );\n },\n },\n });\n }\n\n /**\n * Play tells the MonoSynth to start playing a note. This method schedules\n * the calling of .triggerAttack and .triggerRelease.\n *\n * @method play\n * @for p5.MonoSynth\n * @param {String | Number} note the note you want to play, specified as a\n * frequency in Hertz (Number) or as a midi\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n * See \n * Tone. Defaults to 440 hz.\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope. Defaults to 0.15 seconds.\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * let note = random(['Fb4', 'G4']);\n * // note velocity (volume, from 0 to 1)\n * let velocity = random();\n * // time from now (in seconds)\n * let time = 0;\n * // note duration (in seconds)\n * let dur = 1/6;\n *\n * monoSynth.play(note, velocity, time, dur);\n * }\n *
\n *\n */\n play(note, velocity, secondsFromNow, susTime) {\n this.triggerAttack(note, velocity, ~~secondsFromNow);\n this.triggerRelease(~~secondsFromNow + (susTime || DEFAULT_SUSTAIN));\n }\n\n /**\n * Trigger the Attack, and Decay portion of the Envelope.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go.\n *\n * @param {String | Number} note the note you want to play, specified as a\n * frequency in Hertz (Number) or as a midi\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n * See \n * Tone. Defaults to 440 hz\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @method triggerAttack\n * @for p5.MonoSynth\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(triggerAttack);\n * background(220);\n * text('tap here for attack, let go to release', 5, 20, width - 20);\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function triggerAttack() {\n * userStartAudio();\n *\n * monoSynth.triggerAttack(\"E3\");\n * }\n *\n * function mouseReleased() {\n * monoSynth.triggerRelease();\n * }\n *
\n */\n triggerAttack(note, velocity, secondsFromNow = 0) {\n var freq = noteToFreq(note);\n var vel = velocity || 0.1;\n this.oscillator.freq(freq, 0, secondsFromNow);\n this.env.ramp(this.output.gain, secondsFromNow, vel);\n }\n\n /**\n * Trigger the release of the Envelope. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @param {Number} secondsFromNow time to trigger the release\n * @method triggerRelease\n * @for p5.MonoSynth\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(triggerAttack);\n * background(220);\n * text('tap here for attack, let go to release', 5, 20, width - 20);\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function triggerAttack() {\n * userStartAudio();\n *\n * monoSynth.triggerAttack(\"E3\");\n * }\n *\n * function mouseReleased() {\n * monoSynth.triggerRelease();\n * }\n *
\n */\n triggerRelease(secondsFromNow = 0) {\n this.env.ramp(this.output.gain, secondsFromNow, 0);\n }\n\n /**\n * Set values like a traditional\n * \n * ADSR envelope\n * .\n *\n * @method setADSR\n * @for p5.MonoSynth\n * @param {Number} attackTime Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n */\n setADSR(attack, decay, sustain, release) {\n this.env.setADSR(attack, decay, sustain, release);\n }\n\n /**\n * MonoSynth amp\n * @method amp\n * @for p5.MonoSynth\n * @param {Number} vol desired volume\n * @param {Number} [rampTime] Time to reach new volume\n * @return {Number} new volume value\n */\n amp(vol, rampTime) {\n var t = rampTime || 0;\n if (typeof vol !== 'undefined') {\n this.oscillator.amp(vol, t);\n }\n return this.oscillator.amp().value;\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.MonoSynth\n * @param {Object} unit A p5.sound or Web Audio object\n */\n\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.MonoSynth\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Get rid of the MonoSynth and free up its resources / memory.\n *\n * @method dispose\n * @for p5.MonoSynth\n */\n dispose() {\n super.dispose();\n\n if (this.env) {\n this.env.dispose();\n }\n if (this.oscillator) {\n this.oscillator.dispose();\n }\n }\n}\n\nexport default MonoSynth;\n","/**\n * Listen for onsets (a sharp increase in volume) within a given\n * frequency range.\n *\n * @class p5.OnsetDetect\n * @constructor\n * @param {Number} freqLow Low frequency\n * @param {Number} freqHigh High frequency\n * @param {Number} threshold Amplitude threshold between 0 (no energy) and 1 (maximum)\n * @param {Function} callback Function to call when an onset is detected\n */\nclass OnsetDetect {\n constructor(freqLow, freqHigh, threshold, callback) {\n this.isDetected = false;\n this.freqLow = freqLow;\n this.freqHigh = freqHigh;\n this.treshold = threshold;\n this.energy = 0;\n this.penergy = 0;\n\n // speed of decay\n this.sensitivity = 500;\n\n this.callback = callback;\n }\n\n // callback here too?\n update(fftObject, callback) {\n this.energy = fftObject.getEnergy(this.freqLow, this.freqHigh) / 255;\n\n if (this.isDetected === false) {\n if (this.energy - this.penergy > this.treshold) {\n this.isDetected = true;\n\n if (this.callback) {\n this.callback(this.energy);\n } else if (callback) {\n callback(this.energy);\n }\n\n var self = this;\n setTimeout(function () {\n self.isDetected = false;\n }, this.sensitivity);\n }\n }\n\n this.penergy = this.energy;\n }\n}\n\nexport default OnsetDetect;\n","import p5sound from './main';\nimport TimelineSignal from 'Tone/signal/TimelineSignal.js';\nimport { noteToFreq, freqToMidi } from './helpers';\n\n/**\n * An AudioVoice is used as a single voice for sound synthesis.\n * The PolySynth class holds an array of AudioVoice, and deals\n * with voices allocations, with setting notes to be played, and\n * parameters to be set.\n *\n * @class p5.PolySynth\n * @constructor\n *\n * @param {Number} [synthVoice] A monophonic synth voice inheriting\n * the AudioVoice class. Defaults to p5.MonoSynth\n * @param {Number} [maxVoices] Number of voices, defaults to 8;\n * @example\n *
\n * let polySynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * text('click to play', 20, 20);\n *\n * polySynth = new p5.PolySynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * // note duration (in seconds)\n * let dur = 1.5;\n *\n * // time from now (in seconds)\n * let time = 0;\n *\n * // velocity (volume, from 0 to 1)\n * let vel = 0.1;\n *\n * // notes can overlap with each other\n * polySynth.play('G2', vel, 0, dur);\n * polySynth.play('C3', vel, time += 1/3, dur);\n * polySynth.play('G3', vel, time += 1/3, dur);\n * }\n *
\n **/\nclass PolySynth {\n constructor(audioVoice, maxVoices) {\n //audiovoices will contain maxVoices many monophonic synths\n this.audiovoices = [];\n\n /**\n * An object that holds information about which notes have been played and\n * which notes are currently being played. New notes are added as keys\n * on the fly. While a note has been attacked, but not released, the value of the\n * key is the audiovoice which is generating that note. When notes are released,\n * the value of the key becomes undefined.\n * @property notes\n */\n this.notes = {};\n\n //indices of the most recently used, and least recently used audiovoice\n this._newest = 0;\n this._oldest = 0;\n\n /**\n * A PolySynth must have at least 1 voice, defaults to 8\n * @property polyvalue\n */\n this.maxVoices = maxVoices || 8;\n\n /**\n * Monosynth that generates the sound for each note that is triggered. The\n * p5.PolySynth defaults to using the p5.MonoSynth as its voice.\n * @property AudioVoice\n */\n this.AudioVoice = audioVoice === undefined ? p5.MonoSynth : audioVoice;\n\n /**\n * This value must only change as a note is attacked or released. Due to delay\n * and sustain times, Tone.TimelineSignal is required to schedule the change in value.\n * @private\n * @property {Tone.TimelineSignal} _voicesInUse\n */\n this._voicesInUse = new TimelineSignal(0);\n\n this.output = p5sound.audiocontext.createGain();\n this.connect();\n\n //Construct the appropriate number of audiovoices\n this._allocateVoices();\n p5sound.soundArray.push(this);\n }\n\n /**\n * Construct the appropriate number of audiovoices\n * @private\n * @for p5.PolySynth\n * @method _allocateVoices\n */\n _allocateVoices() {\n for (var i = 0; i < this.maxVoices; i++) {\n this.audiovoices.push(new this.AudioVoice());\n this.audiovoices[i].disconnect();\n this.audiovoices[i].connect(this.output);\n }\n }\n\n /**\n * Play a note by triggering noteAttack and noteRelease with sustain time\n *\n * @method play\n * @for p5.PolySynth\n * @param {Number} [note] midi note to play (ranging from 0 to 127 - 60 being a middle C)\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\n * @example\n *
\n * let polySynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * text('click to play', 20, 20);\n *\n * polySynth = new p5.PolySynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * // note duration (in seconds)\n * let dur = 1.5;\n *\n * // time from now (in seconds)\n * let time = 0;\n *\n * // velocity (volume, from 0 to 1)\n * let vel = 0.1;\n *\n * // notes can overlap with each other\n * polySynth.play('G2', vel, 0, dur);\n * polySynth.play('C3', vel, time += 1/3, dur);\n * polySynth.play('G3', vel, time += 1/3, dur);\n * }\n *
\n */\n play(note, velocity, secondsFromNow, susTime = 1) {\n this.noteAttack(note, velocity, secondsFromNow);\n this.noteRelease(note, secondsFromNow + susTime);\n }\n\n /**\n * noteADSR sets the envelope for a specific note that has just been triggered.\n * Using this method modifies the envelope of whichever audiovoice is being used\n * to play the desired note. The envelope should be reset before noteRelease is called\n * in order to prevent the modified envelope from being used on other notes.\n *\n * @method noteADSR\n * @for p5.PolySynth\n * @param {Number} [note] Midi note on which ADSR should be set.\n * @param {Number} [attackTime] Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n **/\n\n noteADSR(note, a, d, s, r, timeFromNow = 0) {\n var now = p5sound.audiocontext.currentTime;\n var t = now + timeFromNow;\n this.audiovoices[this.notes[note].getValueAtTime(t)].setADSR(a, d, s, r);\n }\n\n /**\n * Set the PolySynths global envelope. This method modifies the envelopes of each\n * monosynth so that all notes are played with this envelope.\n *\n * @method setADSR\n * @for p5.PolySynth\n * @param {Number} [attackTime] Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n **/\n setADSR(a, d, s, r) {\n this.audiovoices.forEach(function (voice) {\n voice.setADSR(a, d, s, r);\n });\n }\n\n /**\n * Trigger the Attack, and Decay portion of a MonoSynth.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go.\n *\n * @method noteAttack\n * @for p5.PolySynth\n * @param {Number} [note] midi note on which attack should be triggered.\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)/\n * @param {Number} [secondsFromNow] time from now (in seconds)\n * @example\n *
\n * let polySynth = new p5.PolySynth();\n * let pitches = ['G', 'D', 'G', 'C'];\n * let octaves = [2, 3, 4];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playChord);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playChord() {\n * userStartAudio();\n *\n * // play a chord: multiple notes at the same time\n * for (let i = 0; i < 4; i++) {\n * let note = random(pitches) + random(octaves);\n * polySynth.noteAttack(note, 0.1);\n * }\n * }\n *\n * function mouseReleased() {\n * // release all voices\n * polySynth.noteRelease();\n * }\n *
\n */\n noteAttack(_note, _velocity, secondsFromNow = 0) {\n //this value is used by this._voicesInUse\n var acTime = p5sound.audiocontext.currentTime + secondsFromNow;\n\n //Convert note to frequency if necessary. This is because entries into this.notes\n //should be based on frequency for the sake of consistency.\n var note = noteToFreq(_note);\n var velocity = _velocity || 0.1;\n\n var currentVoice;\n\n //Release the note if it is already playing\n if (this.notes[note] && this.notes[note].getValueAtTime(acTime) !== null) {\n this.noteRelease(note, 0);\n }\n\n //Check to see how many voices are in use at the time the note will start\n if (this._voicesInUse.getValueAtTime(acTime) < this.maxVoices) {\n currentVoice = Math.max(~~this._voicesInUse.getValueAtTime(acTime), 0);\n }\n //If we are exceeding the polyvalue, bump off the oldest notes and replace\n //with a new note\n else {\n currentVoice = this._oldest;\n\n oldestNote = freqToMidi(\n this.audiovoices[this._oldest].oscillator.freq().value\n );\n this.noteRelease(oldestNote);\n this._oldest = (this._oldest + 1) % (this.maxVoices - 1);\n }\n\n //Overrite the entry in the notes object. A note (frequency value)\n //corresponds to the index of the audiovoice that is playing it\n this.notes[note] = new TimelineSignal();\n this.notes[note].setValueAtTime(currentVoice, acTime);\n\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\n //Add 1 and schedule this value at time 't', when this note will start playing\n var previousVal =\n this._voicesInUse._searchBefore(acTime) === null\n ? 0\n : this._voicesInUse._searchBefore(acTime).value;\n this._voicesInUse.setValueAtTime(previousVal + 1, acTime);\n\n //Then update all scheduled values that follow to increase by 1\n this._updateAfter(acTime, 1);\n\n this._newest = currentVoice;\n //The audiovoice handles the actual scheduling of the note\n if (typeof velocity === 'number') {\n var maxRange = (1 / this._voicesInUse.getValueAtTime(acTime)) * 2;\n velocity = velocity > maxRange ? maxRange : velocity;\n }\n\n // use secondsFromNow because this method will add AudioContext currentTime\n this.audiovoices[currentVoice].triggerAttack(\n note,\n velocity,\n secondsFromNow\n );\n }\n\n /**\n * Private method to ensure accurate values of this._voicesInUse\n * Any time a new value is scheduled, it is necessary to increment all subsequent\n * scheduledValues after attack, and decrement all subsequent\n * scheduledValues after release\n *\n * @private\n * @for p5.PolySynth\n * @param {[type]} time [description]\n * @param {[type]} value [description]\n * @return {[type]} [description]\n */\n _updateAfter(time, value) {\n if (this._voicesInUse._searchAfter(time) === null) {\n return;\n } else {\n this._voicesInUse._searchAfter(time).value += value;\n var nextTime = this._voicesInUse._searchAfter(time).time;\n this._updateAfter(nextTime, value);\n }\n }\n\n /**\n * Trigger the Release of an AudioVoice note. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @method noteRelease\n * @for p5.PolySynth\n * @param {Number} [note] midi note on which attack should be triggered.\n * If no value is provided, all notes will be released.\n * @param {Number} [secondsFromNow] time to trigger the release\n * @example\n *
\n * let polySynth = new p5.PolySynth();\n * let pitches = ['G', 'D', 'G', 'C'];\n * let octaves = [2, 3, 4];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playChord);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playChord() {\n * userStartAudio();\n *\n * // play a chord: multiple notes at the same time\n * for (let i = 0; i < 4; i++) {\n * let note = random(pitches) + random(octaves);\n * polySynth.noteAttack(note, 0.1);\n * }\n * }\n *\n * function mouseReleased() {\n * // release all voices\n * polySynth.noteRelease();\n * }\n *
\n *\n */\n noteRelease(_note, secondsFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n\n // if a note value is not provided, release all voices\n if (!_note) {\n this.audiovoices.forEach(function (voice) {\n voice.triggerRelease(tFromNow);\n });\n this._voicesInUse.setValueAtTime(0, t);\n for (var n in this.notes) {\n this.notes[n].dispose();\n delete this.notes[n];\n }\n return;\n }\n\n //Make sure note is in frequency inorder to query the this.notes object\n var note = noteToFreq(_note);\n\n if (!this.notes[note] || this.notes[note].getValueAtTime(t) === null) {\n console.warn('Cannot release a note that is not already playing');\n } else {\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\n //subtract 1 and schedule this value at time 't', when this note will stop playing\n var previousVal = Math.max(\n ~~this._voicesInUse.getValueAtTime(t).value,\n 1\n );\n this._voicesInUse.setValueAtTime(previousVal - 1, t);\n //Then update all scheduled values that follow to decrease by 1 but never go below 0\n if (previousVal > 0) {\n this._updateAfter(t, -1);\n }\n\n this.audiovoices[this.notes[note].getValueAtTime(t)].triggerRelease(\n tFromNow\n );\n this.notes[note].dispose();\n delete this.notes[note];\n\n this._newest =\n this._newest === 0 ? 0 : (this._newest - 1) % (this.maxVoices - 1);\n }\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.PolySynth\n * @param {Object} unit A p5.sound or Web Audio object\n */\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.PolySynth\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Get rid of the MonoSynth and free up its resources / memory.\n *\n * @method dispose\n * @for p5.PolySynth\n */\n dispose() {\n this.audiovoices.forEach(function (voice) {\n voice.dispose();\n });\n\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n }\n}\n\nexport default PolySynth;\n","class Signal {\n constructor() {\n console.warn('p5.Signal is deprecated , Use Tone.js Signal instead ');\n }\n}\n\nexport default Signal;\n","import 'audioworklet-polyfill';\nimport './shims';\n\nimport { getAudioContext, userStartAudio } from './audiocontext';\np5.prototype.getAudioContext = getAudioContext;\np5.prototype.userStartAudio = userStartAudio;\n\nimport './main';\n\nimport {\n sampleRate,\n freqToMidi,\n midiToFreq,\n noteToFreq,\n soundFormats,\n disposeSound,\n _checkFileFormats,\n _mathChain,\n convertToWav,\n interleave,\n writeUTFBytes,\n safeBufferSize,\n saveSound,\n} from './helpers';\np5.prototype.sampleRate = sampleRate;\np5.prototype.freqToMidi = freqToMidi;\np5.prototype.midiToFreq = midiToFreq;\np5.prototype.noteToFreq = noteToFreq;\np5.prototype.soundFormats = soundFormats;\np5.prototype.disposeSound = disposeSound;\np5.prototype._checkFileFormats = _checkFileFormats;\np5.prototype._mathChain = _mathChain;\np5.prototype.convertToWav = convertToWav;\np5.prototype.interleave = interleave;\np5.prototype.writeUTFBytes = writeUTFBytes;\np5.prototype.safeBufferSize = safeBufferSize;\np5.prototype.saveSound = saveSound;\n\n// register removeSound to dispose of p5sound SoundFiles, Convolvers,\n// Oscillators etc when sketch ends\np5.prototype.registerMethod('remove', p5.prototype.disposeSound);\n\nimport './errorHandler';\nimport './audioWorklet';\n\nimport Panner from './panner';\np5.Panner = Panner;\n\nimport SoundFile, { loadSound } from './soundfile';\np5.SoundFile = SoundFile;\np5.prototype.loadSound = loadSound;\n// register preload handling of loadSound\np5.prototype.registerPreloadMethod('loadSound', p5.prototype);\n\nimport Amplitude from './amplitude';\np5.Amplitude = Amplitude;\n\nimport FFT from './fft';\np5.FFT = FFT;\n\nimport Oscillator, { SinOsc, TriOsc, SawOsc, SqrOsc } from './oscillator';\np5.Oscillator = Oscillator;\np5.SinOsc = SinOsc;\np5.TriOsc = TriOsc;\np5.SawOsc = SawOsc;\np5.SqrOsc = SqrOsc;\n\nimport './envelope';\n\nimport Noise from './noise';\np5.Noise = Noise;\n\nimport Pulse from './pulse';\np5.Pulse = Pulse;\n\nimport AudioIn from './audioin';\np5.AudioIn = AudioIn;\n\nimport Effect from './effect';\np5.Effect = Effect;\n\nimport Filter, { LowPass, HighPass, BandPass } from './filter';\np5.Filter = Filter;\np5.LowPass = LowPass;\np5.HighPass = HighPass;\np5.BandPass = BandPass;\n\nimport EQ from './eq';\np5.EQ = EQ;\n\nimport listener3D from './listener3d';\np5.listener3D = listener3D;\n\nimport Panner3D from './panner3d';\np5.Panner3D = Panner3D;\n\nimport Delay from './delay';\np5.Delay = Delay;\n\nimport { Reverb, Convolver, createConvolver } from './reverb';\np5.Reverb = Reverb;\np5.Convolver = Convolver;\np5.prototype.createConvolver = createConvolver;\np5.prototype.registerPreloadMethod('createConvolver', p5.prototype);\n\nimport Metro from './metro';\np5.Metro = Metro;\n\nimport { Phrase, Part, Score } from './looper';\np5.Phrase = Phrase;\np5.Part = Part;\np5.Score = Score;\n\nimport SoundLoop from './soundLoop';\np5.SoundLoop = SoundLoop;\n\nimport Compressor from './compressor';\np5.Compressor = Compressor;\n\nimport peakDetect from './peakDetect';\np5.peakDetect = peakDetect;\n\nimport SoundRecorder from './soundRecorder';\np5.SoundRecorder = SoundRecorder;\n\nimport Distortion from './distortion';\np5.Distortion = Distortion;\n\nimport Gain from './gain';\np5.Gain = Gain;\n\nimport AudioVoice from './audioVoice';\np5.AudioVoice = AudioVoice;\n\nimport MonoSynth from './monosynth';\np5.MonoSynth = MonoSynth;\n\nimport OnsetDetect from './onsetDetect';\np5.OnsetDetect = OnsetDetect;\n\nimport PolySynth from './polysynth';\np5.PolySynth = PolySynth;\n\n// Following are the deprecated classes\nimport Signal from './deprecations/Signal';\np5.Signal = Signal;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/lib/p5.sound.min.js b/lib/p5.sound.min.js index 496c8638..bd49587d 100644 --- a/lib/p5.sound.min.js +++ b/lib/p5.sound.min.js @@ -1,3 +1,3 @@ -/** [p5.sound] Version: 1.0.0 - 2021-04-19 */ - !function(n){var i={};function r(t){if(i[t])return i[t].exports;var e=i[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}r.m=n,r.c=i,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=40)}([function(t,e,n){var i;void 0===(i=function(){"use strict";function l(t,e){this.isUndef(t)||1===t?this.input=this.context.createGain():1t)this.cancelScheduledValues(t),this.linearRampToValueAtTime(e,t);else{var i=this._searchAfter(t);i&&(this.cancelScheduledValues(t),i.type===u.TimelineSignal.Type.Linear?this.linearRampToValueAtTime(e,t):i.type===u.TimelineSignal.Type.Exponential&&this.exponentialRampToValueAtTime(e,t)),this.setValueAtTime(e,t)}return this},u.TimelineSignal.prototype.linearRampToValueBetween=function(t,e,n){return this.setRampPoint(e),this.linearRampToValueAtTime(t,n),this},u.TimelineSignal.prototype.exponentialRampToValueBetween=function(t,e,n){return this.setRampPoint(e),this.exponentialRampToValueAtTime(t,n),this},u.TimelineSignal.prototype._searchBefore=function(t){return this._events.get(t)},u.TimelineSignal.prototype._searchAfter=function(t){return this._events.getAfter(t)},u.TimelineSignal.prototype.getValueAtTime=function(t){t=this.toSeconds(t);var e=this._searchAfter(t),n=this._searchBefore(t),i=this._initial;if(null===n)i=this._initial;else if(n.type===u.TimelineSignal.Type.Target){var r,o=this._events.getBefore(n.time);r=null===o?this._initial:o.value,i=this._exponentialApproach(n.time,r,n.value,n.constant,t)}else i=n.type===u.TimelineSignal.Type.Curve?this._curveInterpolate(n.time,n.value,n.duration,t):null===e?n.value:e.type===u.TimelineSignal.Type.Linear?this._linearInterpolate(n.time,n.value,e.time,e.value,t):e.type===u.TimelineSignal.Type.Exponential?this._exponentialInterpolate(n.time,n.value,e.time,e.value,t):n.value;return i},u.TimelineSignal.prototype.connect=u.SignalBase.prototype.connect,u.TimelineSignal.prototype._exponentialApproach=function(t,e,n,i,r){return n+(e-n)*Math.exp(-(r-t)/i)},u.TimelineSignal.prototype._linearInterpolate=function(t,e,n,i,r){return e+(r-t)/(n-t)*(i-e)},u.TimelineSignal.prototype._exponentialInterpolate=function(t,e,n,i,r){return(e=Math.max(this._minOutput,e))*Math.pow(i/e,(r-t)/(n-t))},u.TimelineSignal.prototype._curveInterpolate=function(t,e,n,i){var r=e.length;if(t+n<=i)return e[r-1];if(i<=t)return e[0];var o=(i-t)/n,s=Math.floor((r-1)*o),a=Math.ceil((r-1)*o),u=e[s],c=e[a];return a===s?u:this._linearInterpolate(s,u,a,c,o*(r-1))},u.TimelineSignal.prototype.dispose=function(){u.Signal.prototype.dispose.call(this),u.Param.prototype.dispose.call(this),this._events.dispose(),this._events=null},u.TimelineSignal}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(4),n(1),n(2)],void 0===(r=function(n){"use strict";return n.Scale=function(t,e){this._outputMin=this.defaultArg(t,0),this._outputMax=this.defaultArg(e,1),this._scale=this.input=new n.Multiply(1),this._add=this.output=new n.Add(0),this._scale.connect(this._add),this._setRange()},n.extend(n.Scale,n.SignalBase),Object.defineProperty(n.Scale.prototype,"min",{get:function(){return this._outputMin},set:function(t){this._outputMin=t,this._setRange()}}),Object.defineProperty(n.Scale.prototype,"max",{get:function(){return this._outputMax},set:function(t){this._outputMax=t,this._setRange()}}),n.Scale.prototype._setRange=function(){this._add.value=this._outputMin,this._scale.value=this._outputMax-this._outputMin},n.Scale.prototype.dispose=function(){return n.prototype.dispose.call(this),this._add.dispose(),this._add=null,this._scale.dispose(),this._scale=null,this},n.Scale}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(16),n(30),n(31),n(12)],void 0===(r=function(e){return e.Type={Default:"number",Time:"time",Frequency:"frequency",TransportTime:"transportTime",Ticks:"ticks",NormalRange:"normalRange",AudioRange:"audioRange",Decibels:"db",Interval:"interval",BPM:"bpm",Positive:"positive",Cents:"cents",Degrees:"degrees",MIDI:"midi",BarsBeatsSixteenths:"barsBeatsSixteenths",Samples:"samples",Hertz:"hertz",Note:"note",Milliseconds:"milliseconds",Seconds:"seconds",Notation:"notation"},e.prototype.toSeconds=function(t){return this.isNumber(t)?t:this.isUndef(t)?this.now():this.isString(t)?new e.Time(t).toSeconds():t instanceof e.TimeBase?t.toSeconds():void 0},e.prototype.toFrequency=function(t){return this.isNumber(t)?t:this.isString(t)||this.isUndef(t)?new e.Frequency(t).valueOf():t instanceof e.TimeBase?t.toFrequency():void 0},e.prototype.toTicks=function(t){return this.isNumber(t)||this.isString(t)?new e.TransportTime(t).toTicks():this.isUndef(t)?e.Transport.ticks:t instanceof e.TimeBase?t.toTicks():void 0},e}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(18),n(9)],void 0===(r=function(n){"use strict";return window.GainNode&&!AudioContext.prototype.createGain&&(AudioContext.prototype.createGain=AudioContext.prototype.createGainNode),n.Gain=function(){var t=this.optionsObject(arguments,["gain","units"],n.Gain.defaults);this.input=this.output=this._gainNode=this.context.createGain(),this.gain=new n.Param({param:this._gainNode.gain,units:t.units,value:t.gain,convert:t.convert}),this._readOnly("gain")},n.extend(n.Gain),n.Gain.defaults={gain:1,convert:!0},n.Gain.prototype.dispose=function(){n.Param.prototype.dispose.call(this),this._gainNode.disconnect(),this._gainNode=null,this._writable("gain"),this.gain.dispose(),this.gain=null},n.prototype.createInsOuts=function(t,e){1===t?this.input=new n.Gain:1this._nextTick&&this._state;){var e=this._state.getValueAtTime(this._nextTick);if(e!==this._lastState){this._lastState=e;var n=this._state.get(this._nextTick);e===r.State.Started?(this._nextTick=n.time,this.isUndef(n.offset)||(this.ticks=n.offset),this.emit("start",n.time,this.ticks)):e===r.State.Stopped?(this.ticks=0,this.emit("stop",n.time)):e===r.State.Paused&&this.emit("pause",n.time)}var i=this._nextTick;this.frequency&&(this._nextTick+=1/this.frequency.getValueAtTime(this._nextTick),e===r.State.Started&&(this.callback(i),this.ticks++))}},r.Clock.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},r.Clock.prototype.dispose=function(){r.Emitter.prototype.dispose.call(this),this.context.off("tick",this._boundLoop),this._writable("frequency"),this.frequency.dispose(),this.frequency=null,this._boundLoop=null,this._nextTick=1/0,this.callback=null,this._state.dispose(),this._state=null},r.Clock}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(14)],void 0===(r=function(i){function t(t,e,n){if(t.input)Array.isArray(t.input)?(i.prototype.isUndef(n)&&(n=0),this.connect(t.input[n])):this.connect(t.input,e,n);else try{t instanceof AudioNode?r.call(this,t,e,n):r.call(this,t,e)}catch(e){throw new Error("error connecting to node: "+t+"\n"+e)}}var r,o;return!window.hasOwnProperty("AudioContext")&&window.hasOwnProperty("webkitAudioContext")&&(window.AudioContext=window.webkitAudioContext),i.Context=function(t){for(var e in i.Emitter.call(this),t=t||new window.AudioContext,this._context=t,this._context)this._defineProperty(this._context,e);this._latencyHint="interactive",this._lookAhead=.1,this._updateInterval=this._lookAhead/3,this._computedUpdateInterval=0,this._worker=this._createWorker(),this._constants={}},i.extend(i.Context,i.Emitter),i.Emitter.mixin(i.Context),i.Context.prototype._defineProperty=function(e,n){this.isUndef(this[n])&&Object.defineProperty(this,n,{get:function(){return"function"==typeof e[n]?e[n].bind(e):e[n]},set:function(t){e[n]=t}})},i.Context.prototype.now=function(){return this._context.currentTime},i.Context.prototype._createWorker=function(){window.URL=window.URL||window.webkitURL;var t=new Blob(["var timeoutTime = "+(1e3*this._updateInterval).toFixed(1)+";self.onmessage = function(msg){\ttimeoutTime = parseInt(msg.data);};function tick(){\tsetTimeout(tick, timeoutTime);\tself.postMessage('tick');}tick();"]),e=URL.createObjectURL(t),n=new Worker(e);return n.addEventListener("message",function(){this.emit("tick")}.bind(this)),n.addEventListener("message",function(){var t=this.now();if(this.isNumber(this._lastUpdate)){var e=t-this._lastUpdate;this._computedUpdateInterval=Math.max(e,.97*this._computedUpdateInterval)}this._lastUpdate=t}.bind(this)),n},i.Context.prototype.getConstant=function(t){if(this._constants[t])return this._constants[t];for(var e=this._context.createBuffer(1,128,this._context.sampleRate),n=e.getChannelData(0),i=0;ithis.memory){var n=this.length-this.memory;this._timeline.splice(0,n)}return this},e.Timeline.prototype.remove=function(t){if(this._iterating)this._toRemove.push(t);else{var e=this._timeline.indexOf(t);-1!==e&&this._timeline.splice(e,1)}return this},e.Timeline.prototype.get=function(t){var e=this._search(t);return-1!==e?this._timeline[e]:null},e.Timeline.prototype.peek=function(){return this._timeline[0]},e.Timeline.prototype.shift=function(){return this._timeline.shift()},e.Timeline.prototype.getAfter=function(t){var e=this._search(t);return e+1=t&&(this._timeline=[]);return this},e.Timeline.prototype.cancelBefore=function(t){if(this._timeline.length){var e=this._search(t);0<=e&&(this._timeline=this._timeline.slice(e+1))}return this},e.Timeline.prototype._search=function(t){var e=0,n=this._timeline.length,i=n;if(0t)return r;o.time>t?i=r:o.time=t;)n--;return this._iterate(e,n+1),this},e.Timeline.prototype.forEachAtTime=function(e,n){var t=this._search(e);return-1!==t&&this._iterate(function(t){t.time===e&&n(t)},0,t),this},e.Timeline.prototype.dispose=function(){e.prototype.dispose.call(this),this._timeline=null,this._toRemove=null},e.Timeline}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(1),n(2)],void 0===(r=function(t){"use strict";return t.Negate=function(){this._multiply=this.input=this.output=new t.Multiply(-1)},t.extend(t.Negate,t.SignalBase),t.Negate.prototype.dispose=function(){return t.prototype.dispose.call(this),this._multiply.dispose(),this._multiply=null,this},t.Negate}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(2),n(1),n(6)],void 0===(r=function(t){"use strict";return t.GreaterThanZero=function(){this._thresh=this.output=new t.WaveShaper(function(t){return t<=0?0:1},127),this._scale=this.input=new t.Multiply(1e4),this._scale.connect(this._thresh)},t.extend(t.GreaterThanZero,t.SignalBase),t.GreaterThanZero.prototype.dispose=function(){return t.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._thresh.dispose(),this._thresh=null,this},t.GreaterThanZero}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r,o;r=[],void 0===(o="function"==typeof(i=function(){var s=function(t,e){this._dragged=!1,this._element=t,this._bindedMove=this._moved.bind(this),this._bindedEnd=this._ended.bind(this,e),t.addEventListener("touchstart",this._bindedEnd),t.addEventListener("touchmove",this._bindedMove),t.addEventListener("touchend",this._bindedEnd),t.addEventListener("mouseup",this._bindedEnd)};function o(t){return"running"===t.state}return s.prototype._moved=function(t){this._dragged=!0},s.prototype._ended=function(t){this._dragged||function(t){var e=t.createBuffer(1,1,t.sampleRate),n=t.createBufferSource();n.buffer=e,n.connect(t.destination),n.start(0),t.resume&&t.resume()}(t),this._dragged=!1},s.prototype.dispose=function(){this._element.removeEventListener("touchstart",this._bindedEnd),this._element.removeEventListener("touchmove",this._bindedMove),this._element.removeEventListener("touchend",this._bindedEnd),this._element.removeEventListener("mouseup",this._bindedEnd),this._bindedMove=null,this._bindedEnd=null,this._element=null},function(e,t,n){var i=new Promise(function(t){!function(e,n){o(e)?n():function t(){o(e)?n():(requestAnimationFrame(t),e.resume&&e.resume())}()}(e,t)}),r=[];return function t(e,n,i){if(Array.isArray(e)||NodeList&&e instanceof NodeList)for(var r=0;r= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n\n\n this._framesAvailable += sourceLength;\n\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n\n this._readIndex += destinationLength;\n\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n\n this._framesAvailable -= destinationLength;\n\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }, {\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n }]);\n\n return RingBuffer;\n }()\n}["default"];\n\nvar RecorderProcessor =\n/*#__PURE__*/\nfunction (_AudioWorkletProcesso) {\n _inherits(RecorderProcessor, _AudioWorkletProcesso);\n\n function RecorderProcessor(options) {\n var _this;\n\n _classCallCheck(this, RecorderProcessor);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(RecorderProcessor).call(this));\n var processorOptions = options.processorOptions || {};\n _this.numOutputChannels = options.outputChannelCount || 2;\n _this.numInputChannels = processorOptions.numInputChannels || 2;\n _this.bufferSize = processorOptions.bufferSize || 1024;\n _this.recording = false;\n\n _this.clear();\n\n _this.port.onmessage = function (event) {\n var data = event.data;\n\n if (data.name === \'start\') {\n _this.record(data.duration);\n } else if (data.name === \'stop\') {\n _this.stop();\n }\n };\n\n return _this;\n }\n\n _createClass(RecorderProcessor, [{\n key: "process",\n value: function process(inputs) {\n if (!this.recording) {\n return true;\n } else if (this.sampleLimit && this.recordedSamples >= this.sampleLimit) {\n this.stop();\n return true;\n }\n\n var input = inputs[0];\n this.inputRingBuffer.push(input);\n\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n\n for (var channel = 0; channel < this.numOutputChannels; ++channel) {\n var inputChannelCopy = this.inputRingBufferArraySequence[channel].slice();\n\n if (channel === 0) {\n this.leftBuffers.push(inputChannelCopy);\n\n if (this.numInputChannels === 1) {\n this.rightBuffers.push(inputChannelCopy);\n }\n } else if (channel === 1 && this.numInputChannels > 1) {\n this.rightBuffers.push(inputChannelCopy);\n }\n }\n\n this.recordedSamples += this.bufferSize;\n }\n\n return true;\n }\n }, {\n key: "record",\n value: function record(duration) {\n if (duration) {\n this.sampleLimit = Math.round(duration * sampleRate);\n }\n\n this.recording = true;\n }\n }, {\n key: "stop",\n value: function stop() {\n this.recording = false;\n var buffers = this.getBuffers();\n var leftBuffer = buffers[0].buffer;\n var rightBuffer = buffers[1].buffer;\n this.port.postMessage({\n name: \'buffers\',\n leftBuffer: leftBuffer,\n rightBuffer: rightBuffer\n }, [leftBuffer, rightBuffer]);\n this.clear();\n }\n }, {\n key: "getBuffers",\n value: function getBuffers() {\n var buffers = [];\n buffers.push(this.mergeBuffers(this.leftBuffers));\n buffers.push(this.mergeBuffers(this.rightBuffers));\n return buffers;\n }\n }, {\n key: "mergeBuffers",\n value: function mergeBuffers(channelBuffer) {\n var result = new Float32Array(this.recordedSamples);\n var offset = 0;\n var lng = channelBuffer.length;\n\n for (var i = 0; i < lng; i++) {\n var buffer = channelBuffer[i];\n result.set(buffer, offset);\n offset += buffer.length;\n }\n\n return result;\n }\n }, {\n key: "clear",\n value: function clear() {\n var _this2 = this;\n\n this.leftBuffers = [];\n this.rightBuffers = [];\n this.inputRingBuffer = new RingBuffer(this.bufferSize, this.numInputChannels);\n this.inputRingBufferArraySequence = new Array(this.numInputChannels).fill(null).map(function () {\n return new Float32Array(_this2.bufferSize);\n });\n this.recordedSamples = 0;\n this.sampleLimit = null;\n }\n }]);\n\n return RecorderProcessor;\n}(_wrapNativeSuper(AudioWorkletProcessor));\n\nregisterProcessor(processorNames.recorderProcessor, RecorderProcessor);'},function(t,e,n){"use strict";n.r(e),e.default='function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n// import dependencies via preval.require so that they\'re available as values at compile time\nvar processorNames = {\n "recorderProcessor": "recorder-processor",\n "soundFileProcessor": "sound-file-processor",\n "amplitudeProcessor": "amplitude-processor"\n};\nvar RingBuffer = {\n "default":\n /*#__PURE__*/\n function () {\n /**\n * @constructor\n * @param {number} length Buffer length in frames.\n * @param {number} channelCount Buffer channel count.\n */\n function RingBuffer(length, channelCount) {\n _classCallCheck(this, RingBuffer);\n\n this._readIndex = 0;\n this._writeIndex = 0;\n this._framesAvailable = 0;\n this._channelCount = channelCount;\n this._length = length;\n this._channelData = [];\n\n for (var i = 0; i < this._channelCount; ++i) {\n this._channelData[i] = new Float32Array(length);\n }\n }\n /**\n * Getter for Available frames in buffer.\n *\n * @return {number} Available frames in buffer.\n */\n\n\n _createClass(RingBuffer, [{\n key: "push",\n\n /**\n * Push a sequence of Float32Arrays to buffer.\n *\n * @param {array} arraySequence A sequence of Float32Arrays.\n */\n value: function push(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // Transfer data from the |arraySequence| storage to the internal buffer.\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\n\n for (var i = 0; i < sourceLength; ++i) {\n var writeIndex = (this._writeIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\n }\n }\n\n this._writeIndex += sourceLength;\n\n if (this._writeIndex >= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n\n\n this._framesAvailable += sourceLength;\n\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n\n this._readIndex += destinationLength;\n\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n\n this._framesAvailable -= destinationLength;\n\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }, {\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n }]);\n\n return RingBuffer;\n }()\n}["default"];\n\nvar SoundFileProcessor =\n/*#__PURE__*/\nfunction (_AudioWorkletProcesso) {\n _inherits(SoundFileProcessor, _AudioWorkletProcesso);\n\n function SoundFileProcessor(options) {\n var _this;\n\n _classCallCheck(this, SoundFileProcessor);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SoundFileProcessor).call(this));\n var processorOptions = options.processorOptions || {};\n _this.bufferSize = processorOptions.bufferSize || 256;\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, 1);\n _this.inputRingBufferArraySequence = [new Float32Array(_this.bufferSize)];\n return _this;\n }\n\n _createClass(SoundFileProcessor, [{\n key: "process",\n value: function process(inputs) {\n var input = inputs[0]; // we only care about the first input channel, because that contains the position data\n\n this.inputRingBuffer.push([input[0]]);\n\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n var inputChannel = this.inputRingBufferArraySequence[0];\n var position = inputChannel[inputChannel.length - 1] || 0;\n this.port.postMessage({\n name: \'position\',\n position: position\n });\n }\n\n return true;\n }\n }]);\n\n return SoundFileProcessor;\n}(_wrapNativeSuper(AudioWorkletProcessor));\n\nregisterProcessor(processorNames.soundFileProcessor, SoundFileProcessor);'},function(t,e,n){"use strict";n.r(e),e.default='function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n// import dependencies via preval.require so that they\'re available as values at compile time\nvar processorNames = {\n "recorderProcessor": "recorder-processor",\n "soundFileProcessor": "sound-file-processor",\n "amplitudeProcessor": "amplitude-processor"\n};\nvar RingBuffer = {\n "default":\n /*#__PURE__*/\n function () {\n /**\n * @constructor\n * @param {number} length Buffer length in frames.\n * @param {number} channelCount Buffer channel count.\n */\n function RingBuffer(length, channelCount) {\n _classCallCheck(this, RingBuffer);\n\n this._readIndex = 0;\n this._writeIndex = 0;\n this._framesAvailable = 0;\n this._channelCount = channelCount;\n this._length = length;\n this._channelData = [];\n\n for (var i = 0; i < this._channelCount; ++i) {\n this._channelData[i] = new Float32Array(length);\n }\n }\n /**\n * Getter for Available frames in buffer.\n *\n * @return {number} Available frames in buffer.\n */\n\n\n _createClass(RingBuffer, [{\n key: "push",\n\n /**\n * Push a sequence of Float32Arrays to buffer.\n *\n * @param {array} arraySequence A sequence of Float32Arrays.\n */\n value: function push(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // Transfer data from the |arraySequence| storage to the internal buffer.\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\n\n for (var i = 0; i < sourceLength; ++i) {\n var writeIndex = (this._writeIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\n }\n }\n\n this._writeIndex += sourceLength;\n\n if (this._writeIndex >= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n\n\n this._framesAvailable += sourceLength;\n\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n\n this._readIndex += destinationLength;\n\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n\n this._framesAvailable -= destinationLength;\n\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }, {\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n }]);\n\n return RingBuffer;\n }()\n}["default"];\n\nvar AmplitudeProcessor =\n/*#__PURE__*/\nfunction (_AudioWorkletProcesso) {\n _inherits(AmplitudeProcessor, _AudioWorkletProcesso);\n\n function AmplitudeProcessor(options) {\n var _this;\n\n _classCallCheck(this, AmplitudeProcessor);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(AmplitudeProcessor).call(this));\n var processorOptions = options.processorOptions || {};\n _this.numOutputChannels = options.outputChannelCount || 1;\n _this.numInputChannels = processorOptions.numInputChannels || 2;\n _this.normalize = processorOptions.normalize || false;\n _this.smoothing = processorOptions.smoothing || 0;\n _this.bufferSize = processorOptions.bufferSize || 2048;\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, _this.numInputChannels);\n _this.outputRingBuffer = new RingBuffer(_this.bufferSize, _this.numOutputChannels);\n _this.inputRingBufferArraySequence = new Array(_this.numInputChannels).fill(null).map(function () {\n return new Float32Array(_this.bufferSize);\n });\n _this.stereoVol = [0, 0];\n _this.stereoVolNorm = [0, 0];\n _this.volMax = 0.001;\n\n _this.port.onmessage = function (event) {\n var data = event.data;\n\n if (data.name === \'toggleNormalize\') {\n _this.normalize = data.normalize;\n } else if (data.name === \'smoothing\') {\n _this.smoothing = Math.max(0, Math.min(1, data.smoothing));\n }\n };\n\n return _this;\n } // TO DO make this stereo / dependent on # of audio channels\n\n\n _createClass(AmplitudeProcessor, [{\n key: "process",\n value: function process(inputs, outputs) {\n var input = inputs[0];\n var output = outputs[0];\n var smoothing = this.smoothing;\n this.inputRingBuffer.push(input);\n\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n\n for (var channel = 0; channel < this.numInputChannels; ++channel) {\n var inputBuffer = this.inputRingBufferArraySequence[channel];\n var bufLength = inputBuffer.length;\n var sum = 0;\n\n for (var i = 0; i < bufLength; i++) {\n var x = inputBuffer[i];\n\n if (this.normalize) {\n sum += Math.max(Math.min(x / this.volMax, 1), -1) * Math.max(Math.min(x / this.volMax, 1), -1);\n } else {\n sum += x * x;\n }\n } // ... then take the square root of the sum.\n\n\n var rms = Math.sqrt(sum / bufLength);\n this.stereoVol[channel] = Math.max(rms, this.stereoVol[channel] * smoothing);\n this.volMax = Math.max(this.stereoVol[channel], this.volMax);\n } // calculate stero normalized volume and add volume from all channels together\n\n\n var volSum = 0;\n\n for (var index = 0; index < this.stereoVol.length; index++) {\n this.stereoVolNorm[index] = Math.max(Math.min(this.stereoVol[index] / this.volMax, 1), 0);\n volSum += this.stereoVol[index];\n } // volume is average of channels\n\n\n var volume = volSum / this.stereoVol.length; // normalized value\n\n var volNorm = Math.max(Math.min(volume / this.volMax, 1), 0);\n this.port.postMessage({\n name: \'amplitude\',\n volume: volume,\n volNorm: volNorm,\n stereoVol: this.stereoVol,\n stereoVolNorm: this.stereoVolNorm\n }); // pass input through to output\n\n this.outputRingBuffer.push(this.inputRingBufferArraySequence);\n } // pull 128 frames out of the ring buffer\n // if the ring buffer does not have enough frames, the output will be silent\n\n\n this.outputRingBuffer.pull(output);\n return true;\n }\n }]);\n\n return AmplitudeProcessor;\n}(_wrapNativeSuper(AudioWorkletProcessor));\n\nregisterProcessor(processorNames.amplitudeProcessor, AmplitudeProcessor);'},function(t,e,n){var i,r;i=[n(0),n(17)],void 0===(r=function(r){r.Frequency=function(t,e){if(!(this instanceof r.Frequency))return new r.Frequency(t,e);r.TimeBase.call(this,t,e)},r.extend(r.Frequency,r.TimeBase),r.Frequency.prototype._primaryExpressions=Object.create(r.TimeBase.prototype._primaryExpressions),r.Frequency.prototype._primaryExpressions.midi={regexp:/^(\d+(?:\.\d+)?midi)/,method:function(t){return this.midiToFrequency(t)}},r.Frequency.prototype._primaryExpressions.note={regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method:function(t,e){var n=i[t.toLowerCase()]+12*(parseInt(e)+1);return this.midiToFrequency(n)}},r.Frequency.prototype._primaryExpressions.tr={regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method:function(t,e,n){var i=1;return t&&"0"!==t&&(i*=this._beatsToUnits(this._timeSignature()*parseFloat(t))),e&&"0"!==e&&(i*=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(i*=this._beatsToUnits(parseFloat(n)/4)),i}},r.Frequency.prototype.transpose=function(t){return this._expr=function(t,e){return t()*this.intervalToFrequencyRatio(e)}.bind(this,this._expr,t),this},r.Frequency.prototype.harmonize=function(t){return this._expr=function(t,e){for(var n=t(),i=[],r=0;rthis.buffer.duration)throw"jump time out of range";if(e>this.buffer.duration-t)throw"end time out of range";var n=t||0,i=e||void 0;this.isPlaying()&&(this.stop(0),this.play(0,this.playbackRate,this.output.gain.value,n,i))}},{key:"channels",value:function(){return this.buffer.numberOfChannels}},{key:"sampleRate",value:function(){return this.buffer.sampleRate}},{key:"frames",value:function(){return this.buffer.length}},{key:"getPeaks",value:function(t){if(!this.buffer)throw"Cannot load peaks yet, buffer is not loaded";if(t=t||5*window.width,this.buffer){for(var e=this.buffer,n=e.length/t,i=~~(n/10)||1,r=e.numberOfChannels,o=new Float32Array(Math.round(t)),s=0;so[u])&&(o[u]=h)}return o}}},{key:"reverseBuffer",value:function(){if(!this.buffer)throw"SoundFile is not done loading";var t=this._lastPos/R.sampleRate,e=this.getVolume();this.setVolume(0,.001);for(var n=this.buffer.numberOfChannels,i=0;it[o].hi&&o++,r[o]=void 0!==r[o]?(r[o]+n[s])/2:n[s]}return r}},{key:"getOctaveBands",value:function(t,e){var n=t||3,i=e||15.625,r=[],o={lo:i/Math.pow(2,1/(2*n)),ctr:i,hi:i*Math.pow(2,1/(2*n))};r.push(o);for(var s=p.audiocontext.sampleRate/2;o.hi=this._maxDelay)throw new Error("Delay Time exceeds maximum delay time of "+this._maxDelay+" second.");t.connect(this.input),this.leftDelay.delayTime.setValueAtTime(o,this.ac.currentTime),this.rightDelay.delayTime.setValueAtTime(o,this.ac.currentTime),this._leftGain.gain.value=r,this._rightGain.gain.value=r,i&&(this._leftFilter.freq(i),this._rightFilter.freq(i))}},{key:"delayTime",value:function(t){"number"!=typeof t?(t.connect(this.leftDelay.delayTime),t.connect(this.rightDelay.delayTime)):(this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime),this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime),this.leftDelay.delayTime.linearRampToValueAtTime(t,this.ac.currentTime),this.rightDelay.delayTime.linearRampToValueAtTime(t,this.ac.currentTime))}},{key:"feedback",value:function(t){if(t&&"number"!=typeof t)t.connect(this._leftGain.gain),t.connect(this._rightGain.gain);else{if(1<=t)throw new Error("Feedback value will force a positive feedback loop.");"number"==typeof t&&(this._leftGain.gain.value=t,this._rightGain.gain.value=t)}return this._leftGain.gain.value}},{key:"filter",value:function(t,e){this._leftFilter.set(t,e),this._rightFilter.set(t,e)}},{key:"setType",value:function(t){switch(1===t&&(t="pingPong"),this._split.disconnect(),this._leftFilter.disconnect(),this._rightFilter.disconnect(),this._split.connect(this.leftDelay,0),this._split.connect(this.rightDelay,1),t){case"pingPong":this._rightFilter.setType(this._leftFilter.biquad.type),this._leftFilter.output.connect(this._merge,0,0),this._rightFilter.output.connect(this._merge,0,1),this._leftFilter.output.connect(this.rightDelay),this._rightFilter.output.connect(this.leftDelay);break;default:this._leftFilter.output.connect(this._merge,0,0),this._rightFilter.output.connect(this._merge,0,1),this._leftFilter.output.connect(this.leftDelay),this._rightFilter.output.connect(this.rightDelay)}}},{key:"dispose",value:function(){de(ye(e.prototype),"dispose",this).call(this),this._split.disconnect(),this._leftFilter.dispose(),this._rightFilter.dispose(),this._merge.disconnect(),this._leftGain.disconnect(),this._rightGain.disconnect(),this.leftDelay.disconnect(),this.rightDelay.disconnect(),this._split=void 0,this._leftFilter=void 0,this._rightFilter=void 0,this._merge=void 0,this._leftGain=void 0,this._rightGain=void 0,this.leftDelay=void 0,this.rightDelay=void 0}}]),e}();function _e(t){return(_e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ge(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function be(t,e){for(var n=0;nthis.length&&(this.length=i.sequence.length)}},{key:"removePhrase",value:function(t){for(var e in this.phrases)this.phrases[e].name===t&&this.phrases.splice(e,1)}},{key:"getPhrase",value:function(t){for(var e in this.phrases)if(this.phrases[e].name===t)return this.phrases[e]}},{key:"replaceSequence",value:function(t,e){for(var n in this.phrases)this.phrases[n].name===t&&(this.phrases[n].sequence=e)}},{key:"incrementStep",value:function(t){this.partStep=t.parts.length?(t.scoreStep=0,t.onended()):(t.scoreStep=0,t.parts[t.currentPart-1].stop(),t.parts[t.currentPart].start())}function Ue(t,e){for(var n=0;nthis.cutoff&&e>this.threshold&&0this.treshold){this.isDetected=!0,this.callback?this.callback(this.energy):e&&e(this.energy);var n=this;setTimeout(function(){n.isDetected=!1},this.sensitivity)}this.penergy=this.energy}}]),r}();function xn(t,e){for(var n=0;nt)this.cancelScheduledValues(t),this.linearRampToValueAtTime(e,t);else{var i=this._searchAfter(t);i&&(this.cancelScheduledValues(t),i.type===u.TimelineSignal.Type.Linear?this.linearRampToValueAtTime(e,t):i.type===u.TimelineSignal.Type.Exponential&&this.exponentialRampToValueAtTime(e,t)),this.setValueAtTime(e,t)}return this},u.TimelineSignal.prototype.linearRampToValueBetween=function(t,e,n){return this.setRampPoint(e),this.linearRampToValueAtTime(t,n),this},u.TimelineSignal.prototype.exponentialRampToValueBetween=function(t,e,n){return this.setRampPoint(e),this.exponentialRampToValueAtTime(t,n),this},u.TimelineSignal.prototype._searchBefore=function(t){return this._events.get(t)},u.TimelineSignal.prototype._searchAfter=function(t){return this._events.getAfter(t)},u.TimelineSignal.prototype.getValueAtTime=function(t){t=this.toSeconds(t);var e=this._searchAfter(t),n=this._searchBefore(t),i=this._initial;if(null===n)i=this._initial;else if(n.type===u.TimelineSignal.Type.Target){var r,o=this._events.getBefore(n.time);r=null===o?this._initial:o.value,i=this._exponentialApproach(n.time,r,n.value,n.constant,t)}else i=n.type===u.TimelineSignal.Type.Curve?this._curveInterpolate(n.time,n.value,n.duration,t):null===e?n.value:e.type===u.TimelineSignal.Type.Linear?this._linearInterpolate(n.time,n.value,e.time,e.value,t):e.type===u.TimelineSignal.Type.Exponential?this._exponentialInterpolate(n.time,n.value,e.time,e.value,t):n.value;return i},u.TimelineSignal.prototype.connect=u.SignalBase.prototype.connect,u.TimelineSignal.prototype._exponentialApproach=function(t,e,n,i,r){return n+(e-n)*Math.exp(-(r-t)/i)},u.TimelineSignal.prototype._linearInterpolate=function(t,e,n,i,r){return e+(r-t)/(n-t)*(i-e)},u.TimelineSignal.prototype._exponentialInterpolate=function(t,e,n,i,r){return(e=Math.max(this._minOutput,e))*Math.pow(i/e,(r-t)/(n-t))},u.TimelineSignal.prototype._curveInterpolate=function(t,e,n,i){var r=e.length;if(t+n<=i)return e[r-1];if(i<=t)return e[0];var o=(i-t)/n,s=Math.floor((r-1)*o),a=Math.ceil((r-1)*o),u=e[s],c=e[a];return a===s?u:this._linearInterpolate(s,u,a,c,o*(r-1))},u.TimelineSignal.prototype.dispose=function(){u.Signal.prototype.dispose.call(this),u.Param.prototype.dispose.call(this),this._events.dispose(),this._events=null},u.TimelineSignal}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(4),n(1),n(2)],void 0===(r=function(n){"use strict";return n.Scale=function(t,e){this._outputMin=this.defaultArg(t,0),this._outputMax=this.defaultArg(e,1),this._scale=this.input=new n.Multiply(1),this._add=this.output=new n.Add(0),this._scale.connect(this._add),this._setRange()},n.extend(n.Scale,n.SignalBase),Object.defineProperty(n.Scale.prototype,"min",{get:function(){return this._outputMin},set:function(t){this._outputMin=t,this._setRange()}}),Object.defineProperty(n.Scale.prototype,"max",{get:function(){return this._outputMax},set:function(t){this._outputMax=t,this._setRange()}}),n.Scale.prototype._setRange=function(){this._add.value=this._outputMin,this._scale.value=this._outputMax-this._outputMin},n.Scale.prototype.dispose=function(){return n.prototype.dispose.call(this),this._add.dispose(),this._add=null,this._scale.dispose(),this._scale=null,this},n.Scale}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(16),n(30),n(31),n(12)],void 0===(r=function(e){return e.Type={Default:"number",Time:"time",Frequency:"frequency",TransportTime:"transportTime",Ticks:"ticks",NormalRange:"normalRange",AudioRange:"audioRange",Decibels:"db",Interval:"interval",BPM:"bpm",Positive:"positive",Cents:"cents",Degrees:"degrees",MIDI:"midi",BarsBeatsSixteenths:"barsBeatsSixteenths",Samples:"samples",Hertz:"hertz",Note:"note",Milliseconds:"milliseconds",Seconds:"seconds",Notation:"notation"},e.prototype.toSeconds=function(t){return this.isNumber(t)?t:this.isUndef(t)?this.now():this.isString(t)?new e.Time(t).toSeconds():t instanceof e.TimeBase?t.toSeconds():void 0},e.prototype.toFrequency=function(t){return this.isNumber(t)?t:this.isString(t)||this.isUndef(t)?new e.Frequency(t).valueOf():t instanceof e.TimeBase?t.toFrequency():void 0},e.prototype.toTicks=function(t){return this.isNumber(t)||this.isString(t)?new e.TransportTime(t).toTicks():this.isUndef(t)?e.Transport.ticks:t instanceof e.TimeBase?t.toTicks():void 0},e}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(18),n(9)],void 0===(r=function(n){"use strict";return window.GainNode&&!AudioContext.prototype.createGain&&(AudioContext.prototype.createGain=AudioContext.prototype.createGainNode),n.Gain=function(){var t=this.optionsObject(arguments,["gain","units"],n.Gain.defaults);this.input=this.output=this._gainNode=this.context.createGain(),this.gain=new n.Param({param:this._gainNode.gain,units:t.units,value:t.gain,convert:t.convert}),this._readOnly("gain")},n.extend(n.Gain),n.Gain.defaults={gain:1,convert:!0},n.Gain.prototype.dispose=function(){n.Param.prototype.dispose.call(this),this._gainNode.disconnect(),this._gainNode=null,this._writable("gain"),this.gain.dispose(),this.gain=null},n.prototype.createInsOuts=function(t,e){1===t?this.input=new n.Gain:1this._nextTick&&this._state;){var e=this._state.getValueAtTime(this._nextTick);if(e!==this._lastState){this._lastState=e;var n=this._state.get(this._nextTick);e===r.State.Started?(this._nextTick=n.time,this.isUndef(n.offset)||(this.ticks=n.offset),this.emit("start",n.time,this.ticks)):e===r.State.Stopped?(this.ticks=0,this.emit("stop",n.time)):e===r.State.Paused&&this.emit("pause",n.time)}var i=this._nextTick;this.frequency&&(this._nextTick+=1/this.frequency.getValueAtTime(this._nextTick),e===r.State.Started&&(this.callback(i),this.ticks++))}},r.Clock.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},r.Clock.prototype.dispose=function(){r.Emitter.prototype.dispose.call(this),this.context.off("tick",this._boundLoop),this._writable("frequency"),this.frequency.dispose(),this.frequency=null,this._boundLoop=null,this._nextTick=1/0,this.callback=null,this._state.dispose(),this._state=null},r.Clock}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(14)],void 0===(r=function(i){function t(t,e,n){if(t.input)Array.isArray(t.input)?(i.prototype.isUndef(n)&&(n=0),this.connect(t.input[n])):this.connect(t.input,e,n);else try{t instanceof AudioNode?r.call(this,t,e,n):r.call(this,t,e)}catch(e){throw new Error("error connecting to node: "+t+"\n"+e)}}var r,o;return!window.hasOwnProperty("AudioContext")&&window.hasOwnProperty("webkitAudioContext")&&(window.AudioContext=window.webkitAudioContext),i.Context=function(t){for(var e in i.Emitter.call(this),t=t||new window.AudioContext,this._context=t,this._context)this._defineProperty(this._context,e);this._latencyHint="interactive",this._lookAhead=.1,this._updateInterval=this._lookAhead/3,this._computedUpdateInterval=0,this._worker=this._createWorker(),this._constants={}},i.extend(i.Context,i.Emitter),i.Emitter.mixin(i.Context),i.Context.prototype._defineProperty=function(e,n){this.isUndef(this[n])&&Object.defineProperty(this,n,{get:function(){return"function"==typeof e[n]?e[n].bind(e):e[n]},set:function(t){e[n]=t}})},i.Context.prototype.now=function(){return this._context.currentTime},i.Context.prototype._createWorker=function(){window.URL=window.URL||window.webkitURL;var t=new Blob(["var timeoutTime = "+(1e3*this._updateInterval).toFixed(1)+";self.onmessage = function(msg){\ttimeoutTime = parseInt(msg.data);};function tick(){\tsetTimeout(tick, timeoutTime);\tself.postMessage('tick');}tick();"]),e=URL.createObjectURL(t),n=new Worker(e);return n.addEventListener("message",function(){this.emit("tick")}.bind(this)),n.addEventListener("message",function(){var t=this.now();if(this.isNumber(this._lastUpdate)){var e=t-this._lastUpdate;this._computedUpdateInterval=Math.max(e,.97*this._computedUpdateInterval)}this._lastUpdate=t}.bind(this)),n},i.Context.prototype.getConstant=function(t){if(this._constants[t])return this._constants[t];for(var e=this._context.createBuffer(1,128,this._context.sampleRate),n=e.getChannelData(0),i=0;ithis.memory){var n=this.length-this.memory;this._timeline.splice(0,n)}return this},e.Timeline.prototype.remove=function(t){if(this._iterating)this._toRemove.push(t);else{var e=this._timeline.indexOf(t);-1!==e&&this._timeline.splice(e,1)}return this},e.Timeline.prototype.get=function(t){var e=this._search(t);return-1!==e?this._timeline[e]:null},e.Timeline.prototype.peek=function(){return this._timeline[0]},e.Timeline.prototype.shift=function(){return this._timeline.shift()},e.Timeline.prototype.getAfter=function(t){var e=this._search(t);return e+1=t&&(this._timeline=[]);return this},e.Timeline.prototype.cancelBefore=function(t){if(this._timeline.length){var e=this._search(t);0<=e&&(this._timeline=this._timeline.slice(e+1))}return this},e.Timeline.prototype._search=function(t){var e=0,n=this._timeline.length,i=n;if(0t)return r;o.time>t?i=r:o.time=t;)n--;return this._iterate(e,n+1),this},e.Timeline.prototype.forEachAtTime=function(e,n){var t=this._search(e);return-1!==t&&this._iterate(function(t){t.time===e&&n(t)},0,t),this},e.Timeline.prototype.dispose=function(){e.prototype.dispose.call(this),this._timeline=null,this._toRemove=null},e.Timeline}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(1),n(2)],void 0===(r=function(t){"use strict";return t.Negate=function(){this._multiply=this.input=this.output=new t.Multiply(-1)},t.extend(t.Negate,t.SignalBase),t.Negate.prototype.dispose=function(){return t.prototype.dispose.call(this),this._multiply.dispose(),this._multiply=null,this},t.Negate}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r;i=[n(0),n(2),n(1),n(6)],void 0===(r=function(t){"use strict";return t.GreaterThanZero=function(){this._thresh=this.output=new t.WaveShaper(function(t){return t<=0?0:1},127),this._scale=this.input=new t.Multiply(1e4),this._scale.connect(this._thresh)},t.extend(t.GreaterThanZero,t.SignalBase),t.GreaterThanZero.prototype.dispose=function(){return t.prototype.dispose.call(this),this._scale.dispose(),this._scale=null,this._thresh.dispose(),this._thresh=null,this},t.GreaterThanZero}.apply(e,i))||(t.exports=r)},function(t,e,n){var i,r,o;r=[],void 0===(o="function"==typeof(i=function(){var s=function(t,e){this._dragged=!1,this._element=t,this._bindedMove=this._moved.bind(this),this._bindedEnd=this._ended.bind(this,e),t.addEventListener("touchstart",this._bindedEnd),t.addEventListener("touchmove",this._bindedMove),t.addEventListener("touchend",this._bindedEnd),t.addEventListener("mouseup",this._bindedEnd)};function o(t){return"running"===t.state}return s.prototype._moved=function(t){this._dragged=!0},s.prototype._ended=function(t){this._dragged||function(t){var e=t.createBuffer(1,1,t.sampleRate),n=t.createBufferSource();n.buffer=e,n.connect(t.destination),n.start(0),t.resume&&t.resume()}(t),this._dragged=!1},s.prototype.dispose=function(){this._element.removeEventListener("touchstart",this._bindedEnd),this._element.removeEventListener("touchmove",this._bindedMove),this._element.removeEventListener("touchend",this._bindedEnd),this._element.removeEventListener("mouseup",this._bindedEnd),this._bindedMove=null,this._bindedEnd=null,this._element=null},function(e,t,n){var i=new Promise(function(t){!function(e,n){o(e)?n():function t(){o(e)?n():(requestAnimationFrame(t),e.resume&&e.resume())}()}(e,t)}),r=[];return function t(e,n,i){if(Array.isArray(e)||NodeList&&e instanceof NodeList)for(var r=0;r= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n\n\n this._framesAvailable += sourceLength;\n\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n\n this._readIndex += destinationLength;\n\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n\n this._framesAvailable -= destinationLength;\n\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }, {\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n }]);\n\n return RingBuffer;\n }()\n}["default"];\n\nvar RecorderProcessor =\n/*#__PURE__*/\nfunction (_AudioWorkletProcesso) {\n _inherits(RecorderProcessor, _AudioWorkletProcesso);\n\n function RecorderProcessor(options) {\n var _this;\n\n _classCallCheck(this, RecorderProcessor);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(RecorderProcessor).call(this));\n var processorOptions = options.processorOptions || {};\n _this.numOutputChannels = options.outputChannelCount || 2;\n _this.numInputChannels = processorOptions.numInputChannels || 2;\n _this.bufferSize = processorOptions.bufferSize || 1024;\n _this.recording = false;\n\n _this.clear();\n\n _this.port.onmessage = function (event) {\n var data = event.data;\n\n if (data.name === \'start\') {\n _this.record(data.duration);\n } else if (data.name === \'stop\') {\n _this.stop();\n }\n };\n\n return _this;\n }\n\n _createClass(RecorderProcessor, [{\n key: "process",\n value: function process(inputs) {\n if (!this.recording) {\n return true;\n } else if (this.sampleLimit && this.recordedSamples >= this.sampleLimit) {\n this.stop();\n return true;\n }\n\n var input = inputs[0];\n this.inputRingBuffer.push(input);\n\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n\n for (var channel = 0; channel < this.numOutputChannels; ++channel) {\n var inputChannelCopy = this.inputRingBufferArraySequence[channel].slice();\n\n if (channel === 0) {\n this.leftBuffers.push(inputChannelCopy);\n\n if (this.numInputChannels === 1) {\n this.rightBuffers.push(inputChannelCopy);\n }\n } else if (channel === 1 && this.numInputChannels > 1) {\n this.rightBuffers.push(inputChannelCopy);\n }\n }\n\n this.recordedSamples += this.bufferSize;\n }\n\n return true;\n }\n }, {\n key: "record",\n value: function record(duration) {\n if (duration) {\n this.sampleLimit = Math.round(duration * sampleRate);\n }\n\n this.recording = true;\n }\n }, {\n key: "stop",\n value: function stop() {\n this.recording = false;\n var buffers = this.getBuffers();\n var leftBuffer = buffers[0].buffer;\n var rightBuffer = buffers[1].buffer;\n this.port.postMessage({\n name: \'buffers\',\n leftBuffer: leftBuffer,\n rightBuffer: rightBuffer\n }, [leftBuffer, rightBuffer]);\n this.clear();\n }\n }, {\n key: "getBuffers",\n value: function getBuffers() {\n var buffers = [];\n buffers.push(this.mergeBuffers(this.leftBuffers));\n buffers.push(this.mergeBuffers(this.rightBuffers));\n return buffers;\n }\n }, {\n key: "mergeBuffers",\n value: function mergeBuffers(channelBuffer) {\n var result = new Float32Array(this.recordedSamples);\n var offset = 0;\n var lng = channelBuffer.length;\n\n for (var i = 0; i < lng; i++) {\n var buffer = channelBuffer[i];\n result.set(buffer, offset);\n offset += buffer.length;\n }\n\n return result;\n }\n }, {\n key: "clear",\n value: function clear() {\n var _this2 = this;\n\n this.leftBuffers = [];\n this.rightBuffers = [];\n this.inputRingBuffer = new RingBuffer(this.bufferSize, this.numInputChannels);\n this.inputRingBufferArraySequence = new Array(this.numInputChannels).fill(null).map(function () {\n return new Float32Array(_this2.bufferSize);\n });\n this.recordedSamples = 0;\n this.sampleLimit = null;\n }\n }]);\n\n return RecorderProcessor;\n}(_wrapNativeSuper(AudioWorkletProcessor));\n\nregisterProcessor(processorNames.recorderProcessor, RecorderProcessor);'},function(t,e,n){"use strict";n.r(e),e.default='function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n// import dependencies via preval.require so that they\'re available as values at compile time\nvar processorNames = {\n "recorderProcessor": "recorder-processor",\n "soundFileProcessor": "sound-file-processor",\n "amplitudeProcessor": "amplitude-processor"\n};\nvar RingBuffer = {\n "default":\n /*#__PURE__*/\n function () {\n /**\n * @constructor\n * @param {number} length Buffer length in frames.\n * @param {number} channelCount Buffer channel count.\n */\n function RingBuffer(length, channelCount) {\n _classCallCheck(this, RingBuffer);\n\n this._readIndex = 0;\n this._writeIndex = 0;\n this._framesAvailable = 0;\n this._channelCount = channelCount;\n this._length = length;\n this._channelData = [];\n\n for (var i = 0; i < this._channelCount; ++i) {\n this._channelData[i] = new Float32Array(length);\n }\n }\n /**\n * Getter for Available frames in buffer.\n *\n * @return {number} Available frames in buffer.\n */\n\n\n _createClass(RingBuffer, [{\n key: "push",\n\n /**\n * Push a sequence of Float32Arrays to buffer.\n *\n * @param {array} arraySequence A sequence of Float32Arrays.\n */\n value: function push(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // Transfer data from the |arraySequence| storage to the internal buffer.\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\n\n for (var i = 0; i < sourceLength; ++i) {\n var writeIndex = (this._writeIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\n }\n }\n\n this._writeIndex += sourceLength;\n\n if (this._writeIndex >= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n\n\n this._framesAvailable += sourceLength;\n\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n\n this._readIndex += destinationLength;\n\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n\n this._framesAvailable -= destinationLength;\n\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }, {\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n }]);\n\n return RingBuffer;\n }()\n}["default"];\n\nvar SoundFileProcessor =\n/*#__PURE__*/\nfunction (_AudioWorkletProcesso) {\n _inherits(SoundFileProcessor, _AudioWorkletProcesso);\n\n function SoundFileProcessor(options) {\n var _this;\n\n _classCallCheck(this, SoundFileProcessor);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SoundFileProcessor).call(this));\n var processorOptions = options.processorOptions || {};\n _this.bufferSize = processorOptions.bufferSize || 256;\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, 1);\n _this.inputRingBufferArraySequence = [new Float32Array(_this.bufferSize)];\n return _this;\n }\n\n _createClass(SoundFileProcessor, [{\n key: "process",\n value: function process(inputs) {\n var input = inputs[0]; // we only care about the first input channel, because that contains the position data\n\n this.inputRingBuffer.push([input[0]]);\n\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n var inputChannel = this.inputRingBufferArraySequence[0];\n var position = inputChannel[inputChannel.length - 1] || 0;\n this.port.postMessage({\n name: \'position\',\n position: position\n });\n }\n\n return true;\n }\n }]);\n\n return SoundFileProcessor;\n}(_wrapNativeSuper(AudioWorkletProcessor));\n\nregisterProcessor(processorNames.soundFileProcessor, SoundFileProcessor);'},function(t,e,n){"use strict";n.r(e),e.default='function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n// import dependencies via preval.require so that they\'re available as values at compile time\nvar processorNames = {\n "recorderProcessor": "recorder-processor",\n "soundFileProcessor": "sound-file-processor",\n "amplitudeProcessor": "amplitude-processor"\n};\nvar RingBuffer = {\n "default":\n /*#__PURE__*/\n function () {\n /**\n * @constructor\n * @param {number} length Buffer length in frames.\n * @param {number} channelCount Buffer channel count.\n */\n function RingBuffer(length, channelCount) {\n _classCallCheck(this, RingBuffer);\n\n this._readIndex = 0;\n this._writeIndex = 0;\n this._framesAvailable = 0;\n this._channelCount = channelCount;\n this._length = length;\n this._channelData = [];\n\n for (var i = 0; i < this._channelCount; ++i) {\n this._channelData[i] = new Float32Array(length);\n }\n }\n /**\n * Getter for Available frames in buffer.\n *\n * @return {number} Available frames in buffer.\n */\n\n\n _createClass(RingBuffer, [{\n key: "push",\n\n /**\n * Push a sequence of Float32Arrays to buffer.\n *\n * @param {array} arraySequence A sequence of Float32Arrays.\n */\n value: function push(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // Transfer data from the |arraySequence| storage to the internal buffer.\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\n\n for (var i = 0; i < sourceLength; ++i) {\n var writeIndex = (this._writeIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\n }\n }\n\n this._writeIndex += sourceLength;\n\n if (this._writeIndex >= this._length) {\n this._writeIndex = 0;\n } // For excessive frames, the buffer will be overwritten.\n\n\n this._framesAvailable += sourceLength;\n\n if (this._framesAvailable > this._length) {\n this._framesAvailable = this._length;\n }\n }\n /**\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\n *\n * @param {array} arraySequence An array of Float32Arrays.\n */\n\n }, {\n key: "pull",\n value: function pull(arraySequence) {\n // The channel count of arraySequence and the length of each channel must\n // match with this buffer obejct.\n // If the FIFO is completely empty, do nothing.\n if (this._framesAvailable === 0) {\n return;\n }\n\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\n\n for (var i = 0; i < destinationLength; ++i) {\n var readIndex = (this._readIndex + i) % this._length;\n\n for (var channel = 0; channel < this._channelCount; ++channel) {\n arraySequence[channel][i] = this._channelData[channel][readIndex];\n }\n }\n\n this._readIndex += destinationLength;\n\n if (this._readIndex >= this._length) {\n this._readIndex = 0;\n }\n\n this._framesAvailable -= destinationLength;\n\n if (this._framesAvailable < 0) {\n this._framesAvailable = 0;\n }\n }\n }, {\n key: "framesAvailable",\n get: function get() {\n return this._framesAvailable;\n }\n }]);\n\n return RingBuffer;\n }()\n}["default"];\n\nvar AmplitudeProcessor =\n/*#__PURE__*/\nfunction (_AudioWorkletProcesso) {\n _inherits(AmplitudeProcessor, _AudioWorkletProcesso);\n\n function AmplitudeProcessor(options) {\n var _this;\n\n _classCallCheck(this, AmplitudeProcessor);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(AmplitudeProcessor).call(this));\n var processorOptions = options.processorOptions || {};\n _this.numOutputChannels = options.outputChannelCount || 1;\n _this.numInputChannels = processorOptions.numInputChannels || 2;\n _this.normalize = processorOptions.normalize || false;\n _this.smoothing = processorOptions.smoothing || 0;\n _this.bufferSize = processorOptions.bufferSize || 2048;\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, _this.numInputChannels);\n _this.outputRingBuffer = new RingBuffer(_this.bufferSize, _this.numOutputChannels);\n _this.inputRingBufferArraySequence = new Array(_this.numInputChannels).fill(null).map(function () {\n return new Float32Array(_this.bufferSize);\n });\n _this.stereoVol = [0, 0];\n _this.stereoVolNorm = [0, 0];\n _this.volMax = 0.001;\n\n _this.port.onmessage = function (event) {\n var data = event.data;\n\n if (data.name === \'toggleNormalize\') {\n _this.normalize = data.normalize;\n } else if (data.name === \'smoothing\') {\n _this.smoothing = Math.max(0, Math.min(1, data.smoothing));\n }\n };\n\n return _this;\n } // TO DO make this stereo / dependent on # of audio channels\n\n\n _createClass(AmplitudeProcessor, [{\n key: "process",\n value: function process(inputs, outputs) {\n var input = inputs[0];\n var output = outputs[0];\n var smoothing = this.smoothing;\n this.inputRingBuffer.push(input);\n\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\n\n for (var channel = 0; channel < this.numInputChannels; ++channel) {\n var inputBuffer = this.inputRingBufferArraySequence[channel];\n var bufLength = inputBuffer.length;\n var sum = 0;\n\n for (var i = 0; i < bufLength; i++) {\n var x = inputBuffer[i];\n\n if (this.normalize) {\n sum += Math.max(Math.min(x / this.volMax, 1), -1) * Math.max(Math.min(x / this.volMax, 1), -1);\n } else {\n sum += x * x;\n }\n } // ... then take the square root of the sum.\n\n\n var rms = Math.sqrt(sum / bufLength);\n this.stereoVol[channel] = Math.max(rms, this.stereoVol[channel] * smoothing);\n this.volMax = Math.max(this.stereoVol[channel], this.volMax);\n } // calculate stero normalized volume and add volume from all channels together\n\n\n var volSum = 0;\n\n for (var index = 0; index < this.stereoVol.length; index++) {\n this.stereoVolNorm[index] = Math.max(Math.min(this.stereoVol[index] / this.volMax, 1), 0);\n volSum += this.stereoVol[index];\n } // volume is average of channels\n\n\n var volume = volSum / this.stereoVol.length; // normalized value\n\n var volNorm = Math.max(Math.min(volume / this.volMax, 1), 0);\n this.port.postMessage({\n name: \'amplitude\',\n volume: volume,\n volNorm: volNorm,\n stereoVol: this.stereoVol,\n stereoVolNorm: this.stereoVolNorm\n }); // pass input through to output\n\n this.outputRingBuffer.push(this.inputRingBufferArraySequence);\n } // pull 128 frames out of the ring buffer\n // if the ring buffer does not have enough frames, the output will be silent\n\n\n this.outputRingBuffer.pull(output);\n return true;\n }\n }]);\n\n return AmplitudeProcessor;\n}(_wrapNativeSuper(AudioWorkletProcessor));\n\nregisterProcessor(processorNames.amplitudeProcessor, AmplitudeProcessor);'},function(t,e,n){var i,r;i=[n(0),n(17)],void 0===(r=function(r){r.Frequency=function(t,e){if(!(this instanceof r.Frequency))return new r.Frequency(t,e);r.TimeBase.call(this,t,e)},r.extend(r.Frequency,r.TimeBase),r.Frequency.prototype._primaryExpressions=Object.create(r.TimeBase.prototype._primaryExpressions),r.Frequency.prototype._primaryExpressions.midi={regexp:/^(\d+(?:\.\d+)?midi)/,method:function(t){return this.midiToFrequency(t)}},r.Frequency.prototype._primaryExpressions.note={regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method:function(t,e){var n=i[t.toLowerCase()]+12*(parseInt(e)+1);return this.midiToFrequency(n)}},r.Frequency.prototype._primaryExpressions.tr={regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method:function(t,e,n){var i=1;return t&&"0"!==t&&(i*=this._beatsToUnits(this._timeSignature()*parseFloat(t))),e&&"0"!==e&&(i*=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(i*=this._beatsToUnits(parseFloat(n)/4)),i}},r.Frequency.prototype.transpose=function(t){return this._expr=function(t,e){return t()*this.intervalToFrequencyRatio(e)}.bind(this,this._expr,t),this},r.Frequency.prototype.harmonize=function(t){return this._expr=function(t,e){for(var n=t(),i=[],r=0;rthis.buffer.duration)throw"jump time out of range";if(e>this.buffer.duration-t)throw"end time out of range";var n=t||0,i=e||void 0;this.isPlaying()&&(this.stop(0),this.play(0,this.playbackRate,this.output.gain.value,n,i))}},{key:"channels",value:function(){return this.buffer.numberOfChannels}},{key:"sampleRate",value:function(){return this.buffer.sampleRate}},{key:"frames",value:function(){return this.buffer.length}},{key:"getPeaks",value:function(t){if(!this.buffer)throw"Cannot load peaks yet, buffer is not loaded";if(t=t||5*window.width,this.buffer){for(var e=this.buffer,n=e.length/t,i=~~(n/10)||1,r=e.numberOfChannels,o=new Float32Array(Math.round(t)),s=0;so[u])&&(o[u]=h)}return o}}},{key:"reverseBuffer",value:function(){if(!this.buffer)throw"SoundFile is not done loading";var t=this._lastPos/R.sampleRate,e=this.getVolume();this.setVolume(0,.001);for(var n=this.buffer.numberOfChannels,i=0;it[o].hi&&o++,r[o]=void 0!==r[o]?(r[o]+n[s])/2:n[s]}return r}},{key:"getOctaveBands",value:function(t,e){var n=t||3,i=e||15.625,r=[],o={lo:i/Math.pow(2,1/(2*n)),ctr:i,hi:i*Math.pow(2,1/(2*n))};r.push(o);for(var s=p.audiocontext.sampleRate/2;o.hi=this._maxDelay)throw new Error("Delay Time exceeds maximum delay time of "+this._maxDelay+" second.");t.connect(this.input),this.leftDelay.delayTime.setValueAtTime(o,this.ac.currentTime),this.rightDelay.delayTime.setValueAtTime(o,this.ac.currentTime),this._leftGain.gain.value=r,this._rightGain.gain.value=r,i&&(this._leftFilter.freq(i),this._rightFilter.freq(i))}},{key:"delayTime",value:function(t){"number"!=typeof t?(t.connect(this.leftDelay.delayTime),t.connect(this.rightDelay.delayTime)):(this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime),this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime),this.leftDelay.delayTime.linearRampToValueAtTime(t,this.ac.currentTime),this.rightDelay.delayTime.linearRampToValueAtTime(t,this.ac.currentTime))}},{key:"feedback",value:function(t){if(t&&"number"!=typeof t)t.connect(this._leftGain.gain),t.connect(this._rightGain.gain);else{if(1<=t)throw new Error("Feedback value will force a positive feedback loop.");"number"==typeof t&&(this._leftGain.gain.value=t,this._rightGain.gain.value=t)}return this._leftGain.gain.value}},{key:"filter",value:function(t,e){this._leftFilter.set(t,e),this._rightFilter.set(t,e)}},{key:"setType",value:function(t){switch(1===t&&(t="pingPong"),this._split.disconnect(),this._leftFilter.disconnect(),this._rightFilter.disconnect(),this._split.connect(this.leftDelay,0),this._split.connect(this.rightDelay,1),t){case"pingPong":this._rightFilter.setType(this._leftFilter.biquad.type),this._leftFilter.output.connect(this._merge,0,0),this._rightFilter.output.connect(this._merge,0,1),this._leftFilter.output.connect(this.rightDelay),this._rightFilter.output.connect(this.leftDelay);break;default:this._leftFilter.output.connect(this._merge,0,0),this._rightFilter.output.connect(this._merge,0,1),this._leftFilter.output.connect(this.leftDelay),this._rightFilter.output.connect(this.rightDelay)}}},{key:"dispose",value:function(){de(ye(e.prototype),"dispose",this).call(this),this._split.disconnect(),this._leftFilter.dispose(),this._rightFilter.dispose(),this._merge.disconnect(),this._leftGain.disconnect(),this._rightGain.disconnect(),this.leftDelay.disconnect(),this.rightDelay.disconnect(),this._split=void 0,this._leftFilter=void 0,this._rightFilter=void 0,this._merge=void 0,this._leftGain=void 0,this._rightGain=void 0,this.leftDelay=void 0,this.rightDelay=void 0}}]),e}();function _e(t){return(_e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ge(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function be(t,e){for(var n=0;nthis.length&&(this.length=i.sequence.length)}},{key:"removePhrase",value:function(t){for(var e in this.phrases)this.phrases[e].name===t&&this.phrases.splice(e,1)}},{key:"getPhrase",value:function(t){for(var e in this.phrases)if(this.phrases[e].name===t)return this.phrases[e]}},{key:"replaceSequence",value:function(t,e){for(var n in this.phrases)this.phrases[n].name===t&&(this.phrases[n].sequence=e)}},{key:"incrementStep",value:function(t){this.partStep=t.parts.length?(t.scoreStep=0,t.onended()):(t.scoreStep=0,t.parts[t.currentPart-1].stop(),t.parts[t.currentPart].start())}function Ue(t,e){for(var n=0;nthis.cutoff&&e>this.threshold&&0this.treshold){this.isDetected=!0,this.callback?this.callback(this.energy):e&&e(this.energy);var n=this;setTimeout(function(){n.isDetected=!1},this.sensitivity)}this.penergy=this.energy}}]),r}();function xn(t,e){for(var n=0;n 1){\n\t\t\tthis.input = new Array(inputs);\n\t\t}\n\n\t\t/**\n\t\t * the output node(s)\n\t\t * @type {GainNode|Array}\n\t\t */\n\t\tif (this.isUndef(outputs) || outputs === 1){\n\t\t\tthis.output = this.context.createGain();\n\t\t} else if (outputs > 1){\n\t\t\tthis.output = new Array(inputs);\n\t\t}\n\t};\n\n\t/**\n\t * Set the parameters at once. Either pass in an\n\t * object mapping parameters to values, or to set a\n\t * single parameter, by passing in a string and value.\n\t * The last argument is an optional ramp time which \n\t * will ramp any signal values to their destination value\n\t * over the duration of the rampTime.\n\t * @param {Object|string} params\n\t * @param {number=} value\n\t * @param {Time=} rampTime\n\t * @returns {Tone} this\n\t * @example\n\t * //set values using an object\n\t * filter.set({\n\t * \t\"frequency\" : 300,\n\t * \t\"type\" : highpass\n\t * });\n\t * @example\n\t * filter.set(\"type\", \"highpass\");\n\t * @example\n\t * //ramp to the value 220 over 3 seconds. \n\t * oscillator.set({\n\t * \t\"frequency\" : 220\n\t * }, 3);\n\t */\n\tTone.prototype.set = function(params, value, rampTime){\n\t\tif (this.isObject(params)){\n\t\t\trampTime = value;\n\t\t} else if (this.isString(params)){\n\t\t\tvar tmpObj = {};\n\t\t\ttmpObj[params] = value;\n\t\t\tparams = tmpObj;\n\t\t}\n\n\t\tparamLoop:\n\t\tfor (var attr in params){\n\t\t\tvalue = params[attr];\n\t\t\tvar parent = this;\n\t\t\tif (attr.indexOf(\".\") !== -1){\n\t\t\t\tvar attrSplit = attr.split(\".\");\n\t\t\t\tfor (var i = 0; i < attrSplit.length - 1; i++){\n\t\t\t\t\tparent = parent[attrSplit[i]];\n\t\t\t\t\tif (parent instanceof Tone) {\n\t\t\t\t\t\tattrSplit.splice(0,i+1);\n\t\t\t\t\t\tvar innerParam = attrSplit.join(\".\");\n\t\t\t\t\t\tparent.set(innerParam, value);\n\t\t\t\t\t\tcontinue paramLoop;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tattr = attrSplit[attrSplit.length - 1];\n\t\t\t}\n\t\t\tvar param = parent[attr];\n\t\t\tif (this.isUndef(param)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((Tone.Signal && param instanceof Tone.Signal) || \n\t\t\t\t\t(Tone.Param && param instanceof Tone.Param)){\n\t\t\t\tif (param.value !== value){\n\t\t\t\t\tif (this.isUndef(rampTime)){\n\t\t\t\t\t\tparam.value = value;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparam.rampTo(value, rampTime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (param instanceof AudioParam){\n\t\t\t\tif (param.value !== value){\n\t\t\t\t\tparam.value = value;\n\t\t\t\t}\t\t\t\t\n\t\t\t} else if (param instanceof Tone){\n\t\t\t\tparam.set(value);\n\t\t\t} else if (param !== value){\n\t\t\t\tparent[attr] = value;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Get the object's attributes. Given no arguments get\n\t * will return all available object properties and their corresponding\n\t * values. Pass in a single attribute to retrieve or an array\n\t * of attributes. The attribute strings can also include a \".\"\n\t * to access deeper properties.\n\t * @example\n\t * osc.get();\n\t * //returns {\"type\" : \"sine\", \"frequency\" : 440, ...etc}\n\t * @example\n\t * osc.get(\"type\");\n\t * //returns { \"type\" : \"sine\"}\n\t * @example\n\t * //use dot notation to access deep properties\n\t * synth.get([\"envelope.attack\", \"envelope.release\"]);\n\t * //returns {\"envelope\" : {\"attack\" : 0.2, \"release\" : 0.4}}\n\t * @param {Array=|string|undefined} params the parameters to get, otherwise will return \n\t * \t\t\t\t\t all available.\n\t * @returns {Object}\n\t */\n\tTone.prototype.get = function(params){\n\t\tif (this.isUndef(params)){\n\t\t\tparams = this._collectDefaults(this.constructor);\n\t\t} else if (this.isString(params)){\n\t\t\tparams = [params];\n\t\t} \n\t\tvar ret = {};\n\t\tfor (var i = 0; i < params.length; i++){\n\t\t\tvar attr = params[i];\n\t\t\tvar parent = this;\n\t\t\tvar subRet = ret;\n\t\t\tif (attr.indexOf(\".\") !== -1){\n\t\t\t\tvar attrSplit = attr.split(\".\");\n\t\t\t\tfor (var j = 0; j < attrSplit.length - 1; j++){\n\t\t\t\t\tvar subAttr = attrSplit[j];\n\t\t\t\t\tsubRet[subAttr] = subRet[subAttr] || {};\n\t\t\t\t\tsubRet = subRet[subAttr];\n\t\t\t\t\tparent = parent[subAttr];\n\t\t\t\t}\n\t\t\t\tattr = attrSplit[attrSplit.length - 1];\n\t\t\t}\n\t\t\tvar param = parent[attr];\n\t\t\tif (this.isObject(params[attr])){\n\t\t\t\tsubRet[attr] = param.get();\n\t\t\t} else if (Tone.Signal && param instanceof Tone.Signal){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (Tone.Param && param instanceof Tone.Param){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (param instanceof AudioParam){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (param instanceof Tone){\n\t\t\t\tsubRet[attr] = param.get();\n\t\t\t} else if (!this.isFunction(param) && !this.isUndef(param)){\n\t\t\t\tsubRet[attr] = param;\n\t\t\t} \n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * collect all of the default attributes in one\n\t * @private\n\t * @param {function} constr the constructor to find the defaults from\n\t * @return {Array} all of the attributes which belong to the class\n\t */\n\tTone.prototype._collectDefaults = function(constr){\n\t\tvar ret = [];\n\t\tif (!this.isUndef(constr.defaults)){\n\t\t\tret = Object.keys(constr.defaults);\n\t\t}\n\t\tif (!this.isUndef(constr._super)){\n\t\t\tvar superDefs = this._collectDefaults(constr._super);\n\t\t\t//filter out repeats\n\t\t\tfor (var i = 0; i < superDefs.length; i++){\n\t\t\t\tif (ret.indexOf(superDefs[i]) === -1){\n\t\t\t\t\tret.push(superDefs[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * @returns {string} returns the name of the class as a string\n\t */\n\tTone.prototype.toString = function(){\n\t\tfor (var className in Tone){\n\t\t\tvar isLetter = className[0].match(/^[A-Z]$/);\n\t\t\tvar sameConstructor = Tone[className] === this.constructor;\n\t\t\tif (this.isFunction(Tone[className]) && isLetter && sameConstructor){\n\t\t\t\treturn className;\n\t\t\t}\n\t\t}\n\t\treturn \"Tone\";\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCLASS VARS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The number of inputs feeding into the AudioNode. \n\t * For source nodes, this will be 0.\n\t * @memberOf Tone#\n\t * @name numberOfInputs\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"numberOfInputs\", {\n\t\tget : function(){\n\t\t\tif (this.input){\n\t\t\t\tif (this.isArray(this.input)){\n\t\t\t\t\treturn this.input.length;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * The number of outputs coming out of the AudioNode. \n\t * For source nodes, this will be 0.\n\t * @memberOf Tone#\n\t * @name numberOfInputs\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"numberOfOutputs\", {\n\t\tget : function(){\n\t\t\tif (this.output){\n\t\t\t\tif (this.isArray(this.output)){\n\t\t\t\t\treturn this.output.length;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\t\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCONNECTIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * disconnect and dispose\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.dispose = function(){\n\t\tif (!this.isUndef(this.input)){\n\t\t\tif (this.input instanceof AudioNode){\n\t\t\t\tthis.input.disconnect();\n\t\t\t} \n\t\t\tthis.input = null;\n\t\t}\n\t\tif (!this.isUndef(this.output)){\n\t\t\tif (this.output instanceof AudioNode){\n\t\t\t\tthis.output.disconnect();\n\t\t\t} \n\t\t\tthis.output = null;\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode\n\t * @param {Tone | AudioParam | AudioNode} unit \n\t * @param {number} [outputNum=0] optionally which output to connect from\n\t * @param {number} [inputNum=0] optionally which input to connect to\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.connect = function(unit, outputNum, inputNum){\n\t\tif (Array.isArray(this.output)){\n\t\t\toutputNum = this.defaultArg(outputNum, 0);\n\t\t\tthis.output[outputNum].connect(unit, 0, inputNum);\n\t\t} else {\n\t\t\tthis.output.connect(unit, outputNum, inputNum);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * disconnect the output\n\t * @param {Number|AudioNode} output Either the output index to disconnect\n\t * if the output is an array, or the\n\t * node to disconnect from.\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.disconnect = function(destination, outputNum, inputNum){\n\t\tif (this.isArray(this.output)){\n\t\t\tif (this.isNumber(destination)){\n\t\t\t\tthis.output[destination].disconnect();\n\t\t\t} else {\n\t\t\t\toutputNum = this.defaultArg(outputNum, 0);\n\t\t\t\tthis.output[outputNum].disconnect(destination, 0, inputNum);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.output.disconnect.apply(this.output, arguments);\n\t\t}\n\t};\n\n\t/**\n\t * connect together all of the arguments in series\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.connectSeries = function(){\n\t\tif (arguments.length > 1){\n\t\t\tvar currentUnit = arguments[0];\n\t\t\tfor (var i = 1; i < arguments.length; i++){\n\t\t\t\tvar toUnit = arguments[i];\n\t\t\t\tcurrentUnit.connect(toUnit);\n\t\t\t\tcurrentUnit = toUnit;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Connect the output of this node to the rest of the nodes in series.\n\t * @example\n\t * //connect a node to an effect, panVol and then to the master output\n\t * node.chain(effect, panVol, Tone.Master);\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.chain = function(){\n\t\tif (arguments.length > 0){\n\t\t\tvar currentUnit = this;\n\t\t\tfor (var i = 0; i < arguments.length; i++){\n\t\t\t\tvar toUnit = arguments[i];\n\t\t\t\tcurrentUnit.connect(toUnit);\n\t\t\t\tcurrentUnit = toUnit;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * connect the output of this node to the rest of the nodes in parallel.\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.fan = function(){\n\t\tif (arguments.length > 0){\n\t\t\tfor (var i = 0; i < arguments.length; i++){\n\t\t\t\tthis.connect(arguments[i]);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t//give native nodes chain and fan methods\n\tAudioNode.prototype.chain = Tone.prototype.chain;\n\tAudioNode.prototype.fan = Tone.prototype.fan;\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUTILITIES / HELPERS / MATHS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * If the `given` parameter is undefined, use the `fallback`. \n\t * If both `given` and `fallback` are object literals, it will\n\t * return a deep copy which includes all of the parameters from both \n\t * objects. If a parameter is undefined in given, it will return\n\t * the fallback property. \n\t *

\n\t * WARNING: if object is self referential, it will go into an an \n\t * infinite recursive loop.\n\t * \n\t * @param {*} given \n\t * @param {*} fallback \n\t * @return {*} \n\t */\n\tTone.prototype.defaultArg = function(given, fallback){\n\t\tif (this.isObject(given) && this.isObject(fallback)){\n\t\t\tvar ret = {};\n\t\t\t//make a deep copy of the given object\n\t\t\tfor (var givenProp in given) {\n\t\t\t\tret[givenProp] = this.defaultArg(fallback[givenProp], given[givenProp]);\n\t\t\t}\n\t\t\tfor (var fallbackProp in fallback) {\n\t\t\t\tret[fallbackProp] = this.defaultArg(given[fallbackProp], fallback[fallbackProp]);\n\t\t\t}\n\t\t\treturn ret;\n\t\t} else {\n\t\t\treturn this.isUndef(given) ? fallback : given;\n\t\t}\n\t};\n\n\t/**\n\t * returns the args as an options object with given arguments\n\t * mapped to the names provided. \n\t *\n\t * if the args given is an array containing only one object, it is assumed\n\t * that that's already the options object and will just return it. \n\t * \n\t * @param {Array} values the 'arguments' object of the function\n\t * @param {Array} keys the names of the arguments as they\n\t * should appear in the options object\n\t * @param {Object=} defaults optional defaults to mixin to the returned \n\t * options object \n\t * @return {Object} the options object with the names mapped to the arguments\n\t */\n\tTone.prototype.optionsObject = function(values, keys, defaults){\n\t\tvar options = {};\n\t\tif (values.length === 1 && this.isObject(values[0])){\n\t\t\toptions = values[0];\n\t\t} else {\n\t\t\tfor (var i = 0; i < keys.length; i++){\n\t\t\t\toptions[keys[i]] = values[i];\n\t\t\t}\n\t\t}\n\t\tif (!this.isUndef(defaults)){\n\t\t\treturn this.defaultArg(options, defaults);\n\t\t} else {\n\t\t\treturn options;\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// TYPE CHECKING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * test if the arg is undefined\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is undefined\n\t * @function\n\t */\n\tTone.prototype.isUndef = function(val){\n\t\treturn typeof val === \"undefined\";\n\t};\n\n\t/**\n\t * test if the arg is a function\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a function\n\t * @function\n\t */\n\tTone.prototype.isFunction = function(val){\n\t\treturn typeof val === \"function\";\n\t};\n\n\t/**\n\t * Test if the argument is a number.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a number\n\t */\n\tTone.prototype.isNumber = function(arg){\n\t\treturn (typeof arg === \"number\");\n\t};\n\n\t/**\n\t * Test if the given argument is an object literal (i.e. `{}`);\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is an object literal.\n\t */\n\tTone.prototype.isObject = function(arg){\n\t\treturn (Object.prototype.toString.call(arg) === \"[object Object]\" && arg.constructor === Object);\n\t};\n\n\t/**\n\t * Test if the argument is a boolean.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a boolean\n\t */\n\tTone.prototype.isBoolean = function(arg){\n\t\treturn (typeof arg === \"boolean\");\n\t};\n\n\t/**\n\t * Test if the argument is an Array\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is an array\n\t */\n\tTone.prototype.isArray = function(arg){\n\t\treturn (Array.isArray(arg));\n\t};\n\n\t/**\n\t * Test if the argument is a string.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a string\n\t */\n\tTone.prototype.isString = function(arg){\n\t\treturn (typeof arg === \"string\");\n\t};\n\n \t/**\n\t * An empty function.\n\t * @static\n\t */\n\tTone.noOp = function(){};\n\n\t/**\n\t * Make the property not writable. Internal use only. \n\t * @private\n\t * @param {string} property the property to make not writable\n\t */\n\tTone.prototype._readOnly = function(property){\n\t\tif (Array.isArray(property)){\n\t\t\tfor (var i = 0; i < property.length; i++){\n\t\t\t\tthis._readOnly(property[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tObject.defineProperty(this, property, { \n\t\t\t\twritable: false,\n\t\t\t\tenumerable : true,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Make an attribute writeable. Interal use only. \n\t * @private\n\t * @param {string} property the property to make writable\n\t */\n\tTone.prototype._writable = function(property){\n\t\tif (Array.isArray(property)){\n\t\t\tfor (var i = 0; i < property.length; i++){\n\t\t\t\tthis._writable(property[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tObject.defineProperty(this, property, { \n\t\t\t\twritable: true,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Possible play states. \n\t * @enum {string}\n\t */\n\tTone.State = {\n\t\tStarted : \"started\",\n\t\tStopped : \"stopped\",\n\t\tPaused : \"paused\",\n \t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Equal power gain scale. Good for cross-fading.\n\t * @param {NormalRange} percent (0-1)\n\t * @return {Number} output gain (0-1)\n\t */\n\tTone.prototype.equalPowerScale = function(percent){\n\t\tvar piFactor = 0.5 * Math.PI;\n\t\treturn Math.sin(percent * piFactor);\n\t};\n\n\t/**\n\t * Convert decibels into gain.\n\t * @param {Decibels} db\n\t * @return {Number} \n\t */\n\tTone.prototype.dbToGain = function(db) {\n\t\treturn Math.pow(2, db / 6);\n\t};\n\n\t/**\n\t * Convert gain to decibels.\n\t * @param {Number} gain (0-1)\n\t * @return {Decibels} \n\t */\n\tTone.prototype.gainToDb = function(gain) {\n\t\treturn 20 * (Math.log(gain) / Math.LN10);\n\t};\n\n\t/**\n\t * Convert an interval (in semitones) to a frequency ratio.\n\t * @param {Interval} interval the number of semitones above the base note\n\t * @return {number} the frequency ratio\n\t * @example\n\t * tone.intervalToFrequencyRatio(0); // 1\n\t * tone.intervalToFrequencyRatio(12); // 2\n\t * tone.intervalToFrequencyRatio(-12); // 0.5\n\t */\n\tTone.prototype.intervalToFrequencyRatio = function(interval){\n\t\treturn Math.pow(2,(interval/12));\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTIMING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Return the current time of the AudioContext clock.\n\t * @return {Number} the currentTime from the AudioContext\n\t */\n\tTone.prototype.now = function(){\n\t\treturn Tone.context.now();\n\t};\n\n\t/**\n\t * Return the current time of the AudioContext clock.\n\t * @return {Number} the currentTime from the AudioContext\n\t * @static\n\t */\n\tTone.now = function(){\n\t\treturn Tone.context.now();\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tINHERITANCE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * have a child inherit all of Tone's (or a parent's) prototype\n\t * to inherit the parent's properties, make sure to call \n\t * Parent.call(this) in the child's constructor\n\t *\n\t * based on closure library's inherit function\n\t *\n\t * @static\n\t * @param {function} \tchild \n\t * @param {function=} parent (optional) parent to inherit from\n\t * if no parent is supplied, the child\n\t * will inherit from Tone\n\t */\n\tTone.extend = function(child, parent){\n\t\tif (Tone.prototype.isUndef(parent)){\n\t\t\tparent = Tone;\n\t\t}\n\t\tfunction TempConstructor(){}\n\t\tTempConstructor.prototype = parent.prototype;\n\t\tchild.prototype = new TempConstructor();\n\t\t/** @override */\n\t\tchild.prototype.constructor = child;\n\t\tchild._super = parent;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCONTEXT\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The private audio context shared by all Tone Nodes. \n\t * @private\n\t * @type {Tone.Context|undefined}\n\t */\n\tvar audioContext;\n\n\t/**\n\t * A static pointer to the audio context accessible as Tone.context. \n\t * @type {Tone.Context}\n\t * @name context\n\t * @memberOf Tone\n\t */\n\tObject.defineProperty(Tone, \"context\", {\n\t\tget : function(){\n\t\t\treturn audioContext;\n\t\t},\n\t\tset : function(context){\n\t\t\tif (Tone.Context && context instanceof Tone.Context){\n\t\t\t\taudioContext = context;\n\t\t\t} else {\n\t\t\t\taudioContext = new Tone.Context(context);\n\t\t\t}\n\t\t\t//initialize the new audio context\n\t\t\tif (Tone.Context){\n\t\t\t\tTone.Context.emit(\"init\", audioContext);\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * The AudioContext\n\t * @type {Tone.Context}\n\t * @name context\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"context\", {\n\t\tget : function(){\n\t\t\treturn Tone.context;\n\t\t}\n\t});\n\n\t/**\n\t * Tone automatically creates a context on init, but if you are working\n\t * with other libraries which also create an AudioContext, it can be\n\t * useful to set your own. If you are going to set your own context, \n\t * be sure to do it at the start of your code, before creating any objects.\n\t * @static\n\t * @param {AudioContext} ctx The new audio context to set\n\t */\n\tTone.setContext = function(ctx){\n\t\tTone.context = ctx;\n\t};\n\n\t/**\n\t * The number of seconds of 1 processing block (128 samples)\n\t * @type {Number}\n\t * @name blockTime\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"blockTime\", {\n\t\tget : function(){\n\t\t\treturn 128 / this.context.sampleRate;\n\t\t}\n\t});\n\n\t/**\n\t * The duration in seconds of one sample.\n\t * @type {Number}\n\t * @name sampleTime\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"sampleTime\", {\n\t\tget : function(){\n\t\t\treturn 1 / this.context.sampleRate;\n\t\t}\n\t});\n\n\t/**\n\t * Whether or not all the technologies that Tone.js relies on are supported by the current browser. \n\t * @type {Boolean}\n\t * @name supported\n\t * @memberOf Tone\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone, \"supported\", {\n\t\tget : function(){\n\t\t\tvar hasAudioContext = window.hasOwnProperty(\"AudioContext\") || window.hasOwnProperty(\"webkitAudioContext\");\n\t\t\tvar hasPromises = window.hasOwnProperty(\"Promise\");\n\t\t\tvar hasWorkers = window.hasOwnProperty(\"Worker\");\n\t\t\treturn hasAudioContext && hasPromises && hasWorkers;\n\t\t}\n\t});\n\n\tTone.version = \"r10\";\n\n\t// allow optional silencing of this log\n\tif (!window.TONE_SILENCE_VERSION_LOGGING) {\n\t\tconsole.log(\"%c * Tone.js \" + Tone.version + \" * \", \"background: #000; color: #fff\");\n\t}\n\n\treturn Tone;\n});\n","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Multiply two incoming signals. Or, if a number is given in the constructor, \n\t * multiplies the incoming signal by that value. \n\t *\n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number=} value Constant value to multiple. If no value is provided,\n\t * it will return the product of the first and second inputs\n\t * @example\n\t * var mult = new Tone.Multiply();\n\t * var sigA = new Tone.Signal(3);\n\t * var sigB = new Tone.Signal(4);\n\t * sigA.connect(mult, 0, 0);\n\t * sigB.connect(mult, 0, 1);\n\t * //output of mult is 12.\n\t * @example\n\t * var mult = new Tone.Multiply(10);\n\t * var sig = new Tone.Signal(2).connect(mult);\n\t * //the output of mult is 20. \n\t */\n\tTone.Multiply = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the input node is the same as the output node\n\t\t * it is also the GainNode which handles the scaling of incoming signal\n\t\t * \n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._mult = this.input[0] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * the scaling parameter\n\t\t * @type {AudioParam}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input[1] = this.output.gain;\n\t\t\n\t\tthis._param.value = this.defaultArg(value, 0);\n\t};\n\n\tTone.extend(Tone.Multiply, Tone.Signal);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Multiply} this\n\t */\n\tTone.Multiply.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._mult.dispose();\n\t\tthis._mult = null;\n\t\tthis._param = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Multiply;\n});\n","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/type/Type\", \"Tone/core/Param\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class A signal is an audio-rate value. Tone.Signal is a core component of the library.\n\t * Unlike a number, Signals can be scheduled with sample-level accuracy. Tone.Signal\n\t * has all of the methods available to native Web Audio \n\t * [AudioParam](http://webaudio.github.io/web-audio-api/#the-audioparam-interface)\n\t * as well as additional conveniences. Read more about working with signals \n\t * [here](https://github.com/Tonejs/Tone.js/wiki/Signals).\n\t *\n\t * @constructor\n\t * @extends {Tone.Param}\n\t * @param {Number|AudioParam} [value] Initial value of the signal. If an AudioParam\n\t * is passed in, that parameter will be wrapped\n\t * and controlled by the Signal. \n\t * @param {string} [units=Number] unit The units the signal is in. \n\t * @example\n\t * var signal = new Tone.Signal(10);\n\t */\n\tTone.Signal = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"value\", \"units\"], Tone.Signal.defaults);\n\n\t\t/**\n\t\t * The node where the constant signal value is scaled.\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis.output = this._gain = this.context.createGain();\n\n\t\toptions.param = this._gain.gain;\n\t\tTone.Param.call(this, options);\n\n\t\t/**\n\t\t * The node where the value is set.\n\t\t * @type {Tone.Param}\n\t\t * @private\n\t\t */\n\t\tthis.input = this._param = this._gain.gain;\n\n\t\t//connect the const output to the node output\n\t\tthis.context.getConstant(1).chain(this._gain);\n\t};\n\n\tTone.extend(Tone.Signal, Tone.Param);\n\n\t/**\n\t * The default values\n\t * @type {Object}\n\t * @static\n\t * @const\n\t */\n\tTone.Signal.defaults = {\n\t\t\"value\" : 0,\n\t\t\"units\" : Tone.Type.Default,\n\t\t\"convert\" : true,\n\t};\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.SignalBase} this\n\t * @method\n\t */\n\tTone.Signal.prototype.connect = Tone.SignalBase.prototype.connect;\n\n\t/**\n\t * dispose and disconnect\n\t * @returns {Tone.Signal} this\n\t */\n\tTone.Signal.prototype.dispose = function(){\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._param = null;\n\t\tthis._gain.disconnect();\n\t\tthis._gain = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Signal;\n});","global.TONE_SILENCE_VERSION_LOGGING = true;\n\nimport StartAudioContext from 'startaudiocontext';\nimport Tone from 'Tone/core/Tone';\nimport 'Tone/core/Context';\n\n// Create the Audio Context\nconst audiocontext = new window.AudioContext();\n\n// Tone and p5.sound share the same audio context\nTone.setContext(audiocontext);\n\n/**\n *

Returns the Audio Context for this sketch. Useful for users\n * who would like to dig deeper into the Web Audio API\n * .

\n *\n *

Some browsers require users to startAudioContext\n * with a user gesture, such as touchStarted in the example below.

\n *\n * @for p5\n * @method getAudioContext\n * @return {Object} AudioContext for this sketch\n * @example\n *
\n * function draw() {\n * background(255);\n * textAlign(CENTER);\n *\n * if (getAudioContext().state !== 'running') {\n * text('click to start audio', width/2, height/2);\n * } else {\n * text('audio is enabled', width/2, height/2);\n * }\n * }\n *\n * function touchStarted() {\n * if (getAudioContext().state !== 'running') {\n * getAudioContext().resume();\n * }\n * var synth = new p5.MonoSynth();\n * synth.play('A4', 0.5, 0, 0.2);\n * }\n *\n *
\n */\nexport function getAudioContext() {\n return audiocontext;\n}\n\n/**\n *

It is not only a good practice to give users control over starting\n * audio. This policy is enforced by many web browsers, including iOS and\n * Google Chrome, which create the Web Audio API's\n * Audio Context\n * in a suspended state.

\n *\n *

In these browser-specific policies, sound will not play until a user\n * interaction event (i.e. mousePressed()) explicitly resumes\n * the AudioContext, or starts an audio node. This can be accomplished by\n * calling start() on a p5.Oscillator,\n * play() on a p5.SoundFile, or simply\n * userStartAudio().

\n *\n *

userStartAudio() starts the AudioContext on a user\n * gesture. The default behavior will enable audio on any\n * mouseUp or touchEnd event. It can also be placed in a specific\n * interaction function, such as mousePressed() as in the\n * example below. This method utilizes\n * StartAudioContext\n * , a library by Yotam Mann (MIT Licence, 2016).

\n * @param {Element|Array} [element(s)] This argument can be an Element,\n * Selector String, NodeList, p5.Element,\n * jQuery Element, or an Array of any of those.\n * @param {Function} [callback] Callback to invoke when the AudioContext\n * has started\n * @return {Promise} Returns a Promise that resolves when\n * the AudioContext state is 'running'\n * @method userStartAudio\n * @for p5\n * @example\n *
\n * function setup() {\n * // mimics the autoplay policy\n * getAudioContext().suspend();\n *\n * let mySynth = new p5.MonoSynth();\n *\n * // This won't play until the context has resumed\n * mySynth.play('A6');\n * }\n * function draw() {\n * background(220);\n * textAlign(CENTER, CENTER);\n * text(getAudioContext().state, width/2, height/2);\n * }\n * function mousePressed() {\n * userStartAudio();\n * }\n *
\n */\nexport function userStartAudio(elements, callback) {\n var elt = elements;\n if (elements instanceof p5.Element) {\n elt = elements.elt;\n } else if (elements instanceof Array && elements[0] instanceof p5.Element) {\n elt = elements.map(function (e) {\n return e.elt;\n });\n }\n return StartAudioContext(audiocontext, elt, callback);\n}\n\nexport default audiocontext;\n","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Add a signal and a number or two signals. When no value is\n\t * passed into the constructor, Tone.Add will sum input[0]\n\t * and input[1]. If a value is passed into the constructor, \n\t * the it will be added to the input.\n\t * \n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number=} value If no value is provided, Tone.Add will sum the first\n\t * and second inputs. \n\t * @example\n\t * var signal = new Tone.Signal(2);\n\t * var add = new Tone.Add(2);\n\t * signal.connect(add);\n\t * //the output of add equals 4\n\t * @example\n\t * //if constructed with no arguments\n\t * //it will add the first and second inputs\n\t * var add = new Tone.Add();\n\t * var sig0 = new Tone.Signal(3).connect(add, 0, 0);\n\t * var sig1 = new Tone.Signal(4).connect(add, 0, 1);\n\t * //the output of add equals 7. \n\t */\n\tTone.Add = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the summing node\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._sum = this.input[0] = this.input[1] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * @private\n\t\t * @type {Tone.Signal}\n\t\t */\n\t\tthis._param = this.input[1] = new Tone.Signal(value);\n\n\t\tthis._param.connect(this._sum);\n\t};\n\n\tTone.extend(Tone.Add, Tone.Signal);\n\t\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Add} this\n\t */\n\tTone.Add.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._sum.dispose();\n\t\tthis._sum = null;\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Add;\n});","module.exports = {\n recorderProcessor: 'recorder-processor',\n soundFileProcessor: 'sound-file-processor',\n amplitudeProcessor: 'amplitude-processor',\n};\n","define([\"Tone/core/Tone\", \"Tone/signal/SignalBase\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Wraps the native Web Audio API \n\t * [WaveShaperNode](http://webaudio.github.io/web-audio-api/#the-waveshapernode-interface).\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {function|Array|Number} mapping The function used to define the values. \n\t * The mapping function should take two arguments: \n\t * the first is the value at the current position \n\t * and the second is the array position. \n\t * If the argument is an array, that array will be\n\t * set as the wave shaping function. The input\n\t * signal is an AudioRange [-1, 1] value and the output\n\t * signal can take on any numerical values. \n\t * \n\t * @param {Number} [bufferLen=1024] The length of the WaveShaperNode buffer.\n\t * @example\n\t * var timesTwo = new Tone.WaveShaper(function(val){\n\t * \treturn val * 2;\n\t * }, 2048);\n\t * @example\n\t * //a waveshaper can also be constructed with an array of values\n\t * var invert = new Tone.WaveShaper([1, -1]);\n\t */\n\tTone.WaveShaper = function(mapping, bufferLen){\n\n\t\t/**\n\t\t * the waveshaper\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._shaper = this.input = this.output = this.context.createWaveShaper();\n\n\t\t/**\n\t\t * the waveshapers curve\n\t\t * @type {Float32Array}\n\t\t * @private\n\t\t */\n\t\tthis._curve = null;\n\n\t\tif (Array.isArray(mapping)){\n\t\t\tthis.curve = mapping;\n\t\t} else if (isFinite(mapping) || this.isUndef(mapping)){\n\t\t\tthis._curve = new Float32Array(this.defaultArg(mapping, 1024));\n\t\t} else if (this.isFunction(mapping)){\n\t\t\tthis._curve = new Float32Array(this.defaultArg(bufferLen, 1024));\n\t\t\tthis.setMap(mapping);\n\t\t} \n\t};\n\n\tTone.extend(Tone.WaveShaper, Tone.SignalBase);\n\n\t/**\n\t * Uses a mapping function to set the value of the curve. \n\t * @param {function} mapping The function used to define the values. \n\t * The mapping function take two arguments: \n\t * the first is the value at the current position \n\t * which goes from -1 to 1 over the number of elements\n\t * in the curve array. The second argument is the array position. \n\t * @returns {Tone.WaveShaper} this\n\t * @example\n\t * //map the input signal from [-1, 1] to [0, 10]\n\t * shaper.setMap(function(val, index){\n\t * \treturn (val + 1) * 5;\n\t * })\n\t */\n\tTone.WaveShaper.prototype.setMap = function(mapping){\n\t\tfor (var i = 0, len = this._curve.length; i < len; i++){\n\t\t\tvar normalized = (i / (len - 1)) * 2 - 1;\n\t\t\tthis._curve[i] = mapping(normalized, i);\n\t\t}\n\t\tthis._shaper.curve = this._curve;\n\t\treturn this;\n\t};\n\n\t/**\n\t * The array to set as the waveshaper curve. For linear curves\n\t * array length does not make much difference, but for complex curves\n\t * longer arrays will provide smoother interpolation. \n\t * @memberOf Tone.WaveShaper#\n\t * @type {Array}\n\t * @name curve\n\t */\n\tObject.defineProperty(Tone.WaveShaper.prototype, \"curve\", {\n\t\tget : function(){\n\t\t\treturn this._shaper.curve;\n\t\t},\n\t\tset : function(mapping){\n\t\t\tthis._curve = new Float32Array(mapping);\n\t\t\tthis._shaper.curve = this._curve;\n\t\t}\n\t});\n\n\t/**\n\t * Specifies what type of oversampling (if any) should be used when \n\t * applying the shaping curve. Can either be \"none\", \"2x\" or \"4x\". \n\t * @memberOf Tone.WaveShaper#\n\t * @type {string}\n\t * @name oversample\n\t */\n\tObject.defineProperty(Tone.WaveShaper.prototype, \"oversample\", {\n\t\tget : function(){\n\t\t\treturn this._shaper.oversample;\n\t\t},\n\t\tset : function(oversampling){\n\t\t\tif ([\"none\", \"2x\", \"4x\"].indexOf(oversampling) !== -1){\n\t\t\t\tthis._shaper.oversample = oversampling;\n\t\t\t} else {\n\t\t\t\tthrow new RangeError(\"Tone.WaveShaper: oversampling must be either 'none', '2x', or '4x'\");\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.WaveShaper} this\n\t */\n\tTone.WaveShaper.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._shaper.disconnect();\n\t\tthis._shaper = null;\n\t\tthis._curve = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.WaveShaper;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Timeline\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A signal which adds the method getValueAtTime. \n\t * Code and inspiration from https://github.com/jsantell/web-audio-automation-timeline\n\t * @extends {Tone.Param}\n\t * @param {Number=} value The initial value of the signal\n\t * @param {String=} units The conversion units of the signal.\n\t */\n\tTone.TimelineSignal = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"value\", \"units\"], Tone.Signal.defaults);\n\t\t\n\t\t/**\n\t\t * The scheduled events\n\t\t * @type {Tone.Timeline}\n\t\t * @private\n\t\t */\n\t\tthis._events = new Tone.Timeline(10);\n\n\t\t//constructors\n\t\tTone.Signal.apply(this, options);\n\t\toptions.param = this._param;\n\t\tTone.Param.call(this, options);\n\n\t\t/**\n\t\t * The initial scheduled value\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._initial = this._fromUnits(this._param.value);\n\t};\n\n\tTone.extend(Tone.TimelineSignal, Tone.Param);\n\n\t/**\n\t * The event types of a schedulable signal.\n\t * @enum {String}\n\t * @private\n\t */\n\tTone.TimelineSignal.Type = {\n\t\tLinear : \"linear\",\n\t\tExponential : \"exponential\",\n\t\tTarget : \"target\",\n\t\tCurve : \"curve\",\n\t\tSet : \"set\"\n\t};\n\n\t/**\n\t * The current value of the signal. \n\t * @memberOf Tone.TimelineSignal#\n\t * @type {Number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.TimelineSignal.prototype, \"value\", {\n\t\tget : function(){\n\t\t\tvar now = this.now();\n\t\t\tvar val = this.getValueAtTime(now);\n\t\t\treturn this._toUnits(val);\n\t\t},\n\t\tset : function(value){\n\t\t\tvar convertedVal = this._fromUnits(value);\n\t\t\tthis._initial = convertedVal;\n\t\t\tthis.cancelScheduledValues();\n\t\t\tthis._param.value = convertedVal;\n\t\t}\n\t});\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tSCHEDULING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Schedules a parameter value change at the given time.\n\t * @param {*}\tvalue The value to set the signal.\n\t * @param {Time} time The time when the change should occur.\n\t * @returns {Tone.TimelineSignal} this\n\t * @example\n\t * //set the frequency to \"G4\" in exactly 1 second from now. \n\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t */\n\tTone.TimelineSignal.prototype.setValueAtTime = function (value, startTime) {\n\t\tvalue = this._fromUnits(value);\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Set,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : startTime\n\t\t});\n\t\t//invoke the original event\n\t\tthis._param.setValueAtTime(value, startTime);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules a linear continuous change in parameter value from the \n\t * previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.linearRampToValueAtTime = function (value, endTime) {\n\t\tvalue = this._fromUnits(value);\n\t\tendTime = this.toSeconds(endTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Linear,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : endTime\n\t\t});\n\t\tthis._param.linearRampToValueAtTime(value, endTime);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.exponentialRampToValueAtTime = function (value, endTime) {\n\t\t//get the previous event and make sure it's not starting from 0\n\t\tendTime = this.toSeconds(endTime);\n\t\tvar beforeEvent = this._searchBefore(endTime);\n\t\tif (beforeEvent && beforeEvent.value === 0){\n\t\t\t//reschedule that event\n\t\t\tthis.setValueAtTime(this._minOutput, beforeEvent.time);\n\t\t}\n\t\tvalue = this._fromUnits(value);\n\t\tvar setValue = Math.max(value, this._minOutput);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Exponential,\n\t\t\t\"value\" : setValue,\n\t\t\t\"time\" : endTime\n\t\t});\n\t\t//if the ramped to value is 0, make it go to the min output, and then set to 0.\n\t\tif (value < this._minOutput){\n\t\t\tthis._param.exponentialRampToValueAtTime(this._minOutput, endTime - this.sampleTime);\n\t\t\tthis.setValueAtTime(0, endTime);\n\t\t} else {\n\t\t\tthis._param.exponentialRampToValueAtTime(value, endTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Start exponentially approaching the target value at the given time with\n\t * a rate having the given time constant.\n\t * @param {number} value \n\t * @param {Time} startTime \n\t * @param {number} timeConstant \n\t * @returns {Tone.TimelineSignal} this \n\t */\n\tTone.TimelineSignal.prototype.setTargetAtTime = function (value, startTime, timeConstant) {\n\t\tvalue = this._fromUnits(value);\n\t\tvalue = Math.max(this._minOutput, value);\n\t\ttimeConstant = Math.max(this._minOutput, timeConstant);\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Target,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : startTime,\n\t\t\t\"constant\" : timeConstant\n\t\t});\n\t\tthis._param.setTargetAtTime(value, startTime, timeConstant);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Set an array of arbitrary values starting at the given time for the given duration.\n\t * @param {Float32Array} values \n\t * @param {Time} startTime \n\t * @param {Time} duration\n\t * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value\n\t * @returns {Tone.TimelineSignal} this \n\t */\n\tTone.TimelineSignal.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) {\n\t\tscaling = this.defaultArg(scaling, 1);\n\t\t//copy the array\n\t\tvar floats = new Array(values.length);\n\t\tfor (var i = 0; i < floats.length; i++){\n\t\t\tfloats[i] = this._fromUnits(values[i]) * scaling;\n\t\t}\n\t\tstartTime = this.toSeconds(startTime);\n\t\tduration = this.toSeconds(duration);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Curve,\n\t\t\t\"value\" : floats,\n\t\t\t\"time\" : startTime,\n\t\t\t\"duration\" : duration\n\t\t});\n\t\t//set the first value\n\t\tthis._param.setValueAtTime(floats[0], startTime);\n\t\t//schedule a lienar ramp for each of the segments\n\t\tfor (var j = 1; j < floats.length; j++){\n\t\t\tvar segmentTime = startTime + (j / (floats.length - 1) * duration);\n\t\t\tthis._param.linearRampToValueAtTime(floats[j], segmentTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancels all scheduled parameter changes with times greater than or \n\t * equal to startTime.\n\t * \n\t * @param {Time} startTime\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.cancelScheduledValues = function (after) {\n\t\tafter = this.toSeconds(after);\n\t\tthis._events.cancel(after);\n\t\tthis._param.cancelScheduledValues(after);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Sets the computed value at the given time. This provides\n\t * a point from which a linear or exponential curve\n\t * can be scheduled after. Will cancel events after \n\t * the given time and shorten the currently scheduled\n\t * linear or exponential ramp so that it ends at `time` .\n\t * This is to avoid discontinuities and clicks in envelopes. \n\t * @param {Time} time When to set the ramp point\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.setRampPoint = function (time) {\n\t\ttime = this.toSeconds(time);\n\t\t//get the value at the given time\n\t\tvar val = this._toUnits(this.getValueAtTime(time));\n\t\t//if there is an event at the given time\n\t\t//and that even is not a \"set\"\n\t\tvar before = this._searchBefore(time);\n\t\tif (before && before.time === time){\n\t\t\t//remove everything after\n\t\t\tthis.cancelScheduledValues(time + this.sampleTime);\n\t\t} else if (before && \n\t\t\t\t before.type === Tone.TimelineSignal.Type.Curve &&\n\t\t\t\t before.time + before.duration > time){\n\t\t\t//if the curve is still playing\n\t\t\t//cancel the curve\n\t\t\tthis.cancelScheduledValues(time);\n\t\t\tthis.linearRampToValueAtTime(val, time);\n\t\t} else {\n\t\t\t//reschedule the next event to end at the given time\n\t\t\tvar after = this._searchAfter(time);\n\t\t\tif (after){\n\t\t\t\t//cancel the next event(s)\n\t\t\t\tthis.cancelScheduledValues(time);\n\t\t\t\tif (after.type === Tone.TimelineSignal.Type.Linear){\n\t\t\t\t\tthis.linearRampToValueAtTime(val, time);\n\t\t\t\t} else if (after.type === Tone.TimelineSignal.Type.Exponential){\n\t\t\t\t\tthis.exponentialRampToValueAtTime(val, time);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setValueAtTime(val, time);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Do a linear ramp to the given value between the start and finish times.\n\t * @param {Number} value The value to ramp to.\n\t * @param {Time} start The beginning anchor point to do the linear ramp\n\t * @param {Time} finish The ending anchor point by which the value of\n\t * the signal will equal the given value.\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.linearRampToValueBetween = function (value, start, finish) {\n\t\tthis.setRampPoint(start);\n\t\tthis.linearRampToValueAtTime(value, finish);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Do a exponential ramp to the given value between the start and finish times.\n\t * @param {Number} value The value to ramp to.\n\t * @param {Time} start The beginning anchor point to do the exponential ramp\n\t * @param {Time} finish The ending anchor point by which the value of\n\t * the signal will equal the given value.\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.exponentialRampToValueBetween = function (value, start, finish) {\n\t\tthis.setRampPoint(start);\n\t\tthis.exponentialRampToValueAtTime(value, finish);\n\t\treturn this;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tGETTING SCHEDULED VALUES\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value before or equal to the given time\n\t * @param {Number} time The time to query\n\t * @return {Object} The event at or before the given time.\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._searchBefore = function(time){\n\t\treturn this._events.get(time);\n\t};\n\n\t/**\n\t * The event after the given time\n\t * @param {Number} time The time to query.\n\t * @return {Object} The next event after the given time\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._searchAfter = function(time){\n\t\treturn this._events.getAfter(time);\n\t};\n\n\t/**\n\t * Get the scheduled value at the given time. This will\n\t * return the unconverted (raw) value.\n\t * @param {Number} time The time in seconds.\n\t * @return {Number} The scheduled value at the given time.\n\t */\n\tTone.TimelineSignal.prototype.getValueAtTime = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tvar after = this._searchAfter(time);\n\t\tvar before = this._searchBefore(time);\n\t\tvar value = this._initial;\n\t\t//if it was set by\n\t\tif (before === null){\n\t\t\tvalue = this._initial;\n\t\t} else if (before.type === Tone.TimelineSignal.Type.Target){\n\t\t\tvar previous = this._events.getBefore(before.time);\n\t\t\tvar previouVal;\n\t\t\tif (previous === null){\n\t\t\t\tpreviouVal = this._initial;\n\t\t\t} else {\n\t\t\t\tpreviouVal = previous.value;\n\t\t\t}\n\t\t\tvalue = this._exponentialApproach(before.time, previouVal, before.value, before.constant, time);\n\t\t} else if (before.type === Tone.TimelineSignal.Type.Curve){\n\t\t\tvalue = this._curveInterpolate(before.time, before.value, before.duration, time);\n\t\t} else if (after === null){\n\t\t\tvalue = before.value;\n\t\t} else if (after.type === Tone.TimelineSignal.Type.Linear){\n\t\t\tvalue = this._linearInterpolate(before.time, before.value, after.time, after.value, time);\n\t\t} else if (after.type === Tone.TimelineSignal.Type.Exponential){\n\t\t\tvalue = this._exponentialInterpolate(before.time, before.value, after.time, after.value, time);\n\t\t} else {\n\t\t\tvalue = before.value;\n\t\t}\n\t\treturn value;\n\t};\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.TimelineSignal} this\n\t * @method\n\t */\n\tTone.TimelineSignal.prototype.connect = Tone.SignalBase.prototype.connect;\n\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tAUTOMATION CURVE CALCULATIONS\n\t//\tMIT License, copyright (c) 2014 Jordan Santell\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Calculates the the value along the curve produced by setTargetAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._exponentialApproach = function (t0, v0, v1, timeConstant, t) {\n\t\treturn v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant);\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by linearRampToValueAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._linearInterpolate = function (t0, v0, t1, v1, t) {\n\t\treturn v0 + (v1 - v0) * ((t - t0) / (t1 - t0));\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by exponentialRampToValueAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._exponentialInterpolate = function (t0, v0, t1, v1, t) {\n\t\tv0 = Math.max(this._minOutput, v0);\n\t\treturn v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0));\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by setValueCurveAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._curveInterpolate = function (start, curve, duration, time) {\n\t\tvar len = curve.length;\n\t\t// If time is after duration, return the last curve value\n\t\tif (time >= start + duration) {\n\t\t\treturn curve[len - 1];\n\t\t} else if (time <= start){\n\t\t\treturn curve[0];\n\t\t} else {\n\t\t\tvar progress = (time - start) / duration;\n\t\t\tvar lowerIndex = Math.floor((len - 1) * progress);\n\t\t\tvar upperIndex = Math.ceil((len - 1) * progress);\n\t\t\tvar lowerVal = curve[lowerIndex];\n\t\t\tvar upperVal = curve[upperIndex];\n\t\t\tif (upperIndex === lowerIndex){\n\t\t\t\treturn lowerVal;\n\t\t\t} else {\n\t\t\t\treturn this._linearInterpolate(lowerIndex, lowerVal, upperIndex, upperVal, progress * (len - 1));\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.dispose = function(){\n\t\tTone.Signal.prototype.dispose.call(this);\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._events.dispose();\n\t\tthis._events = null;\n\t};\n\n\treturn Tone.TimelineSignal;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Multiply\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\t\n\t/**\n\t * @class Performs a linear scaling on an input signal.\n\t * Scales a NormalRange input to between\n\t * outputMin and outputMax.\n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @param {number} [outputMin=0] The output value when the input is 0. \n\t * @param {number} [outputMax=1]\tThe output value when the input is 1. \n\t * @example\n\t * var scale = new Tone.Scale(50, 100);\n\t * var signal = new Tone.Signal(0.5).connect(scale);\n\t * //the output of scale equals 75\n\t */\n\tTone.Scale = function(outputMin, outputMax){\n\n\t\t/** \n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._outputMin = this.defaultArg(outputMin, 0);\n\n\t\t/** \n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._outputMax = this.defaultArg(outputMax, 1);\n\n\n\t\t/** \n\t\t * @private\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._scale = this.input = new Tone.Multiply(1);\n\t\t\n\t\t/** \n\t\t * @private\n\t\t * @type {Tone.Add}\n\t\t * @private\n\t\t */\n\t\tthis._add = this.output = new Tone.Add(0);\n\n\t\tthis._scale.connect(this._add);\n\t\tthis._setRange();\n\t};\n\n\tTone.extend(Tone.Scale, Tone.SignalBase);\n\n\t/**\n\t * The minimum output value. This number is output when \n\t * the value input value is 0. \n\t * @memberOf Tone.Scale#\n\t * @type {number}\n\t * @name min\n\t */\n\tObject.defineProperty(Tone.Scale.prototype, \"min\", {\n\t\tget : function(){\n\t\t\treturn this._outputMin;\n\t\t},\n\t\tset : function(min){\n\t\t\tthis._outputMin = min;\n\t\t\tthis._setRange();\n\t\t}\n\t});\n\n\t/**\n\t * The maximum output value. This number is output when \n\t * the value input value is 1. \n\t * @memberOf Tone.Scale#\n\t * @type {number}\n\t * @name max\n\t */\n\tObject.defineProperty(Tone.Scale.prototype, \"max\", {\n\t\tget : function(){\n\t\t\treturn this._outputMax;\n\t\t},\n\t\tset : function(max){\n\t\t\tthis._outputMax = max;\n\t\t\tthis._setRange();\n\t\t}\n\t});\n\n\t/**\n\t * set the values\n\t * @private\n\t */\n\tTone.Scale.prototype._setRange = function() {\n\t\tthis._add.value = this._outputMin;\n\t\tthis._scale.value = this._outputMax - this._outputMin;\n\t};\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Scale} this\n\t */\n\tTone.Scale.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._add.dispose();\n\t\tthis._add = null;\n\t\tthis._scale.dispose();\n\t\tthis._scale = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Scale;\n});\n","define([\"Tone/core/Tone\", \"Tone/type/Time\", \"Tone/type/Frequency\", \"Tone/type/TransportTime\", \"Tone/core/Context\"],\nfunction (Tone) {\t\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTYPES\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Units which a value can take on.\n\t * @enum {String}\n\t */\n\tTone.Type = {\n\t\t/** \n\t\t * Default units\n\t\t * @typedef {Default}\n\t\t */\n\t\tDefault : \"number\",\n\t\t/**\n\t\t * Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time).\n\t\t *\n\t\t *
    \n\t\t *
  • Numbers, which will be taken literally as the time (in seconds).
  • \n\t\t *
  • Notation, (\"4n\", \"8t\") describes time in BPM and time signature relative values.
  • \n\t\t *
  • TransportTime, (\"4:3:2\") will also provide tempo and time signature relative times \n\t\t * in the form BARS:QUARTERS:SIXTEENTHS.
  • \n\t\t *
  • Frequency, (\"8hz\") is converted to the length of the cycle in seconds.
  • \n\t\t *
  • Now-Relative, (\"+1\") prefix any of the above with \"+\" and it will be interpreted as \n\t\t * \"the current time plus whatever expression follows\".
  • \n\t\t *
  • Expressions, (\"3:0 + 2 - (1m / 7)\") any of the above can also be combined \n\t\t * into a mathematical expression which will be evaluated to compute the desired time.
  • \n\t\t *
  • No Argument, for methods which accept time, no argument will be interpreted as \n\t\t * \"now\" (i.e. the currentTime).
  • \n\t\t *
\n\t\t * \n\t\t * @typedef {Time}\n\t\t */\n\t\tTime : \"time\",\n\t\t/**\n\t\t * Frequency can be described similar to time, except ultimately the\n\t\t * values are converted to frequency instead of seconds. A number\n\t\t * is taken literally as the value in hertz. Additionally any of the \n\t\t * Time encodings can be used. Note names in the form\n\t\t * of NOTE OCTAVE (i.e. C4) are also accepted and converted to their\n\t\t * frequency value. \n\t\t * @typedef {Frequency}\n\t\t */\n\t\tFrequency : \"frequency\",\n\t\t/**\n\t\t * TransportTime describes a position along the Transport's timeline. It is\n\t\t * similar to Time in that it uses all the same encodings, but TransportTime specifically\n\t\t * pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable. \n\t\t * [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime)\n\t\t * @typedef {TransportTime}\n\t\t */\n\t\tTransportTime : \"transportTime\",\n\t\t/** \n\t\t * Ticks are the basic subunit of the Transport. They are\n\t\t * the smallest unit of time that the Transport supports.\n\t\t * @typedef {Ticks}\n\t\t */\n\t\tTicks : \"ticks\",\n\t\t/** \n\t\t * Normal values are within the range [0, 1].\n\t\t * @typedef {NormalRange}\n\t\t */\n\t\tNormalRange : \"normalRange\",\n\t\t/** \n\t\t * AudioRange values are between [-1, 1].\n\t\t * @typedef {AudioRange}\n\t\t */\n\t\tAudioRange : \"audioRange\",\n\t\t/** \n\t\t * Decibels are a logarithmic unit of measurement which is useful for volume\n\t\t * because of the logarithmic way that we perceive loudness. 0 decibels \n\t\t * means no change in volume. -10db is approximately half as loud and 10db \n\t\t * is twice is loud. \n\t\t * @typedef {Decibels}\n\t\t */\n\t\tDecibels : \"db\",\n\t\t/** \n\t\t * Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up.\n\t\t * @typedef {Interval}\n\t\t */\n\t\tInterval : \"interval\",\n\t\t/** \n\t\t * Beats per minute. \n\t\t * @typedef {BPM}\n\t\t */\n\t\tBPM : \"bpm\",\n\t\t/** \n\t\t * The value must be greater than or equal to 0.\n\t\t * @typedef {Positive}\n\t\t */\n\t\tPositive : \"positive\",\n\t\t/** \n\t\t * A cent is a hundredth of a semitone. \n\t\t * @typedef {Cents}\n\t\t */\n\t\tCents : \"cents\",\n\t\t/** \n\t\t * Angle between 0 and 360. \n\t\t * @typedef {Degrees}\n\t\t */\n\t\tDegrees : \"degrees\",\n\t\t/** \n\t\t * A number representing a midi note.\n\t\t * @typedef {MIDI}\n\t\t */\n\t\tMIDI : \"midi\",\n\t\t/** \n\t\t * A colon-separated representation of time in the form of\n\t\t * Bars:Beats:Sixteenths. \n\t\t * @typedef {BarsBeatsSixteenths}\n\t\t */\n\t\tBarsBeatsSixteenths : \"barsBeatsSixteenths\",\n\t\t/** \n\t\t * Sampling is the reduction of a continuous signal to a discrete signal.\n\t\t * Audio is typically sampled 44100 times per second. \n\t\t * @typedef {Samples}\n\t\t */\n\t\tSamples : \"samples\",\n\t\t/** \n\t\t * Hertz are a frequency representation defined as one cycle per second.\n\t\t * @typedef {Hertz}\n\t\t */\n\t\tHertz : \"hertz\",\n\t\t/** \n\t\t * A frequency represented by a letter name, \n\t\t * accidental and octave. This system is known as\n\t\t * [Scientific Pitch Notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation).\n\t\t * @typedef {Note}\n\t\t */\n\t\tNote : \"note\",\n\t\t/** \n\t\t * One millisecond is a thousandth of a second. \n\t\t * @typedef {Milliseconds}\n\t\t */\n\t\tMilliseconds : \"milliseconds\",\n\t\t/** \n\t\t * Seconds are the time unit of the AudioContext. In the end, \n\t\t * all values need to be evaluated to seconds. \n\t\t * @typedef {Seconds}\n\t\t */\n\t\tSeconds : \"seconds\",\n\t\t/** \n\t\t * A string representing a duration relative to a measure. \n\t\t *
    \n\t\t * \t
  • \"4n\" = quarter note
  • \n\t\t * \t
  • \"2m\" = two measures
  • \n\t\t * \t
  • \"8t\" = eighth-note triplet
  • \n\t\t *
\n\t\t * @typedef {Notation}\n\t\t */\n\t\tNotation : \"notation\",\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// AUGMENT TONE's PROTOTYPE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Convert Time into seconds.\n\t * \n\t * Unlike the method which it overrides, this takes into account \n\t * transporttime and musical notation.\n\t *\n\t * Time : 1.40\n\t * Notation: 4n|1m|2t\n\t * Now Relative: +3n\n\t * Math: 3n+16n or even complicated expressions ((3n*2)/6 + 1)\n\t *\n\t * @param {Time} time \n\t * @return {Seconds} \n\t */\n\tTone.prototype.toSeconds = function(time){\n\t\tif (this.isNumber(time)){\n\t\t\treturn time;\n\t\t} else if (this.isUndef(time)){\n\t\t\treturn this.now();\t\t\t\n\t\t} else if (this.isString(time)){\n\t\t\treturn (new Tone.Time(time)).toSeconds();\n\t\t} else if (time instanceof Tone.TimeBase){\n\t\t\treturn time.toSeconds();\n\t\t}\n\t};\n\n\t/**\n\t * Convert a frequency representation into a number.\n\t * @param {Frequency} freq \n\t * @return {Hertz} the frequency in hertz\n\t */\n\tTone.prototype.toFrequency = function(freq){\n\t\tif (this.isNumber(freq)){\n\t\t\treturn freq;\n\t\t} else if (this.isString(freq) || this.isUndef(freq)){\n\t\t\treturn (new Tone.Frequency(freq)).valueOf();\n\t\t} else if (freq instanceof Tone.TimeBase){\n\t\t\treturn freq.toFrequency();\n\t\t}\n\t};\n\n\t/**\n\t * Convert a time representation into ticks.\n\t * @param {Time} time\n\t * @return {Ticks} the time in ticks\n\t */\n\tTone.prototype.toTicks = function(time){\n\t\tif (this.isNumber(time) || this.isString(time)){\n\t\t\treturn (new Tone.TransportTime(time)).toTicks();\n\t\t} else if (this.isUndef(time)){\n\t\t\treturn Tone.Transport.ticks;\t\t\t\n\t\t} else if (time instanceof Tone.TimeBase){\n\t\t\treturn time.toTicks();\n\t\t}\n\t};\n\n\treturn Tone;\n});","define([\"Tone/core/Tone\", \"Tone/core/Param\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * createGain shim\n\t * @private\n\t */\n\tif (window.GainNode && !AudioContext.prototype.createGain){\n\t\tAudioContext.prototype.createGain = AudioContext.prototype.createGainNode;\n\t}\n\n\t/**\n\t * @class A thin wrapper around the Native Web Audio GainNode.\n\t * The GainNode is a basic building block of the Web Audio\n\t * API and is useful for routing audio and adjusting gains. \n\t * @extends {Tone}\n\t * @param {Number=} gain The initial gain of the GainNode\n\t * @param {Tone.Type=} units The units of the gain parameter. \n\t */\n\tTone.Gain = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"gain\", \"units\"], Tone.Gain.defaults);\n\n\t\t/**\n\t\t * The GainNode\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis.input = this.output = this._gainNode = this.context.createGain();\n\n\t\t/**\n\t\t * The gain parameter of the gain node.\n\t\t * @type {Tone.Param}\n\t\t * @signal\n\t\t */\n\t\tthis.gain = new Tone.Param({\n\t\t\t\"param\" : this._gainNode.gain, \n\t\t\t\"units\" : options.units,\n\t\t\t\"value\" : options.gain,\n\t\t\t\"convert\" : options.convert\n\t\t});\n\t\tthis._readOnly(\"gain\");\n\t};\n\n\tTone.extend(Tone.Gain);\n\n\t/**\n\t * The defaults\n\t * @const\n\t * @type {Object}\n\t */\n\tTone.Gain.defaults = {\n\t\t\"gain\" : 1,\n\t\t\"convert\" : true,\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.Gain} this\n\t */\n\tTone.Gain.prototype.dispose = function(){\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._gainNode.disconnect();\n\t\tthis._gainNode = null;\n\t\tthis._writable(\"gain\");\n\t\tthis.gain.dispose();\n\t\tthis.gain = null;\n\t};\n\n\t//STATIC///////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Create input and outputs for this object.\n\t * @param {Number} input The number of inputs\n\t * @param {Number=} outputs The number of outputs\n\t * @return {Tone} this\n\t * @internal\n\t */\n\tTone.prototype.createInsOuts = function(inputs, outputs){\n\n\t\tif (inputs === 1){\n\t\t\tthis.input = new Tone.Gain();\n\t\t} else if (inputs > 1){\n\t\t\tthis.input = new Array(inputs);\n\t\t}\n\n\t\tif (outputs === 1){\n\t\t\tthis.output = new Tone.Gain();\n\t\t} else if (outputs > 1){\n\t\t\tthis.output = new Array(inputs);\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\n\treturn Tone.Gain;\n});","define([\"Tone/core/Tone\", \"Tone/signal/TimelineSignal\", \"Tone/core/TimelineState\", \n\t\"Tone/core/Emitter\", \"Tone/core/Context\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A sample accurate clock which provides a callback at the given rate. \n\t * While the callback is not sample-accurate (it is still susceptible to\n\t * loose JS timing), the time passed in as the argument to the callback\n\t * is precise. For most applications, it is better to use Tone.Transport\n\t * instead of the Clock by itself since you can synchronize multiple callbacks.\n\t *\n\t * \t@constructor\n\t * @extends {Tone.Emitter}\n\t * \t@param {function} callback The callback to be invoked with the time of the audio event\n\t * \t@param {Frequency} frequency The rate of the callback\n\t * \t@example\n\t * //the callback will be invoked approximately once a second\n\t * //and will print the time exactly once a second apart.\n\t * var clock = new Tone.Clock(function(time){\n\t * \tconsole.log(time);\n\t * }, 1);\n\t */\n\tTone.Clock = function(){\n\n\t\tTone.Emitter.call(this);\n\n\t\tvar options = this.optionsObject(arguments, [\"callback\", \"frequency\"], Tone.Clock.defaults);\n\n\t\t/**\n\t\t * The callback function to invoke at the scheduled tick.\n\t\t * @type {Function}\n\t\t */\n\t\tthis.callback = options.callback;\n\n\t\t/**\n\t\t * The next time the callback is scheduled.\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._nextTick = 0;\n\n\t\t/**\n\t\t * The last state of the clock.\n\t\t * @type {State}\n\t\t * @private\n\t\t */\n\t\tthis._lastState = Tone.State.Stopped;\n\n\t\t/**\n\t\t * The rate the callback function should be invoked. \n\t\t * @type {BPM}\n\t\t * @signal\n\t\t */\n\t\tthis.frequency = new Tone.TimelineSignal(options.frequency, Tone.Type.Frequency);\n\t\tthis._readOnly(\"frequency\");\n\n\t\t/**\n\t\t * The number of times the callback was invoked. Starts counting at 0\n\t\t * and increments after the callback was invoked. \n\t\t * @type {Ticks}\n\t\t * @readOnly\n\t\t */\n\t\tthis.ticks = 0;\n\n\t\t/**\n\t\t * The state timeline\n\t\t * @type {Tone.TimelineState}\n\t\t * @private\n\t\t */\n\t\tthis._state = new Tone.TimelineState(Tone.State.Stopped);\n\n\t\t/**\n\t\t * The loop function bound to its context. \n\t\t * This is necessary to remove the event in the end.\n\t\t * @type {Function}\n\t\t * @private\n\t\t */\n\t\tthis._boundLoop = this._loop.bind(this);\n\n\t\t//bind a callback to the worker thread\n \tthis.context.on(\"tick\", this._boundLoop);\n\t};\n\n\tTone.extend(Tone.Clock, Tone.Emitter);\n\n\t/**\n\t * The defaults\n\t * @const\n\t * @type {Object}\n\t */\n\tTone.Clock.defaults = {\n\t\t\"callback\" : Tone.noOp,\n\t\t\"frequency\" : 1,\n\t\t\"lookAhead\" : \"auto\",\n\t};\n\n\t/**\n\t * Returns the playback state of the source, either \"started\", \"stopped\" or \"paused\".\n\t * @type {Tone.State}\n\t * @readOnly\n\t * @memberOf Tone.Clock#\n\t * @name state\n\t */\n\tObject.defineProperty(Tone.Clock.prototype, \"state\", {\n\t\tget : function(){\n\t\t\treturn this._state.getValueAtTime(this.now());\n\t\t}\n\t});\n\n\t/**\n\t * Start the clock at the given time. Optionally pass in an offset\n\t * of where to start the tick counter from.\n\t * @param {Time} time The time the clock should start\n\t * @param {Ticks=} offset Where the tick counter starts counting from.\n\t * @return {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.start = function(time, offset){\n\t\ttime = this.toSeconds(time);\n\t\tif (this._state.getValueAtTime(time) !== Tone.State.Started){\n\t\t\tthis._state.add({\n\t\t\t\t\"state\" : Tone.State.Started, \n\t\t\t\t\"time\" : time,\n\t\t\t\t\"offset\" : offset\n\t\t\t});\n\t\t}\n\t\treturn this;\t\n\t};\n\n\t/**\n\t * Stop the clock. Stopping the clock resets the tick counter to 0.\n\t * @param {Time} [time=now] The time when the clock should stop.\n\t * @returns {Tone.Clock} this\n\t * @example\n\t * clock.stop();\n\t */\n\tTone.Clock.prototype.stop = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tthis._state.cancel(time);\n\t\tthis._state.setStateAtTime(Tone.State.Stopped, time);\n\t\treturn this;\t\n\t};\n\n\n\t/**\n\t * Pause the clock. Pausing does not reset the tick counter.\n\t * @param {Time} [time=now] The time when the clock should stop.\n\t * @returns {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.pause = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tif (this._state.getValueAtTime(time) === Tone.State.Started){\n\t\t\tthis._state.setStateAtTime(Tone.State.Paused, time);\n\t\t}\n\t\treturn this;\t\n\t};\n\n\t/**\n\t * The scheduling loop.\n\t * @param {Number} time The current page time starting from 0\n\t * when the page was loaded.\n\t * @private\n\t */\n\tTone.Clock.prototype._loop = function(){\n\t\t//get the frequency value to compute the value of the next loop\n\t\tvar now = this.now();\n\t\t//if it's started\n\t\tvar lookAhead = this.context.lookAhead;\n\t\tvar updateInterval = this.context.updateInterval;\n\t\tvar lagCompensation = this.context.lag * 2;\n\t\tvar loopInterval = now + lookAhead + updateInterval + lagCompensation;\n\t\twhile (loopInterval > this._nextTick && this._state){\n\t\t\tvar currentState = this._state.getValueAtTime(this._nextTick);\n\t\t\tif (currentState !== this._lastState){\n\t\t\t\tthis._lastState = currentState;\n\t\t\t\tvar event = this._state.get(this._nextTick);\n\t\t\t\t// emit an event\n\t\t\t\tif (currentState === Tone.State.Started){\n\t\t\t\t\t//correct the time\n\t\t\t\t\tthis._nextTick = event.time;\n\t\t\t\t\tif (!this.isUndef(event.offset)){\n\t\t\t\t\t\tthis.ticks = event.offset;\n\t\t\t\t\t}\n\t\t\t\t\tthis.emit(\"start\", event.time, this.ticks);\n\t\t\t\t} else if (currentState === Tone.State.Stopped){\n\t\t\t\t\tthis.ticks = 0;\n\n\t\t\t\t\tthis.emit(\"stop\", event.time);\n\t\t\t\t} else if (currentState === Tone.State.Paused){\n\t\t\t\t\tthis.emit(\"pause\", event.time);\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar tickTime = this._nextTick;\n\t\t\tif (this.frequency){\n\t\t\t\tthis._nextTick += 1 / this.frequency.getValueAtTime(this._nextTick);\n\t\t\t\tif (currentState === Tone.State.Started){\n\t\t\t\t\tthis.callback(tickTime);\n\t\t\t\t\tthis.ticks++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Returns the scheduled state at the given time.\n\t * @param {Time} time The time to query.\n\t * @return {String} The name of the state input in setStateAtTime.\n\t * @example\n\t * clock.start(\"+0.1\");\n\t * clock.getStateAtTime(\"+0.1\"); //returns \"started\"\n\t */\n\tTone.Clock.prototype.getStateAtTime = function(time){\n\t\ttime = this.toSeconds(time);\n\t\treturn this._state.getValueAtTime(time);\n\t};\n\n\t/**\n\t * Clean up\n\t * @returns {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.dispose = function(){\n\t\tTone.Emitter.prototype.dispose.call(this);\n\t\tthis.context.off(\"tick\", this._boundLoop);\n\t\tthis._writable(\"frequency\");\n\t\tthis.frequency.dispose();\n\t\tthis.frequency = null;\n\t\tthis._boundLoop = null;\n\t\tthis._nextTick = Infinity;\n\t\tthis.callback = null;\n\t\tthis._state.dispose();\n\t\tthis._state = null;\n\t};\n\n\treturn Tone.Clock;\n});","define([\"Tone/core/Tone\", \"Tone/core/Emitter\"], function (Tone) {\n\n\t/**\n\t * shim\n\t * @private\n\t */\n\tif (!window.hasOwnProperty(\"AudioContext\") && window.hasOwnProperty(\"webkitAudioContext\")){\n\t\twindow.AudioContext = window.webkitAudioContext;\n\t}\n\n\t/**\n\t * @class Wrapper around the native AudioContext.\n\t * @extends {Tone.Emitter}\n\t * @param {AudioContext=} context optionally pass in a context\n\t */\n\tTone.Context = function(context){\n\n\t\tTone.Emitter.call(this);\n\n\t\tif (!context){\n\t\t\tcontext = new window.AudioContext();\n\t\t}\n\t\tthis._context = context;\n\t\t// extend all of the methods\n\t\tfor (var prop in this._context){\n\t\t\tthis._defineProperty(this._context, prop);\n\t\t}\n\n\t\t///////////////////////////////////////////////////////////////////////\n\t\t// WORKER\n\t\t///////////////////////////////////////////////////////////////////////\n\n\t\t/**\n\t\t * The default latency hint\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t\tthis._latencyHint = \"interactive\";\n\n\t\t/**\n\t\t * The amount of time events are scheduled\n\t\t * into the future\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._lookAhead = 0.1;\n\n\t\t/**\n\t\t * How often the update look runs\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._updateInterval = this._lookAhead/3;\n\n\t\t/**\n\t\t * A reference to the actual computed update interval\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._computedUpdateInterval = 0;\n\n\t\t/**\n\t\t * The web worker which is used to update Tone.Clock\n\t\t * @private\n\t\t * @type {WebWorker}\n\t\t */\n\t\tthis._worker = this._createWorker();\n\n\t\t/**\n\t\t * An object containing all of the constants AudioBufferSourceNodes\n\t\t * @type {Object}\n\t\t * @private\n\t\t */\n\t\tthis._constants = {};\n\n\t};\n\n\tTone.extend(Tone.Context, Tone.Emitter);\n\tTone.Emitter.mixin(Tone.Context);\n\n\t/**\n\t * Define a property on this Tone.Context. \n\t * This is used to extend the native AudioContext\n\t * @param {AudioContext} context\n\t * @param {String} prop \n\t * @private\n\t */\n\tTone.Context.prototype._defineProperty = function(context, prop){\n\t\tif (this.isUndef(this[prop])){\n\t\t\tObject.defineProperty(this, prop, {\n\t\t\t\tget : function(){\n\t\t\t\t\tif (typeof context[prop] === \"function\"){\n\t\t\t\t\t\treturn context[prop].bind(context);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn context[prop];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tset : function(val){\n\t\t\t\t\tcontext[prop] = val;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * The current audio context time\n\t * @return {Number}\n\t */\n\tTone.Context.prototype.now = function(){\n\t\treturn this._context.currentTime;\n\t};\n\n\t/**\n\t * Generate a web worker\n\t * @return {WebWorker}\n\t * @private\n\t */\n\tTone.Context.prototype._createWorker = function(){\n\t\t\n\t\t//URL Shim\n\t\twindow.URL = window.URL || window.webkitURL;\n\n\t\tvar blob = new Blob([\n\t\t\t//the initial timeout time\n\t\t\t\"var timeoutTime = \"+(this._updateInterval * 1000).toFixed(1)+\";\" +\n\t\t\t//onmessage callback\n\t\t\t\"self.onmessage = function(msg){\" +\n\t\t\t\"\ttimeoutTime = parseInt(msg.data);\" + \n\t\t\t\"};\" + \n\t\t\t//the tick function which posts a message\n\t\t\t//and schedules a new tick\n\t\t\t\"function tick(){\" +\n\t\t\t\"\tsetTimeout(tick, timeoutTime);\" +\n\t\t\t\"\tself.postMessage('tick');\" +\n\t\t\t\"}\" +\n\t\t\t//call tick initially\n\t\t\t\"tick();\"\n\t\t]);\n\t\tvar blobUrl = URL.createObjectURL(blob);\n\t\tvar worker = new Worker(blobUrl);\n\n\t\tworker.addEventListener(\"message\", function(){\n\t\t\t// tick the clock\n\t\t\tthis.emit(\"tick\");\n\t\t}.bind(this));\n\n\t\t//lag compensation\n\t\tworker.addEventListener(\"message\", function(){\n\t\t\tvar now = this.now();\n\t\t\tif (this.isNumber(this._lastUpdate)){\n\t\t\t\tvar diff = now - this._lastUpdate;\n\t\t\t\tthis._computedUpdateInterval = Math.max(diff, this._computedUpdateInterval * 0.97);\n\t\t\t}\n\t\t\tthis._lastUpdate = now;\n\t\t}.bind(this));\n\n\t\treturn worker;\n\t};\n\n\t/**\n\t * Generate a looped buffer at some constant value.\n\t * @param {Number} val\n\t * @return {BufferSourceNode}\n\t */\n\tTone.Context.prototype.getConstant = function(val){\n\t\tif (this._constants[val]){\n\t\t\treturn this._constants[val];\n\t\t} else {\n\t\t\tvar buffer = this._context.createBuffer(1, 128, this._context.sampleRate);\n\t\t\tvar arr = buffer.getChannelData(0);\n\t\t\tfor (var i = 0; i < arr.length; i++){\n\t\t\t\tarr[i] = val;\n\t\t\t}\n\t\t\tvar constant = this._context.createBufferSource();\n\t\t\tconstant.channelCount = 1;\n\t\t\tconstant.channelCountMode = \"explicit\";\n\t\t\tconstant.buffer = buffer;\n\t\t\tconstant.loop = true;\n\t\t\tconstant.start(0);\n\t\t\tthis._constants[val] = constant;\n\t\t\treturn constant;\n\t\t}\n\t};\n\n\t/**\n\t * This is the time that the clock is falling behind\n\t * the scheduled update interval. The Context automatically\n\t * adjusts for the lag and schedules further in advance.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name lag\n\t * @static\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"lag\", {\n\t\tget : function(){\n\t\t\tvar diff = this._computedUpdateInterval - this._updateInterval;\n\t\t\tdiff = Math.max(diff, 0);\n\t\t\treturn diff;\n\t\t}\n\t});\n\n\t/**\n\t * The amount of time in advance that events are scheduled.\n\t * The lookAhead will adjust slightly in response to the \n\t * measured update time to try to avoid clicks.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name lookAhead\n\t * @static\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"lookAhead\", {\n\t\tget : function(){\n\t\t\treturn this._lookAhead;\n\t\t},\n\t\tset : function(lA){\n\t\t\tthis._lookAhead = lA;\n\t\t}\n\t});\n\n\t/**\n\t * How often the Web Worker callback is invoked.\n\t * This number corresponds to how responsive the scheduling\n\t * can be. Context.updateInterval + Context.lookAhead gives you the\n\t * total latency between scheduling an event and hearing it.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name updateInterval\n\t * @static\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"updateInterval\", {\n\t\tget : function(){\n\t\t\treturn this._updateInterval;\n\t\t},\n\t\tset : function(interval){\n\t\t\tthis._updateInterval = Math.max(interval, Tone.prototype.blockTime);\n\t\t\tthis._worker.postMessage(Math.max(interval * 1000, 1));\n\t\t}\n\t});\n\n\t/**\n\t * The type of playback, which affects tradeoffs between audio \n\t * output latency and responsiveness. \n\t * \n\t * In addition to setting the value in seconds, the latencyHint also\n\t * accepts the strings \"interactive\" (prioritizes low latency), \n\t * \"playback\" (prioritizes sustained playback), \"balanced\" (balances\n\t * latency and performance), and \"fastest\" (lowest latency, might glitch more often). \n\t * @type {String|Seconds}\n\t * @memberOf Tone.Context#\n\t * @name latencyHint\n\t * @static\n\t * @example\n\t * //set the lookAhead to 0.3 seconds\n\t * Tone.context.latencyHint = 0.3;\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"latencyHint\", {\n\t\tget : function(){\n\t\t\treturn this._latencyHint;\n\t\t},\n\t\tset : function(hint){\n\t\t\tvar lookAhead = hint;\n\t\t\tthis._latencyHint = hint;\n\t\t\tif (this.isString(hint)){\n\t\t\t\tswitch(hint){\n\t\t\t\t\tcase \"interactive\" :\n\t\t\t\t\t\tlookAhead = 0.1;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"playback\" :\n\t\t\t\t\t\tlookAhead = 0.8;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"balanced\" :\n\t\t\t\t\t\tlookAhead = 0.25;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fastest\" :\n\t\t\t\t\t\tlookAhead = 0.01;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.lookAhead = lookAhead;\n\t\t\tthis.updateInterval = lookAhead/3;\n\t\t}\n\t});\n\n\t/**\n\t * Shim all connect/disconnect and some deprecated methods which are still in\n\t * some older implementations.\n\t * @private\n\t */\n\tfunction shimConnect(){\n\n\t\tvar nativeConnect = AudioNode.prototype.connect;\n\t\tvar nativeDisconnect = AudioNode.prototype.disconnect;\n\n\t\t//replace the old connect method\n\t\tfunction toneConnect(B, outNum, inNum){\n\t\t\tif (B.input){\n\t\t\t\tif (Array.isArray(B.input)){\n\t\t\t\t\tif (Tone.prototype.isUndef(inNum)){\n\t\t\t\t\t\tinNum = 0;\n\t\t\t\t\t}\n\t\t\t\t\tthis.connect(B.input[inNum]);\n\t\t\t\t} else {\n\t\t\t\t\tthis.connect(B.input, outNum, inNum);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tif (B instanceof AudioNode){\n\t\t\t\t\t\tnativeConnect.call(this, B, outNum, inNum);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnativeConnect.call(this, B, outNum);\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new Error(\"error connecting to node: \"+B+\"\\n\"+e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//replace the old disconnect method\n\t\tfunction toneDisconnect(B, outNum, inNum){\n\t\t\tif (B && B.input && Array.isArray(B.input)){\n\t\t\t\tif (Tone.prototype.isUndef(inNum)){\n\t\t\t\t\tinNum = 0;\n\t\t\t\t}\n\t\t\t\tthis.disconnect(B.input[inNum], outNum, inNum);\n\t\t\t} else if (B && B.input){\n\t\t\t\tthis.disconnect(B.input, outNum, inNum);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tnativeDisconnect.apply(this, arguments);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new Error(\"error disconnecting node: \"+B+\"\\n\"+e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (AudioNode.prototype.connect !== toneConnect){\n\t\t\tAudioNode.prototype.connect = toneConnect;\n\t\t\tAudioNode.prototype.disconnect = toneDisconnect;\n\t\t}\n\t}\n\n\t// set the audio context initially\n\tif (Tone.supported){\n\t\tshimConnect();\n\t\tTone.context = new Tone.Context();\n\t} else {\n\t\tconsole.warn(\"This browser does not support Tone.js\");\n\t}\n\n\treturn Tone.Context;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Negate\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Subtract the signal connected to input[1] from the signal connected \n\t * to input[0]. If an argument is provided in the constructor, the \n\t * signals .value will be subtracted from the incoming signal.\n\t *\n\t * @extends {Tone.Signal}\n\t * @constructor\n\t * @param {number=} value The value to subtract from the incoming signal. If the value\n\t * is omitted, it will subtract the second signal from the first.\n\t * @example\n\t * var sub = new Tone.Subtract(1);\n\t * var sig = new Tone.Signal(4).connect(sub);\n\t * //the output of sub is 3. \n\t * @example\n\t * var sub = new Tone.Subtract();\n\t * var sigA = new Tone.Signal(10);\n\t * var sigB = new Tone.Signal(2.5);\n\t * sigA.connect(sub, 0, 0);\n\t * sigB.connect(sub, 0, 1);\n\t * //output of sub is 7.5\n\t */\n\tTone.Subtract = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the summing node\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._sum = this.input[0] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * negate the input of the second input before connecting it\n\t\t * to the summing node.\n\t\t * @type {Tone.Negate}\n\t\t * @private\n\t\t */\n\t\tthis._neg = new Tone.Negate();\n\n\t\t/**\n\t\t * the node where the value is set\n\t\t * @private\n\t\t * @type {Tone.Signal}\n\t\t */\n\t\tthis._param = this.input[1] = new Tone.Signal(value);\n\n\t\tthis._param.chain(this._neg, this._sum);\n\t};\n\n\tTone.extend(Tone.Subtract, Tone.Signal);\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.SignalBase} this\n\t */\n\tTone.Subtract.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._neg.dispose();\n\t\tthis._neg = null;\n\t\tthis._sum.disconnect();\n\t\tthis._sum = null;\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Subtract;\n});","define([\"Tone/core/Tone\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Emitter gives classes which extend it\n\t * the ability to listen for and emit events. \n\t * Inspiration and reference from Jerome Etienne's [MicroEvent](https://github.com/jeromeetienne/microevent.js).\n\t * MIT (c) 2011 Jerome Etienne.\n\t * \n\t * @extends {Tone}\n\t */\n\tTone.Emitter = function(){\n\t\t/**\n\t\t * Contains all of the events.\n\t\t * @private\n\t\t * @type {Object}\n\t\t */\n\t\tthis._events = {};\n\t};\n\n\tTone.extend(Tone.Emitter);\n\n\t/**\n\t * Bind a callback to a specific event.\n\t * @param {String} event The name of the event to listen for.\n\t * @param {Function} callback The callback to invoke when the\n\t * event is emitted\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.on = function(event, callback){\n\t\t//split the event\n\t\tvar events = event.split(/\\W+/);\n\t\tfor (var i = 0; i < events.length; i++){\n\t\t\tvar eventName = events[i];\n\t\t\tif (!this._events.hasOwnProperty(eventName)){\n\t\t\t\tthis._events[eventName] = [];\n\t\t\t}\n\t\t\tthis._events[eventName].push(callback);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Remove the event listener.\n\t * @param {String} event The event to stop listening to.\n\t * @param {Function=} callback The callback which was bound to \n\t * the event with Tone.Emitter.on.\n\t * If no callback is given, all callbacks\n\t * events are removed.\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.off = function(event, callback){\n\t\tvar events = event.split(/\\W+/);\n\t\tfor (var ev = 0; ev < events.length; ev++){\n\t\t\tevent = events[ev];\n\t\t\tif (this._events.hasOwnProperty(event)){\n\t\t\t\tif (Tone.prototype.isUndef(callback)){\n\t\t\t\t\tthis._events[event] = [];\n\t\t\t\t} else {\n\t\t\t\t\tvar eventList = this._events[event];\n\t\t\t\t\tfor (var i = 0; i < eventList.length; i++){\n\t\t\t\t\t\tif (eventList[i] === callback){\n\t\t\t\t\t\t\teventList.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Invoke all of the callbacks bound to the event\n\t * with any arguments passed in. \n\t * @param {String} event The name of the event.\n\t * @param {*...} args The arguments to pass to the functions listening.\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.emit = function(event){\n\t\tif (this._events){\n\t\t\tvar args = Array.apply(null, arguments).slice(1);\n\t\t\tif (this._events.hasOwnProperty(event)){\n\t\t\t\tvar eventList = this._events[event];\n\t\t\t\tfor (var i = 0, len = eventList.length; i < len; i++){\n\t\t\t\t\teventList[i].apply(this, args);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Add Emitter functions (on/off/emit) to the object\n\t * @param {Object|Function} object The object or class to extend.\n\t */\n\tTone.Emitter.mixin = function(object){\n\t\tvar functions = [\"on\", \"off\", \"emit\"];\n\t\tobject._events = {};\n\t\tfor (var i = 0; i < functions.length; i++){\n\t\t\tvar func = functions[i];\n\t\t\tvar emitterFunc = Tone.Emitter.prototype[func];\n\t\t\tobject[func] = emitterFunc;\n\t\t}\n\t};\n\n\t/**\n\t * Clean up\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._events = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Emitter;\n});","define([\"Tone/core/Tone\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Base class for all Signals. Used Internally. \n\t *\n\t * @constructor\n\t * @extends {Tone}\n\t */\n\tTone.SignalBase = function(){};\n\n\tTone.extend(Tone.SignalBase);\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.SignalBase} this\n\t */\n\tTone.SignalBase.prototype.connect = function(node, outputNumber, inputNumber){\n\t\t//zero it out so that the signal can have full control\n\t\tif ((Tone.Signal && Tone.Signal === node.constructor) || \n\t\t\t\t(Tone.Param && Tone.Param === node.constructor) || \n\t\t\t\t(Tone.TimelineSignal && Tone.TimelineSignal === node.constructor)){\n\t\t\t//cancel changes\n\t\t\tnode._param.cancelScheduledValues(0);\n\t\t\t//reset the value\n\t\t\tnode._param.value = 0;\n\t\t\t//mark the value as overridden\n\t\t\tnode.overridden = true;\n\t\t} else if (node instanceof AudioParam){\n\t\t\tnode.cancelScheduledValues(0);\n\t\t\tnode.value = 0;\n\t\t} \n\t\tTone.prototype.connect.call(this, node, outputNumber, inputNumber);\n\t\treturn this;\n\t};\n\n\treturn Tone.SignalBase;\n});","define([\"Tone/core/Tone\", \"Tone/type/TimeBase\"], function (Tone) {\n\n\t/**\n\t * @class Tone.Time is a primitive type for encoding Time values. \n\t * Eventually all time values are evaluated to seconds\n\t * using the `eval` method. Tone.Time can be constructed\n\t * with or without the `new` keyword. Tone.Time can be passed\n\t * into the parameter of any method which takes time as an argument. \n\t * @constructor\n\t * @extends {Tone.TimeBase}\n\t * @param {String|Number} val The time value.\n\t * @param {String=} units The units of the value.\n\t * @example\n\t * var t = Tone.Time(\"4n\");//encodes a quarter note\n\t * t.mult(4); // multiply that value by 4\n\t * t.toNotation(); //returns \"1m\"\n\t */\n\tTone.Time = function(val, units){\n\t\tif (this instanceof Tone.Time){\n\n\t\t\t/**\n\t\t\t * If the current clock time should\n\t\t\t * be added to the output\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t\t\tthis._plusNow = false;\n\t\t\t\n\t\t\tTone.TimeBase.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.Time(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.Time, Tone.TimeBase);\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.Time.prototype._unaryExpressions = Object.create(Tone.TimeBase.prototype._unaryExpressions);\n\n\t/*\n\t * Adds an additional unary expression\n\t * which quantizes values to the next subdivision\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Time.prototype._unaryExpressions.quantize = {\n\t\tregexp : /^@/,\n\t\tmethod : function(rh){\n\t\t\treturn Tone.Transport.nextSubdivision(rh());\n\t\t}\n\t};\n\n\t/*\n\t * Adds an additional unary expression\n\t * which adds the current clock time.\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Time.prototype._unaryExpressions.now = {\n\t\tregexp : /^\\+/,\n\t\tmethod : function(lh){\n\t\t\tthis._plusNow = true;\n\t\t\treturn lh();\n\t\t}\n\t};\n\n\t/**\n\t * Quantize the time by the given subdivision. Optionally add a\n\t * percentage which will move the time value towards the ideal\n\t * quantized value by that percentage. \n\t * @param {Number|Time} val The subdivision to quantize to\n\t * @param {NormalRange} [percent=1] Move the time value\n\t * towards the quantized value by\n\t * a percentage.\n\t * @return {Tone.Time} this\n\t * @example\n\t * Tone.Time(21).quantize(2) //returns 22\n\t * Tone.Time(0.6).quantize(\"4n\", 0.5) //returns 0.55\n\t */\n\tTone.Time.prototype.quantize = function(subdiv, percent){\n\t\tpercent = this.defaultArg(percent, 1);\n\t\tthis._expr = function(expr, subdivision, percent){\n\t\t\texpr = expr();\n\t\t\tsubdivision = subdivision.toSeconds();\n\t\t\tvar multiple = Math.round(expr / subdivision);\n\t\t\tvar ideal = multiple * subdivision;\n\t\t\tvar diff = ideal - expr;\n\t\t\treturn expr + diff * percent;\n\t\t}.bind(this, this._expr, new this.constructor(subdiv), percent);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Adds the clock time to the time expression at the \n\t * moment of evaluation. \n\t * @return {Tone.Time} this\n\t */\n\tTone.Time.prototype.addNow = function(){\n\t\tthis._plusNow = true;\n\t\treturn this;\n\t};\n\n\t/**\n\t * @override\n\t * Override the default value return when no arguments are passed in.\n\t * The default value is 'now'\n\t * @private\n\t */\n\tTone.Time.prototype._defaultExpr = function(){\n\t\tthis._plusNow = true;\n\t\treturn this._noOp;\n\t};\n\n\t/**\n\t * Copies the value of time to this Time\n\t * @param {Tone.Time} time\n\t * @return {Time}\n\t */\n\tTone.Time.prototype.copy = function(time){\n\t\tTone.TimeBase.prototype.copy.call(this, time);\n\t\tthis._plusNow = time._plusNow;\n\t\treturn this;\n\t};\n\n\t//CONVERSIONS//////////////////////////////////////////////////////////////\n\n\t/**\n\t * Convert a Time to Notation. Values will be thresholded to the nearest 128th note. \n\t * @return {Notation} \n\t * @example\n\t * //if the Transport is at 120bpm:\n\t * Tone.Time(2).toNotation();//returns \"1m\"\n\t */\n\tTone.Time.prototype.toNotation = function(){\n\t\tvar time = this.toSeconds();\n\t\tvar testNotations = [\"1m\", \"2n\", \"4n\", \"8n\", \"16n\", \"32n\", \"64n\", \"128n\"];\n\t\tvar retNotation = this._toNotationHelper(time, testNotations);\n\t\t//try the same thing but with tripelets\n\t\tvar testTripletNotations = [\"1m\", \"2n\", \"2t\", \"4n\", \"4t\", \"8n\", \"8t\", \"16n\", \"16t\", \"32n\", \"32t\", \"64n\", \"64t\", \"128n\"];\n\t\tvar retTripletNotation = this._toNotationHelper(time, testTripletNotations);\n\t\t//choose the simpler expression of the two\n\t\tif (retTripletNotation.split(\"+\").length < retNotation.split(\"+\").length){\n\t\t\treturn retTripletNotation;\n\t\t} else {\n\t\t\treturn retNotation;\n\t\t}\n\t};\n\n\t/**\n\t * Helper method for Tone.toNotation\n\t * @param {Number} units \n\t * @param {Array} testNotations\n\t * @return {String}\n\t * @private\n\t */\n\tTone.Time.prototype._toNotationHelper = function(units, testNotations){\n\t\t//the threshold is the last value in the array\n\t\tvar threshold = this._notationToUnits(testNotations[testNotations.length - 1]);\n\t\tvar retNotation = \"\";\n\t\tfor (var i = 0; i < testNotations.length; i++){\n\t\t\tvar notationTime = this._notationToUnits(testNotations[i]);\n\t\t\t//account for floating point errors (i.e. round up if the value is 0.999999)\n\t\t\tvar multiple = units / notationTime;\n\t\t\tvar floatingPointError = 0.000001;\n\t\t\tif (1 - multiple % 1 < floatingPointError){\n\t\t\t\tmultiple += floatingPointError;\n\t\t\t}\n\t\t\tmultiple = Math.floor(multiple);\n\t\t\tif (multiple > 0){\n\t\t\t\tif (multiple === 1){\n\t\t\t\t\tretNotation += testNotations[i];\n\t\t\t\t} else {\n\t\t\t\t\tretNotation += multiple.toString() + \"*\" + testNotations[i];\n\t\t\t\t}\n\t\t\t\tunits -= multiple * notationTime;\n\t\t\t\tif (units < threshold){\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tretNotation += \" + \";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (retNotation === \"\"){\n\t\t\tretNotation = \"0\";\n\t\t}\n\t\treturn retNotation;\n\t};\n\n\t/**\n\t * Convert a notation value to the current units\n\t * @param {Notation} notation \n\t * @return {Number} \n\t * @private\n\t */\n\tTone.Time.prototype._notationToUnits = function(notation){\n\t\tvar primaryExprs = this._primaryExpressions;\n\t\tvar notationExprs = [primaryExprs.n, primaryExprs.t, primaryExprs.m];\n\t\tfor (var i = 0; i < notationExprs.length; i++){\n\t\t\tvar expr = notationExprs[i];\n\t\t\tvar match = notation.match(expr.regexp);\n\t\t\tif (match){\n\t\t\t\treturn expr.method.call(this, match[1]);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Return the time encoded as Bars:Beats:Sixteenths.\n\t * @return {BarsBeatsSixteenths}\n\t */\n\tTone.Time.prototype.toBarsBeatsSixteenths = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.toSeconds() / quarterTime;\n\t\tvar measures = Math.floor(quarters / this._timeSignature());\n\t\tvar sixteenths = (quarters % 1) * 4;\n\t\tquarters = Math.floor(quarters) % this._timeSignature();\n\t\tsixteenths = sixteenths.toString();\n\t\tif (sixteenths.length > 3){\n\t\t\tsixteenths = parseFloat(sixteenths).toFixed(3);\n\t\t}\n\t\tvar progress = [measures, quarters, sixteenths];\n\t\treturn progress.join(\":\");\n\t};\n\n\t/**\n\t * Return the time in ticks.\n\t * @return {Ticks}\n\t */\n\tTone.Time.prototype.toTicks = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.valueOf() / quarterTime;\n\t\treturn Math.floor(quarters * Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Return the time in samples\n\t * @return {Samples} \n\t */\n\tTone.Time.prototype.toSamples = function(){\n\t\treturn this.toSeconds() * this.context.sampleRate;\n\t};\n\n\t/**\n\t * Return the time as a frequency value\n\t * @return {Frequency} \n\t * @example\n\t * Tone.Time(2).toFrequency(); //0.5\n\t */\n\tTone.Time.prototype.toFrequency = function(){\n\t\treturn 1/this.toSeconds();\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.Time.prototype.toSeconds = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the time in milliseconds.\n\t * @return {Milliseconds} \n\t */\n\tTone.Time.prototype.toMilliseconds = function(){\n\t\treturn this.toSeconds() * 1000;\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.Time.prototype.valueOf = function(){\n\t\tvar val = this._expr();\n\t\treturn val + (this._plusNow?this.now():0);\n\t};\n\n\treturn Tone.Time;\n});","define([\"Tone/core/Tone\"], function (Tone) {\n\n\t/**\n\t * @class Tone.TimeBase is a flexible encoding of time\n\t * which can be evaluated to and from a string.\n\t * Parsing code modified from https://code.google.com/p/tapdigit/\n\t * Copyright 2011 2012 Ariya Hidayat, New BSD License\n\t * @extends {Tone}\n\t * @param {Time} val The time value as a number or string\n\t * @param {String=} units Unit values\n\t * @example\n\t * Tone.TimeBase(4, \"n\")\n\t * Tone.TimeBase(2, \"t\")\n\t * Tone.TimeBase(\"2t\").add(\"1m\")\n\t * Tone.TimeBase(\"2t + 1m\");\n\t */\n\tTone.TimeBase = function(val, units){\n\n\t\t//allows it to be constructed with or without 'new'\n\t\tif (this instanceof Tone.TimeBase) {\n\n\t\t\t/**\n\t\t\t * Any expressions parsed from the Time\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t\t\tthis._expr = this._noOp;\n\n\t\t\tif (val instanceof Tone.TimeBase){\n\t\t\t\tthis.copy(val);\n\t\t\t} else if (!this.isUndef(units) || this.isNumber(val)){\n\t\t\t\t//default units\n\t\t\t\tunits = this.defaultArg(units, this._defaultUnits);\n\t\t\t\tvar method = this._primaryExpressions[units].method;\n\t\t\t\tthis._expr = method.bind(this, val);\n\t\t\t} else if (this.isString(val)){\n\t\t\t\tthis.set(val);\n\t\t\t} else if (this.isUndef(val)){\n\t\t\t\t//default expression\n\t\t\t\tthis._expr = this._defaultExpr();\n\t\t\t}\n\t\t} else {\n\n\t\t\treturn new Tone.TimeBase(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.TimeBase);\n\n\t/**\n\t * Repalce the current time value with the value\n\t * given by the expression string.\n\t * @param {String} exprString\n\t * @return {Tone.TimeBase} this\n\t */\n\tTone.TimeBase.prototype.set = function(exprString){\n\t\tthis._expr = this._parseExprString(exprString);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Return a clone of the TimeBase object.\n\t * @return {Tone.TimeBase} The new cloned Tone.TimeBase\n\t */\n\tTone.TimeBase.prototype.clone = function(){\n\t\tvar instance = new this.constructor();\n\t\tinstance.copy(this);\n\t\treturn instance;\n\t};\n\n\t/**\n\t * Copies the value of time to this Time\n\t * @param {Tone.TimeBase} time\n\t * @return {TimeBase}\n\t */\n\tTone.TimeBase.prototype.copy = function(time){\n\t\tvar val = time._expr();\n\t\treturn this.set(val);\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tABSTRACT SYNTAX TREE PARSER\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * All the primary expressions.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._primaryExpressions = {\n\t\t\"n\" : {\n\t\t\tregexp : /^(\\d+)n/i,\n\t\t\tmethod : function(value){\n\t\t\t\tvalue = parseInt(value);\n\t\t\t\tif (value === 1){\n\t\t\t\t\treturn this._beatsToUnits(this._timeSignature());\n\t\t\t\t} else {\n\t\t\t\t\treturn this._beatsToUnits(4 / value);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"t\" : {\n\t\t\tregexp : /^(\\d+)t/i,\n\t\t\tmethod : function(value){\n\t\t\t\tvalue = parseInt(value);\n\t\t\t\treturn this._beatsToUnits(8 / (parseInt(value) * 3));\n\t\t\t}\n\t\t},\n\t\t\"m\" : {\n\t\t\tregexp : /^(\\d+)m/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._beatsToUnits(parseInt(value) * this._timeSignature());\n\t\t\t}\n\t\t},\n\t\t\"i\" : {\n\t\t\tregexp : /^(\\d+)i/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._ticksToUnits(parseInt(value));\n\t\t\t}\n\t\t},\n\t\t\"hz\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?)hz/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._frequencyToUnits(parseFloat(value));\n\t\t\t}\n\t\t},\n\t\t\"tr\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t\t\tmethod : function(m, q, s){\n\t\t\t\tvar total = 0;\n\t\t\t\tif (m && m !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(this._timeSignature() * parseFloat(m));\n\t\t\t\t}\n\t\t\t\tif (q && q !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(parseFloat(q));\n\t\t\t\t}\n\t\t\t\tif (s && s !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(parseFloat(s) / 4);\n\t\t\t\t}\n\t\t\t\treturn total;\n\t\t\t}\n\t\t},\n\t\t\"s\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?s)/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._secondsToUnits(parseFloat(value));\n\t\t\t}\n\t\t},\n\t\t\"samples\" : {\n\t\t\tregexp : /^(\\d+)samples/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn parseInt(value) / this.context.sampleRate;\n\t\t\t}\n\t\t},\n\t\t\"default\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?)/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._primaryExpressions[this._defaultUnits].method.call(this, value);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * All the binary expressions that TimeBase can accept.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._binaryExpressions = {\n\t\t\"+\" : {\n\t\t\tregexp : /^\\+/,\n\t\t\tprecedence : 2,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() + rh();\n\t\t\t}\n\t\t},\n\t\t\"-\" : {\n\t\t\tregexp : /^\\-/,\n\t\t\tprecedence : 2,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() - rh();\n\t\t\t}\n\t\t},\n\t\t\"*\" : {\n\t\t\tregexp : /^\\*/,\n\t\t\tprecedence : 1,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() * rh();\n\t\t\t}\n\t\t},\n\t\t\"/\" : {\n\t\t\tregexp : /^\\//,\n\t\t\tprecedence : 1,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() / rh();\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * All the unary expressions.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._unaryExpressions = {\n\t\t\"neg\" : {\n\t\t\tregexp : /^\\-/,\n\t\t\tmethod : function(lh){\n\t\t\t\treturn -lh();\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Syntactic glue which holds expressions together\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._syntaxGlue = {\n\t\t\"(\" : {\n\t\t\tregexp : /^\\(/\n\t\t},\n\t\t\")\" : {\n\t\t\tregexp : /^\\)/\n\t\t}\n\t};\n\n\t/**\n\t * tokenize the expression based on the Expressions object\n\t * @param {string} expr \n\t * @return {Object} returns two methods on the tokenized list, next and peek\n\t * @private\n\t */\n\tTone.TimeBase.prototype._tokenize = function(expr){\n\t\tvar position = -1;\n\t\tvar tokens = [];\n\n\t\twhile(expr.length > 0){\n\t\t\texpr = expr.trim();\n\t\t\tvar token = getNextToken(expr, this);\n\t\t\ttokens.push(token);\n\t\t\texpr = expr.substr(token.value.length);\n\t\t}\n\n\t\tfunction getNextToken(expr, context){\n\t\t\tvar expressions = [\"_binaryExpressions\", \"_unaryExpressions\", \"_primaryExpressions\", \"_syntaxGlue\"];\n\t\t\tfor (var i = 0; i < expressions.length; i++){\n\t\t\t\tvar group = context[expressions[i]];\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tvar reg = op.regexp;\n\t\t\t\t\tvar match = expr.match(reg);\n\t\t\t\t\tif (match !== null){\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tmethod : op.method,\n\t\t\t\t\t\t\tprecedence : op.precedence,\n\t\t\t\t\t\t\tregexp : op.regexp,\n\t\t\t\t\t\t\tvalue : match[0],\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.TimeBase: Unexpected token \"+expr);\n\t\t}\n\n\t\treturn {\n\t\t\tnext : function(){\n\t\t\t\treturn tokens[++position];\n\t\t\t},\n\t\t\tpeek : function(){\n\t\t\t\treturn tokens[position + 1];\n\t\t\t}\n\t\t};\n\t};\n\n\t/**\n\t * Given a token, find the value within the groupName\n\t * @param {Object} token\n\t * @param {String} groupName\n\t * @param {Number} precedence\n\t * @private\n\t */\n\tTone.TimeBase.prototype._matchGroup = function(token, group, prec) {\n\t\tvar ret = false;\n\t\tif (!this.isUndef(token)){\n\t\t\tfor (var opName in group){\n\t\t\t\tvar op = group[opName];\n\t\t\t\tif (op.regexp.test(token.value)){\n\t\t\t\t\tif (!this.isUndef(prec)){\n\t\t\t\t\t\tif(op.precedence === prec){\t\n\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn op;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * Match a binary expression given the token and the precedence\n\t * @param {Lexer} lexer\n\t * @param {Number} precedence\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseBinary = function(lexer, precedence){\n\t\tif (this.isUndef(precedence)){\n\t\t\tprecedence = 2;\n\t\t}\n\t\tvar expr;\n\t\tif (precedence < 0){\n\t\t\texpr = this._parseUnary(lexer);\n\t\t} else {\n\t\t\texpr = this._parseBinary(lexer, precedence - 1);\n\t\t}\n\t\tvar token = lexer.peek();\n\t\twhile (token && this._matchGroup(token, this._binaryExpressions, precedence)){\n\t\t\ttoken = lexer.next();\n\t\t\texpr = token.method.bind(this, expr, this._parseBinary(lexer, precedence - 1));\n\t\t\ttoken = lexer.peek();\n\t\t}\n\t\treturn expr;\n\t};\n\n\t/**\n\t * Match a unary expression.\n\t * @param {Lexer} lexer\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseUnary = function(lexer){\n\t\tvar token, expr;\n\t\ttoken = lexer.peek();\n\t\tvar op = this._matchGroup(token, this._unaryExpressions);\n\t\tif (op) {\n\t\t\ttoken = lexer.next();\n\t\t\texpr = this._parseUnary(lexer);\n\t\t\treturn op.method.bind(this, expr);\n\t\t}\n\t\treturn this._parsePrimary(lexer);\n\t};\n\n\t/**\n\t * Match a primary expression (a value).\n\t * @param {Lexer} lexer\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parsePrimary = function(lexer){\n\t\tvar token, expr;\n\t\ttoken = lexer.peek();\n\t\tif (this.isUndef(token)) {\n\t\t\tthrow new SyntaxError(\"Tone.TimeBase: Unexpected end of expression\");\n\t\t}\n\t\tif (this._matchGroup(token, this._primaryExpressions)) {\n\t\t\ttoken = lexer.next();\n\t\t\tvar matching = token.value.match(token.regexp);\n\t\t\treturn token.method.bind(this, matching[1], matching[2], matching[3]);\n\t\t}\n\t\tif (token && token.value === \"(\"){\n\t\t\tlexer.next();\n\t\t\texpr = this._parseBinary(lexer);\n\t\t\ttoken = lexer.next();\n\t\t\tif (!(token && token.value === \")\")) {\n\t\t\t\tthrow new SyntaxError(\"Expected )\");\n\t\t\t}\n\t\t\treturn expr;\n\t\t}\n\t\tthrow new SyntaxError(\"Tone.TimeBase: Cannot process token \" + token.value);\n\t};\n\n\t/**\n\t * Recursively parse the string expression into a syntax tree.\n\t * @param {string} expr \n\t * @return {Function} the bound method to be evaluated later\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseExprString = function(exprString){\n\t\tif (!this.isString(exprString)){\n\t\t\texprString = exprString.toString();\n\t\t}\n\t\tvar lexer = this._tokenize(exprString);\n\t\tvar tree = this._parseBinary(lexer);\n\t\treturn tree;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tDEFAULTS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The initial expression value\n\t * @return {Number} The initial value 0\n\t * @private\n\t */\n\tTone.TimeBase.prototype._noOp = function(){\n\t\treturn 0;\n\t};\n\n\t/**\n\t * The default expression value if no arguments are given\n\t * @private\n\t */\n\tTone.TimeBase.prototype._defaultExpr = function(){\n\t\treturn this._noOp;\n\t};\n\n\t/**\n\t * The default units if none are given.\n\t * @private\n\t */\n\tTone.TimeBase.prototype._defaultUnits = \"s\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value of a frequency in the current units\n\t * @param {Frequency} freq\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._frequencyToUnits = function(freq){\n\t\treturn 1/freq;\n\t};\n\n\t/**\n\t * Return the value of the beats in the current units\n\t * @param {Number} beats\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._beatsToUnits = function(beats){\n\t\treturn (60 / Tone.Transport.bpm.value) * beats;\n\t};\n\n\t/**\n\t * Returns the value of a second in the current units\n\t * @param {Seconds} seconds\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._secondsToUnits = function(seconds){\n\t\treturn seconds;\n\t};\n\n\t/**\n\t * Returns the value of a tick in the current time units\n\t * @param {Ticks} ticks\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._ticksToUnits = function(ticks){\n\t\treturn ticks * (this._beatsToUnits(1) / Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Return the time signature.\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._timeSignature = function(){\n\t\treturn Tone.Transport.timeSignature;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tEXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Push an expression onto the expression list\n\t * @param {Time} val\n\t * @param {String} type\n\t * @param {String} units\n\t * @return {Tone.TimeBase} \n\t * @private\n\t */\n\tTone.TimeBase.prototype._pushExpr = function(val, name, units){\n\t\t//create the expression\n\t\tif (!(val instanceof Tone.TimeBase)){\n\t\t\tval = new this.constructor(val, units);\n\t\t}\n\t\tthis._expr = this._binaryExpressions[name].method.bind(this, this._expr, val._expr);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Add to the current value.\n\t * @param {Time} val The value to add\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").add(\"1m\"); //\"3m\"\n\t */\n\tTone.TimeBase.prototype.add = function(val, units){\n\t\treturn this._pushExpr(val, \"+\", units);\n\t};\n\n\t/**\n\t * Subtract the value from the current time.\n\t * @param {Time} val The value to subtract\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").sub(\"1m\"); //\"1m\"\n\t */\n\tTone.TimeBase.prototype.sub = function(val, units){\n\t\treturn this._pushExpr(val, \"-\", units);\n\t};\n\n\t/**\n\t * Multiply the current value by the given time.\n\t * @param {Time} val The value to multiply\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").mult(\"2\"); //\"4m\"\n\t */\n\tTone.TimeBase.prototype.mult = function(val, units){\n\t\treturn this._pushExpr(val, \"*\", units);\n\t};\n\n\t/**\n\t * Divide the current value by the given time.\n\t * @param {Time} val The value to divide by\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").div(2); //\"1m\"\n\t */\n\tTone.TimeBase.prototype.div = function(val, units){\n\t\treturn this._pushExpr(val, \"/\", units);\n\t};\n\n\t/**\n\t * Evaluate the time value. Returns the time\n\t * in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.TimeBase.prototype.valueOf = function(){\n\t\treturn this._expr();\n\t};\n\n\t/**\n\t * Clean up\n\t * @return {Tone.TimeBase} this\n\t */\n\tTone.TimeBase.prototype.dispose = function(){\n\t\tthis._expr = null;\n\t};\n\n\treturn Tone.TimeBase;\n});","define([\"Tone/core/Tone\", \"Tone/type/Type\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Param wraps the native Web Audio's AudioParam to provide\n\t * additional unit conversion functionality. It also\n\t * serves as a base-class for classes which have a single,\n\t * automatable parameter. \n\t * @extends {Tone}\n\t * @param {AudioParam} param The parameter to wrap.\n\t * @param {Tone.Type} units The units of the audio param.\n\t * @param {Boolean} convert If the param should be converted.\n\t */\n\tTone.Param = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"param\", \"units\", \"convert\"], Tone.Param.defaults);\n\n\t\t/**\n\t\t * The native parameter to control\n\t\t * @type {AudioParam}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input = options.param;\n\n\t\t/**\n\t\t * The units of the parameter\n\t\t * @type {Tone.Type}\n\t\t */\n\t\tthis.units = options.units;\n\n\t\t/**\n\t\t * If the value should be converted or not\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.convert = options.convert;\n\n\t\t/**\n\t\t * True if the signal value is being overridden by \n\t\t * a connected signal.\n\t\t * @readOnly\n\t\t * @type {boolean}\n\t\t * @private\n\t\t */\n\t\tthis.overridden = false;\n\n\t\t/**\n\t\t * If there is an LFO, this is where it is held.\n\t\t * @type {Tone.LFO}\n\t\t * @private\n\t\t */\n\t\tthis._lfo = null;\n\n\t\tif (this.isObject(options.lfo)){\n\t\t\tthis.value = options.lfo;\n\t\t} else if (!this.isUndef(options.value)){\n\t\t\tthis.value = options.value;\n\t\t}\n\t};\n\n\tTone.extend(Tone.Param);\n\t\n\t/**\n\t * Defaults\n\t * @type {Object}\n\t * @const\n\t */\n\tTone.Param.defaults = {\n\t\t\"units\" : Tone.Type.Default,\n\t\t\"convert\" : true,\n\t\t\"param\" : undefined\n\t};\n\n\t/**\n\t * The current value of the parameter. \n\t * @memberOf Tone.Param#\n\t * @type {Number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Param.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._toUnits(this._param.value);\n\t\t},\n\t\tset : function(value){\n\t\t\tif (this.isObject(value)){\n\t\t\t\t//throw an error if the LFO needs to be included\n\t\t\t\tif (this.isUndef(Tone.LFO)){\n\t\t\t\t\tthrow new Error(\"Include 'Tone.LFO' to use an LFO as a Param value.\");\n\t\t\t\t}\n\t\t\t\t//remove the old one\n\t\t\t\tif (this._lfo){\n\t\t\t\t\tthis._lfo.dispose();\n\t\t\t\t}\n\t\t\t\tthis._lfo = new Tone.LFO(value).start();\n\t\t\t\tthis._lfo.connect(this.input);\n\t\t\t} else {\n\t\t\t\tvar convertedVal = this._fromUnits(value);\n\t\t\t\tthis._param.cancelScheduledValues(0);\n\t\t\t\tthis._param.value = convertedVal;\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Convert the given value from the type specified by Tone.Param.units\n\t * into the destination value (such as Gain or Frequency).\n\t * @private\n\t * @param {*} val the value to convert\n\t * @return {number} the number which the value should be set to\n\t */\n\tTone.Param.prototype._fromUnits = function(val){\n\t\tif (this.convert || this.isUndef(this.convert)){\n\t\t\tswitch(this.units){\n\t\t\t\tcase Tone.Type.Time: \n\t\t\t\t\treturn this.toSeconds(val);\n\t\t\t\tcase Tone.Type.Frequency: \n\t\t\t\t\treturn this.toFrequency(val);\n\t\t\t\tcase Tone.Type.Decibels: \n\t\t\t\t\treturn this.dbToGain(val);\n\t\t\t\tcase Tone.Type.NormalRange: \n\t\t\t\t\treturn Math.min(Math.max(val, 0), 1);\n\t\t\t\tcase Tone.Type.AudioRange: \n\t\t\t\t\treturn Math.min(Math.max(val, -1), 1);\n\t\t\t\tcase Tone.Type.Positive: \n\t\t\t\t\treturn Math.max(val, 0);\n\t\t\t\tdefault:\n\t\t\t\t\treturn val;\n\t\t\t}\n\t\t} else {\n\t\t\treturn val;\n\t\t}\n\t};\n\n\t/**\n\t * Convert the parameters value into the units specified by Tone.Param.units.\n\t * @private\n\t * @param {number} val the value to convert\n\t * @return {number}\n\t */\n\tTone.Param.prototype._toUnits = function(val){\n\t\tif (this.convert || this.isUndef(this.convert)){\n\t\t\tswitch(this.units){\n\t\t\t\tcase Tone.Type.Decibels: \n\t\t\t\t\treturn this.gainToDb(val);\n\t\t\t\tdefault:\n\t\t\t\t\treturn val;\n\t\t\t}\n\t\t} else {\n\t\t\treturn val;\n\t\t}\n\t};\n\n\t/**\n\t * the minimum output value\n\t * @type {Number}\n\t * @private\n\t */\n\tTone.Param.prototype._minOutput = 0.00001;\n\n\t/**\n\t * Schedules a parameter value change at the given time.\n\t * @param {*}\tvalue The value to set the signal.\n\t * @param {Time} time The time when the change should occur.\n\t * @returns {Tone.Param} this\n\t * @example\n\t * //set the frequency to \"G4\" in exactly 1 second from now. \n\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t */\n\tTone.Param.prototype.setValueAtTime = function(value, time){\n\t\tvalue = this._fromUnits(value);\n\t\ttime = this.toSeconds(time);\n\t\tif (time <= this.now() + this.blockTime){\n\t\t\tthis._param.value = value;\n\t\t} else {\n\t\t\tthis._param.setValueAtTime(value, time);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Creates a schedule point with the current value at the current time.\n\t * This is useful for creating an automation anchor point in order to \n\t * schedule changes from the current value. \n\t *\n\t * @param {number=} now (Optionally) pass the now value in. \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.setRampPoint = function(now){\n\t\tnow = this.defaultArg(now, this.now());\n\t\tvar currentVal = this._param.value;\n\t\t// exponentialRampToValueAt cannot ever ramp from or to 0\n\t\t// More info: https://bugzilla.mozilla.org/show_bug.cgi?id=1125600#c2\n\t\tif (currentVal === 0){\n\t\t\tcurrentVal = this._minOutput;\n\t\t}\n\t\tthis._param.setValueAtTime(currentVal, now);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules a linear continuous change in parameter value from the \n\t * previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.linearRampToValueAtTime = function(value, endTime){\n\t\tvalue = this._fromUnits(value);\n\t\tthis._param.linearRampToValueAtTime(value, this.toSeconds(endTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.exponentialRampToValueAtTime = function(value, endTime){\n\t\tvalue = this._fromUnits(value);\n\t\tvalue = Math.max(this._minOutput, value);\n\t\tthis._param.exponentialRampToValueAtTime(value, this.toSeconds(endTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the current time and current value to the given value over the \n\t * duration of the rampTime.\n\t * \n\t * @param {number} value The value to ramp to.\n\t * @param {Time} rampTime the time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //exponentially ramp to the value 2 over 4 seconds. \n\t * signal.exponentialRampToValue(2, 4);\n\t */\n\tTone.Param.prototype.exponentialRampToValue = function(value, rampTime, startTime){\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis.setRampPoint(startTime);\n\t\tthis.exponentialRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an linear continuous change in parameter value from \n\t * the current time and current value to the given value over the \n\t * duration of the rampTime.\n\t * \n\t * @param {number} value The value to ramp to.\n\t * @param {Time} rampTime the time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //linearly ramp to the value 4 over 3 seconds. \n\t * signal.linearRampToValue(4, 3);\n\t */\n\tTone.Param.prototype.linearRampToValue = function(value, rampTime, startTime){\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis.setRampPoint(startTime);\n\t\tthis.linearRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Start exponentially approaching the target value at the given time with\n\t * a rate having the given time constant.\n\t * @param {number} value \n\t * @param {Time} startTime \n\t * @param {number} timeConstant \n\t * @returns {Tone.Param} this \n\t */\n\tTone.Param.prototype.setTargetAtTime = function(value, startTime, timeConstant){\n\t\tvalue = this._fromUnits(value);\n\t\t// The value will never be able to approach without timeConstant > 0.\n\t\t// http://www.w3.org/TR/webaudio/#dfn-setTargetAtTime, where the equation\n\t\t// is described. 0 results in a division by 0.\n\t\tvalue = Math.max(this._minOutput, value);\n\t\ttimeConstant = Math.max(this._minOutput, timeConstant);\n\t\tthis._param.setTargetAtTime(value, this.toSeconds(startTime), timeConstant);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Sets an array of arbitrary parameter values starting at the given time\n\t * for the given duration.\n\t * \t\n\t * @param {Array} values \n\t * @param {Time} startTime \n\t * @param {Time} duration \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.setValueCurveAtTime = function(values, startTime, duration){\n\t\tfor (var i = 0; i < values.length; i++){\n\t\t\tvalues[i] = this._fromUnits(values[i]);\n\t\t}\n\t\tthis._param.setValueCurveAtTime(values, this.toSeconds(startTime), this.toSeconds(duration));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancels all scheduled parameter changes with times greater than or \n\t * equal to startTime.\n\t * \n\t * @param {Time} startTime\n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.cancelScheduledValues = function(startTime){\n\t\tthis._param.cancelScheduledValues(this.toSeconds(startTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Ramps to the given value over the duration of the rampTime. \n\t * Automatically selects the best ramp type (exponential or linear)\n\t * depending on the `units` of the signal\n\t * \n\t * @param {number} value \n\t * @param {Time} rampTime \tThe time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //ramp to the value either linearly or exponentially \n\t * //depending on the \"units\" value of the signal\n\t * signal.rampTo(0, 10);\n\t * @example\n\t * //schedule it to ramp starting at a specific time\n\t * signal.rampTo(0, 10, 5)\n\t */\n\tTone.Param.prototype.rampTo = function(value, rampTime, startTime){\n\t\trampTime = this.defaultArg(rampTime, 0);\n\t\tif (this.units === Tone.Type.Frequency || this.units === Tone.Type.BPM || this.units === Tone.Type.Decibels){\n\t\t\tthis.exponentialRampToValue(value, rampTime, startTime);\n\t\t} else {\n\t\t\tthis.linearRampToValue(value, rampTime, startTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * The LFO created by the signal instance. If none\n\t * was created, this is null.\n\t * @type {Tone.LFO}\n\t * @readOnly\n\t * @memberOf Tone.Param#\n\t * @name lfo\n\t */\n\tObject.defineProperty(Tone.Param.prototype, \"lfo\", {\n\t\tget : function(){\n\t\t\treturn this._lfo;\n\t\t}\n\t});\n\n\t/**\n\t * Clean up\n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._param = null;\n\t\tif (this._lfo){\n\t\t\tthis._lfo.dispose();\n\t\t\tthis._lfo = null;\n\t\t}\n\t\treturn this;\n\t};\n\n\treturn Tone.Param;\n});","define([\"Tone/core/Tone\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A Timeline class for scheduling and maintaining state\n\t * along a timeline. All events must have a \"time\" property. \n\t * Internally, events are stored in time order for fast \n\t * retrieval.\n\t * @extends {Tone}\n\t * @param {Positive} [memory=Infinity] The number of previous events that are retained.\n\t */\n\tTone.Timeline = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"memory\"], Tone.Timeline.defaults);\n\n\t\t/**\n\t\t * The array of scheduled timeline events\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._timeline = [];\n\n\t\t/**\n\t\t * An array of items to remove from the list. \n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._toRemove = [];\n\n\t\t/**\n\t\t * Flag if the tieline is mid iteration\n\t\t * @private\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis._iterating = false;\n\n\t\t/**\n\t\t * The memory of the timeline, i.e.\n\t\t * how many events in the past it will retain\n\t\t * @type {Positive}\n\t\t */\n\t\tthis.memory = options.memory;\n\t};\n\n\tTone.extend(Tone.Timeline);\n\n\t/**\n\t * the default parameters\n\t * @static\n\t * @const\n\t */\n\tTone.Timeline.defaults = {\n\t\t\"memory\" : Infinity\n\t};\n\n\t/**\n\t * The number of items in the timeline.\n\t * @type {Number}\n\t * @memberOf Tone.Timeline#\n\t * @name length\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.Timeline.prototype, \"length\", {\n\t\tget : function(){\n\t\t\treturn this._timeline.length;\n\t\t}\n\t});\n\n\t/**\n\t * Insert an event object onto the timeline. Events must have a \"time\" attribute.\n\t * @param {Object} event The event object to insert into the \n\t * timeline. \n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.add = function(event){\n\t\t//the event needs to have a time attribute\n\t\tif (this.isUndef(event.time)){\n\t\t\tthrow new Error(\"Tone.Timeline: events must have a time attribute\");\n\t\t}\n\t\tif (this._timeline.length){\n\t\t\tvar index = this._search(event.time);\n\t\t\tthis._timeline.splice(index + 1, 0, event);\n\t\t} else {\n\t\t\tthis._timeline.push(event);\t\t\t\n\t\t}\n\t\t//if the length is more than the memory, remove the previous ones\n\t\tif (this.length > this.memory){\n\t\t\tvar diff = this.length - this.memory;\n\t\t\tthis._timeline.splice(0, diff);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Remove an event from the timeline.\n\t * @param {Object} event The event object to remove from the list.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.remove = function(event){\n\t\tif (this._iterating){\n\t\t\tthis._toRemove.push(event);\n\t\t} else {\n\t\t\tvar index = this._timeline.indexOf(event);\n\t\t\tif (index !== -1){\n\t\t\t\tthis._timeline.splice(index, 1);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Get the nearest event whose time is less than or equal to the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object set after that time.\n\t */\n\tTone.Timeline.prototype.get = function(time){\n\t\tvar index = this._search(time);\n\t\tif (index !== -1){\n\t\t\treturn this._timeline[index];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Return the first event in the timeline without removing it\n\t * @returns {Object} The first event object\n\t */\n\tTone.Timeline.prototype.peek = function(){\n\t\treturn this._timeline[0];\n\t};\n\n\t/**\n\t * Return the first event in the timeline and remove it\n\t * @returns {Object} The first event object\n\t */\n\tTone.Timeline.prototype.shift = function(){\n\t\treturn this._timeline.shift();\n\t};\n\n\t/**\n\t * Get the event which is scheduled after the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object after the given time\n\t */\n\tTone.Timeline.prototype.getAfter = function(time){\n\t\tvar index = this._search(time);\n\t\tif (index + 1 < this._timeline.length){\n\t\t\treturn this._timeline[index + 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Get the event before the event at the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object before the given time\n\t */\n\tTone.Timeline.prototype.getBefore = function(time){\n\t\tvar len = this._timeline.length;\n\t\t//if it's after the last item, return the last item\n\t\tif (len > 0 && this._timeline[len - 1].time < time){\n\t\t\treturn this._timeline[len - 1];\n\t\t}\n\t\tvar index = this._search(time);\n\t\tif (index - 1 >= 0){\n\t\t\treturn this._timeline[index - 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Cancel events after the given time\n\t * @param {Number} time The time to query.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.cancel = function(after){\n\t\tif (this._timeline.length > 1){\n\t\t\tvar index = this._search(after);\n\t\t\tif (index >= 0){\n\t\t\t\tif (this._timeline[index].time === after){\n\t\t\t\t\t//get the first item with that time\n\t\t\t\t\tfor (var i = index; i >= 0; i--){\n\t\t\t\t\t\tif (this._timeline[i].time === after){\n\t\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis._timeline = this._timeline.slice(0, index);\n\t\t\t\t} else {\n\t\t\t\t\tthis._timeline = this._timeline.slice(0, index + 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis._timeline = [];\n\t\t\t}\n\t\t} else if (this._timeline.length === 1){\n\t\t\t//the first item's time\n\t\t\tif (this._timeline[0].time >= after){\n\t\t\t\tthis._timeline = [];\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancel events before or equal to the given time.\n\t * @param {Number} time The time to cancel before.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.cancelBefore = function(time){\n\t\tif (this._timeline.length){\n\t\t\tvar index = this._search(time);\n\t\t\tif (index >= 0){\n\t\t\t\tthis._timeline = this._timeline.slice(index + 1);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Does a binary serach on the timeline array and returns the \n\t * nearest event index whose time is after or equal to the given time.\n\t * If a time is searched before the first index in the timeline, -1 is returned.\n\t * If the time is after the end, the index of the last item is returned.\n\t * @param {Number} time \n\t * @return {Number} the index in the timeline array \n\t * @private\n\t */\n\tTone.Timeline.prototype._search = function(time){\n\t\tvar beginning = 0;\n\t\tvar len = this._timeline.length;\n\t\tvar end = len;\n\t\tif (len > 0 && this._timeline[len - 1].time <= time){\n\t\t\treturn len - 1;\n\t\t}\n\t\twhile (beginning < end){\n\t\t\t// calculate the midpoint for roughly equal partition\n\t\t\tvar midPoint = Math.floor(beginning + (end - beginning) / 2);\n\t\t\tvar event = this._timeline[midPoint];\n\t\t\tvar nextEvent = this._timeline[midPoint + 1];\n\t\t\tif (event.time === time){\n\t\t\t\t//choose the last one that has the same time\n\t\t\t\tfor (var i = midPoint; i < this._timeline.length; i++){\n\t\t\t\t\tvar testEvent = this._timeline[i];\n\t\t\t\t\tif (testEvent.time === time){\n\t\t\t\t\t\tmidPoint = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn midPoint;\n\t\t\t} else if (event.time < time && nextEvent.time > time){\n\t\t\t\treturn midPoint;\n\t\t\t} else if (event.time > time){\n\t\t\t\t//search lower\n\t\t\t\tend = midPoint;\n\t\t\t} else if (event.time < time){\n\t\t\t\t//search upper\n\t\t\t\tbeginning = midPoint + 1;\n\t\t\t} \n\t\t}\n\t\treturn -1;\n\t};\n\n\t/**\n\t * Internal iterator. Applies extra safety checks for \n\t * removing items from the array. \n\t * @param {Function} callback \n\t * @param {Number=} lowerBound \n\t * @param {Number=} upperBound \n\t * @private\n\t */\n\tTone.Timeline.prototype._iterate = function(callback, lowerBound, upperBound){\n\t\tthis._iterating = true;\n\t\tlowerBound = this.defaultArg(lowerBound, 0);\n\t\tupperBound = this.defaultArg(upperBound, this._timeline.length - 1);\n\t\tfor (var i = lowerBound; i <= upperBound; i++){\n\t\t\tcallback(this._timeline[i]);\n\t\t}\n\t\tthis._iterating = false;\n\t\tif (this._toRemove.length > 0){\n\t\t\tfor (var j = 0; j < this._toRemove.length; j++){\n\t\t\t\tvar index = this._timeline.indexOf(this._toRemove[j]);\n\t\t\t\tif (index !== -1){\n\t\t\t\t\tthis._timeline.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._toRemove = [];\n\t\t}\n\t};\n\n\t/**\n\t * Iterate over everything in the array\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEach = function(callback){\n\t\tthis._iterate(callback);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at or before the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachBefore = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar upperBound = this._search(time);\n\t\tif (upperBound !== -1){\n\t\t\tthis._iterate(callback, 0, upperBound);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array after the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachAfter = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar lowerBound = this._search(time);\n\t\tthis._iterate(callback, lowerBound + 1);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at or after the given time. Similar to \n\t * forEachAfter, but includes the item(s) at the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachFrom = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar lowerBound = this._search(time);\n\t\t//work backwards until the event time is less than time\n\t\twhile (lowerBound >= 0 && this._timeline[lowerBound].time >= time){\n\t\t\tlowerBound--;\n\t\t}\n\t\tthis._iterate(callback, lowerBound + 1);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at the given time\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachAtTime = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar upperBound = this._search(time);\n\t\tif (upperBound !== -1){\n\t\t\tthis._iterate(function(event){\n\t\t\t\tif (event.time === time){\n\t\t\t\t\tcallback(event);\n\t\t\t\t} \n\t\t\t}, 0, upperBound);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._timeline = null;\n\t\tthis._toRemove = null;\n\t};\n\n\treturn Tone.Timeline;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Multiply\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Negate the incoming signal. i.e. an input signal of 10 will output -10\n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var neg = new Tone.Negate();\n\t * var sig = new Tone.Signal(-2).connect(neg);\n\t * //output of neg is positive 2. \n\t */\n\tTone.Negate = function(){\n\t\t/**\n\t\t * negation is done by multiplying by -1\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._multiply = this.input = this.output = new Tone.Multiply(-1);\n\t};\n\n\tTone.extend(Tone.Negate, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Negate} this\n\t */\n\tTone.Negate.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._multiply.dispose();\n\t\tthis._multiply = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Negate;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/signal/Multiply\", \"Tone/signal/WaveShaper\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class GreaterThanZero outputs 1 when the input is strictly greater than zero\n\t * \n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var gt0 = new Tone.GreaterThanZero();\n\t * var sig = new Tone.Signal(0.01).connect(gt0);\n\t * //the output of gt0 is 1. \n\t * sig.value = 0;\n\t * //the output of gt0 is 0. \n\t */\n\tTone.GreaterThanZero = function(){\n\t\t\n\t\t/**\n\t\t * @type {Tone.WaveShaper}\n\t\t * @private\n\t\t */\n\t\tthis._thresh = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (val <= 0){\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}, 127);\n\n\t\t/**\n\t\t * scale the first thresholded signal by a large value.\n\t\t * this will help with values which are very close to 0\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._scale = this.input = new Tone.Multiply(10000);\n\n\t\t//connections\n\t\tthis._scale.connect(this._thresh);\n\t};\n\n\tTone.extend(Tone.GreaterThanZero, Tone.SignalBase);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.GreaterThanZero} this\n\t */\n\tTone.GreaterThanZero.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._scale.dispose();\n\t\tthis._scale = null;\n\t\tthis._thresh.dispose();\n\t\tthis._thresh = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.GreaterThanZero;\n});","/**\n * StartAudioContext.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2016 Yotam Mann\n */\n(function (root, factory) {\n\tif (typeof define === \"function\" && define.amd) {\n\t\tdefine([], factory)\n\t } else if (typeof module === \"object\" && module.exports) {\n module.exports = factory()\n\t} else {\n\t\troot.StartAudioContext = factory()\n }\n}(this, function () {\n\n\t//TAP LISTENER/////////////////////////////////////////////////////////////\n\n\t/**\n\t * @class Listens for non-dragging tap ends on the given element\n\t * @param {Element} element\n\t * @internal\n\t */\n\tvar TapListener = function(element, context){\n\n\t\tthis._dragged = false\n\n\t\tthis._element = element\n\n\t\tthis._bindedMove = this._moved.bind(this)\n\t\tthis._bindedEnd = this._ended.bind(this, context)\n\n\t\telement.addEventListener(\"touchstart\", this._bindedEnd)\n\t\telement.addEventListener(\"touchmove\", this._bindedMove)\n\t\telement.addEventListener(\"touchend\", this._bindedEnd)\n\t\telement.addEventListener(\"mouseup\", this._bindedEnd)\n\t}\n\n\t/**\n\t * drag move event\n\t */\n\tTapListener.prototype._moved = function(e){\n\t\tthis._dragged = true\n\t};\n\n\t/**\n\t * tap ended listener\n\t */\n\tTapListener.prototype._ended = function(context){\n\t\tif (!this._dragged){\n\t\t\tstartContext(context)\n\t\t}\n\t\tthis._dragged = false\n\t};\n\n\t/**\n\t * remove all the bound events\n\t */\n\tTapListener.prototype.dispose = function(){\n\t\tthis._element.removeEventListener(\"touchstart\", this._bindedEnd)\n\t\tthis._element.removeEventListener(\"touchmove\", this._bindedMove)\n\t\tthis._element.removeEventListener(\"touchend\", this._bindedEnd)\n\t\tthis._element.removeEventListener(\"mouseup\", this._bindedEnd)\n\t\tthis._bindedMove = null\n\t\tthis._bindedEnd = null\n\t\tthis._element = null\n\t};\n\n\t//END TAP LISTENER/////////////////////////////////////////////////////////\n\n\t/**\n\t * Plays a silent sound and also invoke the \"resume\" method\n\t * @param {AudioContext} context\n\t * @private\n\t */\n\tfunction startContext(context){\n\t\t// this accomplishes the iOS specific requirement\n\t\tvar buffer = context.createBuffer(1, 1, context.sampleRate)\n\t\tvar source = context.createBufferSource()\n\t\tsource.buffer = buffer\n\t\tsource.connect(context.destination)\n\t\tsource.start(0)\n\n\t\t// resume the audio context\n\t\tif (context.resume){\n\t\t\tcontext.resume()\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if the audio context is started\n\t * @param {AudioContext} context\n\t * @return {Boolean}\n\t * @private\n\t */\n\tfunction isStarted(context){\n\t\t return context.state === \"running\"\n\t}\n\n\t/**\n\t * Invokes the callback as soon as the AudioContext\n\t * is started\n\t * @param {AudioContext} context\n\t * @param {Function} callback\n\t */\n\tfunction onStarted(context, callback){\n\n\t\tfunction checkLoop(){\n\t\t\tif (isStarted(context)){\n\t\t\t\tcallback()\n\t\t\t} else {\n\t\t\t\trequestAnimationFrame(checkLoop)\n\t\t\t\tif (context.resume){\n\t\t\t\t\tcontext.resume()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isStarted(context)){\n\t\t\tcallback()\n\t\t} else {\n\t\t\tcheckLoop()\n\t\t}\n\t}\n\n\t/**\n\t * Add a tap listener to the audio context\n\t * @param {Array|Element|String|jQuery} element\n\t * @param {Array} tapListeners\n\t */\n\tfunction bindTapListener(element, tapListeners, context){\n\t\tif (Array.isArray(element) || (NodeList && element instanceof NodeList)){\n\t\t\tfor (var i = 0; i < element.length; i++){\n\t\t\t\tbindTapListener(element[i], tapListeners, context)\n\t\t\t}\n\t\t} else if (typeof element === \"string\"){\n\t\t\tbindTapListener(document.querySelectorAll(element), tapListeners, context)\n\t\t} else if (element.jquery && typeof element.toArray === \"function\"){\n\t\t\tbindTapListener(element.toArray(), tapListeners, context)\n\t\t} else if (Element && element instanceof Element){\n\t\t\t//if it's an element, create a TapListener\n\t\t\tvar tap = new TapListener(element, context)\n\t\t\ttapListeners.push(tap)\n\t\t} \n\t}\n\n\t/**\n\t * @param {AudioContext} context The AudioContext to start.\n\t * @param {Array|String|Element|jQuery=} elements For iOS, the list of elements\n\t * to bind tap event listeners\n\t * which will start the AudioContext. If\n\t * no elements are given, it will bind\n\t * to the document.body.\n\t * @param {Function=} callback The callback to invoke when the AudioContext is started.\n\t * @return {Promise} The promise is invoked when the AudioContext\n\t * is started.\n\t */\n\tfunction StartAudioContext(context, elements, callback){\n\n\t\t//the promise is invoked when the AudioContext is started\n\t\tvar promise = new Promise(function(success) {\n\t\t\tonStarted(context, success)\n\t\t})\n\n\t\t// The TapListeners bound to the elements\n\t\tvar tapListeners = []\n\n\t\t// add all the tap listeners\n\t\tif (!elements){\n\t\t\telements = document.body\n\t\t}\n\t\tbindTapListener(elements, tapListeners, context)\n\n\t\t//dispose all these tap listeners when the context is started\n\t\tpromise.then(function(){\n\t\t\tfor (var i = 0; i < tapListeners.length; i++){\n\t\t\t\ttapListeners[i].dispose()\n\t\t\t}\n\t\t\ttapListeners = null\n\n\t\t\tif (callback){\n\t\t\t\tcallback()\n\t\t\t}\n\t\t})\n\n\t\treturn promise\n\t}\n\n\treturn StartAudioContext\n}))","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/signal/Expr\", \n\t\"Tone/signal/EqualPowerGain\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Crossfade provides equal power fading between two inputs. \n\t * More on crossfading technique [here](https://en.wikipedia.org/wiki/Fade_(audio_engineering)#Crossfading).\n\t *\n\t * @constructor\n\t * @extends {Tone}\n\t * @param {NormalRange} [initialFade=0.5]\n\t * @example\n\t * var crossFade = new Tone.CrossFade(0.5);\n\t * //connect effect A to crossfade from\n\t * //effect output 0 to crossfade input 0\n\t * effectA.connect(crossFade, 0, 0);\n\t * //connect effect B to crossfade from\n\t * //effect output 0 to crossfade input 1\n\t * effectB.connect(crossFade, 0, 1);\n\t * crossFade.fade.value = 0;\n\t * // ^ only effectA is output\n\t * crossFade.fade.value = 1;\n\t * // ^ only effectB is output\n\t * crossFade.fade.value = 0.5;\n\t * // ^ the two signals are mixed equally. \n\t */\t\t\n\tTone.CrossFade = function(initialFade){\n\n\t\tthis.createInsOuts(2, 1);\n\n\t\t/**\n\t\t * Alias for input[0]. \n\t\t * @type {Tone.Gain}\n\t\t */\n\t\tthis.a = this.input[0] = new Tone.Gain();\n\n\t\t/**\n\t\t * Alias for input[1]. \n\t\t * @type {Tone.Gain}\n\t\t */\n\t\tthis.b = this.input[1] = new Tone.Gain();\n\n\t\t/**\n\t\t * \tThe mix between the two inputs. A fade value of 0\n\t\t * \twill output 100% input[0] and \n\t\t * \ta value of 1 will output 100% input[1]. \n\t\t * @type {NormalRange}\n\t\t * @signal\n\t\t */\n\t\tthis.fade = new Tone.Signal(this.defaultArg(initialFade, 0.5), Tone.Type.NormalRange);\n\n\t\t/**\n\t\t * equal power gain cross fade\n\t\t * @private\n\t\t * @type {Tone.EqualPowerGain}\n\t\t */\n\t\tthis._equalPowerA = new Tone.EqualPowerGain();\n\n\t\t/**\n\t\t * equal power gain cross fade\n\t\t * @private\n\t\t * @type {Tone.EqualPowerGain}\n\t\t */\n\t\tthis._equalPowerB = new Tone.EqualPowerGain();\n\t\t\n\t\t/**\n\t\t * invert the incoming signal\n\t\t * @private\n\t\t * @type {Tone}\n\t\t */\n\t\tthis._invert = new Tone.Expr(\"1 - $0\");\n\n\t\t//connections\n\t\tthis.a.connect(this.output);\n\t\tthis.b.connect(this.output);\n\t\tthis.fade.chain(this._equalPowerB, this.b.gain);\n\t\tthis.fade.chain(this._invert, this._equalPowerA, this.a.gain);\n\t\tthis._readOnly(\"fade\");\n\t};\n\n\tTone.extend(Tone.CrossFade);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.CrossFade} this\n\t */\n\tTone.CrossFade.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._writable(\"fade\");\n\t\tthis._equalPowerA.dispose();\n\t\tthis._equalPowerA = null;\n\t\tthis._equalPowerB.dispose();\n\t\tthis._equalPowerB = null;\n\t\tthis.fade.dispose();\n\t\tthis.fade = null;\n\t\tthis._invert.dispose();\n\t\tthis._invert = null;\n\t\tthis.a.dispose();\n\t\tthis.a = null;\n\t\tthis.b.dispose();\n\t\tthis.b = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.CrossFade;\n});\n","!function(){var e,t=[];function r(e){var r=this,n={},i=-1;this.parameters.forEach(function(e,o){var s=t[++i]||(t[i]=new Float32Array(r.bufferSize));s.fill(e.value),n[o]=s}),this.processor.realm.exec(\"self.sampleRate=sampleRate=\"+this.context.sampleRate+\";self.currentTime=currentTime=\"+this.context.currentTime);var s=o(e.inputBuffer),a=o(e.outputBuffer);this.instance.process([s],[a],n)}function o(e){for(var t=[],r=0;r= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar RecorderProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(RecorderProcessor, _AudioWorkletProcesso);\\n\\n function RecorderProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, RecorderProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(RecorderProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.numOutputChannels = options.outputChannelCount || 2;\\n _this.numInputChannels = processorOptions.numInputChannels || 2;\\n _this.bufferSize = processorOptions.bufferSize || 1024;\\n _this.recording = false;\\n\\n _this.clear();\\n\\n _this.port.onmessage = function (event) {\\n var data = event.data;\\n\\n if (data.name === 'start') {\\n _this.record(data.duration);\\n } else if (data.name === 'stop') {\\n _this.stop();\\n }\\n };\\n\\n return _this;\\n }\\n\\n _createClass(RecorderProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs) {\\n if (!this.recording) {\\n return true;\\n } else if (this.sampleLimit && this.recordedSamples >= this.sampleLimit) {\\n this.stop();\\n return true;\\n }\\n\\n var input = inputs[0];\\n this.inputRingBuffer.push(input);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n\\n for (var channel = 0; channel < this.numOutputChannels; ++channel) {\\n var inputChannelCopy = this.inputRingBufferArraySequence[channel].slice();\\n\\n if (channel === 0) {\\n this.leftBuffers.push(inputChannelCopy);\\n\\n if (this.numInputChannels === 1) {\\n this.rightBuffers.push(inputChannelCopy);\\n }\\n } else if (channel === 1 && this.numInputChannels > 1) {\\n this.rightBuffers.push(inputChannelCopy);\\n }\\n }\\n\\n this.recordedSamples += this.bufferSize;\\n }\\n\\n return true;\\n }\\n }, {\\n key: \\\"record\\\",\\n value: function record(duration) {\\n if (duration) {\\n this.sampleLimit = Math.round(duration * sampleRate);\\n }\\n\\n this.recording = true;\\n }\\n }, {\\n key: \\\"stop\\\",\\n value: function stop() {\\n this.recording = false;\\n var buffers = this.getBuffers();\\n var leftBuffer = buffers[0].buffer;\\n var rightBuffer = buffers[1].buffer;\\n this.port.postMessage({\\n name: 'buffers',\\n leftBuffer: leftBuffer,\\n rightBuffer: rightBuffer\\n }, [leftBuffer, rightBuffer]);\\n this.clear();\\n }\\n }, {\\n key: \\\"getBuffers\\\",\\n value: function getBuffers() {\\n var buffers = [];\\n buffers.push(this.mergeBuffers(this.leftBuffers));\\n buffers.push(this.mergeBuffers(this.rightBuffers));\\n return buffers;\\n }\\n }, {\\n key: \\\"mergeBuffers\\\",\\n value: function mergeBuffers(channelBuffer) {\\n var result = new Float32Array(this.recordedSamples);\\n var offset = 0;\\n var lng = channelBuffer.length;\\n\\n for (var i = 0; i < lng; i++) {\\n var buffer = channelBuffer[i];\\n result.set(buffer, offset);\\n offset += buffer.length;\\n }\\n\\n return result;\\n }\\n }, {\\n key: \\\"clear\\\",\\n value: function clear() {\\n var _this2 = this;\\n\\n this.leftBuffers = [];\\n this.rightBuffers = [];\\n this.inputRingBuffer = new RingBuffer(this.bufferSize, this.numInputChannels);\\n this.inputRingBufferArraySequence = new Array(this.numInputChannels).fill(null).map(function () {\\n return new Float32Array(_this2.bufferSize);\\n });\\n this.recordedSamples = 0;\\n this.sampleLimit = null;\\n }\\n }]);\\n\\n return RecorderProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.recorderProcessor, RecorderProcessor);\"","export default \"function _typeof(obj) { if (typeof Symbol === \\\"function\\\" && typeof Symbol.iterator === \\\"symbol\\\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \\\"function\\\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \\\"symbol\\\" : typeof obj; }; } return _typeof(obj); }\\n\\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \\\"object\\\" || typeof call === \\\"function\\\")) { return call; } return _assertThisInitialized(self); }\\n\\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\"); } return self; }\\n\\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \\\"function\\\" && superClass !== null) { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\\n\\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \\\"function\\\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \\\"function\\\") { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } if (typeof _cache !== \\\"undefined\\\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\\n\\nfunction isNativeReflectConstruct() { if (typeof Reflect === \\\"undefined\\\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \\\"function\\\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\\n\\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\\n\\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\\\"[native code]\\\") !== -1; }\\n\\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\\n\\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\\n\\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\\"Cannot call a class as a function\\\"); } }\\n\\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\\\"value\\\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\\n\\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\\n\\n// import dependencies via preval.require so that they're available as values at compile time\\nvar processorNames = {\\n \\\"recorderProcessor\\\": \\\"recorder-processor\\\",\\n \\\"soundFileProcessor\\\": \\\"sound-file-processor\\\",\\n \\\"amplitudeProcessor\\\": \\\"amplitude-processor\\\"\\n};\\nvar RingBuffer = {\\n \\\"default\\\":\\n /*#__PURE__*/\\n function () {\\n /**\\n * @constructor\\n * @param {number} length Buffer length in frames.\\n * @param {number} channelCount Buffer channel count.\\n */\\n function RingBuffer(length, channelCount) {\\n _classCallCheck(this, RingBuffer);\\n\\n this._readIndex = 0;\\n this._writeIndex = 0;\\n this._framesAvailable = 0;\\n this._channelCount = channelCount;\\n this._length = length;\\n this._channelData = [];\\n\\n for (var i = 0; i < this._channelCount; ++i) {\\n this._channelData[i] = new Float32Array(length);\\n }\\n }\\n /**\\n * Getter for Available frames in buffer.\\n *\\n * @return {number} Available frames in buffer.\\n */\\n\\n\\n _createClass(RingBuffer, [{\\n key: \\\"push\\\",\\n\\n /**\\n * Push a sequence of Float32Arrays to buffer.\\n *\\n * @param {array} arraySequence A sequence of Float32Arrays.\\n */\\n value: function push(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // Transfer data from the |arraySequence| storage to the internal buffer.\\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\\n\\n for (var i = 0; i < sourceLength; ++i) {\\n var writeIndex = (this._writeIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\\n }\\n }\\n\\n this._writeIndex += sourceLength;\\n\\n if (this._writeIndex >= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar SoundFileProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(SoundFileProcessor, _AudioWorkletProcesso);\\n\\n function SoundFileProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, SoundFileProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SoundFileProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.bufferSize = processorOptions.bufferSize || 256;\\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, 1);\\n _this.inputRingBufferArraySequence = [new Float32Array(_this.bufferSize)];\\n return _this;\\n }\\n\\n _createClass(SoundFileProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs) {\\n var input = inputs[0]; // we only care about the first input channel, because that contains the position data\\n\\n this.inputRingBuffer.push([input[0]]);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n var inputChannel = this.inputRingBufferArraySequence[0];\\n var position = inputChannel[inputChannel.length - 1] || 0;\\n this.port.postMessage({\\n name: 'position',\\n position: position\\n });\\n }\\n\\n return true;\\n }\\n }]);\\n\\n return SoundFileProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.soundFileProcessor, SoundFileProcessor);\"","export default \"function _typeof(obj) { if (typeof Symbol === \\\"function\\\" && typeof Symbol.iterator === \\\"symbol\\\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \\\"function\\\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \\\"symbol\\\" : typeof obj; }; } return _typeof(obj); }\\n\\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \\\"object\\\" || typeof call === \\\"function\\\")) { return call; } return _assertThisInitialized(self); }\\n\\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\"); } return self; }\\n\\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \\\"function\\\" && superClass !== null) { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\\n\\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \\\"function\\\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \\\"function\\\") { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } if (typeof _cache !== \\\"undefined\\\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\\n\\nfunction isNativeReflectConstruct() { if (typeof Reflect === \\\"undefined\\\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \\\"function\\\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\\n\\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\\n\\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\\\"[native code]\\\") !== -1; }\\n\\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\\n\\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\\n\\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\\"Cannot call a class as a function\\\"); } }\\n\\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\\\"value\\\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\\n\\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\\n\\n// import dependencies via preval.require so that they're available as values at compile time\\nvar processorNames = {\\n \\\"recorderProcessor\\\": \\\"recorder-processor\\\",\\n \\\"soundFileProcessor\\\": \\\"sound-file-processor\\\",\\n \\\"amplitudeProcessor\\\": \\\"amplitude-processor\\\"\\n};\\nvar RingBuffer = {\\n \\\"default\\\":\\n /*#__PURE__*/\\n function () {\\n /**\\n * @constructor\\n * @param {number} length Buffer length in frames.\\n * @param {number} channelCount Buffer channel count.\\n */\\n function RingBuffer(length, channelCount) {\\n _classCallCheck(this, RingBuffer);\\n\\n this._readIndex = 0;\\n this._writeIndex = 0;\\n this._framesAvailable = 0;\\n this._channelCount = channelCount;\\n this._length = length;\\n this._channelData = [];\\n\\n for (var i = 0; i < this._channelCount; ++i) {\\n this._channelData[i] = new Float32Array(length);\\n }\\n }\\n /**\\n * Getter for Available frames in buffer.\\n *\\n * @return {number} Available frames in buffer.\\n */\\n\\n\\n _createClass(RingBuffer, [{\\n key: \\\"push\\\",\\n\\n /**\\n * Push a sequence of Float32Arrays to buffer.\\n *\\n * @param {array} arraySequence A sequence of Float32Arrays.\\n */\\n value: function push(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // Transfer data from the |arraySequence| storage to the internal buffer.\\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\\n\\n for (var i = 0; i < sourceLength; ++i) {\\n var writeIndex = (this._writeIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\\n }\\n }\\n\\n this._writeIndex += sourceLength;\\n\\n if (this._writeIndex >= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar AmplitudeProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(AmplitudeProcessor, _AudioWorkletProcesso);\\n\\n function AmplitudeProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, AmplitudeProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(AmplitudeProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.numOutputChannels = options.outputChannelCount || 1;\\n _this.numInputChannels = processorOptions.numInputChannels || 2;\\n _this.normalize = processorOptions.normalize || false;\\n _this.smoothing = processorOptions.smoothing || 0;\\n _this.bufferSize = processorOptions.bufferSize || 2048;\\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, _this.numInputChannels);\\n _this.outputRingBuffer = new RingBuffer(_this.bufferSize, _this.numOutputChannels);\\n _this.inputRingBufferArraySequence = new Array(_this.numInputChannels).fill(null).map(function () {\\n return new Float32Array(_this.bufferSize);\\n });\\n _this.stereoVol = [0, 0];\\n _this.stereoVolNorm = [0, 0];\\n _this.volMax = 0.001;\\n\\n _this.port.onmessage = function (event) {\\n var data = event.data;\\n\\n if (data.name === 'toggleNormalize') {\\n _this.normalize = data.normalize;\\n } else if (data.name === 'smoothing') {\\n _this.smoothing = Math.max(0, Math.min(1, data.smoothing));\\n }\\n };\\n\\n return _this;\\n } // TO DO make this stereo / dependent on # of audio channels\\n\\n\\n _createClass(AmplitudeProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs, outputs) {\\n var input = inputs[0];\\n var output = outputs[0];\\n var smoothing = this.smoothing;\\n this.inputRingBuffer.push(input);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n\\n for (var channel = 0; channel < this.numInputChannels; ++channel) {\\n var inputBuffer = this.inputRingBufferArraySequence[channel];\\n var bufLength = inputBuffer.length;\\n var sum = 0;\\n\\n for (var i = 0; i < bufLength; i++) {\\n var x = inputBuffer[i];\\n\\n if (this.normalize) {\\n sum += Math.max(Math.min(x / this.volMax, 1), -1) * Math.max(Math.min(x / this.volMax, 1), -1);\\n } else {\\n sum += x * x;\\n }\\n } // ... then take the square root of the sum.\\n\\n\\n var rms = Math.sqrt(sum / bufLength);\\n this.stereoVol[channel] = Math.max(rms, this.stereoVol[channel] * smoothing);\\n this.volMax = Math.max(this.stereoVol[channel], this.volMax);\\n } // calculate stero normalized volume and add volume from all channels together\\n\\n\\n var volSum = 0;\\n\\n for (var index = 0; index < this.stereoVol.length; index++) {\\n this.stereoVolNorm[index] = Math.max(Math.min(this.stereoVol[index] / this.volMax, 1), 0);\\n volSum += this.stereoVol[index];\\n } // volume is average of channels\\n\\n\\n var volume = volSum / this.stereoVol.length; // normalized value\\n\\n var volNorm = Math.max(Math.min(volume / this.volMax, 1), 0);\\n this.port.postMessage({\\n name: 'amplitude',\\n volume: volume,\\n volNorm: volNorm,\\n stereoVol: this.stereoVol,\\n stereoVolNorm: this.stereoVolNorm\\n }); // pass input through to output\\n\\n this.outputRingBuffer.push(this.inputRingBufferArraySequence);\\n } // pull 128 frames out of the ring buffer\\n // if the ring buffer does not have enough frames, the output will be silent\\n\\n\\n this.outputRingBuffer.pull(output);\\n return true;\\n }\\n }]);\\n\\n return AmplitudeProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.amplitudeProcessor, AmplitudeProcessor);\"","define([\"Tone/core/Tone\", \"Tone/type/TimeBase\"], function (Tone) {\n\n\t/**\n\t * @class Tone.Frequency is a primitive type for encoding Frequency values. \n\t * Eventually all time values are evaluated to hertz\n\t * using the `eval` method. \n\t * @constructor\n\t * @extends {Tone.TimeBase}\n\t * @param {String|Number} val The time value.\n\t * @param {String=} units The units of the value.\n\t * @example\n\t * Tone.Frequency(\"C3\") // 261\n\t * Tone.Frequency(38, \"midi\") //\n\t * Tone.Frequency(\"C3\").transpose(4);\n\t */\n\tTone.Frequency = function(val, units){\n\t\tif (this instanceof Tone.Frequency){\n\t\t\t\n\t\t\tTone.TimeBase.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.Frequency(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.Frequency, Tone.TimeBase);\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tAUGMENT BASE EXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.Frequency.prototype._primaryExpressions = Object.create(Tone.TimeBase.prototype._primaryExpressions);\n\n\t/*\n\t * midi type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.midi = {\n\t\tregexp : /^(\\d+(?:\\.\\d+)?midi)/,\n\t\tmethod : function(value){\n\t\t\treturn this.midiToFrequency(value);\n\t\t}\t\n\t};\n\n\t/*\n\t * note type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.note = {\n\t\tregexp : /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,\n\t\tmethod : function(pitch, octave){\n\t\t\tvar index = noteToScaleIndex[pitch.toLowerCase()];\n\t\t\tvar noteNumber = index + (parseInt(octave) + 1) * 12;\n\t\t\treturn this.midiToFrequency(noteNumber);\n\t\t}\t\n\t};\n\n\t/*\n\t * BeatsBarsSixteenths type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.tr = {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t\t\tmethod : function(m, q, s){\n\t\t\tvar total = 1;\n\t\t\tif (m && m !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(this._timeSignature() * parseFloat(m));\n\t\t\t}\n\t\t\tif (q && q !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(parseFloat(q));\n\t\t\t}\n\t\t\tif (s && s !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(parseFloat(s) / 4);\n\t\t\t}\n\t\t\treturn total;\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tEXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Transposes the frequency by the given number of semitones.\n\t * @param {Interval} interval\n\t * @return {Tone.Frequency} this\n\t * @example\n\t * Tone.Frequency(\"A4\").transpose(3); //\"C5\"\n\t */\n\tTone.Frequency.prototype.transpose = function(interval){\n\t\tthis._expr = function(expr, interval){\n\t\t\tvar val = expr();\n\t\t\treturn val * this.intervalToFrequencyRatio(interval);\n\t\t}.bind(this, this._expr, interval);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Takes an array of semitone intervals and returns\n\t * an array of frequencies transposed by those intervals.\n\t * @param {Array} intervals\n\t * @return {Tone.Frequency} this\n\t * @example\n\t * Tone.Frequency(\"A4\").harmonize([0, 3, 7]); //[\"A4\", \"C5\", \"E5\"]\n\t */\n\tTone.Frequency.prototype.harmonize = function(intervals){\n\t\tthis._expr = function(expr, intervals){\n\t\t\tvar val = expr();\n\t\t\tvar ret = [];\n\t\t\tfor (var i = 0; i < intervals.length; i++){\n\t\t\t\tret[i] = val * this.intervalToFrequencyRatio(intervals[i]);\n\t\t\t}\n\t\t\treturn ret;\n\t\t}.bind(this, this._expr, intervals);\n\t\treturn this;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Return the value of the frequency as a MIDI note\n\t * @return {MIDI}\n\t * @example\n\t * Tone.Frequency(\"C4\").toMidi(); //60\n\t */\n\tTone.Frequency.prototype.toMidi = function(){\n\t\treturn this.frequencyToMidi(this.valueOf());\n\t};\n\n\t/**\n\t * Return the value of the frequency in Scientific Pitch Notation\n\t * @return {Note}\n\t * @example\n\t * Tone.Frequency(69, \"midi\").toNote(); //\"A4\"\n\t */\n\tTone.Frequency.prototype.toNote = function(){\n\t\tvar freq = this.valueOf();\n\t\tvar log = Math.log(freq / Tone.Frequency.A4) / Math.LN2;\n\t\tvar noteNumber = Math.round(12 * log) + 57;\n\t\tvar octave = Math.floor(noteNumber/12);\n\t\tif(octave < 0){\n\t\t\tnoteNumber += -12 * octave;\n\t\t}\n\t\tvar noteName = scaleIndexToNote[noteNumber % 12];\n\t\treturn noteName + octave.toString();\n\t};\n\n\t/**\n\t * Return the duration of one cycle in seconds.\n\t * @return {Seconds}\n\t */\n\tTone.Frequency.prototype.toSeconds = function(){\n\t\treturn 1 / this.valueOf();\n\t};\n\n\t/**\n\t * Return the value in Hertz\n\t * @return {Frequency}\n\t */\n\tTone.Frequency.prototype.toFrequency = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the duration of one cycle in ticks\n\t * @return {Ticks}\n\t */\n\tTone.Frequency.prototype.toTicks = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.valueOf() / quarterTime;\n\t\treturn Math.floor(quarters * Tone.Transport.PPQ);\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS HELPERS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value of a frequency in the current units\n\t * @param {Frequency} freq\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._frequencyToUnits = function(freq){\n\t\treturn freq;\n\t};\n\n\t/**\n\t * Returns the value of a tick in the current time units\n\t * @param {Ticks} ticks\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._ticksToUnits = function(ticks){\n\t\treturn 1 / ((ticks * 60) / (Tone.Transport.bpm.value * Tone.Transport.PPQ));\n\t};\n\n\t/**\n\t * Return the value of the beats in the current units\n\t * @param {Number} beats\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._beatsToUnits = function(beats){\n\t\treturn 1 / Tone.TimeBase.prototype._beatsToUnits.call(this, beats);\n\t};\n\n\t/**\n\t * Returns the value of a second in the current units\n\t * @param {Seconds} seconds\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._secondsToUnits = function(seconds){\n\t\treturn 1 / seconds;\n\t};\n\n\t/**\n\t * The default units if none are given.\n\t * @private\n\t */\n\tTone.Frequency.prototype._defaultUnits = \"hz\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tFREQUENCY CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Note to scale index\n\t * @type {Object}\n\t */\n\tvar noteToScaleIndex = {\n\t\t\"cbb\" : -2, \"cb\" : -1, \"c\" : 0, \"c#\" : 1, \"cx\" : 2, \n\t\t\"dbb\" : 0, \"db\" : 1, \"d\" : 2, \"d#\" : 3, \"dx\" : 4,\n\t\t\"ebb\" : 2, \"eb\" : 3, \"e\" : 4, \"e#\" : 5, \"ex\" : 6, \n\t\t\"fbb\" : 3, \"fb\" : 4, \"f\" : 5, \"f#\" : 6, \"fx\" : 7,\n\t\t\"gbb\" : 5, \"gb\" : 6, \"g\" : 7, \"g#\" : 8, \"gx\" : 9,\n\t\t\"abb\" : 7, \"ab\" : 8, \"a\" : 9, \"a#\" : 10, \"ax\" : 11,\n\t\t\"bbb\" : 9, \"bb\" : 10, \"b\" : 11, \"b#\" : 12, \"bx\" : 13,\n\t};\n\n\t/**\n\t * scale index to note (sharps)\n\t * @type {Array}\n\t */\n\tvar scaleIndexToNote = [\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"A#\", \"B\"];\n\n\t/**\n\t * The [concert pitch](https://en.wikipedia.org/wiki/Concert_pitch)\n\t * A4's values in Hertz. \n\t * @type {Frequency}\n\t * @static\n\t */\n\tTone.Frequency.A4 = 440;\n\n\t/**\n\t * Convert a MIDI note to frequency value. \n\t * @param {MIDI} midi The midi number to convert.\n\t * @return {Frequency} the corresponding frequency value\n\t * @example\n\t * tone.midiToFrequency(69); // returns 440\n\t */\n\tTone.Frequency.prototype.midiToFrequency = function(midi){\n\t\treturn Tone.Frequency.A4 * Math.pow(2, (midi - 69) / 12);\n\t};\n\n\t/**\n\t * Convert a frequency value to a MIDI note.\n\t * @param {Frequency} frequency The value to frequency value to convert.\n\t * @returns {MIDI}\n\t * @example\n\t * tone.midiToFrequency(440); // returns 69\n\t */\n\tTone.Frequency.prototype.frequencyToMidi = function(frequency){\n\t\treturn 69 + 12 * Math.log(frequency / Tone.Frequency.A4) / Math.LN2;\n\t};\n\n\treturn Tone.Frequency;\n});","define([\"Tone/core/Tone\", \"Tone/type/Time\"], function (Tone) {\n\n\t/**\n\t * @class Tone.TransportTime is a the time along the Transport's\n\t * timeline. It is similar to Tone.Time, but instead of evaluating\n\t * against the AudioContext's clock, it is evaluated against\n\t * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime).\n\t * @constructor\n\t * @param {Time} val The time value as a number or string\n\t * @param {String=} units Unit values\n\t * @extends {Tone.Time}\n\t */\n\tTone.TransportTime = function(val, units){\n\t\tif (this instanceof Tone.TransportTime){\n\t\t\t\n\t\t\tTone.Time.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.TransportTime(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.TransportTime, Tone.Time);\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.TransportTime.prototype._unaryExpressions = Object.create(Tone.Time.prototype._unaryExpressions);\n\n\t/**\n\t * Adds an additional unary expression\n\t * which quantizes values to the next subdivision\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.TransportTime.prototype._unaryExpressions.quantize = {\n\t\tregexp : /^@/,\n\t\tmethod : function(rh){\n\t\t\tvar subdivision = this._secondsToTicks(rh());\n\t\t\tvar multiple = Math.ceil(Tone.Transport.ticks / subdivision);\n\t\t\treturn this._ticksToUnits(multiple * subdivision);\n\t\t}\n\t};\n\n\t/**\n\t * Convert seconds into ticks\n\t * @param {Seconds} seconds\n\t * @return {Ticks}\n\t * @private\n\t */\n\tTone.TransportTime.prototype._secondsToTicks = function(seconds){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = seconds / quarterTime;\n\t\treturn Math.round(quarters * Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Evaluate the time expression. Returns values in ticks\n\t * @return {Ticks}\n\t */\n\tTone.TransportTime.prototype.valueOf = function(){\n\t\tvar val = this._secondsToTicks(this._expr());\n\t\treturn val + (this._plusNow ? Tone.Transport.ticks : 0);\n\t};\n\n\t/**\n\t * Return the time in ticks.\n\t * @return {Ticks}\n\t */\n\tTone.TransportTime.prototype.toTicks = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds}\n\t */\n\tTone.TransportTime.prototype.toSeconds = function(){\n\t\tvar val = this._expr();\n\t\treturn val + (this._plusNow ? Tone.Transport.seconds : 0);\n\t};\n\n\t/**\n\t * Return the time as a frequency value\n\t * @return {Frequency} \n\t */\n\tTone.TransportTime.prototype.toFrequency = function(){\n\t\treturn 1/this.toSeconds();\n\t};\n\n\treturn Tone.TransportTime;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Subtract\", \"Tone/signal/Multiply\", \n\t\"Tone/signal/GreaterThan\", \"Tone/signal/GreaterThanZero\", \"Tone/signal/Abs\", \"Tone/signal/Negate\", \n\t\"Tone/signal/Modulo\", \"Tone/signal/Pow\", \"Tone/signal/AudioToGain\"], \n\tfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Evaluate an expression at audio rate.

\n\t * Parsing code modified from https://code.google.com/p/tapdigit/\n\t * Copyright 2011 2012 Ariya Hidayat, New BSD License\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {string} expr the expression to generate\n\t * @example\n\t * //adds the signals from input[0] and input[1].\n\t * var expr = new Tone.Expr(\"$0 + $1\");\n\t */\n\tTone.Expr = function(){\n\n\t\tvar expr = this._replacements(Array.prototype.slice.call(arguments));\n\t\tvar inputCount = this._parseInputs(expr);\n\n\t\t/**\n\t\t * hold onto all of the nodes for disposal\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._nodes = [];\n\n\t\t/**\n\t\t * The inputs. The length is determined by the expression. \n\t\t * @type {Array}\n\t\t */\n\t\tthis.input = new Array(inputCount);\n\n\t\t//create a gain for each input\n\t\tfor (var i = 0; i < inputCount; i++){\n\t\t\tthis.input[i] = this.context.createGain();\n\t\t}\n\n\t\t//parse the syntax tree\n\t\tvar tree = this._parseTree(expr);\n\t\t//evaluate the results\n\t\tvar result;\n\t\ttry {\n\t\t\tresult = this._eval(tree);\n\t\t} catch (e){\n\t\t\tthis._disposeNodes();\n\t\t\tthrow new Error(\"Tone.Expr: Could evaluate expression: \"+expr);\n\t\t}\n\n\t\t/**\n\t\t * The output node is the result of the expression\n\t\t * @type {Tone}\n\t\t */\n\t\tthis.output = result;\n\t};\n\n\tTone.extend(Tone.Expr, Tone.SignalBase);\n\n\t//some helpers to cut down the amount of code\n\tfunction applyBinary(Constructor, args, self){\n\t\tvar op = new Constructor();\n\t\tself._eval(args[0]).connect(op, 0, 0);\n\t\tself._eval(args[1]).connect(op, 0, 1);\n\t\treturn op;\n\t}\n\tfunction applyUnary(Constructor, args, self){\n\t\tvar op = new Constructor();\n\t\tself._eval(args[0]).connect(op, 0, 0);\n\t\treturn op;\n\t}\n\tfunction getNumber(arg){\n\t\treturn arg ? parseFloat(arg) : undefined;\n\t}\n\tfunction literalNumber(arg){\n\t\treturn arg && arg.args ? parseFloat(arg.args) : undefined;\n\t}\n\n\t/*\n\t * the Expressions that Tone.Expr can parse.\n\t *\n\t * each expression belongs to a group and contains a regexp \n\t * for selecting the operator as well as that operators method\n\t * \n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Expr._Expressions = {\n\t\t//values\n\t\t\"value\" : {\n\t\t\t\"signal\" : {\n\t\t\t\tregexp : /^\\d+\\.\\d+|^\\d+/,\n\t\t\t\tmethod : function(arg){\n\t\t\t\t\tvar sig = new Tone.Signal(getNumber(arg));\n\t\t\t\t\treturn sig;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"input\" : {\n\t\t\t\tregexp : /^\\$\\d/,\n\t\t\t\tmethod : function(arg, self){\n\t\t\t\t\treturn self.input[getNumber(arg.substr(1))];\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t//syntactic glue\n\t\t\"glue\" : {\n\t\t\t\"(\" : {\n\t\t\t\tregexp : /^\\(/,\n\t\t\t},\n\t\t\t\")\" : {\n\t\t\t\tregexp : /^\\)/,\n\t\t\t},\n\t\t\t\",\" : {\n\t\t\t\tregexp : /^,/,\n\t\t\t}\n\t\t},\n\t\t//functions\n\t\t\"func\" : {\n\t\t\t\"abs\" : {\n\t\t\t\tregexp : /^abs/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.Abs)\n\t\t\t},\n\t\t\t\"mod\" : {\n\t\t\t\tregexp : /^mod/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar modulus = literalNumber(args[1]);\n\t\t\t\t\tvar op = new Tone.Modulo(modulus);\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"pow\" : {\n\t\t\t\tregexp : /^pow/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar exp = literalNumber(args[1]);\n\t\t\t\t\tvar op = new Tone.Pow(exp);\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"a2g\" : {\n\t\t\t\tregexp : /^a2g/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar op = new Tone.AudioToGain();\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t//binary expressions\n\t\t\"binary\" : {\n\t\t\t\"+\" : {\n\t\t\t\tregexp : /^\\+/,\n\t\t\t\tprecedence : 1,\n\t\t\t\tmethod : applyBinary.bind(this, Tone.Add)\n\t\t\t},\n\t\t\t\"-\" : {\n\t\t\t\tregexp : /^\\-/,\n\t\t\t\tprecedence : 1,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\t//both unary and binary op\n\t\t\t\t\tif (args.length === 1){\n\t\t\t\t\t\treturn applyUnary(Tone.Negate, args, self);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn applyBinary(Tone.Subtract, args, self);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"*\" : {\n\t\t\t\tregexp : /^\\*/,\n\t\t\t\tprecedence : 0,\n\t\t\t\tmethod : applyBinary.bind(this, Tone.Multiply)\n\t\t\t}\n\t\t},\n\t\t//unary expressions\n\t\t\"unary\" : {\n\t\t\t\"-\" : {\n\t\t\t\tregexp : /^\\-/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.Negate)\n\t\t\t},\n\t\t\t\"!\" : {\n\t\t\t\tregexp : /^\\!/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.NOT)\n\t\t\t},\n\t\t},\n\t};\n\t\t\n\t/**\n\t * @param {string} expr the expression string\n\t * @return {number} the input count\n\t * @private\n\t */\n\tTone.Expr.prototype._parseInputs = function(expr){\n\t\tvar inputArray = expr.match(/\\$\\d/g);\n\t\tvar inputMax = 0;\n\t\tif (inputArray !== null){\n\t\t\tfor (var i = 0; i < inputArray.length; i++){\n\t\t\t\tvar inputNum = parseInt(inputArray[i].substr(1)) + 1;\n\t\t\t\tinputMax = Math.max(inputMax, inputNum);\n\t\t\t}\n\t\t}\n\t\treturn inputMax;\n\t};\n\n\t/**\n\t * @param {Array} args \tan array of arguments\n\t * @return {string} the results of the replacements being replaced\n\t * @private\n\t */\n\tTone.Expr.prototype._replacements = function(args){\n\t\tvar expr = args.shift();\n\t\tfor (var i = 0; i < args.length; i++){\n\t\t\texpr = expr.replace(/\\%/i, args[i]);\n\t\t}\n\t\treturn expr;\n\t};\n\n\t/**\n\t * tokenize the expression based on the Expressions object\n\t * @param {string} expr \n\t * @return {Object} returns two methods on the tokenized list, next and peek\n\t * @private\n\t */\n\tTone.Expr.prototype._tokenize = function(expr){\n\t\tvar position = -1;\n\t\tvar tokens = [];\n\n\t\twhile(expr.length > 0){\n\t\t\texpr = expr.trim();\n\t\t\tvar token = getNextToken(expr);\n\t\t\ttokens.push(token);\n\t\t\texpr = expr.substr(token.value.length);\n\t\t}\n\n\t\tfunction getNextToken(expr){\n\t\t\tfor (var type in Tone.Expr._Expressions){\n\t\t\t\tvar group = Tone.Expr._Expressions[type];\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tvar reg = op.regexp;\n\t\t\t\t\tvar match = expr.match(reg);\n\t\t\t\t\tif (match !== null){\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype : type,\n\t\t\t\t\t\t\tvalue : match[0],\n\t\t\t\t\t\t\tmethod : op.method\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.Expr: Unexpected token \"+expr);\n\t\t}\n\n\t\treturn {\n\t\t\tnext : function(){\n\t\t\t\treturn tokens[++position];\n\t\t\t},\n\t\t\tpeek : function(){\n\t\t\t\treturn tokens[position + 1];\n\t\t\t}\n\t\t};\n\t};\n\n\t/**\n\t * recursively parse the string expression into a syntax tree\n\t * \n\t * @param {string} expr \n\t * @return {Object}\n\t * @private\n\t */\n\tTone.Expr.prototype._parseTree = function(expr){\n\t\tvar lexer = this._tokenize(expr);\n\t\tvar isUndef = this.isUndef.bind(this);\n\n\t\tfunction matchSyntax(token, syn) {\n\t\t\treturn !isUndef(token) && \n\t\t\t\ttoken.type === \"glue\" &&\n\t\t\t\ttoken.value === syn;\n\t\t}\n\n\t\tfunction matchGroup(token, groupName, prec) {\n\t\t\tvar ret = false;\n\t\t\tvar group = Tone.Expr._Expressions[groupName];\n\t\t\tif (!isUndef(token)){\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tif (op.regexp.test(token.value)){\n\t\t\t\t\t\tif (!isUndef(prec)){\n\t\t\t\t\t\t\tif(op.precedence === prec){\t\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tfunction parseExpression(precedence) {\n\t\t\tif (isUndef(precedence)){\n\t\t\t\tprecedence = 5;\n\t\t\t}\n\t\t\tvar expr;\n\t\t\tif (precedence < 0){\n\t\t\t\texpr = parseUnary();\n\t\t\t} else {\n\t\t\t\texpr = parseExpression(precedence-1);\n\t\t\t}\n\t\t\tvar token = lexer.peek();\n\t\t\twhile (matchGroup(token, \"binary\", precedence)) {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\texpr = {\n\t\t\t\t\toperator: token.value,\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : [\n\t\t\t\t\t\texpr,\n\t\t\t\t\t\tparseExpression(precedence-1)\n\t\t\t\t\t]\n\t\t\t\t};\n\t\t\t\ttoken = lexer.peek();\n\t\t\t}\n\t\t\treturn expr;\n\t\t}\n\n\t\tfunction parseUnary() {\n\t\t\tvar token, expr;\n\t\t\ttoken = lexer.peek();\n\t\t\tif (matchGroup(token, \"unary\")) {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\texpr = parseUnary();\n\t\t\t\treturn {\n\t\t\t\t\toperator: token.value,\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : [expr]\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn parsePrimary();\n\t\t}\n\n\t\tfunction parsePrimary() {\n\t\t\tvar token, expr;\n\t\t\ttoken = lexer.peek();\n\t\t\tif (isUndef(token)) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Unexpected termination of expression\");\n\t\t\t}\n\t\t\tif (token.type === \"func\") {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\treturn parseFunctionCall(token);\n\t\t\t}\n\t\t\tif (token.type === \"value\") {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\treturn {\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : token.value\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (matchSyntax(token, \"(\")) {\n\t\t\t\tlexer.next();\n\t\t\t\texpr = parseExpression();\n\t\t\t\ttoken = lexer.next();\n\t\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\t\tthrow new SyntaxError(\"Expected )\");\n\t\t\t\t}\n\t\t\t\treturn expr;\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.Expr: Parse error, cannot process token \" + token.value);\n\t\t}\n\n\t\tfunction parseFunctionCall(func) {\n\t\t\tvar token, args = [];\n\t\t\ttoken = lexer.next();\n\t\t\tif (!matchSyntax(token, \"(\")) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Expected ( in a function call \\\"\" + func.value + \"\\\"\");\n\t\t\t}\n\t\t\ttoken = lexer.peek();\n\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\targs = parseArgumentList();\n\t\t\t}\n\t\t\ttoken = lexer.next();\n\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Expected ) in a function call \\\"\" + func.value + \"\\\"\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tmethod : func.method,\n\t\t\t\targs : args,\n\t\t\t\tname : name\n\t\t\t};\n\t\t}\n\n\t\tfunction parseArgumentList() {\n\t\t\tvar token, expr, args = [];\n\t\t\twhile (true) {\n\t\t\t\texpr = parseExpression();\n\t\t\t\tif (isUndef(expr)) {\n\t\t\t\t\t// TODO maybe throw exception?\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\targs.push(expr);\n\t\t\t\ttoken = lexer.peek();\n\t\t\t\tif (!matchSyntax(token, \",\")) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tlexer.next();\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\n\t\treturn parseExpression();\n\t};\n\n\t/**\n\t * recursively evaluate the expression tree\n\t * @param {Object} tree \n\t * @return {AudioNode} the resulting audio node from the expression\n\t * @private\n\t */\n\tTone.Expr.prototype._eval = function(tree){\n\t\tif (!this.isUndef(tree)){\n\t\t\tvar node = tree.method(tree.args, this);\n\t\t\tthis._nodes.push(node);\n\t\t\treturn node;\n\t\t} \n\t};\n\n\t/**\n\t * dispose all the nodes\n\t * @private\n\t */\n\tTone.Expr.prototype._disposeNodes = function(){\n\t\tfor (var i = 0; i < this._nodes.length; i++){\n\t\t\tvar node = this._nodes[i];\n\t\t\tif (this.isFunction(node.dispose)) {\n\t\t\t\tnode.dispose();\n\t\t\t} else if (this.isFunction(node.disconnect)) {\n\t\t\t\tnode.disconnect();\n\t\t\t}\n\t\t\tnode = null;\n\t\t\tthis._nodes[i] = null;\n\t\t}\n\t\tthis._nodes = null;\n\t};\n\n\t/**\n\t * clean up\n\t */\n\tTone.Expr.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._disposeNodes();\n\t};\n\n\treturn Tone.Expr;\n});","define([\"Tone/core/Tone\", \"Tone/signal/GreaterThanZero\", \"Tone/signal/Subtract\", \"Tone/signal/Signal\"], \n\tfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Output 1 if the signal is greater than the value, otherwise outputs 0.\n\t * can compare two signals or a signal and a number. \n\t * \n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number} [value=0] the value to compare to the incoming signal\n\t * @example\n\t * var gt = new Tone.GreaterThan(2);\n\t * var sig = new Tone.Signal(4).connect(gt);\n\t * //output of gt is equal 1. \n\t */\n\tTone.GreaterThan = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\t\t\n\t\t/**\n\t\t * subtract the amount from the incoming signal\n\t\t * @type {Tone.Subtract}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input[0] = new Tone.Subtract(value);\n\t\tthis.input[1] = this._param.input[1];\n\n\t\t/**\n\t\t * compare that amount to zero\n\t\t * @type {Tone.GreaterThanZero}\n\t\t * @private\n\t\t */\n\t\tthis._gtz = this.output = new Tone.GreaterThanZero();\n\n\t\t//connect\n\t\tthis._param.connect(this._gtz);\n\t};\n\n\tTone.extend(Tone.GreaterThan, Tone.Signal);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.GreaterThan} this\n\t */\n\tTone.GreaterThan.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\tthis._gtz.dispose();\n\t\tthis._gtz = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.GreaterThan;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/SignalBase\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Return the absolute value of an incoming signal. \n\t * \n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var signal = new Tone.Signal(-1);\n\t * var abs = new Tone.Abs();\n\t * signal.connect(abs);\n\t * //the output of abs is 1. \n\t */\n\tTone.Abs = function(){\n\t\t/**\n\t\t * @type {Tone.LessThan}\n\t\t * @private\n\t\t */\n\t\tthis._abs = this.input = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (val === 0){\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn Math.abs(val);\n\t\t\t}\n\t\t}, 127);\n\t};\n\n\tTone.extend(Tone.Abs, Tone.SignalBase);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.Abs} this\n\t */\n\tTone.Abs.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._abs.dispose();\n\t\tthis._abs = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Abs;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/Multiply\", \"Tone/signal/Subtract\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Signal-rate modulo operator. Only works in AudioRange [-1, 1] and for modulus\n\t * values in the NormalRange. \n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @param {NormalRange} modulus The modulus to apply.\n\t * @example\n\t * var mod = new Tone.Modulo(0.2)\n\t * var sig = new Tone.Signal(0.5).connect(mod);\n\t * //mod outputs 0.1\n\t */\n\tTone.Modulo = function(modulus){\n\n\t\tthis.createInsOuts(1, 0);\n\n\t\t/**\n\t\t * A waveshaper gets the integer multiple of \n\t\t * the input signal and the modulus.\n\t\t * @private\n\t\t * @type {Tone.WaveShaper}\n\t\t */\n\t\tthis._shaper = new Tone.WaveShaper(Math.pow(2, 16));\n\n\t\t/**\n\t\t * the integer multiple is multiplied by the modulus\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._multiply = new Tone.Multiply();\n\n\t\t/**\n\t\t * and subtracted from the input signal\n\t\t * @type {Tone.Subtract}\n\t\t * @private\n\t\t */\n\t\tthis._subtract = this.output = new Tone.Subtract();\n\n\t\t/**\n\t\t * the modulus signal\n\t\t * @type {Tone.Signal}\n\t\t * @private\n\t\t */\n\t\tthis._modSignal = new Tone.Signal(modulus);\n\n\t\t//connections\n\t\tthis.input.fan(this._shaper, this._subtract);\n\t\tthis._modSignal.connect(this._multiply, 0, 0);\n\t\tthis._shaper.connect(this._multiply, 0, 1);\n\t\tthis._multiply.connect(this._subtract, 0, 1);\n\t\tthis._setWaveShaper(modulus);\n\t};\n\n\tTone.extend(Tone.Modulo, Tone.SignalBase);\n\n\t/**\n\t * @param {number} mod the modulus to apply\n\t * @private\n\t */\n\tTone.Modulo.prototype._setWaveShaper = function(mod){\n\t\tthis._shaper.setMap(function(val){\n\t\t\tvar multiple = Math.floor((val + 0.0001) / mod);\n\t\t\treturn multiple;\n\t\t});\n\t};\n\n\t/**\n\t * The modulus value.\n\t * @memberOf Tone.Modulo#\n\t * @type {NormalRange}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Modulo.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._modSignal.value;\n\t\t},\n\t\tset : function(mod){\n\t\t\tthis._modSignal.value = mod;\n\t\t\tthis._setWaveShaper(mod);\n\t\t}\n\t});\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Modulo} this\n\t */\n\tTone.Modulo.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._shaper.dispose();\n\t\tthis._shaper = null;\n\t\tthis._multiply.dispose();\n\t\tthis._multiply = null;\n\t\tthis._subtract.dispose();\n\t\tthis._subtract = null;\n\t\tthis._modSignal.dispose();\n\t\tthis._modSignal = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Modulo;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Pow applies an exponent to the incoming signal. The incoming signal\n\t * must be AudioRange.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {Positive} exp The exponent to apply to the incoming signal, must be at least 2. \n\t * @example\n\t * var pow = new Tone.Pow(2);\n\t * var sig = new Tone.Signal(0.5).connect(pow);\n\t * //output of pow is 0.25. \n\t */\n\tTone.Pow = function(exp){\n\n\t\t/**\n\t\t * the exponent\n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._exp = this.defaultArg(exp, 1);\n\n\t\t/**\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._expScaler = this.input = this.output = new Tone.WaveShaper(this._expFunc(this._exp), 8192);\n\t};\n\n\tTone.extend(Tone.Pow, Tone.SignalBase);\n\n\t/**\n\t * The value of the exponent.\n\t * @memberOf Tone.Pow#\n\t * @type {number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Pow.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._exp;\n\t\t},\n\t\tset : function(exp){\n\t\t\tthis._exp = exp;\n\t\t\tthis._expScaler.setMap(this._expFunc(this._exp));\n\t\t}\n\t});\n\n\n\t/**\n\t * the function which maps the waveshaper\n\t * @param {number} exp\n\t * @return {function}\n\t * @private\n\t */\n\tTone.Pow.prototype._expFunc = function(exp){\n\t\treturn function(val){\n\t\t\treturn Math.pow(Math.abs(val), exp);\n\t\t};\n\t};\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Pow} this\n\t */\n\tTone.Pow.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._expScaler.dispose();\n\t\tthis._expScaler = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Pow;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1]. \n\t * See Tone.GainToAudio.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @example\n\t * var a2g = new Tone.AudioToGain();\n\t */\n\tTone.AudioToGain = function(){\n\n\t\t/**\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._norm = this.input = this.output = new Tone.WaveShaper(function(x){\n\t\t\treturn (x + 1) / 2;\n\t\t});\n\t};\n\n\tTone.extend(Tone.AudioToGain, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.AudioToGain} this\n\t */\n\tTone.AudioToGain.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._norm.dispose();\n\t\tthis._norm = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.AudioToGain;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Convert an incoming signal between 0, 1 to an equal power gain scale.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @example\n\t * var eqPowGain = new Tone.EqualPowerGain();\n\t */\n\tTone.EqualPowerGain = function(){\n\n\t\t/**\n\t\t * @type {Tone.WaveShaper}\n\t\t * @private\n\t\t */\n\t\tthis._eqPower = this.input = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (Math.abs(val) < 0.001){\n\t\t\t\t//should output 0 when input is 0\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn this.equalPowerScale(val);\n\t\t\t}\n\t\t}.bind(this), 4096);\n\t};\n\n\tTone.extend(Tone.EqualPowerGain, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.EqualPowerGain} this\n\t */\n\tTone.EqualPowerGain.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._eqPower.dispose();\n\t\tthis._eqPower = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.EqualPowerGain;\n});","define([\"Tone/core/Tone\", \"Tone/core/Timeline\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A Timeline State. Provides the methods: setStateAtTime(\"state\", time)\n\t * and getValueAtTime(time).\n\t *\n\t * @extends {Tone.Timeline}\n\t * @param {String} initial The initial state of the TimelineState. \n\t * Defaults to undefined\n\t */\n\tTone.TimelineState = function(initial){\n\n\t\tTone.Timeline.call(this);\n\n\t\t/**\n\t\t * The initial state\n\t\t * @private\n\t\t * @type {String}\n\t\t */\n\t\tthis._initial = initial;\n\t};\n\n\tTone.extend(Tone.TimelineState, Tone.Timeline);\n\n\t/**\n\t * Returns the scheduled state scheduled before or at\n\t * the given time.\n\t * @param {Number} time The time to query.\n\t * @return {String} The name of the state input in setStateAtTime.\n\t */\n\tTone.TimelineState.prototype.getValueAtTime = function(time){\n\t\tvar event = this.get(time);\n\t\tif (event !== null){\n\t\t\treturn event.state;\n\t\t} else {\n\t\t\treturn this._initial;\n\t\t}\n\t};\n\n\t/**\n\t * Returns the scheduled state scheduled before or at\n\t * the given time.\n\t * @param {String} state The name of the state to set.\n\t * @param {Number} time The time to query.\n\t */\n\tTone.TimelineState.prototype.setStateAtTime = function(state, time){\n\t\tthis.add({\n\t\t\t\"state\" : state,\n\t\t\t\"time\" : time\n\t\t});\n\t};\n\n\treturn Tone.TimelineState;\n});","import audiocontext from './audiocontext.js';\n// Master contains the master sound output.\nclass Master {\n constructor() {\n this.input = audiocontext.createGain();\n this.output = audiocontext.createGain();\n\n //put a hard limiter on the output\n this.limiter = audiocontext.createDynamicsCompressor();\n this.limiter.threshold.value = -3;\n this.limiter.ratio.value = 20;\n this.limiter.knee.value = 1;\n\n this.audiocontext = audiocontext;\n\n this.output.disconnect();\n\n // connect input to limiter\n this.input.connect(this.limiter);\n\n // connect limiter to output\n this.limiter.connect(this.output);\n\n // meter is just for global Amplitude / FFT analysis\n this.meter = audiocontext.createGain();\n this.fftMeter = audiocontext.createGain();\n this.output.connect(this.meter);\n this.output.connect(this.fftMeter);\n\n // connect output to destination\n this.output.connect(this.audiocontext.destination);\n\n // an array of all sounds in the sketch\n this.soundArray = [];\n // an array of all musical parts in the sketch\n this.parts = [];\n\n // file extensions to search for\n this.extensions = [];\n }\n}\n\n// create a single instance of the p5Sound / master output for use within this sketch\nconst p5sound = new Master();\n\n/**\n * Returns a number representing the master amplitude (volume) for sound\n * in this sketch.\n *\n * @method getMasterVolume\n * @return {Number} Master amplitude (volume) for sound in this sketch.\n * Should be between 0.0 (silence) and 1.0.\n */\np5.prototype.getMasterVolume = function () {\n return p5sound.output.gain.value;\n};\n\n/**\n *

Scale the output of all sound in this sketch

\n * Scaled between 0.0 (silence) and 1.0 (full volume).\n * 1.0 is the maximum amplitude of a digital sound, so multiplying\n * by greater than 1.0 may cause digital distortion. To\n * fade, provide a rampTime parameter. For more\n * complex fades, see the Envelope class.\n *\n * Alternately, you can pass in a signal source such as an\n * oscillator to modulate the amplitude with an audio signal.\n *\n *

How This Works: When you load the p5.sound module, it\n * creates a single instance of p5sound. All sound objects in this\n * module output to p5sound before reaching your computer's output.\n * So if you change the amplitude of p5sound, it impacts all of the\n * sound in this module.

\n *\n *

If no value is provided, returns a Web Audio API Gain Node

\n *\n * @method masterVolume\n * @param {Number|Object} volume Volume (amplitude) between 0.0\n * and 1.0 or modulating signal/oscillator\n * @param {Number} [rampTime] Fade for t seconds\n * @param {Number} [timeFromNow] Schedule this event to happen at\n * t seconds in the future\n */\np5.prototype.masterVolume = function (vol, rampTime = 0, tFromNow = 0) {\n if (typeof vol === 'number') {\n var now = p5sound.audiocontext.currentTime;\n var currentVol = p5sound.output.gain.value;\n p5sound.output.gain.cancelScheduledValues(now + tFromNow);\n p5sound.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n p5sound.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(p5sound.output.gain);\n } else {\n // return the Gain Node\n return p5sound.output.gain;\n }\n};\n\n/**\n * `p5.soundOut` is the p5.sound master output. It sends output to\n * the destination of this window's web audio context. It contains\n * Web Audio API nodes including a dyanmicsCompressor (.limiter),\n * and Gain Nodes for .input and .output.\n *\n * @property {Object} soundOut\n */\np5.prototype.soundOut = p5.soundOut = p5sound;\n\n// a silent connection to the DesinationNode\n// which will ensure that anything connected to it\n// will not be garbage collected\np5.soundOut._silentNode = p5sound.audiocontext.createGain();\np5.soundOut._silentNode.gain.value = 0;\np5.soundOut._silentNode.connect(p5sound.audiocontext.destination);\n\nexport default p5sound;\n","import p5sound from './master';\nimport processorNames from './audioWorklet/processorNames';\n/**\n * @for p5\n */\n\n/**\n * Returns a number representing the sample rate, in samples per second,\n * of all sound objects in this audio context. It is determined by the\n * sampling rate of your operating system's sound card, and it is not\n * currently possile to change.\n * It is often 44100, or twice the range of human hearing.\n *\n * @method sampleRate\n * @return {Number} samplerate samples per second\n */\nfunction sampleRate() {\n return p5sound.audiocontext.sampleRate;\n}\n\n/**\n * Returns the closest MIDI note value for\n * a given frequency.\n *\n * @method freqToMidi\n * @param {Number} frequency A freqeuncy, for example, the \"A\"\n * above Middle C is 440Hz\n * @return {Number} MIDI note value\n */\nfunction freqToMidi(f) {\n var mathlog2 = Math.log(f / 440) / Math.log(2);\n var m = Math.round(12 * mathlog2) + 69;\n return m;\n}\n\n/**\n * Returns the frequency value of a MIDI note value.\n * General MIDI treats notes as integers where middle C\n * is 60, C# is 61, D is 62 etc. Useful for generating\n * musical frequencies with oscillators.\n *\n * @method midiToFreq\n * @param {Number} midiNote The number of a MIDI note\n * @return {Number} Frequency value of the given MIDI note\n * @example\n *
\n * let midiNotes = [60, 64, 67, 72];\n * let noteIndex = 0;\n * let midiVal, freq;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startSound);\n * osc = new p5.TriOsc();\n * env = new p5.Envelope();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 10, 20);\n * if (midiVal) {\n * text('MIDI: ' + midiVal, 10, 40);\n * text('Freq: ' + freq, 10, 60);\n * }\n * }\n *\n * function startSound() {\n * // see also: userStartAudio();\n * osc.start();\n *\n * midiVal = midiNotes[noteIndex % midiNotes.length];\n * freq = midiToFreq(midiVal);\n * osc.freq(freq);\n * env.ramp(osc, 0, 1.0, 0);\n *\n * noteIndex++;\n * }\n *
\n */\nfunction midiToFreq(m) {\n return 440 * Math.pow(2, (m - 69) / 12.0);\n}\n\n// This method converts ANSI notes specified as a string \"C4\", \"Eb3\" to a frequency\nfunction noteToFreq(note) {\n if (typeof note !== 'string') {\n return note;\n }\n var wholeNotes = { A: 21, B: 23, C: 24, D: 26, E: 28, F: 29, G: 31 };\n var value = wholeNotes[note[0].toUpperCase()];\n var octave = ~~note.slice(-1);\n value += 12 * (octave - 1);\n\n switch (note[1]) {\n case '#':\n value += 1;\n break;\n case 'b':\n value -= 1;\n break;\n default:\n break;\n }\n return midiToFreq(value);\n}\n\n/**\n * List the SoundFile formats that you will include. LoadSound\n * will search your directory for these extensions, and will pick\n * a format that is compatable with the client's web browser.\n * Here is a free online file\n * converter.\n *\n * @method soundFormats\n * @param {String} [...formats] i.e. 'mp3', 'wav', 'ogg'\n * @example\n *
\n * function preload() {\n * // set the global sound formats\n * soundFormats('mp3', 'ogg');\n *\n * // load either beatbox.mp3, or .ogg, depending on browser\n * mySound = loadSound('assets/beatbox.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * text('sound loaded! tap to play', 10, 20, width - 20);\n * cnv.mousePressed(function() {\n * mySound.play();\n * });\n * }\n *
\n */\n\nfunction soundFormats() {\n // reset extensions array\n p5sound.extensions = [];\n // add extensions\n for (var i = 0; i < arguments.length; i++) {\n arguments[i] = arguments[i].toLowerCase();\n if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(arguments[i]) > -1) {\n p5sound.extensions.push(arguments[i]);\n } else {\n throw arguments[i] + ' is not a valid sound format!';\n }\n }\n}\n\nfunction disposeSound() {\n for (var i = 0; i < p5sound.soundArray.length; i++) {\n p5sound.soundArray[i].dispose();\n }\n}\n\nfunction _checkFileFormats(paths) {\n var path;\n // if path is a single string, check to see if extension is provided\n if (typeof paths === 'string') {\n path = paths;\n // see if extension is provided\n var extTest = path.split('.').pop();\n // if an extension is provided...\n if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(extTest) > -1) {\n if (!p5.prototype.isFileSupported(extTest)) {\n var pathSplit = path.split('.');\n var pathCore = pathSplit[pathSplit.length - 1];\n for (let i = 0; i < p5sound.extensions.length; i++) {\n const extension = p5sound.extensions[i];\n const supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n pathCore = '';\n if (pathSplit.length === 2) {\n pathCore += pathSplit[0];\n }\n for (let i = 1; i <= pathSplit.length - 2; i++) {\n var p = pathSplit[i];\n pathCore += '.' + p;\n }\n path = pathCore += '.';\n path = path += extension;\n break;\n }\n }\n }\n }\n // if no extension is provided...\n else {\n for (let i = 0; i < p5sound.extensions.length; i++) {\n const extension = p5sound.extensions[i];\n const supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n path = path + '.' + extension;\n break;\n }\n }\n }\n } // end 'if string'\n\n // path can either be a single string, or an array\n else if (typeof paths === 'object') {\n for (var i = 0; i < paths.length; i++) {\n var extension = paths[i].split('.').pop();\n var supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n // console.log('.'+extension + ' is ' + supported +\n // ' supported by your browser.');\n path = paths[i];\n break;\n }\n }\n }\n return path;\n}\n\n/**\n * Used by Osc and Envelope to chain signal math\n */\nfunction _mathChain(o, math, thisChain, nextChain, type) {\n // if this type of math already exists in the chain, replace it\n for (var i in o.mathOps) {\n if (o.mathOps[i] instanceof type) {\n o.mathOps[i].dispose();\n thisChain = i;\n if (thisChain < o.mathOps.length - 1) {\n nextChain = o.mathOps[i + 1];\n }\n }\n }\n o.mathOps[thisChain - 1].disconnect();\n o.mathOps[thisChain - 1].connect(math);\n math.connect(nextChain);\n o.mathOps[thisChain] = math;\n return o;\n}\n\n// helper methods to convert audio file as .wav format,\n// will use as saving .wav file and saving blob object\n// Thank you to Matt Diamond's RecorderJS (MIT License)\n// https://github.com/mattdiamond/Recorderjs\nfunction convertToWav(audioBuffer) {\n var leftChannel, rightChannel;\n leftChannel = audioBuffer.getChannelData(0);\n\n // handle mono files\n if (audioBuffer.numberOfChannels > 1) {\n rightChannel = audioBuffer.getChannelData(1);\n } else {\n rightChannel = leftChannel;\n }\n\n var interleaved = interleave(leftChannel, rightChannel);\n\n // create the buffer and view to create the .WAV file\n var buffer = new window.ArrayBuffer(44 + interleaved.length * 2);\n var view = new window.DataView(buffer);\n\n // write the WAV container,\n // check spec at: https://web.archive.org/web/20171215131933/http://tiny.systems/software/soundProgrammer/WavFormatDocs.pdf\n\n // RIFF chunk descriptor\n writeUTFBytes(view, 0, 'RIFF');\n view.setUint32(4, 36 + interleaved.length * 2, true);\n writeUTFBytes(view, 8, 'WAVE');\n // FMT sub-chunk\n writeUTFBytes(view, 12, 'fmt ');\n view.setUint32(16, 16, true);\n view.setUint16(20, 1, true);\n // stereo (2 channels)\n view.setUint16(22, 2, true);\n view.setUint32(24, p5sound.audiocontext.sampleRate, true);\n view.setUint32(28, p5sound.audiocontext.sampleRate * 4, true);\n view.setUint16(32, 4, true);\n view.setUint16(34, 16, true);\n // data sub-chunk\n writeUTFBytes(view, 36, 'data');\n view.setUint32(40, interleaved.length * 2, true);\n\n // write the PCM samples\n var lng = interleaved.length;\n var index = 44;\n var volume = 1;\n for (var i = 0; i < lng; i++) {\n view.setInt16(index, interleaved[i] * (0x7fff * volume), true);\n index += 2;\n }\n\n return view;\n}\n\n// helper methods to save waves\nfunction interleave(leftChannel, rightChannel) {\n var length = leftChannel.length + rightChannel.length;\n var result = new Float32Array(length);\n\n var inputIndex = 0;\n\n for (var index = 0; index < length; ) {\n result[index++] = leftChannel[inputIndex];\n result[index++] = rightChannel[inputIndex];\n inputIndex++;\n }\n return result;\n}\n\nfunction writeUTFBytes(view, offset, string) {\n var lng = string.length;\n for (var i = 0; i < lng; i++) {\n view.setUint8(offset + i, string.charCodeAt(i));\n }\n}\n\nfunction safeBufferSize(idealBufferSize) {\n let bufferSize = idealBufferSize;\n\n // if the AudioWorkletNode is actually a ScriptProcessorNode created via polyfill,\n // make sure that our chosen buffer size isn't smaller than the buffer size automatically\n // selected by the polyfill\n // reference: https://github.com/GoogleChromeLabs/audioworklet-polyfill/issues/13#issuecomment-425014930\n let tempAudioWorkletNode = new AudioWorkletNode(\n p5sound.audiocontext,\n processorNames.soundFileProcessor\n );\n if (tempAudioWorkletNode instanceof ScriptProcessorNode) {\n bufferSize = tempAudioWorkletNode.bufferSize;\n }\n tempAudioWorkletNode.disconnect();\n tempAudioWorkletNode = null;\n\n return bufferSize;\n}\n\n/**\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\n * to download the file to their device.\n * For uploading audio to a server, use\n * `p5.SoundFile.saveBlob`.\n *\n * @for p5\n * @method saveSound\n * @param {p5.SoundFile} soundFile p5.SoundFile that you wish to save\n * @param {String} fileName name of the resulting .wav file.\n */\n// add to p5.prototype as this is used by the p5 `save()` method.\nfunction saveSound(soundFile, fileName) {\n const dataView = convertToWav(soundFile.buffer);\n p5.prototype.writeFile([dataView], fileName, 'wav');\n}\n\nexport {\n sampleRate,\n freqToMidi,\n midiToFreq,\n noteToFreq,\n soundFormats,\n disposeSound,\n _checkFileFormats,\n _mathChain,\n convertToWav,\n interleave,\n writeUTFBytes,\n safeBufferSize,\n saveSound,\n};\n","/*\n Helper function to generate an error\n with a custom stack trace that points to the sketch\n and removes other parts of the stack trace.\n\n @private\n @class customError\n @constructor\n @param {String} name custom error name\n @param {String} errorTrace custom error trace\n @param {String} failedPath path to the file that failed to load\n @property {String} name custom error name\n @property {String} message custom error message\n @property {String} stack trace the error back to a line in the user's sketch.\n Note: this edits out stack trace within p5.js and p5.sound.\n @property {String} originalStack unedited, original stack trace\n @property {String} failedPath path to the file that failed to load\n @return {Error} returns a custom Error object\n */\nvar CustomError = function (name, errorTrace, failedPath) {\n var err = new Error();\n var tempStack, splitStack;\n\n err.name = name;\n err.originalStack = err.stack + errorTrace;\n tempStack = err.stack + errorTrace;\n err.failedPath = failedPath;\n\n // only print the part of the stack trace that refers to the user code:\n splitStack = tempStack.split('\\n').filter(function (ln) {\n return !ln.match(/(p5.|native code|globalInit)/g);\n });\n err.stack = splitStack.join('\\n');\n\n return err; // TODO: is this really a constructor?\n};\nexport default CustomError;\n","import p5sound from '../master.js';\nconst moduleSources = [\n require('raw-loader!./recorderProcessor').default,\n require('raw-loader!./soundFileProcessor').default,\n require('raw-loader!./amplitudeProcessor').default,\n];\nconst ac = p5sound.audiocontext;\nlet initializedAudioWorklets = false;\n\nfunction loadAudioWorkletModules() {\n return Promise.all(\n moduleSources.map(function (moduleSrc) {\n const blob = new Blob([moduleSrc], { type: 'application/javascript' });\n const objectURL = URL.createObjectURL(blob);\n return ac.audioWorklet.addModule(objectURL);\n })\n );\n}\n\np5.prototype.registerMethod('init', function () {\n if (initializedAudioWorklets) return;\n // ensure that a preload function exists so that p5 will wait for preloads to finish\n if (!this.preload && !window.preload) {\n this.preload = function () {};\n }\n\n // use p5's preload system to load necessary AudioWorklet modules before setup()\n this._incrementPreload();\n const onWorkletModulesLoad = function () {\n initializedAudioWorklets = true;\n this._decrementPreload();\n }.bind(this);\n loadAudioWorkletModules().then(onWorkletModulesLoad);\n});\n","import p5sound from './master';\nvar ac = p5sound.audiocontext;\nvar panner;\n// Stereo panner\n// if there is a stereo panner node use it\nif (typeof ac.createStereoPanner !== 'undefined') {\n class Panner {\n constructor(input, output) {\n this.stereoPanner = this.input = ac.createStereoPanner();\n input.connect(this.stereoPanner);\n this.stereoPanner.connect(output);\n }\n\n pan(val, tFromNow) {\n var time = tFromNow || 0;\n var t = ac.currentTime + time;\n\n this.stereoPanner.pan.linearRampToValueAtTime(val, t);\n }\n\n //not implemented because stereopanner\n //node does not require this and will automatically\n //convert single channel or multichannel to stereo.\n //tested with single and stereo, not with (>2) multichannel\n inputChannels() {}\n\n connect(obj) {\n this.stereoPanner.connect(obj);\n }\n\n disconnect() {\n if (this.stereoPanner) {\n this.stereoPanner.disconnect();\n }\n }\n }\n\n panner = Panner;\n} else {\n // if there is no createStereoPanner object\n // such as in safari 7.1.7 at the time of writing this\n // use this method to create the effect\n class Panner {\n constructor(input, output, numInputChannels) {\n this.input = ac.createGain();\n input.connect(this.input);\n\n this.left = ac.createGain();\n this.right = ac.createGain();\n this.left.channelInterpretation = 'discrete';\n this.right.channelInterpretation = 'discrete';\n\n // if input is stereo\n if (numInputChannels > 1) {\n this.splitter = ac.createChannelSplitter(2);\n this.input.connect(this.splitter);\n\n this.splitter.connect(this.left, 1);\n this.splitter.connect(this.right, 0);\n } else {\n this.input.connect(this.left);\n this.input.connect(this.right);\n }\n\n this.output = ac.createChannelMerger(2);\n this.left.connect(this.output, 0, 1);\n this.right.connect(this.output, 0, 0);\n this.output.connect(output);\n }\n\n // -1 is left, +1 is right\n pan(val, tFromNow) {\n var time = tFromNow || 0;\n var t = ac.currentTime + time;\n var v = (val + 1) / 2;\n var rightVal = Math.cos((v * Math.PI) / 2);\n var leftVal = Math.sin((v * Math.PI) / 2);\n this.left.gain.linearRampToValueAtTime(leftVal, t);\n this.right.gain.linearRampToValueAtTime(rightVal, t);\n }\n\n inputChannels(numChannels) {\n if (numChannels === 1) {\n this.input.disconnect();\n this.input.connect(this.left);\n this.input.connect(this.right);\n } else if (numChannels === 2) {\n if (typeof this.splitter === 'undefined') {\n this.splitter = ac.createChannelSplitter(2);\n }\n this.input.disconnect();\n this.input.connect(this.splitter);\n this.splitter.connect(this.left, 1);\n this.splitter.connect(this.right, 0);\n }\n }\n\n connect(obj) {\n this.output.connect(obj);\n }\n\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n }\n panner = Panner;\n}\n\nexport default panner;\n","import CustomError from './errorHandler';\nimport p5sound from './master';\nimport { midiToFreq, convertToWav, safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\nimport Panner from './panner';\n\nconst ac = p5sound.audiocontext;\n\nvar _createCounterBuffer = function (buffer) {\n const len = buffer.length;\n const audioBuf = ac.createBuffer(1, buffer.length, ac.sampleRate);\n const arrayBuffer = audioBuf.getChannelData(0);\n for (var index = 0; index < len; index++) {\n arrayBuffer[index] = index;\n }\n return audioBuf;\n};\n\n/*** SCHEDULE EVENTS ***/\n\n// Cue inspired by JavaScript setTimeout, and the\n// Tone.js Transport Timeline Event, MIT License Yotam Mann 2015 tonejs.org\nclass Cue {\n constructor(callback, time, id, val) {\n this.callback = callback;\n this.time = time;\n this.id = id;\n this.val = val;\n }\n}\n\n// event handler to remove references to the bufferSourceNode when it is done playing\nfunction _clearOnEnd(e) {\n const thisBufferSourceNode = e.target;\n const soundFile = this;\n\n // delete this.bufferSourceNode from the sources array when it is done playing:\n thisBufferSourceNode._playing = false;\n thisBufferSourceNode.removeEventListener('ended', soundFile._clearOnEnd);\n\n // call the onended callback\n soundFile._onended(soundFile);\n\n // delete bufferSourceNode(s) in soundFile.bufferSourceNodes\n // iterate in reverse order because the index changes by splice\n soundFile.bufferSourceNodes\n .map((_, i) => i)\n .reverse()\n .forEach(function (i) {\n const n = soundFile.bufferSourceNodes[i];\n\n if (n._playing === false) {\n soundFile.bufferSourceNodes.splice(i, 1);\n }\n });\n\n if (soundFile.bufferSourceNodes.length === 0) {\n soundFile._playing = false;\n }\n}\n\n/**\n *

SoundFile object with a path to a file.

\n *\n *

The p5.SoundFile may not be available immediately because\n * it loads the file information asynchronously.

\n *\n *

To do something with the sound as soon as it loads\n * pass the name of a function as the second parameter.

\n *\n *

Only one file path is required. However, audio file formats\n * (i.e. mp3, ogg, wav and m4a/aac) are not supported by all\n * web browsers. If you want to ensure compatability, instead of a single\n * file path, you may include an Array of filepaths, and the browser will\n * choose a format that works.

\n *\n * @class p5.SoundFile\n * @constructor\n * @param {String|Array} path path to a sound file (String). Optionally,\n * you may include multiple file formats in\n * an array. Alternately, accepts an object\n * from the HTML5 File API, or a p5.File.\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if file fails to\n * load. This function will receive an error or\n * XMLHttpRequest object with information\n * about what went wrong.\n * @param {Function} [whileLoadingCallback] Name of a function to call while file\n * is loading. That function will\n * receive progress of the request to\n * load the sound file\n * (between 0 and 1) as its first\n * parameter. This progress\n * does not account for the additional\n * time needed to decode the audio data.\n *\n * @example\n *
\n * let mySound;\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * mySound = loadSound('assets/doorbell');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap here to play', 10, 20);\n * }\n *\n * function canvasPressed() {\n * // playing a sound file on a user gesture\n * // is equivalent to `userStartAudio()`\n * mySound.play();\n * }\n *
\n */\nclass SoundFile {\n constructor(paths, onload, onerror, whileLoading) {\n if (typeof paths !== 'undefined') {\n if (typeof paths === 'string' || typeof paths[0] === 'string') {\n var path = p5.prototype._checkFileFormats(paths);\n this.url = path;\n } else if (typeof paths === 'object') {\n if (\n !(window.File && window.FileReader && window.FileList && window.Blob)\n ) {\n // The File API isn't supported in this browser\n throw 'Unable to load file because the File API is not supported';\n }\n }\n\n // if type is a p5.File...get the actual file\n if (paths.file) {\n paths = paths.file;\n }\n\n this.file = paths;\n }\n\n // private _onended callback, set by the method: onended(callback)\n this._onended = function () {};\n\n this._looping = false;\n this._playing = false;\n this._paused = false;\n this._pauseTime = 0;\n\n // cues for scheduling events with addCue() removeCue()\n this._cues = [];\n this._cueIDCounter = 0;\n\n // position of the most recently played sample\n this._lastPos = 0;\n this._counterNode = null;\n this._workletNode = null;\n\n // array of sources so that they can all be stopped!\n this.bufferSourceNodes = [];\n\n // current source\n this.bufferSourceNode = null;\n\n this.buffer = null;\n this.playbackRate = 1;\n\n this.input = p5sound.audiocontext.createGain();\n this.output = p5sound.audiocontext.createGain();\n\n this.reversed = false;\n\n // start and end of playback / loop\n this.startTime = 0;\n this.endTime = null;\n this.pauseTime = 0;\n\n // \"restart\" would stop playback before retriggering\n this.mode = 'sustain';\n\n // time that playback was started, in millis\n this.startMillis = null;\n\n // stereo panning\n this.panPosition = 0.0;\n this.panner = new Panner(this.output, p5sound.input, 2);\n\n // it is possible to instantiate a soundfile with no path\n if (this.url || this.file) {\n this.load(onload, onerror);\n }\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n\n if (typeof whileLoading === 'function') {\n this._whileLoading = whileLoading;\n } else {\n this._whileLoading = function () {};\n }\n\n this._clearOnEnd = _clearOnEnd.bind(this);\n\n // same as setVolume, to match Processing Sound\n this.amp = this.setVolume;\n\n // these are the same thing\n this.fade = this.setVolume;\n }\n\n /**\n * This is a helper function that the p5.SoundFile calls to load\n * itself. Accepts a callback (the name of another function)\n * as an optional parameter.\n *\n * @private\n * @for p5.SoundFile\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if there is an error\n */\n load(callback, errorCallback) {\n var self = this;\n var errorTrace = new Error().stack;\n\n if (this.url !== undefined && this.url !== '') {\n var request = new XMLHttpRequest();\n request.addEventListener(\n 'progress',\n function (evt) {\n self._updateProgress(evt);\n },\n false\n );\n request.open('GET', this.url, true);\n request.responseType = 'arraybuffer';\n\n request.onload = function () {\n if (request.status === 200) {\n // on sucess loading file:\n if (!self.panner) return;\n ac.decodeAudioData(\n request.response,\n // success decoding buffer:\n function (buff) {\n if (!self.panner) return;\n self.buffer = buff;\n self.panner.inputChannels(buff.numberOfChannels);\n if (callback) {\n callback(self);\n }\n },\n // error decoding buffer. \"e\" is undefined in Chrome 11/22/2015\n function () {\n if (!self.panner) return;\n var err = new CustomError(\n 'decodeAudioData',\n errorTrace,\n self.url\n );\n var msg = 'AudioContext error at decodeAudioData for ' + self.url;\n if (errorCallback) {\n err.msg = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n );\n }\n // if request status != 200, it failed\n else {\n if (!self.panner) return;\n var err = new CustomError('loadSound', errorTrace, self.url);\n var msg =\n 'Unable to load ' +\n self.url +\n '. The request status was: ' +\n request.status +\n ' (' +\n request.statusText +\n ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n };\n\n // if there is another error, aside from 404...\n request.onerror = function () {\n var err = new CustomError('loadSound', errorTrace, self.url);\n var msg =\n 'There was no response from the server at ' +\n self.url +\n '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n };\n\n request.send();\n } else if (this.file !== undefined) {\n var reader = new FileReader();\n reader.onload = function () {\n if (!self.panner) return;\n ac.decodeAudioData(reader.result, function (buff) {\n if (!self.panner) return;\n self.buffer = buff;\n self.panner.inputChannels(buff.numberOfChannels);\n if (callback) {\n callback(self);\n }\n });\n };\n reader.onerror = function (e) {\n if (!self.panner) return;\n if (onerror) {\n onerror(e);\n }\n };\n reader.readAsArrayBuffer(this.file);\n }\n }\n\n // TO DO: use this method to create a loading bar that shows progress during file upload/decode.\n _updateProgress(evt) {\n if (evt.lengthComputable) {\n var percentComplete = (evt.loaded / evt.total) * 0.99;\n this._whileLoading(percentComplete, evt);\n // ...\n } else {\n // Unable to compute progress information since the total size is unknown\n this._whileLoading('size unknown');\n }\n }\n\n /**\n * Returns true if the sound file finished loading successfully.\n *\n * @method isLoaded\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isLoaded() {\n if (this.buffer) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Play the p5.SoundFile\n *\n * @method play\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule playback to start (in seconds from now).\n * @param {Number} [rate] (optional) playback rate\n * @param {Number} [amp] (optional) amplitude (volume)\n * of playback\n * @param {Number} [cueStart] (optional) cue start time in seconds\n * @param {Number} [duration] (optional) duration of playback in seconds\n */\n play(startTime, rate, amp, _cueStart, duration) {\n if (!this.output) {\n console.warn('SoundFile.play() called after dispose');\n return;\n }\n\n var now = p5sound.audiocontext.currentTime;\n var cueStart, cueEnd;\n var time = startTime || 0;\n if (time < 0) {\n time = 0;\n }\n\n time = time + now;\n\n if (typeof rate !== 'undefined') {\n this.rate(rate);\n }\n\n if (typeof amp !== 'undefined') {\n this.setVolume(amp);\n }\n\n // TO DO: if already playing, create array of buffers for easy stop()\n if (this.buffer) {\n // reset the pause time (if it was paused)\n this._pauseTime = 0;\n\n // handle restart playmode\n if (this.mode === 'restart' && this.buffer && this.bufferSourceNode) {\n this.bufferSourceNode.stop(time);\n this._counterNode.stop(time);\n }\n\n //dont create another instance if already playing\n if (this.mode === 'untildone' && this.isPlaying()) {\n return;\n }\n // make a new source and counter. They are automatically assigned playbackRate and buffer\n this.bufferSourceNode = this._initSourceNode();\n\n // garbage collect counterNode and create a new one\n delete this._counterNode;\n this._counterNode = this._initCounterNode();\n\n if (_cueStart) {\n if (_cueStart >= 0 && _cueStart < this.buffer.duration) {\n // this.startTime = cueStart;\n cueStart = _cueStart;\n } else {\n throw 'start time out of range';\n }\n } else {\n cueStart = 0;\n }\n\n if (duration) {\n // if duration is greater than buffer.duration, just play entire file anyway rather than throw an error\n duration =\n duration <= this.buffer.duration - cueStart\n ? duration\n : this.buffer.duration;\n }\n\n // if it was paused, play at the pause position\n if (this._paused) {\n this.bufferSourceNode.start(time, this.pauseTime, duration);\n this._counterNode.start(time, this.pauseTime, duration);\n } else {\n this.bufferSourceNode.start(time, cueStart, duration);\n this._counterNode.start(time, cueStart, duration);\n }\n\n this._playing = true;\n this._paused = false;\n\n // add source to sources array, which is used in stopAll()\n this.bufferSourceNodes.push(this.bufferSourceNode);\n this.bufferSourceNode._arrayIndex = this.bufferSourceNodes.length - 1;\n\n this.bufferSourceNode.addEventListener('ended', this._clearOnEnd);\n }\n // If soundFile hasn't loaded the buffer yet, throw an error\n else {\n throw 'not ready to play file, buffer has yet to load. Try preload()';\n }\n\n // if looping, will restart at original time\n this.bufferSourceNode.loop = this._looping;\n this._counterNode.loop = this._looping;\n\n if (this._looping === true) {\n cueEnd = duration ? duration : cueStart - 0.000000000000001;\n this.bufferSourceNode.loopStart = cueStart;\n this.bufferSourceNode.loopEnd = cueEnd;\n this._counterNode.loopStart = cueStart;\n this._counterNode.loopEnd = cueEnd;\n }\n }\n\n /**\n * p5.SoundFile has two play modes: restart and\n * sustain. Play Mode determines what happens to a\n * p5.SoundFile if it is triggered while in the middle of playback.\n * In sustain mode, playback will continue simultaneous to the\n * new playback. In restart mode, play() will stop playback\n * and start over. With untilDone, a sound will play only if it's\n * not already playing. Sustain is the default mode.\n *\n * @method playMode\n * @for p5.SoundFile\n * @param {String} str 'restart' or 'sustain' or 'untilDone'\n * @example\n *
\n * let mySound;\n * function preload(){\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * noFill();\n * rect(0, height/2, width - 1, height/2 - 1);\n * rect(0, 0, width - 1, height/2);\n * textAlign(CENTER, CENTER);\n * fill(20);\n * text('restart', width/2, 1 * height/4);\n * text('sustain', width/2, 3 * height/4);\n * }\n * function canvasPressed() {\n * if (mouseX < height/2) {\n * mySound.playMode('restart');\n * } else {\n * mySound.playMode('sustain');\n * }\n * mySound.play();\n * }\n *\n *
\n */\n playMode(str) {\n var s = str.toLowerCase();\n\n // if restart, stop all other sounds from playing\n if (s === 'restart' && this.buffer && this.bufferSourceNode) {\n for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {\n var now = p5sound.audiocontext.currentTime;\n this.bufferSourceNodes[i].stop(now);\n }\n }\n\n // set play mode to effect future playback\n if (s === 'restart' || s === 'sustain' || s === 'untildone') {\n this.mode = s;\n } else {\n throw 'Invalid play mode. Must be either \"restart\" or \"sustain\"';\n }\n }\n\n /**\n * Pauses a file that is currently playing. If the file is not\n * playing, then nothing will happen.\n *\n * After pausing, .play() will resume from the paused\n * position.\n * If p5.SoundFile had been set to loop before it was paused,\n * it will continue to loop after it is unpaused with .play().\n *\n * @method pause\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * seconds from now\n * @example\n *
\n * let soundFile;\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play, release to pause', 10, 20, width - 20);\n * }\n * function canvasPressed() {\n * soundFile.loop();\n * background(0, 200, 50);\n * }\n * function mouseReleased() {\n * soundFile.pause();\n * background(220);\n * }\n * \n *
\n */\n pause(startTime) {\n var now = p5sound.audiocontext.currentTime;\n var time = startTime || 0;\n var pTime = time + now;\n\n if (this.isPlaying() && this.buffer && this.bufferSourceNode) {\n this._paused = true;\n this._playing = false;\n\n this.pauseTime = this.currentTime();\n this.bufferSourceNode.stop(pTime);\n this._counterNode.stop(pTime);\n\n this._pauseTime = this.currentTime();\n // TO DO: make sure play() still starts from orig start position\n } else {\n this._pauseTime = 0;\n }\n }\n\n /**\n * Loop the p5.SoundFile. Accepts optional parameters to set the\n * playback rate, playback volume, loopStart, loopEnd.\n *\n * @method loop\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * seconds from now\n * @param {Number} [rate] (optional) playback rate\n * @param {Number} [amp] (optional) playback volume\n * @param {Number} [cueLoopStart] (optional) startTime in seconds\n * @param {Number} [duration] (optional) loop duration in seconds\n * @example\n *
\n * let soundFile;\n * let loopStart = 0.5;\n * let loopDuration = 0.2;\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play, release to pause', 10, 20, width - 20);\n * }\n * function canvasPressed() {\n * soundFile.loop();\n * background(0, 200, 50);\n * }\n * function mouseReleased() {\n * soundFile.pause();\n * background(220);\n * }\n * \n *
\n */\n loop(startTime, rate, amp, loopStart, duration) {\n this._looping = true;\n this.play(startTime, rate, amp, loopStart, duration);\n }\n\n /**\n * Set a p5.SoundFile's looping flag to true or false. If the sound\n * is currently playing, this change will take effect when it\n * reaches the end of the current playback.\n *\n * @method setLoop\n * @for p5.SoundFile\n * @param {Boolean} Boolean set looping to true or false\n */\n setLoop(bool) {\n if (bool === true) {\n this._looping = true;\n } else if (bool === false) {\n this._looping = false;\n } else {\n throw 'Error: setLoop accepts either true or false';\n }\n if (this.bufferSourceNode) {\n this.bufferSourceNode.loop = this._looping;\n this._counterNode.loop = this._looping;\n }\n }\n\n /**\n * Returns 'true' if a p5.SoundFile is currently looping and playing, 'false' if not.\n *\n * @method isLooping\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isLooping() {\n if (!this.bufferSourceNode) {\n return false;\n }\n if (this._looping === true && this.isPlaying() === true) {\n return true;\n }\n return false;\n }\n\n /**\n * Returns true if a p5.SoundFile is playing, false if not (i.e.\n * paused or stopped).\n *\n * @method isPlaying\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isPlaying() {\n return this._playing;\n }\n\n /**\n * Returns true if a p5.SoundFile is paused, false if not (i.e.\n * playing or stopped).\n *\n * @method isPaused\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isPaused() {\n return this._paused;\n }\n\n /**\n * Stop soundfile playback.\n *\n * @method stop\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * in seconds from now\n */\n stop(timeFromNow) {\n var time = timeFromNow || 0;\n\n if (this.mode === 'sustain' || this.mode === 'untildone') {\n this.stopAll(time);\n this._playing = false;\n this.pauseTime = 0;\n this._paused = false;\n } else if (this.buffer && this.bufferSourceNode) {\n var now = p5sound.audiocontext.currentTime;\n var t = time || 0;\n this.pauseTime = 0;\n this.bufferSourceNode.stop(now + t);\n this._counterNode.stop(now + t);\n this._playing = false;\n this._paused = false;\n }\n }\n\n /**\n * Stop playback on all of this soundfile's sources.\n * @private\n */\n stopAll(_time) {\n var now = p5sound.audiocontext.currentTime;\n var time = _time || 0;\n if (this.buffer && this.bufferSourceNode) {\n for (var i in this.bufferSourceNodes) {\n const bufferSourceNode = this.bufferSourceNodes[i];\n if (bufferSourceNode) {\n try {\n bufferSourceNode.stop(now + time);\n } catch (e) {\n // this was throwing errors only on Safari\n }\n }\n }\n this._counterNode.stop(now + time);\n }\n }\n\n getVolume() {\n return this.output.gain.value;\n }\n\n /**\n * Set the stereo panning of a p5.sound object to\n * a floating point number between -1.0 (left) and 1.0 (right).\n * Default is 0.0 (center).\n *\n * @method pan\n * @for p5.SoundFile\n * @param {Number} [panValue] Set the stereo panner\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @example\n *
\n * let ballX = 0;\n * let soundFile;\n *\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/beatbox.mp3');\n * }\n *\n * function draw() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * ballX = constrain(mouseX, 0, width);\n * ellipse(ballX, height/2, 20, 20);\n * }\n *\n * function canvasPressed(){\n * // map the ball's x location to a panning degree\n * // between -1.0 (left) and 1.0 (right)\n * let panning = map(ballX, 0., width,-1.0, 1.0);\n * soundFile.pan(panning);\n * soundFile.play();\n * }\n *
\n */\n pan(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n }\n\n /**\n * Returns the current stereo pan position (-1.0 to 1.0)\n *\n * @method getPan\n * @for p5.SoundFile\n * @return {Number} Returns the stereo pan setting of the Oscillator\n * as a number between -1.0 (left) and 1.0 (right).\n * 0.0 is center and default.\n */\n getPan() {\n return this.panPosition;\n }\n\n /**\n * Set the playback rate of a sound file. Will change the speed and the pitch.\n * Values less than zero will reverse the audio buffer.\n *\n * @method rate\n * @for p5.SoundFile\n * @param {Number} [playbackRate] Set the playback rate. 1.0 is normal,\n * .5 is half-speed, 2.0 is twice as fast.\n * Values less than zero play backwards.\n * @example\n *
\n * let mySound;\n *\n * function preload() {\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * }\n * function canvasPressed() {\n * mySound.loop();\n * }\n * function mouseReleased() {\n * mySound.pause();\n * }\n * function draw() {\n * background(220);\n *\n * // Set the rate to a range between 0.1 and 4\n * // Changing the rate also alters the pitch\n * let playbackRate = map(mouseY, 0.1, height, 2, 0);\n * playbackRate = constrain(playbackRate, 0.01, 4);\n * mySound.rate(playbackRate);\n *\n * line(0, mouseY, width, mouseY);\n * text('rate: ' + round(playbackRate * 100) + '%', 10, 20);\n * }\n *\n * \n *
\n *\n */\n rate(playbackRate) {\n var reverse = false;\n if (typeof playbackRate === 'undefined') {\n return this.playbackRate;\n }\n\n this.playbackRate = playbackRate;\n\n if (playbackRate === 0) {\n playbackRate = 0.0000000000001;\n } else if (playbackRate < 0 && !this.reversed) {\n playbackRate = Math.abs(playbackRate);\n reverse = true;\n } else if (playbackRate > 0 && this.reversed) {\n reverse = true;\n }\n\n if (this.bufferSourceNode) {\n var now = p5sound.audiocontext.currentTime;\n this.bufferSourceNode.playbackRate.cancelScheduledValues(now);\n this.bufferSourceNode.playbackRate.linearRampToValueAtTime(\n Math.abs(playbackRate),\n now\n );\n this._counterNode.playbackRate.cancelScheduledValues(now);\n this._counterNode.playbackRate.linearRampToValueAtTime(\n Math.abs(playbackRate),\n now\n );\n }\n\n if (reverse) {\n this.reverseBuffer();\n }\n return this.playbackRate;\n }\n\n // TO DO: document this\n setPitch(num) {\n var newPlaybackRate = midiToFreq(num) / midiToFreq(60);\n this.rate(newPlaybackRate);\n }\n\n getPlaybackRate() {\n return this.playbackRate;\n }\n\n /**\n * Multiply the output volume (amplitude) of a sound file\n * between 0.0 (silence) and 1.0 (full volume).\n * 1.0 is the maximum amplitude of a digital sound, so multiplying\n * by greater than 1.0 may cause digital distortion. To\n * fade, provide a rampTime parameter. For more\n * complex fades, see the Envelope class.\n *\n * Alternately, you can pass in a signal source such as an\n * oscillator to modulate the amplitude with an audio signal.\n *\n * @method setVolume\n * @for p5.SoundFile\n * @param {Number|Object} volume Volume (amplitude) between 0.0\n * and 1.0 or modulating signal/oscillator\n * @param {Number} [rampTime] Fade for t seconds\n * @param {Number} [timeFromNow] Schedule this event to happen at\n * t seconds in the future\n */\n setVolume(vol, _rampTime, _tFromNow) {\n if (typeof vol === 'number') {\n var rampTime = _rampTime || 0;\n var tFromNow = _tFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now + tFromNow);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(this.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n }\n /**\n * Returns the duration of a sound file in seconds.\n *\n * @method duration\n * @for p5.SoundFile\n * @return {Number} The duration of the soundFile in seconds.\n */\n duration() {\n // Return Duration\n if (this.buffer) {\n return this.buffer.duration;\n } else {\n return 0;\n }\n }\n\n /**\n * Return the current position of the p5.SoundFile playhead, in seconds.\n * Time is relative to the normal buffer direction, so if `reverseBuffer`\n * has been called, currentTime will count backwards.\n *\n * @method currentTime\n * @for p5.SoundFile\n * @return {Number} currentTime of the soundFile in seconds.\n */\n currentTime() {\n return this.reversed\n ? Math.abs(this._lastPos - this.buffer.length) / ac.sampleRate\n : this._lastPos / ac.sampleRate;\n }\n\n /**\n * Move the playhead of a soundfile that is currently playing to a\n * new position and a new duration, in seconds.\n * If none are given, will reset the file to play entire duration\n * from start to finish. To set the position of a soundfile that is\n * not currently playing, use the `play` or `loop` methods.\n *\n * @method jump\n * @for p5.SoundFile\n * @param {Number} cueTime cueTime of the soundFile in seconds.\n * @param {Number} duration duration in seconds.\n */\n jump(cueTime, duration) {\n if (cueTime < 0 || cueTime > this.buffer.duration) {\n throw 'jump time out of range';\n }\n if (duration > this.buffer.duration - cueTime) {\n throw 'end time out of range';\n }\n\n var cTime = cueTime || 0;\n var dur = duration || undefined;\n if (this.isPlaying()) {\n this.stop(0);\n this.play(0, this.playbackRate, this.output.gain.value, cTime, dur);\n }\n }\n\n /**\n * Return the number of channels in a sound file.\n * For example, Mono = 1, Stereo = 2.\n *\n * @method channels\n * @for p5.SoundFile\n * @return {Number} [channels]\n */\n channels() {\n return this.buffer.numberOfChannels;\n }\n\n /**\n * Return the sample rate of the sound file.\n *\n * @method sampleRate\n * @for p5.SoundFile\n * @return {Number} [sampleRate]\n */\n sampleRate() {\n return this.buffer.sampleRate;\n }\n\n /**\n * Return the number of samples in a sound file.\n * Equal to sampleRate * duration.\n *\n * @method frames\n * @for p5.SoundFile\n * @return {Number} [sampleCount]\n */\n frames() {\n return this.buffer.length;\n }\n\n /**\n * Returns an array of amplitude peaks in a p5.SoundFile that can be\n * used to draw a static waveform. Scans through the p5.SoundFile's\n * audio buffer to find the greatest amplitudes. Accepts one\n * parameter, 'length', which determines size of the array.\n * Larger arrays result in more precise waveform visualizations.\n *\n * Inspired by Wavesurfer.js.\n *\n * @method getPeaks\n * @for p5.SoundFile\n * @params {Number} [length] length is the size of the returned array.\n * Larger length results in more precision.\n * Defaults to 5*width of the browser window.\n * @returns {Float32Array} Array of peaks.\n */\n getPeaks(length) {\n if (this.buffer) {\n // set length to window's width if no length is provided\n if (!length) {\n length = window.width * 5;\n }\n if (this.buffer) {\n var buffer = this.buffer;\n var sampleSize = buffer.length / length;\n var sampleStep = ~~(sampleSize / 10) || 1;\n var channels = buffer.numberOfChannels;\n var peaks = new Float32Array(Math.round(length));\n\n for (var c = 0; c < channels; c++) {\n var chan = buffer.getChannelData(c);\n for (var i = 0; i < length; i++) {\n var start = ~~(i * sampleSize);\n var end = ~~(start + sampleSize);\n var max = 0;\n for (var j = start; j < end; j += sampleStep) {\n var value = chan[j];\n if (value > max) {\n max = value;\n // faster than Math.abs\n } else if (-value > max) {\n max = value;\n }\n }\n if (c === 0 || Math.abs(max) > peaks[i]) {\n peaks[i] = max;\n }\n }\n }\n\n return peaks;\n }\n } else {\n throw 'Cannot load peaks yet, buffer is not loaded';\n }\n }\n\n /**\n * Reverses the p5.SoundFile's buffer source.\n * Playback must be handled separately (see example).\n *\n * @method reverseBuffer\n * @for p5.SoundFile\n * @example\n *
\n * let drum;\n * function preload() {\n * drum = loadSound('assets/drum.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function canvasPressed() {\n * drum.stop();\n * drum.reverseBuffer();\n * drum.play();\n * }\n * \n *
\n */\n reverseBuffer() {\n if (this.buffer) {\n var currentPos = this._lastPos / ac.sampleRate;\n var curVol = this.getVolume();\n this.setVolume(0, 0.001);\n\n const numChannels = this.buffer.numberOfChannels;\n for (var i = 0; i < numChannels; i++) {\n this.buffer.getChannelData(i).reverse();\n }\n // set reversed flag\n this.reversed = !this.reversed;\n\n if (this.isPlaying() && currentPos) {\n this.jump(this.duration() - currentPos);\n }\n this.setVolume(curVol, 0.001);\n } else {\n throw 'SoundFile is not done loading';\n }\n }\n\n /**\n * Schedule an event to be called when the soundfile\n * reaches the end of a buffer. If the soundfile is\n * playing through once, this will be called when it\n * ends. If it is looping, it will be called when\n * stop is called.\n *\n * @method onended\n * @for p5.SoundFile\n * @param {Function} callback function to call when the\n * soundfile has ended.\n */\n onended(callback) {\n this._onended = callback;\n return this;\n }\n\n add() {\n // TO DO\n }\n\n dispose() {\n var now = p5sound.audiocontext.currentTime;\n\n // remove reference to soundfile\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.stop(now);\n if (this.buffer && this.bufferSourceNode) {\n for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {\n if (this.bufferSourceNodes[i] !== null) {\n this.bufferSourceNodes[i].disconnect();\n try {\n this.bufferSourceNodes[i].stop(now);\n } catch (e) {\n console.warn('no buffer source node to dispose');\n }\n this.bufferSourceNodes[i] = null;\n }\n }\n if (this.isPlaying()) {\n try {\n this._counterNode.stop(now);\n } catch (e) {\n console.log(e);\n }\n this._counterNode = null;\n }\n }\n if (this.output) {\n this.output.disconnect();\n this.output = null;\n }\n if (this.panner) {\n this.panner.disconnect();\n this.panner = null;\n }\n }\n\n /**\n * Connects the output of a p5sound object to input of another\n * p5.sound object. For example, you may connect a p5.SoundFile to an\n * FFT or an Effect. If no parameter is given, it will connect to\n * the master output. Most p5sound objects connect to the master\n * output when they are created.\n *\n * @method connect\n * @for p5.SoundFile\n * @param {Object} [object] Audio object that accepts an input\n */\n connect(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n } else {\n if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n } else {\n this.panner.connect(unit);\n }\n }\n }\n\n /**\n * Disconnects the output of this p5sound object.\n *\n * @method disconnect\n * @for p5.SoundFile\n */\n disconnect() {\n if (this.panner) {\n this.panner.disconnect();\n }\n }\n\n /**\n */\n getLevel() {\n console.warn(\n 'p5.SoundFile.getLevel has been removed from the library. Use p5.Amplitude instead'\n );\n }\n\n /**\n * Reset the source for this SoundFile to a\n * new path (URL).\n *\n * @method setPath\n * @for p5.SoundFile\n * @param {String} path path to audio file\n * @param {Function} callback Callback\n */\n setPath(p, callback) {\n var path = p5.prototype._checkFileFormats(p);\n this.url = path;\n this.load(callback);\n }\n\n /**\n * Replace the current Audio Buffer with a new Buffer.\n *\n * @method setBuffer\n * @for p5.SoundFile\n * @param {Array} buf Array of Float32 Array(s). 2 Float32 Arrays\n * will create a stereo source. 1 will create\n * a mono source.\n */\n setBuffer(buf) {\n var numChannels = buf.length;\n var size = buf[0].length;\n var newBuffer = ac.createBuffer(numChannels, size, ac.sampleRate);\n\n if (!(buf[0] instanceof Float32Array)) {\n buf[0] = new Float32Array(buf[0]);\n }\n\n for (var channelNum = 0; channelNum < numChannels; channelNum++) {\n var channel = newBuffer.getChannelData(channelNum);\n channel.set(buf[channelNum]);\n }\n\n this.buffer = newBuffer;\n\n // set numbers of channels on input to the panner\n this.panner.inputChannels(numChannels);\n }\n\n // initialize counterNode, set its initial buffer and playbackRate\n _initCounterNode() {\n var self = this;\n var now = ac.currentTime;\n var cNode = ac.createBufferSource();\n\n const workletBufferSize = safeBufferSize(256);\n\n // dispose of worklet node if it already exists\n if (self._workletNode) {\n self._workletNode.disconnect();\n delete self._workletNode;\n }\n self._workletNode = new AudioWorkletNode(\n ac,\n processorNames.soundFileProcessor,\n {\n processorOptions: { bufferSize: workletBufferSize },\n }\n );\n self._workletNode.port.onmessage = (event) => {\n if (event.data.name === 'position') {\n // event.data.position should only be 0 when paused\n if (event.data.position === 0) {\n return;\n }\n this._lastPos = event.data.position;\n\n // do any callbacks that have been scheduled\n this._onTimeUpdate(self._lastPos);\n }\n };\n\n // create counter buffer of the same length as self.buffer\n cNode.buffer = _createCounterBuffer(self.buffer);\n\n cNode.playbackRate.setValueAtTime(self.playbackRate, now);\n\n cNode.connect(self._workletNode);\n self._workletNode.connect(p5.soundOut._silentNode);\n\n return cNode;\n }\n\n // initialize sourceNode, set its initial buffer and playbackRate\n _initSourceNode() {\n var bufferSourceNode = ac.createBufferSource();\n bufferSourceNode.buffer = this.buffer;\n bufferSourceNode.playbackRate.value = this.playbackRate;\n bufferSourceNode.connect(this.output);\n return bufferSourceNode;\n }\n\n processPeaks(callback, _initThreshold, _minThreshold, _minPeaks) {\n console.warn('processPeaks is deprecated');\n }\n\n /**\n * Schedule events to trigger every time a MediaElement\n * (audio/video) reaches a playback cue point.\n *\n * Accepts a callback function, a time (in seconds) at which to trigger\n * the callback, and an optional parameter for the callback.\n *\n * Time will be passed as the first parameter to the callback function,\n * and param will be the second parameter.\n *\n *\n * @method addCue\n * @for p5.SoundFile\n * @param {Number} time Time in seconds, relative to this media\n * element's playback. For example, to trigger\n * an event every time playback reaches two\n * seconds, pass in the number 2. This will be\n * passed as the first parameter to\n * the callback function.\n * @param {Function} callback Name of a function that will be\n * called at the given time. The callback will\n * receive time and (optionally) param as its\n * two parameters.\n * @param {Object} [value] An object to be passed as the\n * second parameter to the\n * callback function.\n * @return {Number} id ID of this cue,\n * useful for removeCue(id)\n * @example\n *
\n * let mySound;\n * function preload() {\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play', 10, 20);\n *\n * // schedule calls to changeText\n * mySound.addCue(0, changeText, \"hello\" );\n * mySound.addCue(0.5, changeText, \"hello,\" );\n * mySound.addCue(1, changeText, \"hello, p5!\");\n * mySound.addCue(1.5, changeText, \"hello, p5!!\");\n * mySound.addCue(2, changeText, \"hello, p5!!!!!\");\n * }\n *\n * function changeText(val) {\n * background(220);\n * text(val, 10, 20);\n * }\n *\n * function canvasPressed() {\n * mySound.play();\n * }\n *
\n */\n addCue(time, callback, val) {\n var id = this._cueIDCounter++;\n\n var cue = new Cue(callback, time, id, val);\n this._cues.push(cue);\n\n // if (!this.elt.ontimeupdate) {\n // this.elt.ontimeupdate = this._onTimeUpdate.bind(this);\n // }\n\n return id;\n }\n\n /**\n * Remove a callback based on its ID. The ID is returned by the\n * addCue method.\n *\n * @method removeCue\n * @for p5.SoundFile\n * @param {Number} id ID of the cue, as returned by addCue\n */\n removeCue(id) {\n var cueLength = this._cues.length;\n for (var i = 0; i < cueLength; i++) {\n var cue = this._cues[i];\n if (cue.id === id) {\n this._cues.splice(i, 1);\n break;\n }\n }\n\n if (this._cues.length === 0) {\n // TO DO: remove callback\n // this.elt.ontimeupdate = null\n }\n }\n\n /**\n * Remove all of the callbacks that had originally been scheduled\n * via the addCue method.\n *\n * @method clearCues\n */\n clearCues() {\n this._cues = [];\n // this.elt.ontimeupdate = null;\n }\n\n // private method that checks for cues to be fired if events\n // have been scheduled using addCue(callback, time).\n _onTimeUpdate(position) {\n var playbackTime = position / this.buffer.sampleRate;\n var cueLength = this._cues.length;\n\n for (var i = 0; i < cueLength; i++) {\n var cue = this._cues[i];\n var callbackTime = cue.time;\n var val = cue.val;\n var leftLimit = this._prevUpdateTime || 0;\n var rightLimit = playbackTime;\n if (leftLimit <= callbackTime && callbackTime <= rightLimit) {\n // pass the scheduled callbackTime as parameter to the callback\n cue.callback(val);\n }\n }\n\n this._prevUpdateTime = playbackTime;\n }\n\n /**\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\n * to download the file to their device. To upload a file to a server, see\n * getBlob\n *\n * @method save\n * @for p5.SoundFile\n * @param {String} [fileName] name of the resulting .wav file.\n * @example\n *
\n * let mySound;\n * function preload() {\n * mySound = loadSound('assets/doorbell.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to download', 10, 20);\n * }\n *\n * function canvasPressed() {\n * mySound.save('my cool filename');\n * }\n *
\n */\n save(fileName) {\n p5.prototype.saveSound(this, fileName, 'wav');\n }\n\n /**\n * This method is useful for sending a SoundFile to a server. It returns the\n * .wav-encoded audio data as a \"Blob\".\n * A Blob is a file-like data object that can be uploaded to a server\n * with an http request. We'll\n * use the `httpDo` options object to send a POST request with some\n * specific options: we encode the request as `multipart/form-data`,\n * and attach the blob as one of the form values using `FormData`.\n *\n *\n * @method getBlob\n * @for p5.SoundFile\n * @returns {Blob} A file-like data object\n * @example\n *
\n * function preload() {\n * mySound = loadSound('assets/doorbell.mp3');\n * }\n *\n * function setup() {\n * noCanvas();\n * let soundBlob = mySound.getBlob();\n *\n * // Now we can send the blob to a server...\n * let serverUrl = 'https://jsonplaceholder.typicode.com/posts';\n * let httpRequestOptions = {\n * method: 'POST',\n * body: new FormData().append('soundBlob', soundBlob),\n * headers: new Headers({\n * 'Content-Type': 'multipart/form-data'\n * })\n * };\n * httpDo(serverUrl, httpRequestOptions);\n *\n * // We can also create an `ObjectURL` pointing to the Blob\n * let blobUrl = URL.createObjectURL(soundBlob);\n *\n * // The `
\n */\n getBlob() {\n const dataView = convertToWav(this.buffer);\n return new Blob([dataView], { type: 'audio/wav' });\n }\n}\n\n/**\n * loadSound() returns a new p5.SoundFile from a specified\n * path. If called during preload(), the p5.SoundFile will be ready\n * to play in time for setup() and draw(). If called outside of\n * preload, the p5.SoundFile will not be ready immediately, so\n * loadSound accepts a callback as the second parameter. Using a\n * \n * local server is recommended when loading external files.\n *\n * @method loadSound\n * @for p5\n * @param {String|Array} path Path to the sound file, or an array with\n * paths to soundfiles in multiple formats\n * i.e. ['sound.ogg', 'sound.mp3'].\n * Alternately, accepts an object: either\n * from the HTML5 File API, or a p5.File.\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if there is\n * an error loading the file.\n * @param {Function} [whileLoading] Name of a function to call while file is loading.\n * This function will receive the percentage loaded\n * so far, from 0.0 to 1.0.\n * @return {SoundFile} Returns a p5.SoundFile\n * @example\n *
\n * let mySound;\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * mySound = loadSound('assets/doorbell');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap here to play', 10, 20);\n * }\n *\n * function canvasPressed() {\n * // playing a sound file on a user gesture\n * // is equivalent to `userStartAudio()`\n * mySound.play();\n * }\n *
\n */\nfunction loadSound(path, callback, onerror, whileLoading) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n window.alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n\n var self = this;\n var s = new SoundFile(\n path,\n function () {\n if (typeof callback === 'function') {\n callback.apply(self, arguments);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n },\n onerror,\n whileLoading\n );\n\n return s;\n}\n\nexport default SoundFile;\nexport { loadSound };\n","import p5sound from './master';\nimport { safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\n\n/**\n * Amplitude measures volume between 0.0 and 1.0.\n * Listens to all p5sound by default, or use setInput()\n * to listen to a specific sound source. Accepts an optional\n * smoothing value, which defaults to 0.\n *\n * @class p5.Amplitude\n * @constructor\n * @param {Number} [smoothing] between 0.0 and .999 to smooth\n * amplitude readings (defaults to 0)\n * @example\n *
\n * let sound, amplitude;\n *\n * function preload(){\n * sound = loadSound('assets/beat.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100,100);\n * cnv.mouseClicked(toggleSound);\n * amplitude = new p5.Amplitude();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 20, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function togglePlay() {\n * if (sound.isPlaying() ){\n * sound.pause();\n * } else {\n * sound.loop();\n *\t\tamplitude = new p5.Amplitude();\n *\t\tamplitude.setInput(sound);\n * }\n * }\n *\n *
\n */\nclass Amplitude {\n constructor(smoothing) {\n // Set to 2048 for now. In future iterations, this should be inherited or parsed from p5sound's default\n this.bufferSize = safeBufferSize(2048);\n\n // set audio context\n this.audiocontext = p5sound.audiocontext;\n this._workletNode = new AudioWorkletNode(\n this.audiocontext,\n processorNames.amplitudeProcessor,\n {\n outputChannelCount: [1],\n\n parameterData: { smoothing: smoothing || 0 },\n processorOptions: {\n normalize: false,\n smoothing: smoothing || 0,\n numInputChannels: 2,\n bufferSize: this.bufferSize,\n },\n }\n );\n\n this._workletNode.port.onmessage = function (event) {\n if (event.data.name === 'amplitude') {\n this.volume = event.data.volume;\n this.volNorm = event.data.volNorm;\n this.stereoVol = event.data.stereoVol;\n this.stereoVolNorm = event.data.stereoVolNorm;\n }\n }.bind(this);\n\n // for connections\n this.input = this._workletNode;\n\n this.output = this.audiocontext.createGain();\n\n // the variables to return\n this.volume = 0;\n this.volNorm = 0;\n this.stereoVol = [0, 0];\n this.stereoVolNorm = [0, 0];\n\n this.normalize = false;\n\n this._workletNode.connect(this.output);\n this.output.gain.value = 0;\n\n // this may only be necessary because of a Chrome bug\n this.output.connect(this.audiocontext.destination);\n\n // connect to p5sound master output by default, unless set by input()\n p5sound.meter.connect(this._workletNode);\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connects to the p5sound instance (master output) by default.\n * Optionally, you can pass in a specific source (i.e. a soundfile).\n *\n * @method setInput\n * @for p5.Amplitude\n * @param {soundObject|undefined} [snd] set the sound source\n * (optional, defaults to\n * master output)\n * @param {Number|undefined} [smoothing] a range between 0.0 and 1.0\n * to smooth amplitude readings\n * @example\n *
\n * function preload(){\n * sound1 = loadSound('assets/beat.mp3');\n * sound2 = loadSound('assets/drum.mp3');\n * }\n * function setup(){\n * cnv = createCanvas(100, 100);\n * cnv.mouseClicked(toggleSound);\n *\n * amplitude = new p5.Amplitude();\n * amplitude.setInput(sound2);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 20, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function toggleSound(){\n * if (sound1.isPlaying() && sound2.isPlaying()) {\n * sound1.stop();\n * sound2.stop();\n * } else {\n * sound1.play();\n * sound2.play();\n * }\n * }\n *
\n */\n setInput(source, smoothing) {\n p5sound.meter.disconnect();\n\n if (smoothing) {\n this._workletNode.parameters.get('smoothing').value = smoothing;\n }\n\n // connect to the master out of p5s instance if no snd is provided\n if (source == null) {\n console.log(\n 'Amplitude input source is not ready! Connecting to master output instead'\n );\n p5sound.meter.connect(this._workletNode);\n }\n\n // connect to the sound if it is available\n else if (source) {\n source.connect(this._workletNode);\n this._workletNode.disconnect();\n this._workletNode.connect(this.output);\n }\n\n // otherwise, connect to the master out of p5s instance (default)\n else {\n p5sound.meter.connect(this._workletNode);\n }\n }\n\n connect(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n } else {\n this.output.connect(unit);\n }\n } else {\n this.output.connect(this.panner.connect(p5sound.input));\n }\n }\n\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Returns a single Amplitude reading at the moment it is called.\n * For continuous readings, run in the draw loop.\n *\n * @method getLevel\n * @for p5.Amplitude\n * @param {Number} [channel] Optionally return only channel 0 (left) or 1 (right)\n * @return {Number} Amplitude as a number between 0.0 and 1.0\n * @example\n *
\n * function preload(){\n * sound = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mouseClicked(toggleSound);\n * amplitude = new p5.Amplitude();\n * }\n *\n * function draw() {\n * background(220, 150);\n * textAlign(CENTER);\n * text('tap to play', width/2, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function toggleSound(){\n * if (sound.isPlaying()) {\n * sound.stop();\n * } else {\n * sound.play();\n * }\n * }\n *
\n */\n getLevel(channel) {\n if (typeof channel !== 'undefined') {\n if (this.normalize) {\n return this.stereoVolNorm[channel];\n } else {\n return this.stereoVol[channel];\n }\n } else if (this.normalize) {\n return this.volNorm;\n } else {\n return this.volume;\n }\n }\n\n /**\n * Determines whether the results of Amplitude.process() will be\n * Normalized. To normalize, Amplitude finds the difference the\n * loudest reading it has processed and the maximum amplitude of\n * 1.0. Amplitude adds this difference to all values to produce\n * results that will reliably map between 0.0 and 1.0. However,\n * if a louder moment occurs, the amount that Normalize adds to\n * all the values will change. Accepts an optional boolean parameter\n * (true or false). Normalizing is off by default.\n *\n * @method toggleNormalize\n * @for p5.Amplitude\n * @param {boolean} [boolean] set normalize to true (1) or false (0)\n */\n toggleNormalize(bool) {\n if (typeof bool === 'boolean') {\n this.normalize = bool;\n } else {\n this.normalize = !this.normalize;\n }\n this._workletNode.port.postMessage({\n name: 'toggleNormalize',\n normalize: this.normalize,\n });\n }\n /**\n * Smooth Amplitude analysis by averaging with the last analysis\n * frame. Off by default.\n *\n * @method smooth\n * @for p5.Amplitude\n * @param {Number} set smoothing from 0.0 <= 1\n */\n smooth(s) {\n if (s >= 0 && s < 1) {\n this._workletNode.port.postMessage({ name: 'smoothing', smoothing: s });\n } else {\n console.log('Error: smoothing must be between 0 and 1');\n }\n }\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n\n this._workletNode.disconnect();\n delete this._workletNode;\n }\n}\n\nexport default Amplitude;\n","import p5sound from './master';\n\n/**\n *

FFT (Fast Fourier Transform) is an analysis algorithm that\n * isolates individual\n * \n * audio frequencies within a waveform.

\n *\n *

Once instantiated, a p5.FFT object can return an array based on\n * two types of analyses:
• FFT.waveform() computes\n * amplitude values along the time domain. The array indices correspond\n * to samples across a brief moment in time. Each value represents\n * amplitude of the waveform at that sample of time.
\n * • FFT.analyze() computes amplitude values along the\n * frequency domain. The array indices correspond to frequencies (i.e.\n * pitches), from the lowest to the highest that humans can hear. Each\n * value represents amplitude at that slice of the frequency spectrum.\n * Use with getEnergy() to measure amplitude at specific\n * frequencies, or within a range of frequencies.

\n *\n *

FFT analyzes a very short snapshot of sound called a sample\n * buffer. It returns an array of amplitude measurements, referred\n * to as bins. The array is 1024 bins long by default.\n * You can change the bin array length, but it must be a power of 2\n * between 16 and 1024 in order for the FFT algorithm to function\n * correctly. The actual size of the FFT buffer is twice the\n * number of bins, so given a standard sample rate, the buffer is\n * 2048/44100 seconds long.

\n *\n *\n * @class p5.FFT\n * @constructor\n * @param {Number} [smoothing] Smooth results of Freq Spectrum.\n * 0.0 < smoothing < 1.0.\n * Defaults to 0.8.\n * @param {Number} [bins] Length of resulting array.\n * Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @example\n *
\n * function preload(){\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup(){\n * let cnv = createCanvas(100,100);\n * cnv.mouseClicked(togglePlay);\n * fft = new p5.FFT();\n * sound.amp(0.2);\n * }\n *\n * function draw(){\n * background(220);\n *\n * let spectrum = fft.analyze();\n * noStroke();\n * fill(255, 0, 255);\n * for (let i = 0; i< spectrum.length; i++){\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width / spectrum.length, h )\n * }\n *\n * let waveform = fft.waveform();\n * noFill();\n * beginShape();\n * stroke(20);\n * for (let i = 0; i < waveform.length; i++){\n * let x = map(i, 0, waveform.length, 0, width);\n * let y = map( waveform[i], -1, 1, 0, height);\n * vertex(x,y);\n * }\n * endShape();\n *\n * text('tap to play', 20, 20);\n * }\n *\n * function togglePlay() {\n * if (sound.isPlaying()) {\n * sound.pause();\n * } else {\n * sound.loop();\n * }\n * }\n *
\n */\nclass FFT {\n constructor(smoothing, bins) {\n this.input = this.analyser = p5sound.audiocontext.createAnalyser();\n\n Object.defineProperties(this, {\n bins: {\n get: function () {\n return this.analyser.fftSize / 2;\n },\n set: function (b) {\n this.analyser.fftSize = b * 2;\n },\n configurable: true,\n enumerable: true,\n },\n smoothing: {\n get: function () {\n return this.analyser.smoothingTimeConstant;\n },\n set: function (s) {\n this.analyser.smoothingTimeConstant = s;\n },\n configurable: true,\n enumerable: true,\n },\n });\n\n // set default smoothing and bins\n this.smooth(smoothing);\n this.bins = bins || 1024;\n\n // default connections to p5sound fftMeter\n p5sound.fftMeter.connect(this.analyser);\n\n this.freqDomain = new Uint8Array(this.analyser.frequencyBinCount);\n this.timeDomain = new Uint8Array(this.analyser.frequencyBinCount);\n\n // predefined frequency ranges, these will be tweakable\n this.bass = [20, 140];\n this.lowMid = [140, 400];\n this.mid = [400, 2600];\n this.highMid = [2600, 5200];\n this.treble = [5200, 14000];\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Set the input source for the FFT analysis. If no source is\n * provided, FFT will analyze all sound in the sketch.\n *\n * @method setInput\n * @for p5.FFT\n * @param {Object} [source] p5.sound object (or web audio API source node)\n */\n setInput(source) {\n if (!source) {\n p5sound.fftMeter.connect(this.analyser);\n } else {\n if (source.output) {\n source.output.connect(this.analyser);\n } else if (source.connect) {\n source.connect(this.analyser);\n }\n p5sound.fftMeter.disconnect();\n }\n }\n\n /**\n * Returns an array of amplitude values (between -1.0 and +1.0) that represent\n * a snapshot of amplitude readings in a single buffer. Length will be\n * equal to bins (defaults to 1024). Can be used to draw the waveform\n * of a sound.\n *\n * @method waveform\n * @for p5.FFT\n * @param {Number} [bins] Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @param {String} [precision] If any value is provided, will return results\n * in a Float32 Array which is more precise\n * than a regular array.\n * @return {Array} Array Array of amplitude values (-1 to 1)\n * over time. Array length = bins.\n *\n */\n waveform() {\n var bins, mode;\n var normalArray = new Array();\n\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'number') {\n bins = arguments[i];\n this.analyser.fftSize = bins * 2;\n }\n if (typeof arguments[i] === 'string') {\n mode = arguments[i];\n }\n }\n\n // getFloatFrequencyData doesnt work in Safari as of 5/2015\n if (mode && !p5.prototype._isSafari()) {\n timeToFloat(this, this.timeDomain);\n this.analyser.getFloatTimeDomainData(this.timeDomain);\n return this.timeDomain;\n } else {\n timeToInt(this, this.timeDomain);\n this.analyser.getByteTimeDomainData(this.timeDomain);\n for (var j = 0; j < this.timeDomain.length; j++) {\n var scaled = p5.prototype.map(this.timeDomain[j], 0, 255, -1, 1);\n normalArray.push(scaled);\n }\n return normalArray;\n }\n }\n\n /**\n * Returns an array of amplitude values (between 0 and 255)\n * across the frequency spectrum. Length is equal to FFT bins\n * (1024 by default). The array indices correspond to frequencies\n * (i.e. pitches), from the lowest to the highest that humans can\n * hear. Each value represents amplitude at that slice of the\n * frequency spectrum. Must be called prior to using\n * getEnergy().\n *\n * @method analyze\n * @for p5.FFT\n * @param {Number} [bins] Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @param {Number} [scale] If \"dB,\" returns decibel\n * float measurements between\n * -140 and 0 (max).\n * Otherwise returns integers from 0-255.\n * @return {Array} spectrum Array of energy (amplitude/volume)\n * values across the frequency spectrum.\n * Lowest energy (silence) = 0, highest\n * possible is 255.\n * @example\n *
\n * let osc, fft;\n *\n * function setup(){\n * let cnv = createCanvas(100,100);\n * cnv.mousePressed(startSound);\n * osc = new p5.Oscillator();\n * osc.amp(0);\n * fft = new p5.FFT();\n * }\n *\n * function draw(){\n * background(220);\n *\n * let freq = map(mouseX, 0, windowWidth, 20, 10000);\n * freq = constrain(freq, 1, 20000);\n * osc.freq(freq);\n *\n * let spectrum = fft.analyze();\n * noStroke();\n * fill(255, 0, 255);\n * for (let i = 0; i< spectrum.length; i++){\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width / spectrum.length, h );\n * }\n *\n * stroke(255);\n * if (!osc.started) {\n * text('tap here and drag to change frequency', 10, 20, width - 20);\n * } else {\n * text(round(freq)+'Hz', 10, 20);\n * }\n * }\n *\n * function startSound() {\n * osc.start();\n * osc.amp(0.5, 0.2);\n * }\n *\n * function mouseReleased() {\n * osc.amp(0, 0.2);\n * }\n *
\n *\n *\n */\n analyze() {\n var mode;\n\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'number') {\n this.bins = arguments[i];\n this.analyser.fftSize = this.bins * 2;\n }\n if (typeof arguments[i] === 'string') {\n mode = arguments[i];\n }\n }\n\n if (mode && mode.toLowerCase() === 'db') {\n freqToFloat(this);\n this.analyser.getFloatFrequencyData(this.freqDomain);\n return this.freqDomain;\n } else {\n freqToInt(this, this.freqDomain);\n this.analyser.getByteFrequencyData(this.freqDomain);\n var normalArray = Array.apply([], this.freqDomain);\n\n return normalArray;\n }\n }\n\n /**\n * Returns the amount of energy (volume) at a specific\n * \n * frequency, or the average amount of energy between two\n * frequencies. Accepts Number(s) corresponding\n * to frequency (in Hz), or a \"string\" corresponding to predefined\n * frequency ranges (\"bass\", \"lowMid\", \"mid\", \"highMid\", \"treble\").\n * Returns a range between 0 (no energy/volume at that frequency) and\n * 255 (maximum energy).\n * NOTE: analyze() must be called prior to getEnergy(). analyze()\n * tells the FFT to analyze frequency data, and getEnergy() uses\n * the results to determine the value at a specific frequency or\n * range of frequencies.

\n *\n * @method getEnergy\n * @for p5.FFT\n * @param {Number|String} frequency1 Will return a value representing\n * energy at this frequency. Alternately,\n * the strings \"bass\", \"lowMid\" \"mid\",\n * \"highMid\", and \"treble\" will return\n * predefined frequency ranges.\n * @param {Number} [frequency2] If a second frequency is given,\n * will return average amount of\n * energy that exists between the\n * two frequencies.\n * @return {Number} Energy Energy (volume/amplitude) from\n * 0 and 255.\n *\n */\n getEnergy(frequency1, frequency2) {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n\n if (frequency1 === 'bass') {\n frequency1 = this.bass[0];\n frequency2 = this.bass[1];\n } else if (frequency1 === 'lowMid') {\n frequency1 = this.lowMid[0];\n frequency2 = this.lowMid[1];\n } else if (frequency1 === 'mid') {\n frequency1 = this.mid[0];\n frequency2 = this.mid[1];\n } else if (frequency1 === 'highMid') {\n frequency1 = this.highMid[0];\n frequency2 = this.highMid[1];\n } else if (frequency1 === 'treble') {\n frequency1 = this.treble[0];\n frequency2 = this.treble[1];\n }\n\n if (typeof frequency1 !== 'number') {\n throw 'invalid input for getEnergy()';\n } else if (!frequency2) {\n // if only one parameter:\n var index = Math.round((frequency1 / nyquist) * this.freqDomain.length);\n return this.freqDomain[index];\n } else if (frequency1 && frequency2) {\n // if two parameters:\n // if second is higher than first\n if (frequency1 > frequency2) {\n var swap = frequency2;\n frequency2 = frequency1;\n frequency1 = swap;\n }\n var lowIndex = Math.round(\n (frequency1 / nyquist) * this.freqDomain.length\n );\n var highIndex = Math.round(\n (frequency2 / nyquist) * this.freqDomain.length\n );\n\n var total = 0;\n var numFrequencies = 0;\n // add up all of the values for the frequencies\n for (var i = lowIndex; i <= highIndex; i++) {\n total += this.freqDomain[i];\n numFrequencies += 1;\n }\n // divide by total number of frequencies\n var toReturn = total / numFrequencies;\n return toReturn;\n } else {\n throw 'invalid input for getEnergy()';\n }\n }\n\n // compatability with v.012, changed to getEnergy in v.0121. Will be deprecated...\n getFreq(freq1, freq2) {\n console.log('getFreq() is deprecated. Please use getEnergy() instead.');\n var x = this.getEnergy(freq1, freq2);\n return x;\n }\n\n /**\n * Returns the\n * \n * spectral centroid of the input signal.\n * NOTE: analyze() must be called prior to getCentroid(). Analyze()\n * tells the FFT to analyze frequency data, and getCentroid() uses\n * the results determine the spectral centroid.

\n *\n * @method getCentroid\n * @for p5.FFT\n * @return {Number} Spectral Centroid Frequency of the spectral centroid in Hz.\n *\n *\n * @example\n *
\n * function setup(){\n * cnv = createCanvas(100,100);\n * cnv.mousePressed(userStartAudio);\n * sound = new p5.AudioIn();\n * sound.start();\n * fft = new p5.FFT();\n * sound.connect(fft);\n *}\n *\n *function draw() {\n * if (getAudioContext().state !== 'running') {\n * background(220);\n * text('tap here and enable mic to begin', 10, 20, width - 20);\n * return;\n * }\n * let centroidplot = 0.0;\n * let spectralCentroid = 0;\n *\n * background(0);\n * stroke(0,255,0);\n * let spectrum = fft.analyze();\n * fill(0,255,0); // spectrum is green\n *\n * //draw the spectrum\n * for (let i = 0; i < spectrum.length; i++){\n * let x = map(log(i), 0, log(spectrum.length), 0, width);\n * let h = map(spectrum[i], 0, 255, 0, height);\n * let rectangle_width = (log(i+1)-log(i))*(width/log(spectrum.length));\n * rect(x, height, rectangle_width, -h )\n * }\n * let nyquist = 22050;\n *\n * // get the centroid\n * spectralCentroid = fft.getCentroid();\n *\n * // the mean_freq_index calculation is for the display.\n * let mean_freq_index = spectralCentroid/(nyquist/spectrum.length);\n *\n * centroidplot = map(log(mean_freq_index), 0, log(spectrum.length), 0, width);\n *\n * stroke(255,0,0); // the line showing where the centroid is will be red\n *\n * rect(centroidplot, 0, width / spectrum.length, height)\n * noStroke();\n * fill(255,255,255); // text is white\n * text('centroid: ', 10, 20);\n * text(round(spectralCentroid)+' Hz', 10, 40);\n *}\n *
\n */\n getCentroid() {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n var cumulative_sum = 0;\n var centroid_normalization = 0;\n\n for (var i = 0; i < this.freqDomain.length; i++) {\n cumulative_sum += i * this.freqDomain[i];\n centroid_normalization += this.freqDomain[i];\n }\n\n var mean_freq_index = 0;\n\n if (centroid_normalization !== 0) {\n mean_freq_index = cumulative_sum / centroid_normalization;\n }\n\n var spec_centroid_freq =\n mean_freq_index * (nyquist / this.freqDomain.length);\n return spec_centroid_freq;\n }\n\n /**\n * Smooth FFT analysis by averaging with the last analysis frame.\n *\n * @method smooth\n * @param {Number} smoothing 0.0 < smoothing < 1.0.\n * Defaults to 0.8.\n */\n smooth(s) {\n if (typeof s !== 'undefined') {\n this.smoothing = s;\n }\n return this.smoothing;\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.analyser) {\n this.analyser.disconnect();\n delete this.analyser;\n }\n }\n\n /**\n * Returns an array of average amplitude values for a given number\n * of frequency bands split equally. N defaults to 16.\n * NOTE: analyze() must be called prior to linAverages(). Analyze()\n * tells the FFT to analyze frequency data, and linAverages() uses\n * the results to group them into a smaller set of averages.

\n *\n * @method linAverages\n * @for p5.FFT\n * @param {Number} N Number of returned frequency groups\n * @return {Array} linearAverages Array of average amplitude values for each group\n */\n\n linAverages(_N) {\n var N = _N || 16; // This prevents undefined, null or 0 values of N\n\n var spectrum = this.freqDomain;\n var spectrumLength = spectrum.length;\n var spectrumStep = Math.floor(spectrumLength / N);\n\n var linearAverages = new Array(N);\n // Keep a second index for the current average group and place the values accordingly\n // with only one loop in the spectrum data\n var groupIndex = 0;\n\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\n linearAverages[groupIndex] =\n linearAverages[groupIndex] !== undefined\n ? (linearAverages[groupIndex] + spectrum[specIndex]) / 2\n : spectrum[specIndex];\n\n // Increase the group index when the last element of the group is processed\n if (specIndex % spectrumStep === spectrumStep - 1) {\n groupIndex++;\n }\n }\n\n return linearAverages;\n }\n\n /**\n * Returns an array of average amplitude values of the spectrum, for a given\n * set of \n * Octave Bands\n * NOTE: analyze() must be called prior to logAverages(). Analyze()\n * tells the FFT to analyze frequency data, and logAverages() uses\n * the results to group them into a smaller set of averages.

\n *\n * @method logAverages\n * @for p5.FFT\n * @param {Array} octaveBands Array of Octave Bands objects for grouping\n * @return {Array} logAverages Array of average amplitude values for each group\n */\n logAverages(octaveBands) {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n var spectrum = this.freqDomain;\n var spectrumLength = spectrum.length;\n\n var logAverages = new Array(octaveBands.length);\n // Keep a second index for the current average group and place the values accordingly\n // With only one loop in the spectrum data\n var octaveIndex = 0;\n\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\n var specIndexFrequency = Math.round(\n (specIndex * nyquist) / this.freqDomain.length\n );\n\n // Increase the group index if the current frequency exceeds the limits of the band\n if (specIndexFrequency > octaveBands[octaveIndex].hi) {\n octaveIndex++;\n }\n\n logAverages[octaveIndex] =\n logAverages[octaveIndex] !== undefined\n ? (logAverages[octaveIndex] + spectrum[specIndex]) / 2\n : spectrum[specIndex];\n }\n\n return logAverages;\n }\n\n /**\n * Calculates and Returns the 1/N\n * Octave Bands\n * N defaults to 3 and minimum central frequency to 15.625Hz.\n * (1/3 Octave Bands ~= 31 Frequency Bands)\n * Setting fCtr0 to a central value of a higher octave will ignore the lower bands\n * and produce less frequency groups.\n *\n * @method getOctaveBands\n * @for p5.FFT\n * @param {Number} N Specifies the 1/N type of generated octave bands\n * @param {Number} fCtr0 Minimum central frequency for the lowest band\n * @return {Array} octaveBands Array of octave band objects with their bounds\n */\n getOctaveBands(_N, _fCtr0) {\n var N = _N || 3; // Default to 1/3 Octave Bands\n var fCtr0 = _fCtr0 || 15.625; // Minimum central frequency, defaults to 15.625Hz\n\n var octaveBands = [];\n var lastFrequencyBand = {\n lo: fCtr0 / Math.pow(2, 1 / (2 * N)),\n ctr: fCtr0,\n hi: fCtr0 * Math.pow(2, 1 / (2 * N)),\n };\n octaveBands.push(lastFrequencyBand);\n\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n while (lastFrequencyBand.hi < nyquist) {\n var newFrequencyBand = {};\n newFrequencyBand.lo = lastFrequencyBand.hi;\n newFrequencyBand.ctr = lastFrequencyBand.ctr * Math.pow(2, 1 / N);\n newFrequencyBand.hi = newFrequencyBand.ctr * Math.pow(2, 1 / (2 * N));\n\n octaveBands.push(newFrequencyBand);\n lastFrequencyBand = newFrequencyBand;\n }\n\n return octaveBands;\n }\n}\n\n// helper methods to convert type from float (dB) to int (0-255)\nfunction freqToFloat(fft) {\n if (fft.freqDomain instanceof Float32Array === false) {\n fft.freqDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction freqToInt(fft) {\n if (fft.freqDomain instanceof Uint8Array === false) {\n fft.freqDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction timeToFloat(fft) {\n if (fft.timeDomain instanceof Float32Array === false) {\n fft.timeDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction timeToInt(fft) {\n if (fft.timeDomain instanceof Uint8Array === false) {\n fft.timeDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n}\n\nexport default FFT;\n","import p5sound from './master';\nimport Add from 'Tone/signal/Add';\nimport Mult from 'Tone/signal/Multiply';\nimport Scale from 'Tone/signal/Scale';\nimport Panner from './panner';\n// ========================== //\n// SIGNAL MATH FOR MODULATION //\n// ========================== //\n\n// return sigChain(this, scale, thisChain, nextChain, Scale);\nfunction sigChain(o, mathObj, thisChain, nextChain, type) {\n var chainSource = o.oscillator;\n // if this type of math already exists in the chain, replace it\n for (var i in o.mathOps) {\n if (o.mathOps[i] instanceof type) {\n chainSource.disconnect();\n o.mathOps[i].dispose();\n thisChain = i;\n // assume nextChain is output gain node unless...\n if (thisChain < o.mathOps.length - 2) {\n nextChain = o.mathOps[i + 1];\n }\n }\n }\n if (thisChain === o.mathOps.length - 1) {\n o.mathOps.push(nextChain);\n }\n // assume source is the oscillator unless i > 0\n if (i > 0) {\n chainSource = o.mathOps[i - 1];\n }\n chainSource.disconnect();\n chainSource.connect(mathObj);\n mathObj.connect(nextChain);\n o.mathOps[thisChain] = mathObj;\n return o;\n}\n\n/**\n *

Creates a signal that oscillates between -1.0 and 1.0.\n * By default, the oscillation takes the form of a sinusoidal\n * shape ('sine'). Additional types include 'triangle',\n * 'sawtooth' and 'square'. The frequency defaults to\n * 440 oscillations per second (440Hz, equal to the pitch of an\n * 'A' note).

\n *\n *

Set the type of oscillation with setType(), or by instantiating a\n * specific oscillator: p5.SinOsc, p5.TriOsc, p5.SqrOsc, or p5.SawOsc.\n *

\n *\n * @class p5.Oscillator\n * @constructor\n * @param {Number} [freq] frequency defaults to 440Hz\n * @param {String} [type] type of oscillator. Options:\n * 'sine' (default), 'triangle',\n * 'sawtooth', 'square'\n * @example\n *
\n * let osc, playing, freq, amp;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playOscillator);\n * osc = new p5.Oscillator('sine');\n * }\n *\n * function draw() {\n * background(220)\n * freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\n * amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\n *\n * text('tap to play', 20, 20);\n * text('freq: ' + freq, 20, 40);\n * text('amp: ' + amp, 20, 60);\n *\n * if (playing) {\n * // smooth the transitions by 0.1 seconds\n * osc.freq(freq, 0.1);\n * osc.amp(amp, 0.1);\n * }\n * }\n *\n * function playOscillator() {\n * // starting an oscillator on a user gesture will enable audio\n * // in browsers that have a strict autoplay policy.\n * // See also: userStartAudio();\n * osc.start();\n * playing = true;\n * }\n *\n * function mouseReleased() {\n * // ramp amplitude to 0 over 0.5 seconds\n * osc.amp(0, 0.5);\n * playing = false;\n * }\n *
\n */\nclass Oscillator {\n constructor(freq, type) {\n if (typeof freq === 'string') {\n let f = type;\n type = freq;\n freq = f;\n }\n if (typeof type === 'number') {\n let f = type;\n type = freq;\n freq = f;\n }\n this.started = false;\n\n // components\n this.phaseAmount = undefined;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.f = freq || 440.0; // frequency\n this.oscillator.type = type || 'sine';\n this.oscillator.frequency.setValueAtTime(\n this.f,\n p5sound.audiocontext.currentTime\n );\n\n // connections\n this.output = p5sound.audiocontext.createGain();\n\n this._freqMods = []; // modulators connected to this oscillator's frequency\n\n // set default output gain to 0.5\n this.output.gain.value = 0.5;\n this.output.gain.setValueAtTime(0.5, p5sound.audiocontext.currentTime);\n\n this.oscillator.connect(this.output);\n // stereo panning\n this.panPosition = 0.0;\n this.connection = p5sound.input; // connect to p5sound by default\n this.panner = new Panner(this.output, this.connection, 1);\n\n //array of math operation signal chaining\n this.mathOps = [this.output];\n\n // add to the soundArray so we can dispose of the osc later\n p5sound.soundArray.push(this);\n\n // these methods are now the same thing\n this.fade = this.amp;\n }\n\n /**\n * Start an oscillator.\n *\n * Starting an oscillator on a user gesture will enable audio in browsers\n * that have a strict autoplay policy, including Chrome and most mobile\n * devices. See also: `userStartAudio()`.\n *\n * @method start\n * @for p5.Oscillator\n * @param {Number} [time] startTime in seconds from now.\n * @param {Number} [frequency] frequency in Hz.\n */\n start(time, f) {\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n }\n if (!this.started) {\n var freq = f || this.f;\n var type = this.oscillator.type;\n\n // set old osc free to be garbage collected (memory)\n if (this.oscillator) {\n this.oscillator.disconnect();\n delete this.oscillator;\n }\n\n // var detune = this.oscillator.frequency.value;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.oscillator.frequency.value = Math.abs(freq);\n this.oscillator.type = type;\n // this.oscillator.detune.value = detune;\n this.oscillator.connect(this.output);\n time = time || 0;\n this.oscillator.start(time + p5sound.audiocontext.currentTime);\n this.freqNode = this.oscillator.frequency;\n\n // if other oscillators are already connected to this osc's freq\n for (var i in this._freqMods) {\n if (typeof this._freqMods[i].connect !== 'undefined') {\n this._freqMods[i].connect(this.oscillator.frequency);\n }\n }\n\n this.started = true;\n }\n }\n\n /**\n * Stop an oscillator. Accepts an optional parameter\n * to determine how long (in seconds from now) until the\n * oscillator stops.\n *\n * @method stop\n * @for p5.Oscillator\n * @param {Number} secondsFromNow Time, in seconds from now.\n */\n stop(time) {\n if (this.started) {\n var t = time || 0;\n var now = p5sound.audiocontext.currentTime;\n this.oscillator.stop(t + now);\n this.started = false;\n }\n }\n\n /**\n * Set the amplitude between 0 and 1.0. Or, pass in an object\n * such as an oscillator to modulate amplitude with an audio signal.\n *\n * @method amp\n * @for p5.Oscillator\n * @param {Number|Object} vol between 0 and 1.0\n * or a modulating signal/oscillator\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {AudioParam} gain If no value is provided,\n * returns the Web Audio API\n * AudioParam that controls\n * this oscillator's\n * gain/amplitude/volume)\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n if (typeof vol === 'number') {\n var now = p5sound.audiocontext.currentTime;\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(this.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n }\n\n /**\n * Returns the value of output gain\n *\n * @method getAmp\n * @for p5.Oscillator\n *\n * @returns {number} Amplitude value between 0.0 and 1.0\n */\n\n getAmp() {\n return this.output.gain.value;\n }\n\n /**\n * Set frequency of an oscillator to a value. Or, pass in an object\n * such as an oscillator to modulate the frequency with an audio signal.\n *\n * @method freq\n * @for p5.Oscillator\n * @param {Number|Object} Frequency Frequency in Hz\n * or modulating signal/oscillator\n * @param {Number} [rampTime] Ramp time (in seconds)\n * @param {Number} [timeFromNow] Schedule this event to happen\n * at x seconds from now\n * @return {AudioParam} Frequency If no value is provided,\n * returns the Web Audio API\n * AudioParam that controls\n * this oscillator's frequency\n * @example\n *
\n * let osc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playOscillator);\n * osc = new p5.Oscillator(300);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playOscillator() {\n * osc.start();\n * osc.amp(0.5);\n * // start at 700Hz\n * osc.freq(700);\n * // ramp to 60Hz over 0.7 seconds\n * osc.freq(60, 0.7);\n * osc.amp(0, 0.1, 0.7);\n * }\n *
\n */\n freq(val, rampTime = 0, tFromNow = 0) {\n if (typeof val === 'number' && !isNaN(val)) {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n\n if (rampTime === 0) {\n this.oscillator.frequency.setValueAtTime(val, tFromNow + now);\n } else {\n if (val > 0) {\n this.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n } else {\n this.oscillator.frequency.linearRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n }\n }\n\n // reset phase if oscillator has a phase\n if (this.phaseAmount) {\n this.phase(this.phaseAmount);\n }\n } else if (val) {\n if (val.output) {\n val = val.output;\n }\n val.connect(this.oscillator.frequency);\n\n // keep track of what is modulating this param\n // so it can be re-connected if\n this._freqMods.push(val);\n } else {\n // return the Frequency Node\n return this.oscillator.frequency;\n }\n }\n /**\n * Returns the value of frequency of oscillator\n *\n * @method getFreq\n * @for p5.Oscillator\n * @returns {number} Frequency of oscillator in Hertz\n */\n\n getFreq() {\n return this.oscillator.frequency.value;\n }\n\n /**\n * Set type to 'sine', 'triangle', 'sawtooth' or 'square'.\n *\n * @method setType\n * @for p5.Oscillator\n * @param {String} type 'sine', 'triangle', 'sawtooth' or 'square'.\n */\n setType(type) {\n this.oscillator.type = type;\n }\n /**\n * Returns current type of oscillator eg. 'sine', 'triangle', 'sawtooth' or 'square'.\n *\n * @method getType\n * @for p5.Oscillator\n * @returns {String} type of oscillator eg . 'sine', 'triangle', 'sawtooth' or 'square'.\n */\n\n getType() {\n return this.oscillator.type;\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.Oscillator\n * @param {Object} unit A p5.sound or Web Audio object\n */\n connect(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n } else if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n this.connection = unit.input;\n } else {\n this.panner.connect(unit);\n this.connection = unit;\n }\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.Oscillator\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n if (this.panner) {\n this.panner.disconnect();\n if (this.output) {\n this.output.connect(this.panner);\n }\n }\n this.oscMods = [];\n }\n\n /**\n * Pan between Left (-1) and Right (1)\n *\n * @method pan\n * @for p5.Oscillator\n * @param {Number} panning Number between -1 and 1\n * @param {Number} timeFromNow schedule this event to happen\n * seconds from now\n */\n pan(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n }\n\n /**\n * Returns the current value of panPosition , between Left (-1) and Right (1)\n *\n * @method getPan\n * @for p5.Oscillator\n *\n * @returns {number} panPosition of oscillator , between Left (-1) and Right (1)\n */\n\n getPan() {\n return this.panPosition;\n }\n\n // get rid of the oscillator\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.oscillator) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.disconnect();\n this.panner = null;\n this.oscillator = null;\n }\n // if it is a Pulse\n if (this.osc2) {\n this.osc2.dispose();\n }\n }\n\n /**\n * Set the phase of an oscillator between 0.0 and 1.0.\n * In this implementation, phase is a delay time\n * based on the oscillator's current frequency.\n *\n * @method phase\n * @for p5.Oscillator\n * @param {Number} phase float between 0.0 and 1.0\n */\n phase(p) {\n var delayAmt = p5.prototype.map(p, 0, 1.0, 0, 1 / this.f);\n var now = p5sound.audiocontext.currentTime;\n\n this.phaseAmount = p;\n\n if (!this.dNode) {\n // create a delay node\n this.dNode = p5sound.audiocontext.createDelay();\n // put the delay node in between output and panner\n this.oscillator.disconnect();\n this.oscillator.connect(this.dNode);\n this.dNode.connect(this.output);\n }\n\n // set delay time to match phase:\n this.dNode.delayTime.setValueAtTime(delayAmt, now);\n }\n\n /**\n * Add a value to the p5.Oscillator's output amplitude,\n * and return the oscillator. Calling this method again\n * will override the initial add() with a new value.\n *\n * @method add\n * @for p5.Oscillator\n * @param {Number} number Constant number to add\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with scaled output\n *\n */\n add(num) {\n var add = new Add(num);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, add, thisChain, nextChain, Add);\n }\n /**\n * Multiply the p5.Oscillator's output amplitude\n * by a fixed value (i.e. turn it up!). Calling this method\n * again will override the initial mult() with a new value.\n *\n * @method mult\n * @for p5.Oscillator\n * @param {Number} number Constant number to multiply\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with multiplied output\n */\n mult(num) {\n var mult = new Mult(num);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, mult, thisChain, nextChain, Mult);\n }\n\n /**\n * Scale this oscillator's amplitude values to a given\n * range, and return the oscillator. Calling this method\n * again will override the initial scale() with new values.\n *\n * @method scale\n * @for p5.Oscillator\n * @param {Number} inMin input range minumum\n * @param {Number} inMax input range maximum\n * @param {Number} outMin input range minumum\n * @param {Number} outMax input range maximum\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with scaled output\n */\n scale(inMin, inMax, outMin, outMax) {\n var mapOutMin, mapOutMax;\n if (arguments.length === 4) {\n mapOutMin = p5.prototype.map(outMin, inMin, inMax, 0, 1) - 0.5; //find a way to get rid of p5.prototype ?\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5; //find a way to get rid of p5.prototype ?\n } else {\n mapOutMin = arguments[0];\n mapOutMax = arguments[1];\n }\n var scale = new Scale(mapOutMin, mapOutMax);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, scale, thisChain, nextChain, Scale);\n\n // this.output.disconnect();\n // this.output.connect(scale)\n }\n}\n\n// ============================== //\n// SinOsc, TriOsc, SqrOsc, SawOsc //\n// ============================== //\n\n/**\n * Constructor: new p5.SinOsc().\n * This creates a Sine Wave Oscillator and is\n * equivalent to new p5.Oscillator('sine')\n * or creating a p5.Oscillator and then calling\n * its method setType('sine').\n * See p5.Oscillator for methods.\n *\n * @class p5.SinOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SinOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'sine');\n }\n}\n\n/**\n * Constructor: new p5.TriOsc().\n * This creates a Triangle Wave Oscillator and is\n * equivalent to new p5.Oscillator('triangle')\n * or creating a p5.Oscillator and then calling\n * its method setType('triangle').\n * See p5.Oscillator for methods.\n *\n * @class p5.TriOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass TriOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'triangle');\n }\n}\n\n/**\n * Constructor: new p5.SawOsc().\n * This creates a SawTooth Wave Oscillator and is\n * equivalent to new p5.Oscillator('sawtooth')\n * or creating a p5.Oscillator and then calling\n * its method setType('sawtooth').\n * See p5.Oscillator for methods.\n *\n * @class p5.SawOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SawOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'sawtooth');\n }\n}\n\n/**\n * Constructor: new p5.SqrOsc().\n * This creates a Square Wave Oscillator and is\n * equivalent to new p5.Oscillator('square')\n * or creating a p5.Oscillator and then calling\n * its method setType('square').\n * See p5.Oscillator for methods.\n *\n * @class p5.SqrOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SqrOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'square');\n }\n}\n\nexport default Oscillator;\nexport { SinOsc, TriOsc, SawOsc, SqrOsc };\n","import p5sound from './master';\nimport Add from 'Tone/signal/Add';\nimport Mult from 'Tone/signal/Multiply';\nimport Scale from 'Tone/signal/Scale';\nimport TimelineSignal from 'Tone/signal/TimelineSignal.js';\n\n/**\n *

Envelopes are pre-defined amplitude distribution over time.\n * Typically, envelopes are used to control the output volume\n * of an object, a series of fades referred to as Attack, Decay,\n * Sustain and Release (\n * ADSR\n * ). Envelopes can also control other Web Audio Parameters—for example, a p5.Envelope can\n * control an Oscillator's frequency like this: osc.freq(env).

\n *

Use setRange to change the attack/release level.\n * Use setADSR to change attackTime, decayTime, sustainPercent and releaseTime.

\n *

Use the play method to play the entire envelope,\n * the ramp method for a pingable trigger,\n * or triggerAttack/\n * triggerRelease to trigger noteOn/noteOff.

\n *\n * @class p5.Envelope\n * @constructor\n * @example\n *
\n * let t1 = 0.1; // attack time in seconds\n * let l1 = 0.7; // attack level 0.0 to 1.0\n * let t2 = 0.3; // decay time in seconds\n * let l2 = 0.1; // decay level 0.0 to 1.0\n *\n * let env;\n * let triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * text('tap to play', 20, 20);\n * cnv.mousePressed(playSound);\n *\n * env = new p5.Envelope(t1, l1, t2, l2);\n * triOsc = new p5.Oscillator('triangle');\n * }\n *\n * function playSound() {\n * // starting the oscillator ensures that audio is enabled.\n * triOsc.start();\n * env.play(triOsc);\n * }\n *
\n */\np5.Envelope = function (t1, l1, t2, l2, t3, l3) {\n /**\n * Time until envelope reaches attackLevel\n * @property attackTime\n */\n this.aTime = t1 || 0.1;\n /**\n * Level once attack is complete.\n * @property attackLevel\n */\n this.aLevel = l1 || 1;\n /**\n * Time until envelope reaches decayLevel.\n * @property decayTime\n */\n this.dTime = t2 || 0.5;\n /**\n * Level after decay. The envelope will sustain here until it is released.\n * @property decayLevel\n */\n this.dLevel = l2 || 0;\n /**\n * Duration of the release portion of the envelope.\n * @property releaseTime\n */\n this.rTime = t3 || 0;\n /**\n * Level at the end of the release.\n * @property releaseLevel\n */\n this.rLevel = l3 || 0;\n\n this._rampHighPercentage = 0.98;\n\n this._rampLowPercentage = 0.02;\n\n this.output = p5sound.audiocontext.createGain();\n\n this.control = new TimelineSignal();\n\n this._init(); // this makes sure the envelope starts at zero\n\n this.control.connect(this.output); // connect to the output\n\n this.connection = null; // store connection\n\n //array of math operation signal chaining\n this.mathOps = [this.control];\n\n //whether envelope should be linear or exponential curve\n this.isExponential = false;\n\n // oscillator or buffer source to clear on env complete\n // to save resources if/when it is retriggered\n this.sourceToClear = null;\n\n // set to true if attack is set, then false on release\n this.wasTriggered = false;\n\n // add to the soundArray so we can dispose of the env later\n p5sound.soundArray.push(this);\n};\n\n// this init function just smooths the starting value to zero and gives a start point for the timeline\n// - it was necessary to remove glitches at the beginning.\np5.Envelope.prototype._init = function () {\n var now = p5sound.audiocontext.currentTime;\n var t = now;\n this.control.setTargetAtTime(0.00001, t, 0.001);\n //also, compute the correct time constants\n this._setRampAD(this.aTime, this.dTime);\n};\n\n/**\n * Reset the envelope with a series of time/value pairs.\n *\n * @method set\n * @for p5.Envelope\n * @param {Number} attackTime Time (in seconds) before level\n * reaches attackLevel\n * @param {Number} attackLevel Typically an amplitude between\n * 0.0 and 1.0\n * @param {Number} decayTime Time\n * @param {Number} decayLevel Amplitude (In a standard ADSR envelope,\n * decayLevel = sustainLevel)\n * @param {Number} releaseTime Release Time (in seconds)\n * @param {Number} releaseLevel Amplitude\n * @example\n *
\n * let attackTime;\n * let l1 = 0.7; // attack level 0.0 to 1.0\n * let t2 = 0.3; // decay time in seconds\n * let l2 = 0.1; // decay level 0.0 to 1.0\n * let l3 = 0.2; // release time in seconds\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n *\n * attackTime = map(mouseX, 0, width, 0.0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 20);\n * }\n *\n * // mouseClick triggers envelope if over canvas\n * function playSound() {\n * env.set(attackTime, l1, t2, l2, l3);\n *\n * triOsc.start();\n * env.play(triOsc);\n * }\n *
\n *\n */\np5.Envelope.prototype.set = function (t1, l1, t2, l2, t3, l3) {\n this.aTime = t1;\n this.aLevel = l1;\n this.dTime = t2 || 0;\n this.dLevel = l2 || 0;\n this.rTime = t3 || 0;\n this.rLevel = l3 || 0;\n\n // set time constants for ramp\n this._setRampAD(t1, t2);\n};\n\n/**\n * Set values like a traditional\n * \n * ADSR envelope\n * .\n *\n * @method setADSR\n * @for p5.Envelope\n * @param {Number} attackTime Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackTime = map(mouseX, 0, width, 0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 40);\n * }\n *\n * function playEnv() {\n * triOsc.start();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.setADSR = function (aTime, dTime, sPercent, rTime) {\n this.aTime = aTime;\n this.dTime = dTime || 0;\n\n // lerp\n this.sPercent = sPercent || 0;\n this.dLevel =\n typeof sPercent !== 'undefined'\n ? sPercent * (this.aLevel - this.rLevel) + this.rLevel\n : 0;\n\n this.rTime = rTime || 0;\n\n // also set time constants for ramp\n this._setRampAD(aTime, dTime);\n};\n\n/**\n * Set max (attackLevel) and min (releaseLevel) of envelope.\n *\n * @method setRange\n * @for p5.Envelope\n * @param {Number} aLevel attack level (defaults to 1)\n * @param {Number} rLevel release level (defaults to 0)\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackLevel = map(mouseY, height, 0, 0, 1.0);\n * text('attack level: ' + attackLevel, 5, height - 20);\n * }\n *\n * function playEnv() {\n * triOsc.start();\n * env.setRange(attackLevel, releaseLevel);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.setRange = function (aLevel, rLevel) {\n this.aLevel = aLevel || 1;\n this.rLevel = rLevel || 0;\n\n // not sure if this belongs here:\n\n // {Number} [dLevel] decay/sustain level (optional)\n // if (typeof(dLevel) !== 'undefined') {\n // this.dLevel = dLevel\n // } else if (this.sPercent) {\n // this.dLevel = this.sPercent ? this.sPercent * (this.aLevel - this.rLevel) + this.rLevel : 0;\n // }\n};\n\n// private (undocumented) method called when ADSR is set to set time constants for ramp\n//\n// Set the \n// time constants for simple exponential ramps.\n// The larger the time constant value, the slower the\n// transition will be.\n//\n// method _setRampAD\n// param {Number} attackTimeConstant attack time constant\n// param {Number} decayTimeConstant decay time constant\n//\np5.Envelope.prototype._setRampAD = function (t1, t2) {\n this._rampAttackTime = this.checkExpInput(t1);\n this._rampDecayTime = this.checkExpInput(t2);\n\n var TCDenominator = 1.0;\n /// Aatish Bhatia's calculation for time constant for rise(to adjust 1/1-e calculation to any percentage)\n TCDenominator = Math.log(\n 1.0 / this.checkExpInput(1.0 - this._rampHighPercentage)\n );\n this._rampAttackTC = t1 / this.checkExpInput(TCDenominator);\n TCDenominator = Math.log(1.0 / this._rampLowPercentage);\n this._rampDecayTC = t2 / this.checkExpInput(TCDenominator);\n};\n\n// private method\np5.Envelope.prototype.setRampPercentages = function (p1, p2) {\n //set the percentages that the simple exponential ramps go to\n this._rampHighPercentage = this.checkExpInput(p1);\n this._rampLowPercentage = this.checkExpInput(p2);\n var TCDenominator = 1.0;\n //now re-compute the time constants based on those percentages\n /// Aatish Bhatia's calculation for time constant for rise(to adjust 1/1-e calculation to any percentage)\n TCDenominator = Math.log(\n 1.0 / this.checkExpInput(1.0 - this._rampHighPercentage)\n );\n this._rampAttackTC = this._rampAttackTime / this.checkExpInput(TCDenominator);\n TCDenominator = Math.log(1.0 / this._rampLowPercentage);\n this._rampDecayTC = this._rampDecayTime / this.checkExpInput(TCDenominator);\n};\n\n/**\n * Assign a parameter to be controlled by this envelope.\n * If a p5.Sound object is given, then the p5.Envelope will control its\n * output gain. If multiple inputs are provided, the env will\n * control all of them.\n *\n * @method setInput\n * @for p5.Envelope\n * @param {Object} [...inputs] A p5.sound object or\n * Web Audio Param.\n */\np5.Envelope.prototype.setInput = function () {\n for (var i = 0; i < arguments.length; i++) {\n this.connect(arguments[i]);\n }\n};\n\n/**\n * Set whether the envelope ramp is linear (default) or exponential.\n * Exponential ramps can be useful because we perceive amplitude\n * and frequency logarithmically.\n *\n * @method setExp\n * @for p5.Envelope\n * @param {Boolean} isExp true is exponential, false is linear\n */\np5.Envelope.prototype.setExp = function (isExp) {\n this.isExponential = isExp;\n};\n\n//helper method to protect against zero values being sent to exponential functions\np5.Envelope.prototype.checkExpInput = function (value) {\n if (value <= 0) {\n value = 0.00000001;\n }\n return value;\n};\n\n/**\n *

Play tells the envelope to start acting on a given input.\n * If the input is a p5.sound object (i.e. AudioIn, Oscillator,\n * SoundFile), then Envelope will control its output volume.\n * Envelopes can also be used to control any \n * Web Audio Audio Param.

\n *\n * @method play\n * @for p5.Envelope\n * @param {Object} unit A p5.sound object or\n * Web Audio Param.\n * @param {Number} [startTime] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * triOsc.start();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackTime = map(mouseX, 0, width, 0, 1.0);\n * attackLevel = map(mouseY, height, 0, 0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 40);\n * text('attack level: ' + attackLevel, 5, height - 20);\n * }\n *\n * function playEnv() {\n * // ensure that audio is enabled\n * userStartAudio();\n *\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(attackLevel, releaseLevel);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.play = function (unit, secondsFromNow, susTime) {\n var tFromNow = secondsFromNow || 0;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n this.triggerAttack(unit, tFromNow);\n\n this.triggerRelease(unit, tFromNow + this.aTime + this.dTime + ~~susTime);\n};\n\n/**\n * Trigger the Attack, and Decay portion of the Envelope.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go. Input can be\n * any p5.sound object, or a \n * Web Audio Param.\n *\n * @method triggerAttack\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow time from now (in seconds)\n * @example\n *
\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.3;\n * let releaseTime = 0.4;\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * textSize(10);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(1.0, 0.0);\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.freq(220);\n *\n * cnv.mousePressed(envAttack);\n * }\n *\n * function envAttack() {\n * background(0, 255, 255);\n * text('release to release', width/2, height/2);\n *\n * // ensures audio is enabled. See also: `userStartAudio`\n * triOsc.start();\n *\n * env.triggerAttack(triOsc);\n * }\n *\n * function mouseReleased() {\n * background(220);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env.triggerRelease(triOsc);\n * }\n *
\n */\np5.Envelope.prototype.triggerAttack = function (unit, secondsFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n this.lastAttack = t;\n this.wasTriggered = true;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n // get and set value (with linear ramp) to anchor automation\n var valToSet = this.control.getValueAtTime(t);\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n } else {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // after each ramp completes, cancel scheduled values\n // (so they can be overridden in case env has been re-triggered)\n // then, set current value (with linearRamp to avoid click)\n // then, schedule the next automation...\n\n // attack\n t += this.aTime;\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.aLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.aLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // decay to decay level (if using ADSR, then decay level == sustain level)\n t += this.dTime;\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.dLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.dLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n};\n\n/**\n * Trigger the Release of the Envelope. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @method triggerRelease\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow time to trigger the release\n * @example\n *
\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.3;\n * let releaseTime = 0.4;\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * textSize(10);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(1.0, 0.0);\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.freq(220);\n *\n * cnv.mousePressed(envAttack);\n * }\n *\n * function envAttack() {\n * background(0, 255, 255);\n * text('release to release', width/2, height/2);\n *\n * // ensures audio is enabled. See also: `userStartAudio`\n * triOsc.start();\n *\n * env.triggerAttack(triOsc);\n * }\n *\n * function mouseReleased() {\n * background(220);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env.triggerRelease(triOsc);\n * }\n *
\n */\np5.Envelope.prototype.triggerRelease = function (unit, secondsFromNow) {\n // only trigger a release if an attack was triggered\n if (!this.wasTriggered) {\n // this currently causes a bit of trouble:\n // if a later release has been scheduled (via the play function)\n // a new earlier release won't interrupt it, because\n // this.wasTriggered has already been set to false.\n // If we want new earlier releases to override, then we need to\n // keep track of the last release time, and if the new release time is\n // earlier, then use it.\n return;\n }\n\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n // get and set value (with linear or exponential ramp) to anchor automation\n var valToSet = this.control.getValueAtTime(t);\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n } else {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // release\n t += this.rTime;\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.rLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.rLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n this.wasTriggered = false;\n};\n\n/**\n * Exponentially ramp to a value using the first two\n * values from setADSR(attackTime, decayTime)\n * as \n * time constants for simple exponential ramps.\n * If the value is higher than current value, it uses attackTime,\n * while a decrease uses decayTime.\n *\n * @method ramp\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow When to trigger the ramp\n * @param {Number} v Target value\n * @param {Number} [v2] Second target value\n * @example\n *
\n * let env, osc, amp;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let attackLevel = 1;\n * let decayLevel = 0;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * fill(0,255,0);\n * noStroke();\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime);\n * osc = new p5.Oscillator();\n * osc.amp(env);\n * amp = new p5.Amplitude();\n *\n * cnv.mousePressed(triggerRamp);\n * }\n *\n * function triggerRamp() {\n * // ensures audio is enabled. See also: `userStartAudio`\n * osc.start();\n *\n * env.ramp(osc, 0, attackLevel, decayLevel);\n * }\n *\n * function draw() {\n * background(20);\n * text('tap to play', 10, 20);\n * let h = map(amp.getLevel(), 0, 0.4, 0, height);;\n * rect(0, height, width, -h);\n * }\n *
\n */\np5.Envelope.prototype.ramp = function (unit, secondsFromNow, v1, v2) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n var destination1 = this.checkExpInput(v1);\n var destination2 =\n typeof v2 !== 'undefined' ? this.checkExpInput(v2) : undefined;\n\n // connect env to unit if not already connected\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n //get current value\n var currentVal = this.checkExpInput(this.control.getValueAtTime(t));\n // this.control.cancelScheduledValues(t);\n\n //if it's going up\n if (destination1 > currentVal) {\n this.control.setTargetAtTime(destination1, t, this._rampAttackTC);\n t += this._rampAttackTime;\n }\n\n //if it's going down\n else if (destination1 < currentVal) {\n this.control.setTargetAtTime(destination1, t, this._rampDecayTC);\n t += this._rampDecayTime;\n }\n\n // Now the second part of envelope begins\n if (destination2 === undefined) return;\n\n //if it's going up\n if (destination2 > destination1) {\n this.control.setTargetAtTime(destination2, t, this._rampAttackTC);\n }\n\n //if it's going down\n else if (destination2 < destination1) {\n this.control.setTargetAtTime(destination2, t, this._rampDecayTC);\n }\n};\n\np5.Envelope.prototype.connect = function (unit) {\n this.connection = unit;\n\n // assume we're talking about output gain\n // unless given a different audio param\n if (\n unit instanceof p5.Oscillator ||\n unit instanceof p5.SoundFile ||\n unit instanceof p5.AudioIn ||\n unit instanceof p5.Reverb ||\n unit instanceof p5.Noise ||\n unit instanceof p5.Filter ||\n unit instanceof p5.Delay\n ) {\n unit = unit.output.gain;\n }\n if (unit instanceof AudioParam) {\n //set the initial value\n unit.setValueAtTime(0, p5sound.audiocontext.currentTime);\n }\n\n this.output.connect(unit);\n};\n\np5.Envelope.prototype.disconnect = function () {\n if (this.output) {\n this.output.disconnect();\n }\n};\n\n// Signal Math\n\n/**\n * Add a value to the p5.Oscillator's output amplitude,\n * and return the oscillator. Calling this method\n * again will override the initial add() with new values.\n *\n * @method add\n * @for p5.Envelope\n * @param {Number} number Constant number to add\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.add = function (num) {\n var add = new Add(num);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, add, thisChain, nextChain, Add);\n};\n\n/**\n * Multiply the p5.Envelope's output amplitude\n * by a fixed value. Calling this method\n * again will override the initial mult() with new values.\n *\n * @method mult\n * @for p5.Envelope\n * @param {Number} number Constant number to multiply\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.mult = function (num) {\n var mult = new Mult(num);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, mult, thisChain, nextChain, Mult);\n};\n\n/**\n * Scale this envelope's amplitude values to a given\n * range, and return the envelope. Calling this method\n * again will override the initial scale() with new values.\n *\n * @method scale\n * @for p5.Envelope\n * @param {Number} inMin input range minumum\n * @param {Number} inMax input range maximum\n * @param {Number} outMin input range minumum\n * @param {Number} outMax input range maximum\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.scale = function (inMin, inMax, outMin, outMax) {\n var scale = new Scale(inMin, inMax, outMin, outMax);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, scale, thisChain, nextChain, Scale);\n};\n\n// get rid of the oscillator\np5.Envelope.prototype.dispose = function () {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.disconnect();\n if (this.control) {\n this.control.dispose();\n this.control = null;\n }\n for (var i = 1; i < this.mathOps.length; i++) {\n this.mathOps[i].dispose();\n }\n};\n\n// Different name for backwards compatibility, replicates p5.Envelope class\np5.Env = function (t1, l1, t2, l2, t3, l3) {\n console.warn(\n 'WARNING: p5.Env is now deprecated and may be removed in future versions. ' +\n 'Please use the new p5.Envelope instead.'\n );\n p5.Envelope.call(this, t1, l1, t2, l2, t3, l3);\n};\np5.Env.prototype = Object.create(p5.Envelope.prototype);\n\nconst Envelope = p5.Envelope;\nexport default Envelope;\n","import p5sound from './master';\nimport Oscillator from './oscillator';\n\n// generate noise buffers\nconst _whiteNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var whiteBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = whiteBuffer.getChannelData(0);\n for (var i = 0; i < bufferSize; i++) {\n noiseData[i] = Math.random() * 2 - 1;\n }\n whiteBuffer.type = 'white';\n return whiteBuffer;\n})();\n\nconst _pinkNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var pinkBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = pinkBuffer.getChannelData(0);\n var b0, b1, b2, b3, b4, b5, b6;\n b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0.0;\n for (var i = 0; i < bufferSize; i++) {\n var white = Math.random() * 2 - 1;\n b0 = 0.99886 * b0 + white * 0.0555179;\n b1 = 0.99332 * b1 + white * 0.0750759;\n b2 = 0.969 * b2 + white * 0.153852;\n b3 = 0.8665 * b3 + white * 0.3104856;\n b4 = 0.55 * b4 + white * 0.5329522;\n b5 = -0.7616 * b5 - white * 0.016898;\n noiseData[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362;\n noiseData[i] *= 0.11; // (roughly) compensate for gain\n b6 = white * 0.115926;\n }\n pinkBuffer.type = 'pink';\n return pinkBuffer;\n})();\n\nconst _brownNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var brownBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = brownBuffer.getChannelData(0);\n var lastOut = 0.0;\n for (var i = 0; i < bufferSize; i++) {\n var white = Math.random() * 2 - 1;\n noiseData[i] = (lastOut + 0.02 * white) / 1.02;\n lastOut = noiseData[i];\n noiseData[i] *= 3.5;\n }\n brownBuffer.type = 'brown';\n return brownBuffer;\n})();\n\n/**\n * Noise is a type of oscillator that generates a buffer with random values.\n *\n * @class p5.Noise\n * @extends p5.Oscillator\n * @constructor\n * @param {String} type Type of noise can be 'white' (default),\n * 'brown' or 'pink'.\n */\nclass Noise extends Oscillator {\n constructor(type) {\n super();\n var assignType;\n delete this.f;\n delete this.freq;\n delete this.oscillator;\n\n if (type === 'brown') {\n assignType = _brownNoiseBuffer;\n } else if (type === 'pink') {\n assignType = _pinkNoiseBuffer;\n } else {\n assignType = _whiteNoiseBuffer;\n }\n this.buffer = assignType;\n }\n\n /**\n * Set type of noise to 'white', 'pink' or 'brown'.\n * White is the default.\n *\n * @method setType\n * @param {String} [type] 'white', 'pink' or 'brown'\n */\n setType(type) {\n switch (type) {\n case 'white':\n this.buffer = _whiteNoiseBuffer;\n break;\n case 'pink':\n this.buffer = _pinkNoiseBuffer;\n break;\n case 'brown':\n this.buffer = _brownNoiseBuffer;\n break;\n default:\n this.buffer = _whiteNoiseBuffer;\n }\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.start(now + 0.01);\n }\n }\n\n getType() {\n return this.buffer.type;\n }\n start() {\n if (this.started) {\n this.stop();\n }\n this.noise = p5sound.audiocontext.createBufferSource();\n this.noise.buffer = this.buffer;\n this.noise.loop = true;\n this.noise.connect(this.output);\n var now = p5sound.audiocontext.currentTime;\n this.noise.start(now);\n this.started = true;\n }\n\n stop() {\n var now = p5sound.audiocontext.currentTime;\n if (this.noise) {\n this.noise.stop(now);\n this.started = false;\n }\n }\n\n dispose() {\n var now = p5sound.audiocontext.currentTime;\n\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.noise) {\n this.noise.disconnect();\n this.stop(now);\n }\n if (this.output) {\n this.output.disconnect();\n }\n if (this.panner) {\n this.panner.disconnect();\n }\n this.output = null;\n this.panner = null;\n this.buffer = null;\n this.noise = null;\n }\n}\n\nexport default Noise;\n","import Signal from 'Tone/signal/Signal';\nimport Multiply from 'Tone/signal/Multiply';\n\nimport p5sound from './master';\nimport Oscillator, { SawOsc } from './oscillator';\n\n/**\n * Creates a Pulse object, an oscillator that implements\n * Pulse Width Modulation.\n * The pulse is created with two oscillators.\n * Accepts a parameter for frequency, and to set the\n * width between the pulses. See \n * p5.Oscillator for a full list of methods.\n *\n * @class p5.Pulse\n * @extends p5.Oscillator\n * @constructor\n * @param {Number} [freq] Frequency in oscillations per second (Hz)\n * @param {Number} [w] Width between the pulses (0 to 1.0,\n * defaults to 0)\n * @example\n *
\n * let pulse;\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startPulse);\n * background(220);\n *\n * pulse = new p5.Pulse();\n * pulse.amp(0.5);\n * pulse.freq(220);\n * }\n * function startPulse() {\n * pulse.start();\n * pulse.amp(0.5, 0.02);\n * }\n * function mouseReleased() {\n * pulse.amp(0, 0.2);\n * }\n * function draw() {\n * background(220);\n * text('tap to play', 5, 20, width - 20);\n * let w = map(mouseX, 0, width, 0, 1);\n * w = constrain(w, 0, 1);\n * pulse.width(w);\n * text('pulse width: ' + w, 5, height - 20);\n * }\n *
\n */\nclass Pulse extends Oscillator {\n constructor(freq, w) {\n super(freq, 'sawtooth');\n\n // width of PWM, should be betw 0 to 1.0\n this.w = w || 0;\n\n // create a second oscillator with inverse frequency\n this.osc2 = new SawOsc(freq);\n\n // create a delay node\n this.dNode = p5sound.audiocontext.createDelay();\n\n // dc offset\n this.dcOffset = createDCOffset();\n this.dcGain = p5sound.audiocontext.createGain();\n this.dcOffset.connect(this.dcGain);\n this.dcGain.connect(this.output);\n // set delay time based on PWM width\n this.f = freq || 440;\n var mW = this.w / this.oscillator.frequency.value;\n this.dNode.delayTime.value = mW;\n this.dcGain.gain.value = 1.7 * (0.5 - this.w);\n\n // disconnect osc2 and connect it to delay, which is connected to output\n this.osc2.disconnect();\n this.osc2.panner.disconnect();\n this.osc2.amp(-1); // inverted amplitude\n this.osc2.output.connect(this.dNode);\n this.dNode.connect(this.output);\n\n this.output.gain.value = 1;\n this.output.connect(this.panner);\n }\n\n /**\n * Set the width of a Pulse object (an oscillator that implements\n * Pulse Width Modulation).\n *\n * @method width\n * @param {Number} [width] Width between the pulses (0 to 1.0,\n * defaults to 0)\n */\n width(w) {\n if (typeof w === 'number') {\n if (w <= 1.0 && w >= 0.0) {\n this.w = w;\n // set delay time based on PWM width\n\n // var mW = map(this.w, 0, 1.0, 0, 1/this.f);\n var mW = this.w / this.oscillator.frequency.value;\n this.dNode.delayTime.value = mW;\n }\n\n this.dcGain.gain.value = 1.7 * (0.5 - this.w);\n } else {\n w.connect(this.dNode.delayTime);\n let sig = new Signal(-0.5); //repalce it with tones Signals Method\n w.connect(sig);\n let mult1 = new Multiply(-1);\n let mult2 = new Multiply(1.7);\n sig = sig.connect(mult1).connect(mult2);\n sig.connect(this.dcGain.gain);\n }\n }\n\n start(f, time) {\n var now = p5sound.audiocontext.currentTime;\n var t = time || 0;\n if (!this.started) {\n var freq = f || this.f;\n var type = this.oscillator.type;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.oscillator.frequency.setValueAtTime(freq, now);\n this.oscillator.type = type;\n this.oscillator.connect(this.output);\n this.oscillator.start(t + now);\n\n // set up osc2\n this.osc2.oscillator = p5sound.audiocontext.createOscillator();\n this.osc2.oscillator.frequency.setValueAtTime(freq, t + now);\n this.osc2.oscillator.type = type;\n this.osc2.oscillator.connect(this.osc2.output);\n this.osc2.start(t + now);\n this.freqNode = [\n this.oscillator.frequency,\n this.osc2.oscillator.frequency,\n ];\n\n // start dcOffset, too\n this.dcOffset = createDCOffset();\n this.dcOffset.connect(this.dcGain);\n this.dcOffset.start(t + now);\n\n // if LFO connections depend on these oscillators\n if (this.mods !== undefined && this.mods.frequency !== undefined) {\n this.mods.frequency.connect(this.freqNode[0]);\n this.mods.frequency.connect(this.freqNode[1]);\n }\n this.started = true;\n this.osc2.started = true;\n }\n }\n\n stop(time) {\n if (this.started) {\n var t = time || 0;\n var now = p5sound.audiocontext.currentTime;\n this.oscillator.stop(t + now);\n if (this.osc2.oscillator) {\n this.osc2.oscillator.stop(t + now);\n }\n this.dcOffset.stop(t + now);\n this.started = false;\n this.osc2.started = false;\n }\n }\n\n freq(val, rampTime = 0, tFromNow = 0) {\n if (typeof val === 'number') {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n var currentFreq = this.oscillator.frequency.value;\n this.oscillator.frequency.cancelScheduledValues(now);\n this.oscillator.frequency.setValueAtTime(currentFreq, now + tFromNow);\n this.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n this.osc2.oscillator.frequency.cancelScheduledValues(now);\n this.osc2.oscillator.frequency.setValueAtTime(\n currentFreq,\n now + tFromNow\n );\n this.osc2.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n\n if (this.freqMod) {\n this.freqMod.output.disconnect();\n this.freqMod = null;\n }\n } else if (val.output) {\n val.output.disconnect();\n val.output.connect(this.oscillator.frequency);\n val.output.connect(this.osc2.oscillator.frequency);\n this.freqMod = val;\n }\n }\n}\n\n// inspiration: http://webaudiodemos.appspot.com/oscilloscope/\nfunction createDCOffset() {\n var ac = p5sound.audiocontext;\n var buffer = ac.createBuffer(1, 2048, ac.sampleRate);\n var data = buffer.getChannelData(0);\n for (var i = 0; i < 2048; i++) data[i] = 1.0;\n var bufferSource = ac.createBufferSource();\n bufferSource.buffer = buffer;\n bufferSource.loop = true;\n return bufferSource;\n}\n\nexport default Pulse;\n","import p5sound from './master';\nimport Amplitude from './amplitude';\n\n// an array of input sources\np5sound.inputSources = [];\n\n/**\n *

Get audio from an input, i.e. your computer's microphone.

\n *\n *

Turn the mic on/off with the start() and stop() methods. When the mic\n * is on, its volume can be measured with getLevel or by connecting an\n * FFT object.

\n *\n *

If you want to hear the AudioIn, use the .connect() method.\n * AudioIn does not connect to p5.sound output by default to prevent\n * feedback.

\n *\n *

Note: This uses the getUserMedia/\n * Stream API, which is not supported by certain browsers. Access in Chrome browser\n * is limited to localhost and https, but access over http may be limited.

\n *\n * @class p5.AudioIn\n * @constructor\n * @param {Function} [errorCallback] A function to call if there is an error\n * accessing the AudioIn. For example,\n * Safari and iOS devices do not\n * currently allow microphone access.\n * @example\n *
\n * let mic;\n *\n * function setup(){\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(useraudiocontextStartAudio);\n * textAlign(CENTER);\n * mic = new p5.AudioIn();\n * mic.start();\n * }\n *\n * function draw(){\n * background(0);\n * fill(255);\n * text('tap to start', width/2, 20);\n *\n * micLevel = mic.getLevel();\n * let y = height - micLevel * height;\n * ellipse(width/2, y, 10, 10);\n * }\n *
\n */\nclass AudioIn {\n constructor(errorCallback) {\n // set up audio input\n /**\n * @property {GainNode} input\n */\n this.input = p5sound.audiocontext.createGain();\n /**\n * @property {GainNode} output\n */\n this.output = p5sound.audiocontext.createGain();\n\n /**\n * @property {MediaStream|null} stream\n */\n this.stream = null;\n /**\n * @property {MediaStreamAudioSourceNode|null} mediaStream\n */\n this.mediaStream = null;\n /**\n * @property {Number|null} currentSource\n */\n this.currentSource = null;\n\n /**\n * Client must allow browser to access their microphone / audioin source.\n * Default: false. Will become true when the client enables access.\n *\n * @property {Boolean} enabled\n */\n this.enabled = false;\n\n /**\n * Input amplitude, connect to it by default but not to master out\n *\n * @property {p5.Amplitude} amplitude\n */\n this.amplitude = new Amplitude();\n this.output.connect(this.amplitude.input);\n\n if (\n !window.MediaStreamTrack ||\n !window.navigator.mediaDevices ||\n !window.navigator.mediaDevices.getUserMedia\n ) {\n errorCallback\n ? errorCallback()\n : window.alert(\n 'This browser does not support MediaStreamTrack and mediaDevices'\n );\n }\n\n // add to soundArray so we can dispose on close\n p5sound.soundArray.push(this);\n }\n /**\n * Start processing audio input. This enables the use of other\n * AudioIn methods like getLevel(). Note that by default, AudioIn\n * is not connected to p5.sound's output. So you won't hear\n * anything unless you use the connect() method.
\n *\n * Certain browsers limit access to the user's microphone. For example,\n * Chrome only allows access from localhost and over https. For this reason,\n * you may want to include an errorCallback—a function that is called in case\n * the browser won't provide mic access.\n *\n * @method start\n * @for p5.AudioIn\n * @param {Function} [successCallback] Name of a function to call on\n * success.\n * @param {Function} [errorCallback] Name of a function to call if\n * there was an error. For example,\n * some browsers do not support\n * getUserMedia.\n */\n start(successCallback, errorCallback) {\n var self = this;\n\n if (this.stream) {\n this.stop();\n }\n\n // set the audio source\n var audioSource = p5sound.inputSources[self.currentSource];\n var constraints = {\n audio: {\n sampleRate: p5sound.audiocontext.sampleRate,\n echoCancellation: false,\n },\n };\n\n // if developers determine which source to use\n if (p5sound.inputSources[this.currentSource]) {\n constraints.audio.deviceId = audioSource.deviceId;\n }\n\n window.navigator.mediaDevices\n .getUserMedia(constraints)\n .then(function (stream) {\n self.stream = stream;\n self.enabled = true;\n // Wrap a MediaStreamSourceNode around the live input\n self.mediaStream = p5sound.audiocontext.createMediaStreamSource(stream);\n self.mediaStream.connect(self.output);\n // only send to the Amplitude reader, so we can see it but not hear it.\n self.amplitude.setInput(self.output);\n if (successCallback) successCallback();\n })\n .catch(function (err) {\n if (errorCallback) errorCallback(err);\n else console.error(err);\n });\n }\n\n /**\n * Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().\n * If re-starting, the user may be prompted for permission access.\n *\n * @method stop\n * @for p5.AudioIn\n */\n stop() {\n if (this.stream) {\n this.stream.getTracks().forEach(function (track) {\n track.stop();\n });\n\n this.mediaStream.disconnect();\n\n delete this.mediaStream;\n delete this.stream;\n }\n }\n\n /**\n * Connect to an audio unit. If no parameter is provided, will\n * connect to the master output (i.e. your speakers).
\n *\n * @method connect\n * @for p5.AudioIn\n * @param {Object} [unit] An object that accepts audio input,\n * such as an FFT\n */\n connect(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n } else if (unit.hasOwnProperty('analyser')) {\n this.output.connect(unit.analyser);\n } else {\n this.output.connect(unit);\n }\n } else {\n this.output.connect(p5sound.input);\n }\n }\n\n /**\n * Disconnect the AudioIn from all audio units. For example, if\n * connect() had been called, disconnect() will stop sending\n * signal to your speakers.
\n *\n * @method disconnect\n * @for p5.AudioIn\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n // stay connected to amplitude even if not outputting to p5\n this.output.connect(this.amplitude.input);\n }\n }\n\n /**\n * Read the Amplitude (volume level) of an AudioIn. The AudioIn\n * class contains its own instance of the Amplitude class to help\n * make it easy to get a microphone's volume level. Accepts an\n * optional smoothing value (0.0 < 1.0). NOTE: AudioIn must\n * .start() before using .getLevel().
\n *\n * @method getLevel\n * @for p5.AudioIn\n * @param {Number} [smoothing] Smoothing is 0.0 by default.\n * Smooths values based on previous values.\n * @return {Number} Volume level (between 0.0 and 1.0)\n */\n getLevel(smoothing) {\n if (smoothing) {\n this.amplitude.smoothing = smoothing;\n }\n return this.amplitude.getLevel();\n }\n\n /**\n * Set amplitude (volume) of a mic input between 0 and 1.0.
\n *\n * @method amp\n * @for p5.AudioIn\n * @param {Number} vol between 0 and 1.0\n * @param {Number} [time] ramp time (optional)\n */\n amp(vol, t) {\n if (t) {\n var rampTime = t || 0;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\n this.output.gain.setValueAtTime(\n currentVol,\n p5sound.audiocontext.currentTime\n );\n this.output.gain.linearRampToValueAtTime(\n vol,\n rampTime + p5sound.audiocontext.currentTime\n );\n } else {\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\n this.output.gain.setValueAtTime(vol, p5sound.audiocontext.currentTime);\n }\n }\n\n /**\n * Returns a list of available input sources. This is a wrapper\n * for \n * MediaDevices.enumerateDevices() - Web APIs | MDN\n * and it returns a Promise.\n * @method getSources\n * @for p5.AudioIn\n * @param {Function} [successCallback] This callback function handles the sources when they\n * have been enumerated. The callback function\n * receives the deviceList array as its only argument\n * @param {Function} [errorCallback] This optional callback receives the error\n * message as its argument.\n * @returns {Promise} Returns a Promise that can be used in place of the callbacks, similar\n * to the enumerateDevices() method\n * @example\n *
\n * let audioIn;\n *\n * function setup(){\n * text('getting sources...', 0, 20);\n * audioIn = new p5.AudioIn();\n * audioIn.getSources(gotSources);\n * }\n *\n * function gotSources(deviceList) {\n * if (deviceList.length > 0) {\n * //set the source to the first item in the deviceList array\n * audioIn.setSource(0);\n * let currentSource = deviceList[audioIn.currentSource];\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\n * }\n * }\n *
\n */\n getSources(onSuccess, onError) {\n return new Promise(function (resolve, reject) {\n window.navigator.mediaDevices\n .enumerateDevices()\n .then(function (devices) {\n p5sound.inputSources = devices.filter(function (device) {\n return device.kind === 'audioinput';\n });\n resolve(p5sound.inputSources);\n if (onSuccess) {\n onSuccess(p5sound.inputSources);\n }\n })\n .catch(function (error) {\n reject(error);\n if (onError) {\n onError(error);\n } else {\n console.error(\n 'This browser does not support MediaStreamTrack.getSources()'\n );\n }\n });\n });\n }\n\n /**\n * Set the input source. Accepts a number representing a\n * position in the array returned by getSources().\n * This is only available in browsers that support\n * \n * navigator.mediaDevices.enumerateDevices()\n *\n * @method setSource\n * @for p5.AudioIn\n * @param {number} num position of input source in the array\n * @example\n *
\n * let audioIn;\n *\n * function setup(){\n * text('getting sources...', 0, 20);\n * audioIn = new p5.AudioIn();\n * audioIn.getSources(gotSources);\n * }\n *\n * function gotSources(deviceList) {\n * if (deviceList.length > 0) {\n * //set the source to the first item in the deviceList array\n * audioIn.setSource(0);\n * let currentSource = deviceList[audioIn.currentSource];\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\n * }\n * }\n *
\n */\n setSource(num) {\n if (p5sound.inputSources.length > 0 && num < p5sound.inputSources.length) {\n // set the current source\n this.currentSource = num;\n console.log('set source to ', p5sound.inputSources[this.currentSource]);\n } else {\n console.log('unable to set input source');\n }\n\n // restart stream if currently active\n if (this.stream && this.stream.active) {\n this.start();\n }\n }\n\n // private method\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.stop();\n\n if (this.output) {\n this.output.disconnect();\n }\n if (this.amplitude) {\n this.amplitude.disconnect();\n }\n delete this.amplitude;\n delete this.output;\n }\n}\n\nexport default AudioIn;\n","import p5sound from './master';\nimport CrossFade from 'Tone/component/CrossFade.js';\n\n/**\n * Effect is a base class for audio effects in p5.
\n * This module handles the nodes and methods that are\n * common and useful for current and future effects.\n *\n *\n * This class is extended by p5.Distortion,\n * p5.Compressor,\n * p5.Delay,\n * p5.Filter,\n * p5.Reverb.\n *\n * @class p5.Effect\n * @constructor\n *\n * @param {Object} [ac] Reference to the audio context of the p5 object\n * @param {AudioNode} [input] Gain Node effect wrapper\n * @param {AudioNode} [output] Gain Node effect wrapper\n * @param {Object} [_drywet] Tone.JS CrossFade node (defaults to value: 1)\n * @param {AudioNode} [wet] Effects that extend this class should connect\n * to the wet signal to this gain node, so that dry and wet\n * signals are mixed properly.\n */\nclass Effect {\n constructor() {\n this.ac = p5sound.audiocontext;\n\n this.input = this.ac.createGain();\n this.output = this.ac.createGain();\n\n /**\n *\tThe p5.Effect class is built\n * \tusing Tone.js CrossFade\n * \t@private\n */\n\n this._drywet = new CrossFade(1);\n\n /**\n *\tIn classes that extend\n *\tp5.Effect, connect effect nodes\n *\tto the wet parameter\n */\n this.wet = this.ac.createGain();\n\n this.input.connect(this._drywet.a);\n this.wet.connect(this._drywet.b);\n this._drywet.connect(this.output);\n\n this.connect();\n\n //Add to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Set the output volume of the filter.\n *\n * @method amp\n * @for p5.Effect\n * @param {Number} [vol] amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts until rampTime\n * @param {Number} [tFromNow] schedule this event to happen in tFromNow seconds\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n const now = p5sound.audiocontext.currentTime;\n const startTime = now + tFromNow;\n const endTime = startTime + rampTime + 0.001;\n const currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now);\n this.output.gain.linearRampToValueAtTime(currentVol, startTime + 0.001);\n this.output.gain.linearRampToValueAtTime(vol, endTime);\n }\n\n /**\n * Link effects together in a chain\n * Example usage: filter.chain(reverb, delay, panner);\n * May be used with an open-ended number of arguments\n *\n * @method chain\n * @for p5.Effect\n * @param {Object} [arguments] Chain together multiple sound objects\n */\n chain() {\n if (arguments.length > 0) {\n this.connect(arguments[0]);\n for (var i = 1; i < arguments.length; i += 1) {\n arguments[i - 1].connect(arguments[i]);\n }\n }\n return this;\n }\n\n /**\n * Adjust the dry/wet value.\n *\n * @method drywet\n * @for p5.Effect\n * @param {Number} [fade] The desired drywet value (0 - 1.0)\n */\n drywet(fade) {\n if (typeof fade !== 'undefined') {\n this._drywet.fade.value = fade;\n }\n return this._drywet.fade.value;\n }\n\n /**\n * Send output to a p5.js-sound, Web Audio Node, or use signal to\n * control an AudioParam\n *\n * @method connect\n * @for p5.Effect\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5.soundOut.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all output.\n * @method disconnect\n * @for p5.Effect\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n dispose() {\n // remove refernce form soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n\n if (this._drywet) {\n this._drywet.disconnect();\n delete this._drywet;\n }\n\n if (this.wet) {\n this.wet.disconnect();\n delete this.wet;\n }\n\n this.ac = undefined;\n }\n}\n\nexport default Effect;\n","import Effect from './effect';\n\n/**\n *

A p5.Filter uses a Web Audio Biquad Filter to filter\n * the frequency response of an input source. Subclasses\n * include:

\n * p5.LowPass:\n * Allows frequencies below the cutoff frequency to pass through,\n * and attenuates frequencies above the cutoff.
\n * p5.HighPass:\n * The opposite of a lowpass filter.
\n * p5.BandPass:\n * Allows a range of frequencies to pass through and attenuates\n * the frequencies below and above this frequency range.
\n *\n * The .res() method controls either width of the\n * bandpass, or resonance of the low/highpass cutoff frequency.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Filter\n * @extends p5.Effect\n * @constructor\n * @param {String} [type] 'lowpass' (default), 'highpass', 'bandpass'\n * @example\n *
\n * let fft, noise, filter;\n *\n * function setup() {\n * let cnv = createCanvas(100,100);\n * cnv.mousePressed(makeNoise);\n * fill(255, 0, 255);\n *\n * filter = new p5.BandPass();\n * noise = new p5.Noise();\n * noise.disconnect();\n * noise.connect(filter);\n *\n * fft = new p5.FFT();\n * }\n *\n * function draw() {\n * background(220);\n *\n * // set the BandPass frequency based on mouseX\n * let freq = map(mouseX, 0, width, 20, 10000);\n * freq = constrain(freq, 0, 22050);\n * filter.freq(freq);\n * // give the filter a narrow band (lower res = wider bandpass)\n * filter.res(50);\n *\n * // draw filtered spectrum\n * let spectrum = fft.analyze();\n * noStroke();\n * for (let i = 0; i < spectrum.length; i++) {\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width/spectrum.length, h);\n * }\n * if (!noise.started) {\n * text('tap here and drag to change frequency', 10, 20, width - 20);\n * } else {\n * text('Frequency: ' + round(freq)+'Hz', 20, 20, width - 20);\n * }\n * }\n *\n * function makeNoise() {\n * // see also: `userStartAudio()`\n * noise.start();\n * noise.amp(0.5, 0.2);\n * }\n *\n * function mouseReleased() {\n * noise.amp(0, 0.2);\n * }\n *\n *
\n */\nclass Filter extends Effect {\n constructor(type) {\n super();\n //add extend Effect by adding a Biquad Filter\n\n /**\n * The p5.Filter is built with a\n * \n * Web Audio BiquadFilter Node.\n *\n * @property {DelayNode} biquadFilter\n */\n\n this.biquad = this.ac.createBiquadFilter();\n\n this.input.connect(this.biquad);\n\n this.biquad.connect(this.wet);\n\n if (type) {\n this.setType(type);\n }\n\n //Properties useful for the toggle method.\n this._on = true;\n this._untoggledType = this.biquad.type;\n }\n\n /**\n * Filter an audio signal according to a set\n * of filter parameters.\n *\n * @method process\n * @param {Object} Signal An object that outputs audio\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\n * @param {Number} [res] Resonance/Width of the filter frequency\n * from 0.001 to 1000\n */\n process(src, freq, res, time) {\n src.connect(this.input);\n this.set(freq, res, time);\n }\n\n /**\n * Set the frequency and the resonance of the filter.\n *\n * @method set\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\n * @param {Number} [res] Resonance (Q) from 0.001 to 1000\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n set(freq, res, time) {\n if (freq) {\n this.freq(freq, time);\n }\n if (res) {\n this.res(res, time);\n }\n }\n\n /**\n * Set the filter frequency, in Hz, from 10 to 22050 (the range of\n * human hearing, although in reality most people hear in a narrower\n * range).\n *\n * @method freq\n * @param {Number} freq Filter Frequency\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {Number} value Returns the current frequency value\n */\n freq(freq, time) {\n var t = time || 0;\n if (freq <= 0) {\n freq = 1;\n }\n if (typeof freq === 'number') {\n this.biquad.frequency.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.biquad.frequency.exponentialRampToValueAtTime(\n freq,\n this.ac.currentTime + 0.02 + t\n );\n } else if (freq) {\n freq.connect(this.biquad.frequency);\n }\n return this.biquad.frequency.value;\n }\n\n /**\n * Controls either width of a bandpass frequency,\n * or the resonance of a low/highpass cutoff frequency.\n *\n * @method res\n * @param {Number} res Resonance/Width of filter freq\n * from 0.001 to 1000\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {Number} value Returns the current res value\n */\n res(res, time) {\n var t = time || 0;\n if (typeof res === 'number') {\n this.biquad.Q.value = res;\n this.biquad.Q.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.biquad.Q.linearRampToValueAtTime(\n res,\n this.ac.currentTime + 0.02 + t\n );\n } else if (res) {\n res.connect(this.biquad.Q);\n }\n return this.biquad.Q.value;\n }\n\n /**\n * Controls the gain attribute of a Biquad Filter.\n * This is distinctly different from .amp() which is inherited from p5.Effect\n * .amp() controls the volume via the output gain node\n * p5.Filter.gain() controls the gain parameter of a Biquad Filter node.\n *\n * @method gain\n * @param {Number} gain\n * @return {Number} Returns the current or updated gain value\n */\n gain(gain, time) {\n var t = time || 0;\n if (typeof gain === 'number') {\n this.biquad.gain.value = gain;\n this.biquad.gain.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.biquad.gain.linearRampToValueAtTime(\n gain,\n this.ac.currentTime + 0.02 + t\n );\n } else if (gain) {\n gain.connect(this.biquad.gain);\n }\n return this.biquad.gain.value;\n }\n\n /**\n * Toggle function. Switches between the specified type and allpass\n *\n * @method toggle\n * @return {boolean} [Toggle value]\n */\n toggle() {\n this._on = !this._on;\n\n if (this._on === true) {\n this.biquad.type = this._untoggledType;\n } else if (this._on === false) {\n this.biquad.type = 'allpass';\n }\n\n return this._on;\n }\n\n /**\n * Set the type of a p5.Filter. Possible types include:\n * \"lowpass\" (default), \"highpass\", \"bandpass\",\n * \"lowshelf\", \"highshelf\", \"peaking\", \"notch\",\n * \"allpass\".\n *\n * @method setType\n * @param {String} t\n */\n setType(t) {\n this.biquad.type = t;\n this._untoggledType = this.biquad.type;\n }\n\n dispose() {\n // remove reference from soundArray\n super.dispose();\n if (this.biquad) {\n this.biquad.disconnect();\n delete this.biquad;\n }\n }\n}\n\n/**\n * Constructor: new p5.LowPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('lowpass').\n * See p5.Filter for methods.\n *\n * @class p5.LowPass\n * @constructor\n * @extends p5.Filter\n */\nclass LowPass extends Filter {\n constructor() {\n super('lowpass');\n }\n}\n\n/**\n * Constructor: new p5.HighPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('highpass').\n * See p5.Filter for methods.\n *\n * @class p5.HighPass\n * @constructor\n * @extends p5.Filter\n */\nclass HighPass extends Filter {\n constructor() {\n super('highpass');\n }\n}\n\n/**\n * Constructor: new p5.BandPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('bandpass').\n * See p5.Filter for methods.\n *\n * @class p5.BandPass\n * @constructor\n * @extends p5.Filter\n */\nclass BandPass extends Filter {\n constructor() {\n super('bandpass');\n }\n}\nexport default Filter;\nexport { LowPass, HighPass, BandPass };\n","import Filter from './filter';\nimport p5sound from './master';\n\n/**\n * EQFilter extends p5.Filter with constraints\n * necessary for the p5.EQ\n *\n * @private\n */\nclass EQFilter extends Filter {\n constructor(freq, res) {\n super('peaking');\n\n this.disconnect();\n this.set(freq, res);\n this.biquad.gain.value = 0;\n delete this.input;\n delete this.output;\n delete this._drywet;\n delete this.wet;\n }\n\n amp() {\n console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');\n }\n\n drywet() {\n console.warn('`drywet()` is not available for p5.EQ bands.');\n }\n\n connect(unit) {\n var u = unit || p5.soundOut.input;\n if (this.biquad) {\n this.biquad.connect(u.input ? u.input : u);\n } else {\n this.output.connect(u.input ? u.input : u);\n }\n }\n disconnect() {\n if (this.biquad) {\n this.biquad.disconnect();\n }\n }\n\n dispose() {\n // remove reference form soundArray\n const index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n this.disconnect();\n delete this.biquad;\n }\n}\n\nexport default EQFilter;\n","import Effect from './effect';\nimport EQFilter from './eqFilter';\n\n/**\n * p5.EQ is an audio effect that performs the function of a multiband\n * audio equalizer. Equalization is used to adjust the balance of\n * frequency compoenents of an audio signal. This process is commonly used\n * in sound production and recording to change the waveform before it reaches\n * a sound output device. EQ can also be used as an audio effect to create\n * interesting distortions by filtering out parts of the spectrum. p5.EQ is\n * built using a chain of Web Audio Biquad Filter Nodes and can be\n * instantiated with 3 or 8 bands. Bands can be added or removed from\n * the EQ by directly modifying p5.EQ.bands (the array that stores filters).\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.EQ\n * @constructor\n * @extends p5.Effect\n * @param {Number} [_eqsize] Constructor will accept 3 or 8, defaults to 3\n * @return {Object} p5.EQ object\n *\n * @example\n *
\n * let eq, soundFile\n * let eqBandIndex = 0;\n * let eqBandNames = ['lows', 'mids', 'highs'];\n *\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * soundFile = loadSound('assets/beat');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(toggleSound);\n *\n * eq = new p5.EQ(eqBandNames.length);\n * soundFile.disconnect();\n * eq.process(soundFile);\n * }\n *\n * function draw() {\n * background(30);\n * noStroke();\n * fill(255);\n * textAlign(CENTER);\n * text('filtering ', 50, 25);\n *\n * fill(255, 40, 255);\n * textSize(26);\n * text(eqBandNames[eqBandIndex], 50, 55);\n *\n * fill(255);\n * textSize(9);\n *\n * if (!soundFile.isPlaying()) {\n * text('tap to play', 50, 80);\n * } else {\n * text('tap to filter next band', 50, 80)\n * }\n * }\n *\n * function toggleSound() {\n * if (!soundFile.isPlaying()) {\n * soundFile.play();\n * } else {\n * eqBandIndex = (eqBandIndex + 1) % eq.bands.length;\n * }\n *\n * for (let i = 0; i < eq.bands.length; i++) {\n * eq.bands[i].gain(0);\n * }\n * // filter the band we want to filter\n * eq.bands[eqBandIndex].gain(-40);\n * }\n *
\n */\nclass EQ extends Effect {\n constructor(_eqsize) {\n super();\n\n //p5.EQ can be of size (3) or (8), defaults to 3\n _eqsize = _eqsize === 3 || _eqsize === 8 ? _eqsize : 3;\n\n var factor;\n _eqsize === 3 ? (factor = Math.pow(2, 3)) : (factor = 2);\n\n /**\n * The p5.EQ is built with abstracted p5.Filter objects.\n * To modify any bands, use methods of the \n * p5.Filter API, especially `gain` and `freq`.\n * Bands are stored in an array, with indices 0 - 3, or 0 - 7\n * @property {Array} bands\n *\n */\n this.bands = [];\n\n var freq, res;\n for (var i = 0; i < _eqsize; i++) {\n if (i === _eqsize - 1) {\n freq = 21000;\n res = 0.01;\n } else if (i === 0) {\n freq = 100;\n res = 0.1;\n } else if (i === 1) {\n freq = _eqsize === 3 ? 360 * factor : 360;\n res = 1;\n } else {\n freq = this.bands[i - 1].freq() * factor;\n res = 1;\n }\n this.bands[i] = this._newBand(freq, res);\n\n if (i > 0) {\n this.bands[i - 1].connect(this.bands[i].biquad);\n } else {\n this.input.connect(this.bands[i].biquad);\n }\n }\n this.bands[_eqsize - 1].connect(this.output);\n }\n\n /**\n * Process an input by connecting it to the EQ\n * @method process\n * @param {Object} src Audio source\n */\n process(src) {\n src.connect(this.input);\n }\n\n // /**\n // * Set the frequency and gain of each band in the EQ. This method should be\n // * called with 3 or 8 frequency and gain pairs, depending on the size of the EQ.\n // * ex. eq.set(freq0, gain0, freq1, gain1, freq2, gain2);\n // *\n // * @method set\n // * @for p5.EQ\n // * @param {Number} [freq0] Frequency value for band with index 0\n // * @param {Number} [gain0] Gain value for band with index 0\n // * @param {Number} [freq1] Frequency value for band with index 1\n // * @param {Number} [gain1] Gain value for band with index 1\n // * @param {Number} [freq2] Frequency value for band with index 2\n // * @param {Number} [gain2] Gain value for band with index 2\n // * @param {Number} [freq3] Frequency value for band with index 3\n // * @param {Number} [gain3] Gain value for band with index 3\n // * @param {Number} [freq4] Frequency value for band with index 4\n // * @param {Number} [gain4] Gain value for band with index 4\n // * @param {Number} [freq5] Frequency value for band with index 5\n // * @param {Number} [gain5] Gain value for band with index 5\n // * @param {Number} [freq6] Frequency value for band with index 6\n // * @param {Number} [gain6] Gain value for band with index 6\n // * @param {Number} [freq7] Frequency value for band with index 7\n // * @param {Number} [gain7] Gain value for band with index 7\n // */\n set() {\n if (arguments.length === this.bands.length * 2) {\n for (var i = 0; i < arguments.length; i += 2) {\n this.bands[i / 2].freq(arguments[i]);\n this.bands[i / 2].gain(arguments[i + 1]);\n }\n } else {\n console.error(\n 'Argument mismatch. .set() should be called with ' +\n this.bands.length * 2 +\n ' arguments. (one frequency and gain value pair for each band of the eq)'\n );\n }\n }\n\n /**\n * Add a new band. Creates a p5.Filter and strips away everything but\n * the raw biquad filter. This method returns an abstracted p5.Filter,\n * which can be added to p5.EQ.bands, in order to create new EQ bands.\n * @private\n * @for p5.EQ\n * @method _newBand\n * @param {Number} freq\n * @param {Number} res\n * @return {Object} Abstracted Filter\n */\n _newBand(freq, res) {\n return new EQFilter(freq, res);\n }\n\n dispose() {\n super.dispose();\n\n if (this.bands) {\n while (this.bands.length > 0) {\n delete this.bands.pop().dispose();\n }\n delete this.bands;\n }\n }\n}\nexport default EQ;\n","import p5sound from './master';\n\n// /**\n// * listener is a class that can construct both a Spatial Panner\n// * and a Spatial Listener. The panner is based on the\n// * Web Audio Spatial Panner Node\n// * https://www.w3.org/TR/webaudio/#the-listenernode-interface\n// * This panner is a spatial processing node that allows audio to be positioned\n// * and oriented in 3D space.\n// *\n// * The Listener modifies the properties of the Audio Context Listener.\n// * Both objects types use the same methods. The default is a spatial panner.\n// *\n// * p5.Panner3D - Constructs a Spatial Panner
\n// * p5.Listener3D - Constructs a Spatial Listener
\n// *\n// * @class listener\n// * @constructor\n// * @return {Object} p5.Listener3D Object\n// *\n// * @param {Web Audio Node} listener Web Audio Spatial Panning Node\n// * @param {AudioParam} listener.panningModel \"equal power\" or \"HRTF\"\n// * @param {AudioParam} listener.distanceModel \"linear\", \"inverse\", or \"exponential\"\n// * @param {String} [type] [Specify construction of a spatial panner or listener]\n// */\n\nclass Listener3D {\n constructor(type) {\n this.ac = p5sound.audiocontext;\n this.listener = this.ac.listener;\n }\n\n // /**\n // * Connect an audio sorce\n // * @param {Object} src Input source\n // */\n process(src) {\n src.connect(this.input);\n }\n // /**\n // * Set the X,Y,Z position of the Panner\n // * @param {[Number]} xVal\n // * @param {[Number]} yVal\n // * @param {[Number]} zVal\n // * @param {[Number]} time\n // * @return {[Array]} [Updated x, y, z values as an array]\n // */\n position(xVal, yVal, zVal, time) {\n this.positionX(xVal, time);\n this.positionY(yVal, time);\n this.positionZ(zVal, time);\n return [\n this.listener.positionX.value,\n this.listener.positionY.value,\n this.listener.positionZ.value,\n ];\n }\n\n // /**\n // * Getter and setter methods for position coordinates\n // * @return {Number} [updated coordinate value]\n // */\n positionX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.positionX.value = xVal;\n this.listener.positionX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.positionX);\n }\n return this.listener.positionX.value;\n }\n positionY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.positionY.value = yVal;\n this.listener.positionY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.positionY);\n }\n return this.listener.positionY.value;\n }\n positionZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.positionZ.value = zVal;\n this.listener.positionZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.positionZ);\n }\n return this.listener.positionZ.value;\n }\n\n // cannot define method when class definition is commented\n // /**\n // * Overrides the listener orient() method because Listener has slightly\n // * different params. In human terms, Forward vectors are the direction the\n // * nose is pointing. Up vectors are the direction of the top of the head.\n // *\n // * @method orient\n // * @param {Number} xValF Forward vector X direction\n // * @param {Number} yValF Forward vector Y direction\n // * @param {Number} zValF Forward vector Z direction\n // * @param {Number} xValU Up vector X direction\n // * @param {Number} yValU Up vector Y direction\n // * @param {Number} zValU Up vector Z direction\n // * @param {Number} time\n // * @return {Array} All orienation params\n // */\n orient(xValF, yValF, zValF, xValU, yValU, zValU, time) {\n if (arguments.length === 3 || arguments.length === 4) {\n time = arguments[3];\n this.orientForward(xValF, yValF, zValF, time);\n } else if (arguments.length === 6 || arguments === 7) {\n this.orientForward(xValF, yValF, zValF);\n this.orientUp(xValU, yValU, zValU, time);\n }\n\n return [\n this.listener.forwardX.value,\n this.listener.forwardY.value,\n this.listener.forwardZ.value,\n this.listener.upX.value,\n this.listener.upY.value,\n this.listener.upZ.value,\n ];\n }\n\n orientForward(xValF, yValF, zValF, time) {\n this.forwardX(xValF, time);\n this.forwardY(yValF, time);\n this.forwardZ(zValF, time);\n\n return [\n this.listener.forwardX,\n this.listener.forwardY,\n this.listener.forwardZ,\n ];\n }\n\n orientUp(xValU, yValU, zValU, time) {\n this.upX(xValU, time);\n this.upY(yValU, time);\n this.upZ(zValU, time);\n\n return [this.listener.upX, this.listener.upY, this.listener.upZ];\n }\n // /**\n // * Getter and setter methods for orient coordinates\n // * @return {Number} [updated coordinate value]\n // */\n forwardX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.forwardX.value = xVal;\n this.listener.forwardX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.forwardX);\n }\n return this.listener.forwardX.value;\n }\n forwardY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.forwardY.value = yVal;\n this.listener.forwardY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.forwardY);\n }\n return this.listener.forwardY.value;\n }\n forwardZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.forwardZ.value = zVal;\n this.listener.forwardZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.forwardZ);\n }\n return this.listener.forwardZ.value;\n }\n upX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.upX.value = xVal;\n this.listener.upX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.upX);\n }\n return this.listener.upX.value;\n }\n upY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.upY.value = yVal;\n this.listener.upY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.upY);\n }\n return this.listener.upY.value;\n }\n upZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.upZ.value = zVal;\n this.listener.upZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.upZ);\n }\n return this.listener.upZ.value;\n }\n}\n\nexport default Listener3D;\n","import Effect from './effect';\n\n/**\n * Panner3D is based on the \n * Web Audio Spatial Panner Node.\n * This panner is a spatial processing node that allows audio to be positioned\n * and oriented in 3D space.\n *\n * The position is relative to an \n * Audio Context Listener, which can be accessed\n * by p5.soundOut.audiocontext.listener\n *\n *\n * @class p5.Panner3D\n * @constructor\n */\n\nclass Panner3D extends Effect {\n constructor() {\n super();\n /**\n * \n * Web Audio Spatial Panner Node\n *\n * Properties include
\n * [Panning Model](https://www.w3.org/TR/webaudio/#idl-def-PanningModelType)\n * : \"equal power\" or \"HRTF\"
\n * [DistanceModel](https://www.w3.org/TR/webaudio/#idl-def-DistanceModelType)\n * : \"linear\", \"inverse\", or \"exponential\"\n *\n * @property {AudioNode} panner\n *\n */\n this.panner = this.ac.createPanner();\n this.panner.panningModel = 'HRTF';\n this.panner.distanceModel = 'linear';\n this.panner.connect(this.output);\n this.input.connect(this.panner);\n }\n\n /**\n * Connect an audio sorce\n *\n * @method process\n * @for p5.Panner3D\n * @param {Object} src Input source\n */\n process(src) {\n src.connect(this.input);\n }\n /**\n * Set the X,Y,Z position of the Panner\n * @method set\n * @for p5.Panner3D\n * @param {Number} xVal\n * @param {Number} yVal\n * @param {Number} zVal\n * @param {Number} time\n * @return {Array} Updated x, y, z values as an array\n */\n set(xVal, yVal, zVal, time) {\n this.positionX(xVal, time);\n this.positionY(yVal, time);\n this.positionZ(zVal, time);\n return [\n this.panner.positionX.value,\n this.panner.positionY.value,\n this.panner.positionZ.value,\n ];\n }\n\n /**\n * Getter and setter methods for position coordinates\n * @method positionX\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for position coordinates\n * @method positionY\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for position coordinates\n * @method positionZ\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n positionX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.positionX.value = xVal;\n this.panner.positionX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.panner.positionX);\n }\n return this.panner.positionX.value;\n }\n positionY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.positionY.value = yVal;\n this.panner.positionY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.panner.positionY);\n }\n return this.panner.positionY.value;\n }\n positionZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.positionZ.value = zVal;\n this.panner.positionZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.panner.positionZ);\n }\n return this.panner.positionZ.value;\n }\n\n /**\n * Set the X,Y,Z position of the Panner\n * @method orient\n * @for p5.Panner3D\n * @param {Number} xVal\n * @param {Number} yVal\n * @param {Number} zVal\n * @param {Number} time\n * @return {Array} Updated x, y, z values as an array\n */\n orient(xVal, yVal, zVal, time) {\n this.orientX(xVal, time);\n this.orientY(yVal, time);\n this.orientZ(zVal, time);\n return [\n this.panner.orientationX.value,\n this.panner.orientationY.value,\n this.panner.orientationZ.value,\n ];\n }\n\n /**\n * Getter and setter methods for orient coordinates\n * @method orientX\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for orient coordinates\n * @method orientY\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for orient coordinates\n * @method orientZ\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n orientX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.orientationX.value = xVal;\n this.panner.orientationX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.panner.orientationX);\n }\n return this.panner.orientationX.value;\n }\n orientY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.orientationY.value = yVal;\n this.panner.orientationY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.panner.orientationY);\n }\n return this.panner.orientationY.value;\n }\n orientZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.orientationZ.value = zVal;\n this.panner.orientationZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.panner.orientationZ);\n }\n return this.panner.orientationZ.value;\n }\n\n /**\n * Set the rolloff factor and max distance\n * @method setFalloff\n * @for p5.Panner3D\n * @param {Number} [maxDistance]\n * @param {Number} [rolloffFactor]\n */\n setFalloff(maxDistance, rolloffFactor) {\n this.maxDist(maxDistance);\n this.rolloff(rolloffFactor);\n }\n /**\n * Maxium distance between the source and the listener\n * @method maxDist\n * @for p5.Panner3D\n * @param {Number} maxDistance\n * @return {Number} updated value\n */\n maxDist(maxDistance) {\n if (typeof maxDistance === 'number') {\n this.panner.maxDistance = maxDistance;\n }\n return this.panner.maxDistance;\n }\n\n /**\n * How quickly the volume is reduced as the source moves away from the listener\n * @method rollof\n * @for p5.Panner3D\n * @param {Number} rolloffFactor\n * @return {Number} updated value\n */\n rolloff(rolloffFactor) {\n if (typeof rolloffFactor === 'number') {\n this.panner.rolloffFactor = rolloffFactor;\n }\n return this.panner.rolloffFactor;\n }\n\n dispose() {\n super.dispose();\n if (this.panner) {\n this.panner.disconnect();\n delete this.panner;\n }\n }\n}\n\nexport default Panner3D;\n","import Filter from './filter';\nimport Effect from './effect';\n\n/**\n * Delay is an echo effect. It processes an existing sound source,\n * and outputs a delayed version of that sound. The p5.Delay can\n * produce different effects depending on the delayTime, feedback,\n * filter, and type. In the example below, a feedback of 0.5 (the\n * default value) will produce a looping delay that decreases in\n * volume by 50% each repeat. A filter will cut out the high\n * frequencies so that the delay does not sound as piercing as the\n * original source.\n *\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n * @class p5.Delay\n * @extends p5.Effect\n * @constructor\n * @example\n *
\n * let osc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * osc = new p5.Oscillator('square');\n * osc.amp(0.5);\n * delay = new p5.Delay();\n *\n * // delay.process() accepts 4 parameters:\n * // source, delayTime (in seconds), feedback, filter frequency\n * delay.process(osc, 0.12, .7, 2300);\n *\n * cnv.mousePressed(oscStart);\n * }\n *\n * function oscStart() {\n * osc.start();\n * }\n *\n * function mouseReleased() {\n * osc.stop();\n * }\n *
\n */\nclass Delay extends Effect {\n constructor() {\n super();\n\n this._split = this.ac.createChannelSplitter(2);\n this._merge = this.ac.createChannelMerger(2);\n\n this._leftGain = this.ac.createGain();\n this._rightGain = this.ac.createGain();\n /**\n * The p5.Delay is built with two\n * \n * Web Audio Delay Nodes, one for each stereo channel.\n *\n * @for p5.Delay\n * @property {DelayNode} leftDelay\n */\n this.leftDelay = this.ac.createDelay();\n /**\n * The p5.Delay is built with two\n * \n * Web Audio Delay Nodes, one for each stereo channel.\n * @for p5.Delay\n * @property {DelayNode} rightDelay\n */\n this.rightDelay = this.ac.createDelay();\n\n this._leftFilter = new Filter();\n this._rightFilter = new Filter();\n this._leftFilter.disconnect();\n this._rightFilter.disconnect();\n\n this._leftFilter.biquad.frequency.setValueAtTime(1200, this.ac.currentTime);\n this._rightFilter.biquad.frequency.setValueAtTime(\n 1200,\n this.ac.currentTime\n );\n this._leftFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\n this._rightFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\n\n // graph routing\n this.input.connect(this._split);\n this.leftDelay.connect(this._leftGain);\n this.rightDelay.connect(this._rightGain);\n this._leftGain.connect(this._leftFilter.input);\n this._rightGain.connect(this._rightFilter.input);\n this._merge.connect(this.wet);\n\n this._leftFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\n this._rightFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\n\n // default routing\n this.setType(0);\n\n this._maxDelay = this.leftDelay.delayTime.maxValue;\n\n // set initial feedback to 0.5\n this.feedback(0.5);\n }\n /**\n * Add delay to an audio signal according to a set\n * of delay parameters.\n *\n * @method process\n * @for p5.Delay\n * @param {Object} Signal An object that outputs audio\n * @param {Number} [delayTime] Time (in seconds) of the delay/echo.\n * Some browsers limit delayTime to\n * 1 second.\n * @param {Number} [feedback] sends the delay back through itself\n * in a loop that decreases in volume\n * each time.\n * @param {Number} [lowPass] Cutoff frequency. Only frequencies\n * below the lowPass will be part of the\n * delay.\n */\n process(src, _delayTime, _feedback, _filter) {\n var feedback = _feedback || 0;\n var delayTime = _delayTime || 0;\n if (feedback >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n }\n if (delayTime >= this._maxDelay) {\n throw new Error(\n 'Delay Time exceeds maximum delay time of ' +\n this._maxDelay +\n ' second.'\n );\n }\n\n src.connect(this.input);\n this.leftDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\n this.rightDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\n this._leftGain.gain.value = feedback;\n this._rightGain.gain.value = feedback;\n\n if (_filter) {\n this._leftFilter.freq(_filter);\n this._rightFilter.freq(_filter);\n }\n }\n\n /**\n * Set the delay (echo) time, in seconds. Usually this value will be\n * a floating point number between 0.0 and 1.0.\n *\n * @method delayTime\n * @for p5.Delay\n * @param {Number} delayTime Time (in seconds) of the delay\n */\n delayTime(t) {\n // if t is an audio node...\n if (typeof t !== 'number') {\n t.connect(this.leftDelay.delayTime);\n t.connect(this.rightDelay.delayTime);\n } else {\n this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\n this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\n this.leftDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\n this.rightDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\n }\n }\n\n /**\n * Feedback occurs when Delay sends its signal back through its input\n * in a loop. The feedback amount determines how much signal to send each\n * time through the loop. A feedback greater than 1.0 is not desirable because\n * it will increase the overall output each time through the loop,\n * creating an infinite feedback loop. The default value is 0.5\n *\n * @method feedback\n * @for p5.Delay\n * @param {Number|Object} feedback 0.0 to 1.0, or an object such as an\n * Oscillator that can be used to\n * modulate this param\n * @returns {Number} Feedback value\n *\n */\n feedback(f) {\n // if f is an audio node...\n if (f && typeof f !== 'number') {\n f.connect(this._leftGain.gain);\n f.connect(this._rightGain.gain);\n } else if (f >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n } else if (typeof f === 'number') {\n this._leftGain.gain.value = f;\n this._rightGain.gain.value = f;\n }\n\n // return value of feedback\n return this._leftGain.gain.value;\n }\n\n /**\n * Set a lowpass filter frequency for the delay. A lowpass filter\n * will cut off any frequencies higher than the filter frequency.\n *\n * @method filter\n * @for p5.Delay\n * @param {Number|Object} cutoffFreq A lowpass filter will cut off any\n * frequencies higher than the filter frequency.\n * @param {Number|Object} res Resonance of the filter frequency\n * cutoff, or an object (i.e. a p5.Oscillator)\n * that can be used to modulate this parameter.\n * High numbers (i.e. 15) will produce a resonance,\n * low numbers (i.e. .2) will produce a slope.\n */\n filter(freq, q) {\n this._leftFilter.set(freq, q);\n this._rightFilter.set(freq, q);\n }\n\n /**\n * Choose a preset type of delay. 'pingPong' bounces the signal\n * from the left to the right channel to produce a stereo effect.\n * Any other parameter will revert to the default delay setting.\n *\n * @method setType\n * @for p5.Delay\n * @param {String|Number} type 'pingPong' (1) or 'default' (0)\n */\n setType(t) {\n if (t === 1) {\n t = 'pingPong';\n }\n this._split.disconnect();\n this._leftFilter.disconnect();\n this._rightFilter.disconnect();\n this._split.connect(this.leftDelay, 0);\n this._split.connect(this.rightDelay, 1);\n switch (t) {\n case 'pingPong':\n this._rightFilter.setType(this._leftFilter.biquad.type);\n this._leftFilter.output.connect(this._merge, 0, 0);\n this._rightFilter.output.connect(this._merge, 0, 1);\n this._leftFilter.output.connect(this.rightDelay);\n this._rightFilter.output.connect(this.leftDelay);\n break;\n default:\n this._leftFilter.output.connect(this._merge, 0, 0);\n this._rightFilter.output.connect(this._merge, 0, 1);\n this._leftFilter.output.connect(this.leftDelay);\n this._rightFilter.output.connect(this.rightDelay);\n }\n }\n\n // DocBlocks for methods inherited from p5.Effect\n /**\n * Set the output level of the delay effect.\n *\n * @method amp\n * @for p5.Delay\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Delay\n * @param {Object} unit\n */\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Delay\n */\n\n dispose() {\n super.dispose();\n\n this._split.disconnect();\n this._leftFilter.dispose();\n this._rightFilter.dispose();\n this._merge.disconnect();\n this._leftGain.disconnect();\n this._rightGain.disconnect();\n this.leftDelay.disconnect();\n this.rightDelay.disconnect();\n\n this._split = undefined;\n this._leftFilter = undefined;\n this._rightFilter = undefined;\n this._merge = undefined;\n this._leftGain = undefined;\n this._rightGain = undefined;\n this.leftDelay = undefined;\n this.rightDelay = undefined;\n }\n}\n\nexport default Delay;\n","import { getAudioContext } from './audiocontext';\nimport CustomError from './errorHandler';\nimport Effect from './effect';\n\n/**\n * Reverb adds depth to a sound through a large number of decaying\n * echoes. It creates the perception that sound is occurring in a\n * physical space. The p5.Reverb has paramters for Time (how long does the\n * reverb last) and decayRate (how much the sound decays with each echo)\n * that can be set with the .set() or .process() methods. The p5.Convolver\n * extends p5.Reverb allowing you to recreate the sound of actual physical\n * spaces through convolution.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Reverb\n * @extends p5.Effect\n * @constructor\n * @example\n *
\n * let soundFile, reverb;\n * function preload() {\n * soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n *\n * reverb = new p5.Reverb();\n * soundFile.disconnect(); // so we'll only hear reverb...\n *\n * // connect soundFile to reverb, process w/\n * // 3 second reverbTime, decayRate of 2%\n * reverb.process(soundFile, 3, 2);\n * }\n *\n * function draw() {\n * let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);\n * // 1 = all reverb, 0 = no reverb\n * reverb.drywet(dryWet);\n *\n * background(220);\n * text('tap to play', 10, 20);\n * text('dry/wet: ' + round(dryWet * 100) + '%', 10, height - 20);\n * }\n *\n * function playSound() {\n * soundFile.play();\n * }\n *
\n */\n\nclass Reverb extends Effect {\n constructor() {\n super();\n this._initConvolverNode();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n\n // default params\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n _initConvolverNode() {\n this.convolverNode = this.ac.createConvolver();\n this.input.connect(this.convolverNode);\n this.convolverNode.connect(this.wet);\n }\n\n _teardownConvolverNode() {\n if (this.convolverNode) {\n this.convolverNode.disconnect();\n delete this.convolverNode;\n }\n }\n\n _setBuffer(audioBuffer) {\n this._teardownConvolverNode();\n this._initConvolverNode();\n this.convolverNode.buffer = audioBuffer;\n }\n /**\n * Connect a source to the reverb, and assign reverb parameters.\n *\n * @method process\n * @for p5.Reverb\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n * @param {Number} [seconds] Duration of the reverb, in seconds.\n * Min: 0, Max: 10. Defaults to 3.\n * @param {Number} [decayRate] Percentage of decay with each echo.\n * Min: 0, Max: 100. Defaults to 2.\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\n */\n process(src, seconds, decayRate, reverse) {\n src.connect(this.input);\n var rebuild = false;\n if (seconds) {\n this._seconds = seconds;\n rebuild = true;\n }\n if (decayRate) {\n this._decay = decayRate;\n }\n if (reverse) {\n this._reverse = reverse;\n }\n if (rebuild) {\n this._buildImpulse();\n }\n }\n\n /**\n * Set the reverb settings. Similar to .process(), but without\n * assigning a new input.\n *\n * @method set\n * @for p5.Reverb\n * @param {Number} [seconds] Duration of the reverb, in seconds.\n * Min: 0, Max: 10. Defaults to 3.\n * @param {Number} [decayRate] Percentage of decay with each echo.\n * Min: 0, Max: 100. Defaults to 2.\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\n */\n set(seconds, decayRate, reverse) {\n var rebuild = false;\n if (seconds) {\n this._seconds = seconds;\n rebuild = true;\n }\n if (decayRate) {\n this._decay = decayRate;\n }\n if (reverse) {\n this._reverse = reverse;\n }\n if (rebuild) {\n this._buildImpulse();\n }\n }\n\n // DocBlocks for methods inherited from p5.Effect\n /**\n * Set the output level of the reverb effect.\n *\n * @method amp\n * @for p5.Reverb\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Reverb\n * @param {Object} unit\n */\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Reverb\n */\n\n /**\n * Inspired by Simple Reverb by Jordan Santell\n * https://github.com/web-audio-components/simple-reverb/blob/master/index.js\n *\n * Utility function for building an impulse response\n * based on the module parameters.\n *\n * @private\n */\n _buildImpulse() {\n var rate = this.ac.sampleRate;\n var length = rate * this._seconds;\n var decay = this._decay;\n var impulse = this.ac.createBuffer(2, length, rate);\n var impulseL = impulse.getChannelData(0);\n var impulseR = impulse.getChannelData(1);\n var n, i;\n for (i = 0; i < length; i++) {\n n = this._reverse ? length - i : i;\n impulseL[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\n impulseR[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\n }\n this._setBuffer(impulse);\n }\n\n dispose() {\n super.dispose();\n this._teardownConvolverNode();\n }\n}\n\n// =======================================================================\n// *** p5.Convolver ***\n// =======================================================================\n\n/**\n *

p5.Convolver extends p5.Reverb. It can emulate the sound of real\n * physical spaces through a process called \n * convolution.

\n *\n *

Convolution multiplies any audio input by an \"impulse response\"\n * to simulate the dispersion of sound over time. The impulse response is\n * generated from an audio file that you provide. One way to\n * generate an impulse response is to pop a balloon in a reverberant space\n * and record the echo. Convolution can also be used to experiment with\n * sound.

\n *\n *

Use the method createConvolution(path) to instantiate a\n * p5.Convolver with a path to your impulse response audio file.

\n *\n * @class p5.Convolver\n * @extends p5.Effect\n * @constructor\n * @param {String} path path to a sound file\n * @param {Function} [callback] function to call when loading succeeds\n * @param {Function} [errorCallback] function to call if loading fails.\n * This function will receive an error or\n * XMLHttpRequest object with information\n * about what went wrong.\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from master output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *
\n */\nclass Convolver extends Reverb {\n constructor(path, callback, errorCallback) {\n super();\n /**\n * Internally, the p5.Convolver uses the a\n * \n * Web Audio Convolver Node.\n *\n * @property {ConvolverNode} convolverNode\n */\n this._initConvolverNode();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n\n if (path) {\n this.impulses = [];\n this._loadBuffer(path, callback, errorCallback);\n } else {\n // parameters\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n /**\n * If you load multiple impulse files using the .addImpulse method,\n * they will be stored as Objects in this Array. Toggle between them\n * with the toggleImpulse(id) method.\n *\n * @property {Array} impulses\n * @for p5.Convolver\n */\n this.impulses = [];\n this.set = null;\n }\n\n /**\n * Private method to load a buffer as an Impulse Response,\n * assign it to the convolverNode, and add to the Array of .impulses.\n *\n * @param {String} path\n * @param {Function} callback\n * @param {Function} errorCallback\n * @private\n */\n _loadBuffer(_path, callback, errorCallback) {\n var path = p5.prototype._checkFileFormats(_path);\n var self = this;\n var errorTrace = new Error().stack;\n var ac = getAudioContext();\n\n var request = new XMLHttpRequest();\n request.open('GET', path, true);\n request.responseType = 'arraybuffer';\n\n request.onload = function () {\n if (request.status === 200) {\n // on success loading file:\n ac.decodeAudioData(\n request.response,\n function (buff) {\n var buffer = {};\n var chunks = path.split('/');\n buffer.name = chunks[chunks.length - 1];\n buffer.audioBuffer = buff;\n self.impulses.push(buffer);\n self._setBuffer(buffer.audioBuffer);\n if (callback) {\n callback(buffer);\n }\n },\n // error decoding buffer. \"e\" is undefined in Chrome 11/22/2015\n function () {\n var err = new CustomError('decodeAudioData', errorTrace, self.url);\n var msg = 'AudioContext error at decodeAudioData for ' + self.url;\n if (errorCallback) {\n err.msg = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n );\n }\n // if request status != 200, it failed\n else {\n var err = new CustomError('loadConvolver', errorTrace, self.url);\n var msg =\n 'Unable to load ' +\n self.url +\n '. The request status was: ' +\n request.status +\n ' (' +\n request.statusText +\n ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n };\n\n // if there is another error, aside from 404...\n request.onerror = function () {\n var err = new CustomError('loadConvolver', errorTrace, self.url);\n var msg =\n 'There was no response from the server at ' +\n self.url +\n '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n };\n request.send();\n }\n\n /**\n * Connect a source to the convolver.\n *\n * @method process\n * @for p5.Convolver\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from master output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *\n *
\n */\n process(src) {\n src.connect(this.input);\n }\n\n /**\n * Load and assign a new Impulse Response to the p5.Convolver.\n * The impulse is added to the .impulses array. Previous\n * impulses can be accessed with the .toggleImpulse(id)\n * method.\n *\n * @method addImpulse\n * @for p5.Convolver\n * @param {String} path path to a sound file\n * @param {Function} callback function (optional)\n * @param {Function} errorCallback function (optional)\n */\n addImpulse(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n this._loadBuffer(path, callback, errorCallback);\n }\n\n /**\n * Similar to .addImpulse, except that the .impulses\n * Array is reset to save memory. A new .impulses\n * array is created with this impulse as the only item.\n *\n * @method resetImpulse\n * @for p5.Convolver\n * @param {String} path path to a sound file\n * @param {Function} callback function (optional)\n * @param {Function} errorCallback function (optional)\n */\n resetImpulse(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n this.impulses = [];\n this._loadBuffer(path, callback, errorCallback);\n }\n\n /**\n * If you have used .addImpulse() to add multiple impulses\n * to a p5.Convolver, then you can use this method to toggle between\n * the items in the .impulses Array. Accepts a parameter\n * to identify which impulse you wish to use, identified either by its\n * original filename (String) or by its position in the .impulses\n * Array (Number).
\n * You can access the objects in the .impulses Array directly. Each\n * Object has two attributes: an .audioBuffer (type:\n * Web Audio \n * AudioBuffer) and a .name, a String that corresponds\n * with the original filename.\n *\n * @method toggleImpulse\n * @for p5.Convolver\n * @param {String|Number} id Identify the impulse by its original filename\n * (String), or by its position in the\n * .impulses Array (Number).\n */\n toggleImpulse(id) {\n if (typeof id === 'number' && id < this.impulses.length) {\n this._setBuffer(this.impulses[id].audioBuffer);\n }\n if (typeof id === 'string') {\n for (var i = 0; i < this.impulses.length; i++) {\n if (this.impulses[i].name === id) {\n this._setBuffer(this.impulses[i].audioBuffer);\n break;\n }\n }\n }\n }\n\n dispose() {\n super.dispose();\n\n // remove all the Impulse Response buffers\n for (var i in this.impulses) {\n if (this.impulses[i]) {\n this.impulses[i] = null;\n }\n }\n }\n}\n\n/**\n * Create a p5.Convolver. Accepts a path to a soundfile\n * that will be used to generate an impulse response.\n *\n * @method createConvolver\n * @for p5\n * @param {String} path path to a sound file\n * @param {Function} [callback] function to call if loading is successful.\n * The object will be passed in as the argument\n * to the callback function.\n * @param {Function} [errorCallback] function to call if loading is not successful.\n * A custom error will be passed in as the argument\n * to the callback function.\n * @return {p5.Convolver}\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from master output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *
\n */\nfunction createConvolver(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n var self = this;\n var cReverb = new Convolver(\n path,\n function (buffer) {\n if (typeof callback === 'function') {\n callback(buffer);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n },\n errorCallback\n );\n cReverb.impulses = [];\n return cReverb;\n}\n\nexport { Reverb, Convolver, createConvolver };\n","import p5sound from './master';\n// requires the Tone.js library's Clock (MIT license, Yotam Mann)\n// https://github.com/TONEnoTONE/Tone.js/\nimport Clock from 'Tone/core/Clock';\n\nclass Metro {\n constructor() {\n this.clock = new Clock({\n callback: this.ontick.bind(this),\n });\n this.syncedParts = [];\n this.bpm = 120; // gets overridden by p5.Part\n this._init();\n\n this.prevTick = 0;\n this.tatumTime = 0;\n\n this.tickCallback = function () {};\n }\n\n ontick(tickTime) {\n var elapsedTime = tickTime - this.prevTick;\n var secondsFromNow = tickTime - p5sound.audiocontext.currentTime;\n if (elapsedTime - this.tatumTime <= -0.02) {\n return;\n } else {\n // console.log('ok', this.syncedParts[0].phrases[0].name);\n this.prevTick = tickTime;\n\n // for all of the active things on the metro:\n var self = this;\n this.syncedParts.forEach(function (thisPart) {\n if (!thisPart.isPlaying) return;\n thisPart.incrementStep(secondsFromNow);\n // each synced source keeps track of its own beat number\n thisPart.phrases.forEach(function (thisPhrase) {\n var phraseArray = thisPhrase.sequence;\n var bNum = self.metroTicks % phraseArray.length;\n if (\n phraseArray[bNum] !== 0 &&\n (self.metroTicks < phraseArray.length || !thisPhrase.looping)\n ) {\n thisPhrase.callback(secondsFromNow, phraseArray[bNum]);\n }\n });\n });\n this.metroTicks += 1;\n this.tickCallback(secondsFromNow);\n }\n }\n\n setBPM(bpm, rampTime = 0) {\n var beatTime = 60 / (bpm * this.tatums);\n var now = p5sound.audiocontext.currentTime;\n this.tatumTime = beatTime;\n\n this.clock.frequency.setValueAtTime(this.clock.frequency.value, now);\n this.clock.frequency.linearRampToValueAtTime(bpm, now + rampTime);\n this.bpm = bpm;\n }\n\n getBPM() {\n return (this.clock.getRate() / this.tatums) * 60;\n }\n\n _init() {\n this.metroTicks = 0;\n // this.setBPM(120);\n }\n\n // clear existing synced parts, add only this one\n resetSync(part) {\n this.syncedParts = [part];\n }\n\n // push a new synced part to the array\n pushSync(part) {\n this.syncedParts.push(part);\n }\n\n start(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.start(now + t);\n this.setBPM(this.bpm);\n }\n\n stop(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.stop(now + t);\n }\n\n beatLength(tatums) {\n this.tatums = 1 / tatums / 4; // lowest possible division of a beat\n }\n}\nexport default Metro;\n","import p5sound from './master';\nimport Metro from './metro';\n\nvar BPM = 120;\n\n/**\n * Set the global tempo, in beats per minute, for all\n * p5.Parts. This method will impact all active p5.Parts.\n *\n * @method setBPM\n * @for p5\n * @param {Number} BPM Beats Per Minute\n * @param {Number} rampTime Seconds from now\n */\np5.prototype.setBPM = function (bpm, rampTime) {\n BPM = bpm;\n for (var i in p5sound.parts) {\n if (p5sound.parts[i]) {\n p5sound.parts[i].setBPM(bpm, rampTime);\n }\n }\n};\n\n/**\n *

A phrase is a pattern of musical events over time, i.e.\n * a series of notes and rests.

\n *\n *

Phrases must be added to a p5.Part for playback, and\n * each part can play multiple phrases at the same time.\n * For example, one Phrase might be a kick drum, another\n * could be a snare, and another could be the bassline.

\n *\n *

The first parameter is a name so that the phrase can be\n * modified or deleted later. The callback is a a function that\n * this phrase will call at every step—for example it might be\n * called playNote(value){}. The array determines\n * which value is passed into the callback at each step of the\n * phrase. It can be numbers, an object with multiple numbers,\n * or a zero (0) indicates a rest so the callback won't be called).

\n *\n * @class p5.Phrase\n * @constructor\n * @param {String} name Name so that you can access the Phrase.\n * @param {Function} callback The name of a function that this phrase\n * will call. Typically it will play a sound,\n * and accept two parameters: a time at which\n * to play the sound (in seconds from now),\n * and a value from the sequence array. The\n * time should be passed into the play() or\n * start() method to ensure precision.\n * @param {Array} sequence Array of values to pass into the callback\n * at each step of the phrase.\n * @example\n *
\n * let mySound, myPhrase, myPart;\n * let pattern = [1,0,0,2,0,2,0,0];\n *\n * function preload() {\n * mySound = loadSound('assets/beatbox.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playMyPart);\n * background(220);\n * text('tap to play', width/2, height/2);\n * textAlign(CENTER, CENTER);\n *\n * myPhrase = new p5.Phrase('bbox', onEachStep, pattern);\n * myPart = new p5.Part();\n * myPart.addPhrase(myPhrase);\n * myPart.setBPM(60);\n * }\n *\n * function onEachStep(time, playbackRate) {\n * mySound.rate(playbackRate);\n * mySound.play(time);\n * }\n *\n * function playMyPart() {\n * userStartAudio();\n * myPart.start();\n * }\n *
\n */\nclass Phrase {\n constructor(name, callback, sequence) {\n this.phraseStep = 0;\n this.name = name;\n this.callback = callback;\n /**\n * Array of values to pass into the callback\n * at each step of the phrase. Depending on the callback\n * function's requirements, these values may be numbers,\n * strings, or an object with multiple parameters.\n * Zero (0) indicates a rest.\n *\n * @property {Array} sequence\n */\n this.sequence = sequence;\n }\n}\n\n/**\n *

A p5.Part plays back one or more p5.Phrases. Instantiate a part\n * with steps and tatums. By default, each step represents a 1/16th note.

\n *\n *

See p5.Phrase for more about musical timing.

\n *\n * @class p5.Part\n * @constructor\n * @param {Number} [steps] Steps in the part\n * @param {Number} [tatums] Divisions of a beat, e.g. use 1/4, or 0.25 for a quater note (default is 1/16, a sixteenth note)\n * @example\n *
\n * let box, drum, myPart;\n * let boxPat = [1,0,0,2,0,2,0,0];\n * let drumPat = [0,1,1,0,2,0,1,0];\n *\n * function preload() {\n * box = loadSound('assets/beatbox.mp3');\n * drum = loadSound('assets/drum.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playMyPart);\n * background(220);\n * textAlign(CENTER, CENTER);\n * text('tap to play', width/2, height/2);\n *\n * let boxPhrase = new p5.Phrase('box', playBox, boxPat);\n * let drumPhrase = new p5.Phrase('drum', playDrum, drumPat);\n * myPart = new p5.Part();\n * myPart.addPhrase(boxPhrase);\n * myPart.addPhrase(drumPhrase);\n * myPart.setBPM(60);\n * }\n *\n * function playBox(time, playbackRate) {\n * box.rate(playbackRate);\n * box.play(time);\n * }\n *\n * function playDrum(time, playbackRate) {\n * drum.rate(playbackRate);\n * drum.play(time);\n * }\n *\n * function playMyPart() {\n * userStartAudio();\n *\n * myPart.start();\n * }\n *
\n */\nclass Part {\n constructor(steps, bLength) {\n this.length = steps || 0; // how many beats\n this.partStep = 0;\n this.phrases = [];\n this.isPlaying = false;\n this.noLoop();\n this.tatums = bLength || 0.0625; // defaults to quarter note\n\n this.metro = new Metro();\n this.metro._init();\n this.metro.beatLength(this.tatums);\n this.metro.setBPM(BPM);\n p5sound.parts.push(this);\n this.callback = function () {};\n }\n\n /**\n * Set the tempo of this part, in Beats Per Minute.\n *\n * @method setBPM\n * @for p5.Part\n * @param {Number} BPM Beats Per Minute\n * @param {Number} [rampTime] Seconds from now\n */\n setBPM(tempo, rampTime) {\n this.metro.setBPM(tempo, rampTime);\n }\n\n /**\n * Returns the tempo, in Beats Per Minute, of this part.\n *\n * @method getBPM\n * @for p5.Part\n * @return {Number}\n */\n getBPM() {\n return this.metro.getBPM();\n }\n\n /**\n * Start playback of this part. It will play\n * through all of its phrases at a speed\n * determined by setBPM.\n *\n * @method start\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n start(time) {\n if (!this.isPlaying) {\n this.isPlaying = true;\n this.metro.resetSync(this);\n var t = time || 0;\n this.metro.start(t);\n }\n }\n\n /**\n * Loop playback of this part. It will begin\n * looping through all of its phrases at a speed\n * determined by setBPM.\n *\n * @method loop\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n loop(time) {\n this.looping = true;\n // rest onended function\n this.onended = function () {\n this.partStep = 0;\n };\n var t = time || 0;\n this.start(t);\n }\n\n /**\n * Tell the part to stop looping.\n *\n * @method noLoop\n * @for p5.Part\n */\n noLoop() {\n this.looping = false;\n // rest onended function\n this.onended = function () {\n this.stop();\n };\n }\n\n /**\n * Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.\n *\n * @method stop\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n stop(time) {\n this.partStep = 0;\n this.pause(time);\n }\n\n /**\n * Pause the part. Playback will resume\n * from the current step.\n *\n * @method pause\n * @for p5.Part\n * @param {Number} time seconds from now\n */\n pause(time) {\n this.isPlaying = false;\n var t = time || 0;\n this.metro.stop(t);\n }\n\n /**\n * Add a p5.Phrase to this Part.\n *\n * @method addPhrase\n * @for p5.Part\n * @param {p5.Phrase} phrase reference to a p5.Phrase\n */\n addPhrase(name, callback, array) {\n var p;\n if (arguments.length === 3) {\n p = new Phrase(name, callback, array);\n } else if (arguments[0] instanceof Phrase) {\n p = arguments[0];\n } else {\n throw 'invalid input. addPhrase accepts name, callback, array or a p5.Phrase';\n }\n this.phrases.push(p);\n // reset the length if phrase is longer than part's existing length\n if (p.sequence.length > this.length) {\n this.length = p.sequence.length;\n }\n }\n\n /**\n * Remove a phrase from this part, based on the name it was\n * given when it was created.\n *\n * @method removePhrase\n * @for p5.Part\n * @param {String} phraseName\n */\n removePhrase(name) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n this.phrases.splice(i, 1);\n }\n }\n }\n\n /**\n * Get a phrase from this part, based on the name it was\n * given when it was created. Now you can modify its array.\n *\n * @method getPhrase\n * @for p5.Part\n * @param {String} phraseName\n */\n getPhrase(name) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n return this.phrases[i];\n }\n }\n }\n\n /**\n * Find all sequences with the specified name, and replace their patterns with the specified array.\n *\n * @method replaceSequence\n * @for p5.Part\n * @param {String} phraseName\n * @param {Array} sequence Array of values to pass into the callback\n * at each step of the phrase.\n */\n replaceSequence(name, array) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n this.phrases[i].sequence = array;\n }\n }\n }\n\n incrementStep(time) {\n if (this.partStep < this.length - 1) {\n this.callback(time);\n this.partStep += 1;\n } else {\n if (!this.looping && this.partStep === this.length - 1) {\n // this.callback(time);\n this.onended();\n }\n }\n }\n\n /**\n * Set the function that will be called at every step. This will clear the previous function.\n *\n * @method onStep\n * @for p5.Part\n * @param {Function} callback The name of the callback\n * you want to fire\n * on every beat/tatum.\n */\n onStep(callback) {\n this.callback = callback;\n }\n}\n\n// ===============\n// p5.Score\n// ===============\n\n/**\n * A Score consists of a series of Parts. The parts will\n * be played back in order. For example, you could have an\n * A part, a B part, and a C part, and play them back in this order\n * new p5.Score(a, a, b, a, c)\n *\n * @class p5.Score\n * @constructor\n * @param {p5.Part} [...parts] One or multiple parts, to be played in sequence.\n */\nclass Score {\n constructor() {\n // for all of the arguments\n this.parts = [];\n this.currentPart = 0;\n\n var thisScore = this;\n for (var i in arguments) {\n if (arguments[i] && this.parts[i]) {\n this.parts[i] = arguments[i];\n this.parts[i].nextPart = this.parts[i + 1];\n this.parts[i].onended = function () {\n thisScore.resetPart(i);\n playNextPart(thisScore);\n };\n }\n }\n this.looping = false;\n }\n\n onended() {\n if (this.looping) {\n // this.resetParts();\n this.parts[0].start();\n } else {\n this.parts[this.parts.length - 1].onended = function () {\n this.stop();\n this.resetParts();\n };\n }\n this.currentPart = 0;\n }\n\n /**\n * Start playback of the score.\n *\n * @method start\n * @for p5.Score\n */\n start() {\n this.parts[this.currentPart].start();\n this.scoreStep = 0;\n }\n\n /**\n * Stop playback of the score.\n *\n * @method stop\n * @for p5.Score\n */\n stop() {\n this.parts[this.currentPart].stop();\n this.currentPart = 0;\n this.scoreStep = 0;\n }\n\n /**\n * Pause playback of the score.\n *\n * @method pause\n * @for p5.Score\n */\n pause() {\n this.parts[this.currentPart].stop();\n }\n\n /**\n * Loop playback of the score.\n *\n * @method loop\n * @for p5.Score\n */\n loop() {\n this.looping = true;\n this.start();\n }\n\n /**\n * Stop looping playback of the score. If it\n * is currently playing, this will go into effect\n * after the current round of playback completes.\n *\n * @method noLoop\n * @for p5.Score\n */\n noLoop() {\n this.looping = false;\n }\n\n resetParts() {\n var self = this;\n this.parts.forEach(function (part) {\n self.resetParts[part];\n });\n }\n\n resetPart(i) {\n this.parts[i].stop();\n this.parts[i].partStep = 0;\n for (var p in this.parts[i].phrases) {\n if (this.parts[i]) {\n this.parts[i].phrases[p].phraseStep = 0;\n }\n }\n }\n\n /**\n * Set the tempo for all parts in the score\n *\n * @method setBPM\n * @for p5.Score\n * @param {Number} BPM Beats Per Minute\n * @param {Number} rampTime Seconds from now\n */\n setBPM(bpm, rampTime) {\n for (var i in this.parts) {\n if (this.parts[i]) {\n this.parts[i].setBPM(bpm, rampTime);\n }\n }\n }\n}\n\nfunction playNextPart(aScore) {\n aScore.currentPart++;\n if (aScore.currentPart >= aScore.parts.length) {\n aScore.scoreStep = 0;\n aScore.onended();\n } else {\n aScore.scoreStep = 0;\n aScore.parts[aScore.currentPart - 1].stop();\n aScore.parts[aScore.currentPart].start();\n }\n}\n\nexport { Phrase, Part, Score };\n","import p5sound from './master';\nimport Clock from 'Tone/core/Clock';\n\n/**\n * SoundLoop\n *\n * @class p5.SoundLoop\n * @constructor\n *\n * @param {Function} callback this function will be called on each iteration of theloop\n * @param {Number|String} [interval] amount of time (if a number) or beats (if a string, following Tone.Time convention) for each iteration of the loop. Defaults to 1 second.\n *\n * @example\n *
\n * let synth, soundLoop;\n * let notePattern = [60, 62, 64, 67, 69, 72];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * colorMode(HSB);\n * background(0, 0, 86);\n * text('tap to start/stop', 10, 20);\n *\n * //the looper's callback is passed the timeFromNow\n * //this value should be used as a reference point from\n * //which to schedule sounds\n * let intervalInSeconds = 0.2;\n * soundLoop = new p5.SoundLoop(onSoundLoop, intervalInSeconds);\n *\n * synth = new p5.MonoSynth();\n * }\n *\n * function canvasPressed() {\n * // ensure audio is enabled\n * userStartAudio();\n *\n * if (soundLoop.isPlaying) {\n * soundLoop.stop();\n * } else {\n * // start the loop\n * soundLoop.start();\n * }\n * }\n *\n * function onSoundLoop(timeFromNow) {\n * let noteIndex = (soundLoop.iterations - 1) % notePattern.length;\n * let note = midiToFreq(notePattern[noteIndex]);\n * synth.play(note, 0.5, timeFromNow);\n * background(noteIndex * 360 / notePattern.length, 50, 100);\n * }\n *
\n */\nclass SoundLoop {\n constructor(callback, interval) {\n /**\n * Getters and Setters, setting any paramter will result in a change in the clock's\n * frequency, that will be reflected after the next callback\n * beats per minute (defaults to 60)\n * @property {Number} bpm\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'bpm', {\n get: function () {\n return this._bpm;\n },\n set: function (bpm) {\n if (!this.musicalTimeMode) {\n console.warn(\n 'Changing the BPM in \"seconds\" mode has no effect. ' +\n 'BPM is only relevant in musicalTimeMode ' +\n 'when the interval is specified as a string ' +\n '(\"2n\", \"4n\", \"1m\"...etc)'\n );\n }\n this._bpm = bpm;\n this._update();\n },\n });\n\n /**\n * number of quarter notes in a measure (defaults to 4)\n * @property {Number} timeSignature\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'timeSignature', {\n get: function () {\n return this._timeSignature;\n },\n set: function (timeSig) {\n if (!this.musicalTimeMode) {\n console.warn(\n 'Changing the timeSignature in \"seconds\" mode has no effect. ' +\n 'BPM is only relevant in musicalTimeMode ' +\n 'when the interval is specified as a string ' +\n '(\"2n\", \"4n\", \"1m\"...etc)'\n );\n }\n this._timeSignature = timeSig;\n this._update();\n },\n });\n\n /**\n * length of the loops interval\n * @property {Number|String} interval\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'interval', {\n get: function () {\n return this._interval;\n },\n set: function (interval) {\n this.musicalTimeMode = typeof interval === 'number' ? false : true;\n this._interval = interval;\n this._update();\n },\n });\n\n /**\n * how many times the callback has been called so far\n * @property {Number} iterations\n * @for p5.SoundLoop\n * @readonly\n */\n Object.defineProperty(this, 'iterations', {\n get: function () {\n return this.clock.ticks;\n },\n });\n\n this.callback = callback;\n /**\n * musicalTimeMode uses Tone.Time convention\n * true if string, false if number\n * @property {Boolean} musicalTimeMode\n */\n this.musicalTimeMode = typeof this._interval === 'number' ? false : true;\n\n this._interval = interval || 1;\n\n /**\n * musicalTimeMode variables\n * modify these only when the interval is specified in musicalTime format as a string\n */\n this._timeSignature = 4;\n this._bpm = 60;\n\n this.isPlaying = false;\n\n /**\n * Set a limit to the number of loops to play. defaults to Infinity\n * @property {Number} maxIterations\n */\n this.maxIterations = Infinity;\n var self = this;\n\n this.clock = new Clock({\n callback: function (time) {\n var timeFromNow = time - p5sound.audiocontext.currentTime;\n /**\n * Do not initiate the callback if timeFromNow is < 0\n * This ususually occurs for a few milliseconds when the page\n * is not fully loaded\n *\n * The callback should only be called until maxIterations is reached\n */\n if (timeFromNow > 0 && self.iterations <= self.maxIterations) {\n self.callback(timeFromNow);\n }\n },\n frequency: this._calcFreq(),\n });\n }\n\n /**\n * Start the loop\n * @method start\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a starting time\n */\n start(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (!this.isPlaying) {\n this.clock.start(now + t);\n this.isPlaying = true;\n }\n }\n\n /**\n * Stop the loop\n * @method stop\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a stopping time\n */\n stop(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (this.isPlaying) {\n this.clock.stop(now + t);\n this.isPlaying = false;\n }\n }\n\n /**\n * Pause the loop\n * @method pause\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a pausing time\n */\n pause(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (this.isPlaying) {\n this.clock.pause(now + t);\n this.isPlaying = false;\n }\n }\n\n /**\n * Synchronize loops. Use this method to start two or more loops in synchronization\n * or to start a loop in synchronization with a loop that is already playing\n * This method will schedule the implicit loop in sync with the explicit master loop\n * i.e. loopToStart.syncedStart(loopToSyncWith)\n *\n * @method syncedStart\n * @for p5.SoundLoop\n * @param {Object} otherLoop a p5.SoundLoop to sync with\n * @param {Number} [timeFromNow] Start the loops in sync after timeFromNow seconds\n */\n syncedStart(otherLoop, timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n\n if (!otherLoop.isPlaying) {\n otherLoop.clock.start(now + t);\n otherLoop.isPlaying = true;\n this.clock.start(now + t);\n this.isPlaying = true;\n } else if (otherLoop.isPlaying) {\n var time = otherLoop.clock._nextTick - p5sound.audiocontext.currentTime;\n this.clock.start(now + time);\n this.isPlaying = true;\n }\n }\n /**\n * Updates frequency value, reflected in next callback\n * @private\n * @for p5.SoundLoop\n * @method _update\n */\n _update() {\n this.clock.frequency.value = this._calcFreq();\n }\n\n /**\n * Calculate the frequency of the clock's callback based on bpm, interval, and timesignature\n * @private\n * @for p5.SoundLoop\n * @method _calcFreq\n * @return {Number} new clock frequency value\n */\n _calcFreq() {\n //Seconds mode, bpm / timesignature has no effect\n if (typeof this._interval === 'number') {\n this.musicalTimeMode = false;\n return 1 / this._interval;\n }\n //Musical timing mode, calculate interval based bpm, interval,and time signature\n else if (typeof this._interval === 'string') {\n this.musicalTimeMode = true;\n return (\n (this._bpm / 60 / this._convertNotation(this._interval)) *\n (this._timeSignature / 4)\n );\n }\n }\n\n /**\n * Convert notation from musical time format to seconds\n * Uses Tone.Time convention\n * @private\n * @for p5.SoundLoop\n * @method _convertNotation\n * @param {String} value value to be converted\n * @return {Number} converted value in seconds\n */\n _convertNotation(value) {\n var type = value.slice(-1);\n value = Number(value.slice(0, -1));\n switch (type) {\n case 'm':\n return this._measure(value);\n case 'n':\n return this._note(value);\n default:\n console.warn(\n 'Specified interval is not formatted correctly. See Tone.js ' +\n 'timing reference for more info: https://github.com/Tonejs/Tone.js/wiki/Time'\n );\n }\n }\n\n /**\n * Helper conversion methods of measure and note\n * @private\n * @for p5.SoundLoop\n * @method _measure\n */\n _measure(value) {\n return value * this._timeSignature;\n }\n\n /**\n * @private\n * @method _note\n * @for p5.SoundLoop\n */\n _note(value) {\n return this._timeSignature / value;\n }\n}\n\nexport default SoundLoop;\n","import Effect from './effect';\n\n/**\n * Compressor is an audio effect class that performs dynamics compression\n * on an audio input source. This is a very commonly used technique in music\n * and sound production. Compression creates an overall louder, richer,\n * and fuller sound by lowering the volume of louds and raising that of softs.\n * Compression can be used to avoid clipping (sound distortion due to\n * peaks in volume) and is especially useful when many sounds are played\n * at once. Compression can be used on indivudal sound sources in addition\n * to the master output.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Compressor\n * @constructor\n * @extends p5.Effect\n *\n *\n */\nclass Compressor extends Effect {\n constructor() {\n super();\n /**\n *\n * The p5.Compressor is built with a Web Audio Dynamics Compressor Node\n * \n * @property {AudioNode} compressor\n */\n\n this.compressor = this.ac.createDynamicsCompressor();\n\n this.input.connect(this.compressor);\n this.compressor.connect(this.wet);\n }\n\n /**\n * Performs the same function as .connect, but also accepts\n * optional parameters to set compressor's audioParams\n * @method process\n * @for p5.Compressor\n *\n * @param {Object} src Sound source to be connected\n *\n * @param {Number} [attack] The amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} [knee] A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} [threshold] The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} [release] The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n */\n process(src, attack, knee, ratio, threshold, release) {\n src.connect(this.input);\n this.set(attack, knee, ratio, threshold, release);\n }\n\n /**\n * Set the paramters of a compressor.\n * @method set\n * @for p5.Compressor\n * @param {Number} attack The amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} knee A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} ratio The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} threshold The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n */\n set(attack, knee, ratio, threshold, release) {\n if (typeof attack !== 'undefined') {\n this.attack(attack);\n }\n if (typeof knee !== 'undefined') {\n this.knee(knee);\n }\n if (typeof ratio !== 'undefined') {\n this.ratio(ratio);\n }\n if (typeof threshold !== 'undefined') {\n this.threshold(threshold);\n }\n if (typeof release !== 'undefined') {\n this.release(release);\n }\n }\n\n /**\n * Get current attack or set value w/ time ramp\n *\n *\n * @method attack\n * @for p5.Compressor\n * @param {Number} [attack] Attack is the amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n attack(attack, time) {\n var t = time || 0;\n if (typeof attack === 'number') {\n this.compressor.attack.value = attack;\n this.compressor.attack.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.attack.linearRampToValueAtTime(\n attack,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof attack !== 'undefined') {\n attack.connect(this.compressor.attack);\n }\n return this.compressor.attack.value;\n }\n\n /**\n * Get current knee or set value w/ time ramp\n *\n * @method knee\n * @for p5.Compressor\n * @param {Number} [knee] A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n knee(knee, time) {\n var t = time || 0;\n if (typeof knee === 'number') {\n this.compressor.knee.value = knee;\n this.compressor.knee.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.knee.linearRampToValueAtTime(\n knee,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof knee !== 'undefined') {\n knee.connect(this.compressor.knee);\n }\n return this.compressor.knee.value;\n }\n\n /**\n * Get current ratio or set value w/ time ramp\n * @method ratio\n * @for p5.Compressor\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n ratio(ratio, time) {\n var t = time || 0;\n if (typeof ratio === 'number') {\n this.compressor.ratio.value = ratio;\n this.compressor.ratio.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.ratio.linearRampToValueAtTime(\n ratio,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof ratio !== 'undefined') {\n ratio.connect(this.compressor.ratio);\n }\n return this.compressor.ratio.value;\n }\n\n /**\n * Get current threshold or set value w/ time ramp\n * @method threshold\n * @for p5.Compressor\n * @param {Number} threshold The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n threshold(threshold, time) {\n var t = time || 0;\n if (typeof threshold === 'number') {\n this.compressor.threshold.value = threshold;\n this.compressor.threshold.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.threshold.linearRampToValueAtTime(\n threshold,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof threshold !== 'undefined') {\n threshold.connect(this.compressor.threshold);\n }\n return this.compressor.threshold.value;\n }\n\n /**\n * Get current release or set value w/ time ramp\n * @method release\n * @for p5.Compressor\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n *\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n release(release, time) {\n var t = time || 0;\n if (typeof release === 'number') {\n this.compressor.release.value = release;\n this.compressor.release.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.release.linearRampToValueAtTime(\n release,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof number !== 'undefined') {\n release.connect(this.compressor.release);\n }\n return this.compressor.release.value;\n }\n\n /**\n * Return the current reduction value\n *\n * @method reduction\n * @for p5.Compressor\n * @return {Number} Value of the amount of gain reduction that is applied to the signal\n */\n reduction() {\n return this.compressor.reduction.value;\n }\n\n dispose() {\n super.dispose();\n if (this.compressor) {\n this.compressor.disconnect();\n delete this.compressor;\n }\n }\n}\n\nexport default Compressor;\n","/**\n *

PeakDetect works in conjunction with p5.FFT to\n * look for onsets in some or all of the frequency spectrum.\n *

\n *

\n * To use p5.PeakDetect, call update in the draw loop\n * and pass in a p5.FFT object.\n *

\n *

\n * You can listen for a specific part of the frequency spectrum by\n * setting the range between freq1 and freq2.\n *

\n *\n *

threshold is the threshold for detecting a peak,\n * scaled between 0 and 1. It is logarithmic, so 0.1 is half as loud\n * as 1.0.

\n *\n *

\n * The update method is meant to be run in the draw loop, and\n * frames determines how many loops must pass before\n * another peak can be detected.\n * For example, if the frameRate() = 60, you could detect the beat of a\n * 120 beat-per-minute song with this equation:\n * framesPerPeak = 60 / (estimatedBPM / 60 );\n *

\n *\n *

\n * Based on example contribtued by @b2renger, and a simple beat detection\n * explanation by Felix Turner.\n *

\n *\n * @class p5.PeakDetect\n * @constructor\n * @param {Number} [freq1] lowFrequency - defaults to 20Hz\n * @param {Number} [freq2] highFrequency - defaults to 20000 Hz\n * @param {Number} [threshold] Threshold for detecting a beat between 0 and 1\n * scaled logarithmically where 0.1 is 1/2 the loudness\n * of 1.0. Defaults to 0.35.\n * @param {Number} [framesPerPeak] Defaults to 20.\n * @example\n *
\n *\n * var cnv, soundFile, fft, peakDetect;\n * var ellipseWidth = 10;\n *\n * function preload() {\n * soundFile = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * background(0);\n * noStroke();\n * fill(255);\n * textAlign(CENTER);\n *\n * // p5.PeakDetect requires a p5.FFT\n * fft = new p5.FFT();\n * peakDetect = new p5.PeakDetect();\n * }\n *\n * function draw() {\n * background(0);\n * text('click to play/pause', width/2, height/2);\n *\n * // peakDetect accepts an fft post-analysis\n * fft.analyze();\n * peakDetect.update(fft);\n *\n * if ( peakDetect.isDetected ) {\n * ellipseWidth = 50;\n * } else {\n * ellipseWidth *= 0.95;\n * }\n *\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n * }\n *\n * // toggle play/stop when canvas is clicked\n * function mouseClicked() {\n * if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n * if (soundFile.isPlaying() ) {\n * soundFile.stop();\n * } else {\n * soundFile.play();\n * }\n * }\n * }\n *
\n */\nclass PeakDetect {\n // framesPerPeak determines how often to look for a beat.\n // If a beat is provided, try to look for a beat based on bpm\n constructor(freq1, freq2, threshold, _framesPerPeak) {\n this.framesPerPeak = _framesPerPeak || 20;\n this.framesSinceLastPeak = 0;\n this.decayRate = 0.95;\n\n this.threshold = threshold || 0.35;\n this.cutoff = 0;\n\n // how much to increase the cutoff\n // TO DO: document this / figure out how to make it accessible\n this.cutoffMult = 1.5;\n\n this.energy = 0;\n this.penergy = 0;\n\n // TO DO: document this property / figure out how to make it accessible\n this.currentValue = 0;\n\n /**\n * isDetected is set to true when a peak is detected.\n *\n * @attribute isDetected {Boolean}\n * @default false\n */\n this.isDetected = false;\n\n this.f1 = freq1 || 40;\n this.f2 = freq2 || 20000;\n\n // function to call when a peak is detected\n this._onPeak = function () {};\n }\n\n /**\n * The update method is run in the draw loop.\n *\n * Accepts an FFT object. You must call .analyze()\n * on the FFT object prior to updating the peakDetect\n * because it relies on a completed FFT analysis.\n *\n * @method update\n * @param {p5.FFT} fftObject A p5.FFT object\n */\n update(fftObject) {\n var nrg = (this.energy = fftObject.getEnergy(this.f1, this.f2) / 255);\n if (nrg > this.cutoff && nrg > this.threshold && nrg - this.penergy > 0) {\n // trigger callback\n this._onPeak();\n this.isDetected = true;\n\n // debounce\n this.cutoff = nrg * this.cutoffMult;\n this.framesSinceLastPeak = 0;\n } else {\n this.isDetected = false;\n if (this.framesSinceLastPeak <= this.framesPerPeak) {\n this.framesSinceLastPeak++;\n } else {\n this.cutoff *= this.decayRate;\n this.cutoff = Math.max(this.cutoff, this.threshold);\n }\n }\n\n this.currentValue = nrg;\n this.penergy = nrg;\n }\n\n /**\n * onPeak accepts two arguments: a function to call when\n * a peak is detected. The value of the peak,\n * between 0.0 and 1.0, is passed to the callback.\n *\n * @method onPeak\n * @param {Function} callback Name of a function that will\n * be called when a peak is\n * detected.\n * @param {Object} [val] Optional value to pass\n * into the function when\n * a peak is detected.\n * @example\n *
\n * var cnv, soundFile, fft, peakDetect;\n * var ellipseWidth = 0;\n *\n * function preload() {\n * soundFile = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * cnv = createCanvas(100,100);\n * textAlign(CENTER);\n *\n * fft = new p5.FFT();\n * peakDetect = new p5.PeakDetect();\n *\n * setupSound();\n *\n * // when a beat is detected, call triggerBeat()\n * peakDetect.onPeak(triggerBeat);\n * }\n *\n * function draw() {\n * background(0);\n * fill(255);\n * text('click to play', width/2, height/2);\n *\n * fft.analyze();\n * peakDetect.update(fft);\n *\n * ellipseWidth *= 0.95;\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n * }\n *\n * // this function is called by peakDetect.onPeak\n * function triggerBeat() {\n * ellipseWidth = 50;\n * }\n *\n * // mouseclick starts/stops sound\n * function setupSound() {\n * cnv.mouseClicked( function() {\n * if (soundFile.isPlaying() ) {\n * soundFile.stop();\n * } else {\n * soundFile.play();\n * }\n * });\n * }\n *
\n */\n onPeak(callback, val) {\n var self = this;\n\n self._onPeak = function () {\n callback(self.energy, val);\n };\n }\n}\n\nexport default PeakDetect;\n","// inspiration: recorder.js, Tone.js & typedarray.org\n\nimport p5sound from './master';\nimport { safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\n\nconst ac = p5sound.audiocontext;\n\n/**\n *

Record sounds for playback and/or to save as a .wav file.\n * The p5.SoundRecorder records all sound output from your sketch,\n * or can be assigned a specific source with setInput().

\n *

The record() method accepts a p5.SoundFile as a parameter.\n * When playback is stopped (either after the given amount of time,\n * or with the stop() method), the p5.SoundRecorder will send its\n * recording to that p5.SoundFile for playback.

\n *\n * @class p5.SoundRecorder\n * @constructor\n * @example\n *
\n * let mic, recorder, soundFile;\n * let state = 0;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * textAlign(CENTER, CENTER);\n *\n * // create an audio in\n * mic = new p5.AudioIn();\n *\n * // prompts user to enable their browser mic\n * mic.start();\n *\n * // create a sound recorder\n * recorder = new p5.SoundRecorder();\n *\n * // connect the mic to the recorder\n * recorder.setInput(mic);\n *\n * // this sound file will be used to\n * // playback & save the recording\n * soundFile = new p5.SoundFile();\n *\n * text('tap to record', width/2, height/2);\n * }\n *\n * function canvasPressed() {\n * // ensure audio is enabled\n * userStartAudio();\n *\n * // make sure user enabled the mic\n * if (state === 0 && mic.enabled) {\n *\n * // record to our p5.SoundFile\n * recorder.record(soundFile);\n *\n * background(255,0,0);\n * text('Recording!', width/2, height/2);\n * state++;\n * }\n * else if (state === 1) {\n * background(0,255,0);\n *\n * // stop recorder and\n * // send result to soundFile\n * recorder.stop();\n *\n * text('Done! Tap to play and download', width/2, height/2, width - 20);\n * state++;\n * }\n *\n * else if (state === 2) {\n * soundFile.play(); // play the result!\n * save(soundFile, 'mySound.wav');\n * state++;\n * }\n * }\n *
\n */\nclass SoundRecorder {\n constructor() {\n this.input = ac.createGain();\n this.output = ac.createGain();\n\n this._inputChannels = 2;\n this._outputChannels = 2; // stereo output, even if input is mono\n\n const workletBufferSize = safeBufferSize(1024);\n\n this._workletNode = new AudioWorkletNode(\n ac,\n processorNames.recorderProcessor,\n {\n outputChannelCount: [this._outputChannels],\n processorOptions: {\n numInputChannels: this._inputChannels,\n bufferSize: workletBufferSize,\n },\n }\n );\n\n this._workletNode.port.onmessage = function (event) {\n if (event.data.name === 'buffers') {\n const buffers = [\n new Float32Array(event.data.leftBuffer),\n new Float32Array(event.data.rightBuffer),\n ];\n this._callback(buffers);\n }\n }.bind(this);\n\n /**\n * callback invoked when the recording is over\n * @private\n * @type Function(Float32Array)\n */\n this._callback = function () {};\n\n // connections\n this._workletNode.connect(p5.soundOut._silentNode);\n this.setInput();\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connect a specific device to the p5.SoundRecorder.\n * If no parameter is given, p5.SoundRecorer will record\n * all audible p5.sound from your sketch.\n *\n * @method setInput\n * @for p5.SoundRecorder\n * @param {Object} [unit] p5.sound object or a web audio unit\n * that outputs sound\n */\n setInput(unit) {\n this.input.disconnect();\n this.input = null;\n this.input = ac.createGain();\n this.input.connect(this._workletNode);\n this.input.connect(this.output);\n if (unit) {\n unit.connect(this.input);\n } else {\n p5.soundOut.output.connect(this.input);\n }\n }\n\n /**\n * Start recording. To access the recording, provide\n * a p5.SoundFile as the first parameter. The p5.SoundRecorder\n * will send its recording to that p5.SoundFile for playback once\n * recording is complete. Optional parameters include duration\n * (in seconds) of the recording, and a callback function that\n * will be called once the complete recording has been\n * transfered to the p5.SoundFile.\n *\n * @method record\n * @for p5.SoundRecorder\n * @param {p5.SoundFile} soundFile p5.SoundFile\n * @param {Number} [duration] Time (in seconds)\n * @param {Function} [callback] The name of a function that will be\n * called once the recording completes\n */\n record(sFile, duration, callback) {\n this._workletNode.port.postMessage({ name: 'start', duration: duration });\n\n if (sFile && callback) {\n this._callback = function (buffer) {\n sFile.setBuffer(buffer);\n callback();\n };\n } else if (sFile) {\n this._callback = function (buffer) {\n sFile.setBuffer(buffer);\n };\n }\n }\n\n /**\n * Stop the recording. Once the recording is stopped,\n * the results will be sent to the p5.SoundFile that\n * was given on .record(), and if a callback function\n * was provided on record, that function will be called.\n *\n * @method stop\n * @for p5.SoundRecorder\n */\n stop() {\n this._workletNode.port.postMessage({ name: 'stop' });\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this._callback = function () {};\n if (this.input) {\n this.input.disconnect();\n }\n this.input = null;\n this._workletNode = null;\n }\n}\n\nexport default SoundRecorder;\n","import Effect from './effect.js';\n\n/*\n * Adapted from [Kevin Ennis on StackOverflow](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n */\nfunction makeDistortionCurve(amount) {\n var k = typeof amount === 'number' ? amount : 50;\n var numSamples = 44100;\n var curve = new Float32Array(numSamples);\n var deg = Math.PI / 180;\n var i = 0;\n var x;\n for (; i < numSamples; ++i) {\n x = (i * 2) / numSamples - 1;\n curve[i] = ((3 + k) * x * 20 * deg) / (Math.PI + k * Math.abs(x));\n }\n return curve;\n}\n\n/**\n * A Distortion effect created with a Waveshaper Node,\n * with an approach adapted from\n * [Kevin Ennis](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Distortion\n * @extends p5.Effect\n * @constructor\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n *\n */\nclass Distortion extends Effect {\n constructor(amount, oversample) {\n super();\n if (typeof amount === 'undefined') {\n amount = 0.25;\n }\n if (typeof amount !== 'number') {\n throw new Error('amount must be a number');\n }\n if (typeof oversample === 'undefined') {\n oversample = '2x';\n }\n if (typeof oversample !== 'string') {\n throw new Error('oversample must be a String');\n }\n\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\n\n /**\n * The p5.Distortion is built with a\n * \n * Web Audio WaveShaper Node.\n *\n * @property {AudioNode} WaveShaperNode\n */\n this.waveShaperNode = this.ac.createWaveShaper();\n\n this.amount = curveAmount;\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\n this.waveShaperNode.oversample = oversample;\n\n this.input.connect(this.waveShaperNode);\n\n this.waveShaperNode.connect(this.wet);\n }\n\n /**\n * Process a sound source, optionally specify amount and oversample values.\n *\n * @method process\n * @for p5.Distortion\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n */\n process(src, amount, oversample) {\n src.connect(this.input);\n this.set(amount, oversample);\n }\n\n /**\n * Set the amount and oversample of the waveshaper distortion.\n *\n * @method set\n * @for p5.Distortion\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n */\n set(amount, oversample) {\n if (amount) {\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\n this.amount = curveAmount;\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\n }\n if (oversample) {\n this.waveShaperNode.oversample = oversample;\n }\n }\n\n /**\n * Return the distortion amount, typically between 0-1.\n *\n * @method getAmount\n * @for p5.Distortion\n * @return {Number} Unbounded distortion amount.\n * Normal values range from 0-1.\n */\n getAmount() {\n return this.amount;\n }\n\n /**\n * Return the oversampling.\n *\n * @method getOversample\n * @for p5.Distortion\n * @return {String} Oversample can either be 'none', '2x', or '4x'.\n */\n getOversample() {\n return this.waveShaperNode.oversample;\n }\n\n dispose() {\n super.dispose();\n if (this.waveShaperNode) {\n this.waveShaperNode.disconnect();\n this.waveShaperNode = null;\n }\n }\n}\n\nexport default Distortion;\n","import p5sound from './master';\n\n/**\n * A gain node is usefull to set the relative volume of sound.\n * It's typically used to build mixers.\n *\n * @class p5.Gain\n * @constructor\n * @example\n *
\n *\n * // load two soundfile and crossfade beetween them\n * let sound1,sound2;\n * let sound1Gain, sound2Gain, masterGain;\n * function preload(){\n * soundFormats('ogg', 'mp3');\n * sound1 = loadSound('assets/Damscray_-_Dancing_Tiger_01');\n * sound2 = loadSound('assets/beat');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startSound);\n * // create a 'master' gain to which we will connect both soundfiles\n * masterGain = new p5.Gain();\n * masterGain.connect();\n * sound1.disconnect(); // diconnect from p5 output\n * sound1Gain = new p5.Gain(); // setup a gain node\n * sound1Gain.setInput(sound1); // connect the first sound to its input\n * sound1Gain.connect(masterGain); // connect its output to the 'master'\n * sound2.disconnect();\n * sound2Gain = new p5.Gain();\n * sound2Gain.setInput(sound2);\n * sound2Gain.connect(masterGain);\n * }\n * function startSound() {\n * sound1.loop();\n * sound2.loop();\n * loop();\n * }\n * function mouseReleased() {\n * sound1.stop();\n * sound2.stop();\n * }\n * function draw(){\n * background(220);\n * textAlign(CENTER);\n * textSize(11);\n * fill(0);\n * if (!sound1.isPlaying()) {\n * text('tap and drag to play', width/2, height/2);\n * return;\n * }\n * // map the horizontal position of the mouse to values useable for volume * control of sound1\n * var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);\n * var sound2Volume = 1-sound1Volume;\n * sound1Gain.amp(sound1Volume);\n * sound2Gain.amp(sound2Volume);\n * // map the vertical position of the mouse to values useable for 'master * volume control'\n * var masterVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\n * masterGain.amp(masterVolume);\n * text('master', width/2, height - masterVolume * height * 0.9)\n * fill(255, 0, 255);\n * textAlign(LEFT);\n * text('sound1', 5, height - sound1Volume * height * 0.9);\n * textAlign(RIGHT);\n * text('sound2', width - 5, height - sound2Volume * height * 0.9);\n * }\n *
\n */\n\nclass Gain {\n constructor() {\n this.ac = p5sound.audiocontext;\n\n this.input = this.ac.createGain();\n this.output = this.ac.createGain();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n this.input.connect(this.output);\n\n // add to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connect a source to the gain node.\n *\n * @method setInput\n * @for p5.Gain\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n */\n\n setInput(src) {\n src.connect(this.input);\n }\n\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Gain\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5.soundOut.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Gain\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Set the output level of the gain node.\n *\n * @method amp\n * @for p5.Gain\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n var now = p5sound.audiocontext.currentTime;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n }\n}\n\nexport default Gain;\n","import p5sound from './master';\n\n/**\n * Base class for monophonic synthesizers. Any extensions of this class\n * should follow the API and implement the methods below in order to\n * remain compatible with p5.PolySynth();\n *\n * @class p5.AudioVoice\n * @constructor\n */\nclass AudioVoice {\n constructor() {\n this.ac = p5sound.audiocontext;\n this.output = this.ac.createGain();\n this.connect();\n p5sound.soundArray.push(this);\n }\n play(note, velocity, secondsFromNow, sustime) {}\n\n triggerAttack(note, velocity, secondsFromNow) {}\n\n triggerRelease(secondsFromNow) {}\n\n amp(vol, rampTime) {}\n\n /**\n * Connect to p5 objects or Web Audio Nodes\n * @method connect\n * @for p5.AudioVoice\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect from soundOut\n * @method disconnect\n * @for p5.AudioVoice\n */\n disconnect() {\n this.output.disconnect();\n }\n\n dispose() {\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n }\n}\n\nexport default AudioVoice;\n","import AudioVoice from './audioVoice';\nimport Envelope from './envelope';\nimport p5sound from './master';\nimport Oscillator from './oscillator';\nimport { noteToFreq } from './helpers';\n\nvar DEFAULT_SUSTAIN = 0.15;\n\n/**\n * A MonoSynth is used as a single voice for sound synthesis.\n * This is a class to be used in conjunction with the PolySynth\n * class. Custom synthetisers should be built inheriting from\n * this class.\n *\n * @class p5.MonoSynth\n * @constructor\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * let note = random(['Fb4', 'G4']);\n * // note velocity (volume, from 0 to 1)\n * let velocity = random();\n * // time from now (in seconds)\n * let time = 0;\n * // note duration (in seconds)\n * let dur = 1/6;\n *\n * monoSynth.play(note, velocity, time, dur);\n * }\n *
\n **/\n\nclass MonoSynth extends AudioVoice {\n constructor() {\n super();\n this.oscillator = new Oscillator();\n\n this.env = new Envelope(); //to be changed\n this.env.setRange(1, 0);\n this.env.setExp(true);\n\n //set params\n this.setADSR(0.02, 0.25, 0.05, 0.35);\n\n // oscillator --> env --> this.output (gain) --> p5.soundOut\n this.oscillator.disconnect();\n this.oscillator.connect(this.output);\n\n this.env.disconnect();\n this.env.setInput(this.output.gain);\n\n // reset oscillator gain to 1.0\n this.oscillator.output.gain.value = 1.0;\n\n this.oscillator.start();\n this.connect();\n\n p5sound.soundArray.push(this);\n\n /**\n * Getters and Setters\n * @property {Number} attack\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} decay\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} sustain\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} release\n * @for p5.MonoSynth\n */\n Object.defineProperties(this, {\n attack: {\n get: function () {\n return this.env.aTime;\n },\n set: function (attack) {\n this.env.setADSR(\n attack,\n this.env.dTime,\n this.env.sPercent,\n this.env.rTime\n );\n },\n },\n decay: {\n get: function () {\n return this.env.dTime;\n },\n set: function (decay) {\n this.env.setADSR(\n this.env.aTime,\n decay,\n this.env.sPercent,\n this.env.rTime\n );\n },\n },\n sustain: {\n get: function () {\n return this.env.sPercent;\n },\n set: function (sustain) {\n this.env.setADSR(\n this.env.aTime,\n this.env.dTime,\n sustain,\n this.env.rTime\n );\n },\n },\n release: {\n get: function () {\n return this.env.rTime;\n },\n set: function (release) {\n this.env.setADSR(\n this.env.aTime,\n this.env.dTime,\n this.env.sPercent,\n release\n );\n },\n },\n });\n }\n\n /**\n * Play tells the MonoSynth to start playing a note. This method schedules\n * the calling of .triggerAttack and .triggerRelease.\n *\n * @method play\n * @for p5.MonoSynth\n * @param {String | Number} note the note you want to play, specified as a\n * frequency in Hertz (Number) or as a midi\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n * See \n * Tone. Defaults to 440 hz.\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope. Defaults to 0.15 seconds.\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * let note = random(['Fb4', 'G4']);\n * // note velocity (volume, from 0 to 1)\n * let velocity = random();\n * // time from now (in seconds)\n * let time = 0;\n * // note duration (in seconds)\n * let dur = 1/6;\n *\n * monoSynth.play(note, velocity, time, dur);\n * }\n *
\n *\n */\n play(note, velocity, secondsFromNow, susTime) {\n this.triggerAttack(note, velocity, ~~secondsFromNow);\n this.triggerRelease(~~secondsFromNow + (susTime || DEFAULT_SUSTAIN));\n }\n\n /**\n * Trigger the Attack, and Decay portion of the Envelope.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go.\n *\n * @param {String | Number} note the note you want to play, specified as a\n * frequency in Hertz (Number) or as a midi\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n * See \n * Tone. Defaults to 440 hz\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @method triggerAttack\n * @for p5.MonoSynth\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(triggerAttack);\n * background(220);\n * text('tap here for attack, let go to release', 5, 20, width - 20);\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function triggerAttack() {\n * userStartAudio();\n *\n * monoSynth.triggerAttack(\"E3\");\n * }\n *\n * function mouseReleased() {\n * monoSynth.triggerRelease();\n * }\n *
\n */\n triggerAttack(note, velocity, secondsFromNow = 0) {\n var freq = noteToFreq(note);\n var vel = velocity || 0.1;\n this.oscillator.freq(freq, 0, secondsFromNow);\n this.env.ramp(this.output.gain, secondsFromNow, vel);\n }\n\n /**\n * Trigger the release of the Envelope. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @param {Number} secondsFromNow time to trigger the release\n * @method triggerRelease\n * @for p5.MonoSynth\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(triggerAttack);\n * background(220);\n * text('tap here for attack, let go to release', 5, 20, width - 20);\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function triggerAttack() {\n * userStartAudio();\n *\n * monoSynth.triggerAttack(\"E3\");\n * }\n *\n * function mouseReleased() {\n * monoSynth.triggerRelease();\n * }\n *
\n */\n triggerRelease(secondsFromNow = 0) {\n this.env.ramp(this.output.gain, secondsFromNow, 0);\n }\n\n /**\n * Set values like a traditional\n * \n * ADSR envelope\n * .\n *\n * @method setADSR\n * @for p5.MonoSynth\n * @param {Number} attackTime Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n */\n setADSR(attack, decay, sustain, release) {\n this.env.setADSR(attack, decay, sustain, release);\n }\n\n /**\n * MonoSynth amp\n * @method amp\n * @for p5.MonoSynth\n * @param {Number} vol desired volume\n * @param {Number} [rampTime] Time to reach new volume\n * @return {Number} new volume value\n */\n amp(vol, rampTime) {\n var t = rampTime || 0;\n if (typeof vol !== 'undefined') {\n this.oscillator.amp(vol, t);\n }\n return this.oscillator.amp().value;\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.MonoSynth\n * @param {Object} unit A p5.sound or Web Audio object\n */\n\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.MonoSynth\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Get rid of the MonoSynth and free up its resources / memory.\n *\n * @method dispose\n * @for p5.MonoSynth\n */\n dispose() {\n super.dispose();\n\n if (this.env) {\n this.env.dispose();\n }\n if (this.oscillator) {\n this.oscillator.dispose();\n }\n }\n}\n\nexport default MonoSynth;\n","/**\n * Listen for onsets (a sharp increase in volume) within a given\n * frequency range.\n *\n * @class p5.OnsetDetect\n * @constructor\n * @param {Number} freqLow Low frequency\n * @param {Number} freqHigh High frequency\n * @param {Number} threshold Amplitude threshold between 0 (no energy) and 1 (maximum)\n * @param {Function} callback Function to call when an onset is detected\n */\nclass OnsetDetect {\n constructor(freqLow, freqHigh, threshold, callback) {\n this.isDetected = false;\n this.freqLow = freqLow;\n this.freqHigh = freqHigh;\n this.treshold = threshold;\n this.energy = 0;\n this.penergy = 0;\n\n // speed of decay\n this.sensitivity = 500;\n\n this.callback = callback;\n }\n\n // callback here too?\n update(fftObject, callback) {\n this.energy = fftObject.getEnergy(this.freqLow, this.freqHigh) / 255;\n\n if (this.isDetected === false) {\n if (this.energy - this.penergy > this.treshold) {\n this.isDetected = true;\n\n if (this.callback) {\n this.callback(this.energy);\n } else if (callback) {\n callback(this.energy);\n }\n\n var self = this;\n setTimeout(function () {\n self.isDetected = false;\n }, this.sensitivity);\n }\n }\n\n this.penergy = this.energy;\n }\n}\n\nexport default OnsetDetect;\n","import p5sound from './master';\nimport TimelineSignal from 'Tone/signal/TimelineSignal.js';\nimport { noteToFreq, freqToMidi } from './helpers';\n\n/**\n * An AudioVoice is used as a single voice for sound synthesis.\n * The PolySynth class holds an array of AudioVoice, and deals\n * with voices allocations, with setting notes to be played, and\n * parameters to be set.\n *\n * @class p5.PolySynth\n * @constructor\n *\n * @param {Number} [synthVoice] A monophonic synth voice inheriting\n * the AudioVoice class. Defaults to p5.MonoSynth\n * @param {Number} [maxVoices] Number of voices, defaults to 8;\n * @example\n *
\n * let polySynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * text('click to play', 20, 20);\n *\n * polySynth = new p5.PolySynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * // note duration (in seconds)\n * let dur = 1.5;\n *\n * // time from now (in seconds)\n * let time = 0;\n *\n * // velocity (volume, from 0 to 1)\n * let vel = 0.1;\n *\n * // notes can overlap with each other\n * polySynth.play('G2', vel, 0, dur);\n * polySynth.play('C3', vel, time += 1/3, dur);\n * polySynth.play('G3', vel, time += 1/3, dur);\n * }\n *
\n **/\nclass PolySynth {\n constructor(audioVoice, maxVoices) {\n //audiovoices will contain maxVoices many monophonic synths\n this.audiovoices = [];\n\n /**\n * An object that holds information about which notes have been played and\n * which notes are currently being played. New notes are added as keys\n * on the fly. While a note has been attacked, but not released, the value of the\n * key is the audiovoice which is generating that note. When notes are released,\n * the value of the key becomes undefined.\n * @property notes\n */\n this.notes = {};\n\n //indices of the most recently used, and least recently used audiovoice\n this._newest = 0;\n this._oldest = 0;\n\n /**\n * A PolySynth must have at least 1 voice, defaults to 8\n * @property polyvalue\n */\n this.maxVoices = maxVoices || 8;\n\n /**\n * Monosynth that generates the sound for each note that is triggered. The\n * p5.PolySynth defaults to using the p5.MonoSynth as its voice.\n * @property AudioVoice\n */\n this.AudioVoice = audioVoice === undefined ? p5.MonoSynth : audioVoice;\n\n /**\n * This value must only change as a note is attacked or released. Due to delay\n * and sustain times, Tone.TimelineSignal is required to schedule the change in value.\n * @private\n * @property {Tone.TimelineSignal} _voicesInUse\n */\n this._voicesInUse = new TimelineSignal(0);\n\n this.output = p5sound.audiocontext.createGain();\n this.connect();\n\n //Construct the appropriate number of audiovoices\n this._allocateVoices();\n p5sound.soundArray.push(this);\n }\n\n /**\n * Construct the appropriate number of audiovoices\n * @private\n * @for p5.PolySynth\n * @method _allocateVoices\n */\n _allocateVoices() {\n for (var i = 0; i < this.maxVoices; i++) {\n this.audiovoices.push(new this.AudioVoice());\n this.audiovoices[i].disconnect();\n this.audiovoices[i].connect(this.output);\n }\n }\n\n /**\n * Play a note by triggering noteAttack and noteRelease with sustain time\n *\n * @method play\n * @for p5.PolySynth\n * @param {Number} [note] midi note to play (ranging from 0 to 127 - 60 being a middle C)\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\n * @example\n *
\n * let polySynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * text('click to play', 20, 20);\n *\n * polySynth = new p5.PolySynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * // note duration (in seconds)\n * let dur = 1.5;\n *\n * // time from now (in seconds)\n * let time = 0;\n *\n * // velocity (volume, from 0 to 1)\n * let vel = 0.1;\n *\n * // notes can overlap with each other\n * polySynth.play('G2', vel, 0, dur);\n * polySynth.play('C3', vel, time += 1/3, dur);\n * polySynth.play('G3', vel, time += 1/3, dur);\n * }\n *
\n */\n play(note, velocity, secondsFromNow, susTime = 1) {\n this.noteAttack(note, velocity, secondsFromNow);\n this.noteRelease(note, secondsFromNow + susTime);\n }\n\n /**\n * noteADSR sets the envelope for a specific note that has just been triggered.\n * Using this method modifies the envelope of whichever audiovoice is being used\n * to play the desired note. The envelope should be reset before noteRelease is called\n * in order to prevent the modified envelope from being used on other notes.\n *\n * @method noteADSR\n * @for p5.PolySynth\n * @param {Number} [note] Midi note on which ADSR should be set.\n * @param {Number} [attackTime] Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n **/\n\n noteADSR(note, a, d, s, r, timeFromNow = 0) {\n var now = p5sound.audiocontext.currentTime;\n var t = now + timeFromNow;\n this.audiovoices[this.notes[note].getValueAtTime(t)].setADSR(a, d, s, r);\n }\n\n /**\n * Set the PolySynths global envelope. This method modifies the envelopes of each\n * monosynth so that all notes are played with this envelope.\n *\n * @method setADSR\n * @for p5.PolySynth\n * @param {Number} [attackTime] Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n **/\n setADSR(a, d, s, r) {\n this.audiovoices.forEach(function (voice) {\n voice.setADSR(a, d, s, r);\n });\n }\n\n /**\n * Trigger the Attack, and Decay portion of a MonoSynth.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go.\n *\n * @method noteAttack\n * @for p5.PolySynth\n * @param {Number} [note] midi note on which attack should be triggered.\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)/\n * @param {Number} [secondsFromNow] time from now (in seconds)\n * @example\n *
\n * let polySynth = new p5.PolySynth();\n * let pitches = ['G', 'D', 'G', 'C'];\n * let octaves = [2, 3, 4];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playChord);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playChord() {\n * userStartAudio();\n *\n * // play a chord: multiple notes at the same time\n * for (let i = 0; i < 4; i++) {\n * let note = random(pitches) + random(octaves);\n * polySynth.noteAttack(note, 0.1);\n * }\n * }\n *\n * function mouseReleased() {\n * // release all voices\n * polySynth.noteRelease();\n * }\n *
\n */\n noteAttack(_note, _velocity, secondsFromNow = 0) {\n //this value is used by this._voicesInUse\n var acTime = p5sound.audiocontext.currentTime + secondsFromNow;\n\n //Convert note to frequency if necessary. This is because entries into this.notes\n //should be based on frequency for the sake of consistency.\n var note = noteToFreq(_note);\n var velocity = _velocity || 0.1;\n\n var currentVoice;\n\n //Release the note if it is already playing\n if (this.notes[note] && this.notes[note].getValueAtTime(acTime) !== null) {\n this.noteRelease(note, 0);\n }\n\n //Check to see how many voices are in use at the time the note will start\n if (this._voicesInUse.getValueAtTime(acTime) < this.maxVoices) {\n currentVoice = Math.max(~~this._voicesInUse.getValueAtTime(acTime), 0);\n }\n //If we are exceeding the polyvalue, bump off the oldest notes and replace\n //with a new note\n else {\n currentVoice = this._oldest;\n\n oldestNote = freqToMidi(\n this.audiovoices[this._oldest].oscillator.freq().value\n );\n this.noteRelease(oldestNote);\n this._oldest = (this._oldest + 1) % (this.maxVoices - 1);\n }\n\n //Overrite the entry in the notes object. A note (frequency value)\n //corresponds to the index of the audiovoice that is playing it\n this.notes[note] = new TimelineSignal();\n this.notes[note].setValueAtTime(currentVoice, acTime);\n\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\n //Add 1 and schedule this value at time 't', when this note will start playing\n var previousVal =\n this._voicesInUse._searchBefore(acTime) === null\n ? 0\n : this._voicesInUse._searchBefore(acTime).value;\n this._voicesInUse.setValueAtTime(previousVal + 1, acTime);\n\n //Then update all scheduled values that follow to increase by 1\n this._updateAfter(acTime, 1);\n\n this._newest = currentVoice;\n //The audiovoice handles the actual scheduling of the note\n if (typeof velocity === 'number') {\n var maxRange = (1 / this._voicesInUse.getValueAtTime(acTime)) * 2;\n velocity = velocity > maxRange ? maxRange : velocity;\n }\n\n // use secondsFromNow because this method will add AudioContext currentTime\n this.audiovoices[currentVoice].triggerAttack(\n note,\n velocity,\n secondsFromNow\n );\n }\n\n /**\n * Private method to ensure accurate values of this._voicesInUse\n * Any time a new value is scheduled, it is necessary to increment all subsequent\n * scheduledValues after attack, and decrement all subsequent\n * scheduledValues after release\n *\n * @private\n * @for p5.PolySynth\n * @param {[type]} time [description]\n * @param {[type]} value [description]\n * @return {[type]} [description]\n */\n _updateAfter(time, value) {\n if (this._voicesInUse._searchAfter(time) === null) {\n return;\n } else {\n this._voicesInUse._searchAfter(time).value += value;\n var nextTime = this._voicesInUse._searchAfter(time).time;\n this._updateAfter(nextTime, value);\n }\n }\n\n /**\n * Trigger the Release of an AudioVoice note. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @method noteRelease\n * @for p5.PolySynth\n * @param {Number} [note] midi note on which attack should be triggered.\n * If no value is provided, all notes will be released.\n * @param {Number} [secondsFromNow] time to trigger the release\n * @example\n *
\n * let polySynth = new p5.PolySynth();\n * let pitches = ['G', 'D', 'G', 'C'];\n * let octaves = [2, 3, 4];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playChord);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playChord() {\n * userStartAudio();\n *\n * // play a chord: multiple notes at the same time\n * for (let i = 0; i < 4; i++) {\n * let note = random(pitches) + random(octaves);\n * polySynth.noteAttack(note, 0.1);\n * }\n * }\n *\n * function mouseReleased() {\n * // release all voices\n * polySynth.noteRelease();\n * }\n *
\n *\n */\n noteRelease(_note, secondsFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n\n // if a note value is not provided, release all voices\n if (!_note) {\n this.audiovoices.forEach(function (voice) {\n voice.triggerRelease(tFromNow);\n });\n this._voicesInUse.setValueAtTime(0, t);\n for (var n in this.notes) {\n this.notes[n].dispose();\n delete this.notes[n];\n }\n return;\n }\n\n //Make sure note is in frequency inorder to query the this.notes object\n var note = noteToFreq(_note);\n\n if (!this.notes[note] || this.notes[note].getValueAtTime(t) === null) {\n console.warn('Cannot release a note that is not already playing');\n } else {\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\n //subtract 1 and schedule this value at time 't', when this note will stop playing\n var previousVal = Math.max(\n ~~this._voicesInUse.getValueAtTime(t).value,\n 1\n );\n this._voicesInUse.setValueAtTime(previousVal - 1, t);\n //Then update all scheduled values that follow to decrease by 1 but never go below 0\n if (previousVal > 0) {\n this._updateAfter(t, -1);\n }\n\n this.audiovoices[this.notes[note].getValueAtTime(t)].triggerRelease(\n tFromNow\n );\n this.notes[note].dispose();\n delete this.notes[note];\n\n this._newest =\n this._newest === 0 ? 0 : (this._newest - 1) % (this.maxVoices - 1);\n }\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.PolySynth\n * @param {Object} unit A p5.sound or Web Audio object\n */\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.PolySynth\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Get rid of the MonoSynth and free up its resources / memory.\n *\n * @method dispose\n * @for p5.PolySynth\n */\n dispose() {\n this.audiovoices.forEach(function (voice) {\n voice.dispose();\n });\n\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n }\n}\n\nexport default PolySynth;\n","class Signal {\n constructor() {\n console.warn('p5.Signal is deprecated , Use Tone.js Signal instead ');\n }\n}\n\nexport default Signal;\n","import 'audioworklet-polyfill';\nimport './shims';\n\nimport { getAudioContext, userStartAudio } from './audiocontext';\np5.prototype.getAudioContext = getAudioContext;\np5.prototype.userStartAudio = userStartAudio;\n\nimport './master';\n\nimport {\n sampleRate,\n freqToMidi,\n midiToFreq,\n noteToFreq,\n soundFormats,\n disposeSound,\n _checkFileFormats,\n _mathChain,\n convertToWav,\n interleave,\n writeUTFBytes,\n safeBufferSize,\n saveSound,\n} from './helpers';\np5.prototype.sampleRate = sampleRate;\np5.prototype.freqToMidi = freqToMidi;\np5.prototype.midiToFreq = midiToFreq;\np5.prototype.noteToFreq = noteToFreq;\np5.prototype.soundFormats = soundFormats;\np5.prototype.disposeSound = disposeSound;\np5.prototype._checkFileFormats = _checkFileFormats;\np5.prototype._mathChain = _mathChain;\np5.prototype.convertToWav = convertToWav;\np5.prototype.interleave = interleave;\np5.prototype.writeUTFBytes = writeUTFBytes;\np5.prototype.safeBufferSize = safeBufferSize;\np5.prototype.saveSound = saveSound;\n\n// register removeSound to dispose of p5sound SoundFiles, Convolvers,\n// Oscillators etc when sketch ends\np5.prototype.registerMethod('remove', p5.prototype.disposeSound);\n\nimport './errorHandler';\nimport './audioWorklet';\n\nimport Panner from './panner';\np5.Panner = Panner;\n\nimport SoundFile, { loadSound } from './soundfile';\np5.SoundFile = SoundFile;\np5.prototype.loadSound = loadSound;\n// register preload handling of loadSound\np5.prototype.registerPreloadMethod('loadSound', p5.prototype);\n\nimport Amplitude from './amplitude';\np5.Amplitude = Amplitude;\n\nimport FFT from './fft';\np5.FFT = FFT;\n\nimport Oscillator, { SinOsc, TriOsc, SawOsc, SqrOsc } from './oscillator';\np5.Oscillator = Oscillator;\np5.SinOsc = SinOsc;\np5.TriOsc = TriOsc;\np5.SawOsc = SawOsc;\np5.SqrOsc = SqrOsc;\n\nimport './envelope';\n\nimport Noise from './noise';\np5.Noise = Noise;\n\nimport Pulse from './pulse';\np5.Pulse = Pulse;\n\nimport AudioIn from './audioin';\np5.AudioIn = AudioIn;\n\nimport Effect from './effect';\np5.Effect = Effect;\n\nimport Filter, { LowPass, HighPass, BandPass } from './filter';\np5.Filter = Filter;\np5.LowPass = LowPass;\np5.HighPass = HighPass;\np5.BandPass = BandPass;\n\nimport EQ from './eq';\np5.EQ = EQ;\n\nimport listener3D from './listener3d';\np5.listener3D = listener3D;\n\nimport Panner3D from './panner3d';\np5.Panner3D = Panner3D;\n\nimport Delay from './delay';\np5.Delay = Delay;\n\nimport { Reverb, Convolver, createConvolver } from './reverb';\np5.Reverb = Reverb;\np5.Convolver = Convolver;\np5.prototype.createConvolver = createConvolver;\np5.prototype.registerPreloadMethod('createConvolver', p5.prototype);\n\nimport Metro from './metro';\np5.Metro = Metro;\n\nimport { Phrase, Part, Score } from './looper';\np5.Phrase = Phrase;\np5.Part = Part;\np5.Score = Score;\n\nimport SoundLoop from './soundLoop';\np5.SoundLoop = SoundLoop;\n\nimport Compressor from './compressor';\np5.Compressor = Compressor;\n\nimport peakDetect from './peakDetect';\np5.peakDetect = peakDetect;\n\nimport SoundRecorder from './soundRecorder';\np5.SoundRecorder = SoundRecorder;\n\nimport Distortion from './distortion';\np5.Distortion = Distortion;\n\nimport Gain from './gain';\np5.Gain = Gain;\n\nimport AudioVoice from './audioVoice';\np5.AudioVoice = AudioVoice;\n\nimport MonoSynth from './monosynth';\np5.MonoSynth = MonoSynth;\n\nimport OnsetDetect from './onsetDetect';\np5.OnsetDetect = OnsetDetect;\n\nimport PolySynth from './polysynth';\np5.PolySynth = PolySynth;\n\n// Following are the deprecated classes\nimport Signal from './deprecations/Signal';\np5.Signal = Signal;\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../node_modules/tone/Tone/core/Tone.js","webpack:///../node_modules/tone/Tone/signal/Multiply.js","webpack:///../node_modules/tone/Tone/signal/Signal.js","webpack:///./audiocontext.js","webpack:///../node_modules/tone/Tone/signal/Add.js","webpack:///./audioWorklet/processorNames.js","webpack:///../node_modules/tone/Tone/signal/WaveShaper.js","webpack:///../node_modules/tone/Tone/signal/TimelineSignal.js","webpack:///../node_modules/tone/Tone/signal/Scale.js","webpack:///../node_modules/tone/Tone/type/Type.js","webpack:///../node_modules/tone/Tone/core/Gain.js","webpack:///../node_modules/tone/Tone/core/Clock.js","webpack:///../node_modules/tone/Tone/core/Context.js","webpack:///../node_modules/tone/Tone/signal/Subtract.js","webpack:///../node_modules/tone/Tone/core/Emitter.js","webpack:///../node_modules/tone/Tone/signal/SignalBase.js","webpack:///../node_modules/tone/Tone/type/Time.js","webpack:///../node_modules/tone/Tone/type/TimeBase.js","webpack:///../node_modules/tone/Tone/core/Param.js","webpack:///../node_modules/tone/Tone/core/Timeline.js","webpack:///../node_modules/tone/Tone/signal/Negate.js","webpack:///../node_modules/tone/Tone/signal/GreaterThanZero.js","webpack:///../node_modules/startaudiocontext/StartAudioContext.js","webpack:///../node_modules/tone/Tone/component/CrossFade.js","webpack:///../node_modules/audioworklet-polyfill/dist/audioworklet-polyfill.js","webpack:///./shims.js","webpack:///../node_modules/webpack/buildin/global.js","webpack:///./audioWorklet/recorderProcessor.js","webpack:///./audioWorklet/soundFileProcessor.js","webpack:///./audioWorklet/amplitudeProcessor.js","webpack:///../node_modules/tone/Tone/type/Frequency.js","webpack:///../node_modules/tone/Tone/type/TransportTime.js","webpack:///../node_modules/tone/Tone/signal/Expr.js","webpack:///../node_modules/tone/Tone/signal/GreaterThan.js","webpack:///../node_modules/tone/Tone/signal/Abs.js","webpack:///../node_modules/tone/Tone/signal/Modulo.js","webpack:///../node_modules/tone/Tone/signal/Pow.js","webpack:///../node_modules/tone/Tone/signal/AudioToGain.js","webpack:///../node_modules/tone/Tone/signal/EqualPowerGain.js","webpack:///../node_modules/tone/Tone/core/TimelineState.js","webpack:///./main.js","webpack:///./helpers.js","webpack:///./errorHandler.js","webpack:///./audioWorklet/index.js","webpack:///./panner.js","webpack:///./soundfile.js","webpack:///./amplitude.js","webpack:///./fft.js","webpack:///./oscillator.js","webpack:///./envelope.js","webpack:///./noise.js","webpack:///./pulse.js","webpack:///./audioin.js","webpack:///./effect.js","webpack:///./filter.js","webpack:///./eqFilter.js","webpack:///./eq.js","webpack:///./listener3d.js","webpack:///./panner3d.js","webpack:///./delay.js","webpack:///./reverb.js","webpack:///./metro.js","webpack:///./looper.js","webpack:///./soundLoop.js","webpack:///./compressor.js","webpack:///./peakDetect.js","webpack:///./soundRecorder.js","webpack:///./distortion.js","webpack:///./gain.js","webpack:///./audioVoice.js","webpack:///./monosynth.js","webpack:///./onsetDetect.js","webpack:///./polysynth.js","webpack:///./deprecations/Signal.js","webpack:///./app.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","define","Tone","inputs","outputs","this","isUndef","input","context","createGain","Array","output","audioContext","set","params","rampTime","isObject","isString","tmpObj","paramLoop","attr","parent","indexOf","attrSplit","split","length","splice","innerParam","join","param","Signal","Param","rampTo","AudioParam","_collectDefaults","constructor","ret","subRet","j","subAttr","isFunction","constr","defaults","keys","_super","superDefs","push","toString","className","isLetter","match","sameConstructor","isArray","dispose","AudioNode","disconnect","connect","unit","outputNum","inputNum","defaultArg","destination","isNumber","apply","arguments","connectSeries","currentUnit","toUnit","chain","fan","given","fallback","givenProp","fallbackProp","optionsObject","values","options","val","arg","isBoolean","noOp","_readOnly","writable","_writable","State","Started","Stopped","Paused","equalPowerScale","percent","piFactor","Math","PI","sin","dbToGain","db","pow","gainToDb","gain","log","LN10","intervalToFrequencyRatio","interval","now","extend","child","TempConstructor","Context","emit","setContext","ctx","sampleRate","hasAudioContext","window","hasPromises","hasWorkers","version","TONE_SILENCE_VERSION_LOGGING","Multiply","__WEBPACK_AMD_DEFINE_RESULT__","createInsOuts","_mult","Gain","_param","_gain","getConstant","units","Type","Default","convert","SignalBase","global","audiocontext","AudioContext","getAudioContext","userStartAudio","elements","callback","elt","p5","Element","map","e","StartAudioContext","Add","_sum","recorderProcessor","soundFileProcessor","amplitudeProcessor","WaveShaper","mapping","bufferLen","_shaper","createWaveShaper","_curve","curve","isFinite","Float32Array","setMap","len","normalized","oversample","oversampling","RangeError","TimelineSignal","_events","Timeline","_initial","_fromUnits","Linear","Exponential","Target","Curve","Set","getValueAtTime","_toUnits","convertedVal","cancelScheduledValues","setValueAtTime","startTime","toSeconds","add","type","time","linearRampToValueAtTime","endTime","exponentialRampToValueAtTime","beforeEvent","_searchBefore","_minOutput","setValue","max","sampleTime","setTargetAtTime","timeConstant","constant","setValueCurveAtTime","duration","scaling","floats","segmentTime","after","cancel","setRampPoint","before","_searchAfter","linearRampToValueBetween","start","finish","exponentialRampToValueBetween","getAfter","previouVal","previous","getBefore","_exponentialApproach","_curveInterpolate","_linearInterpolate","_exponentialInterpolate","t0","v0","v1","exp","t1","progress","lowerIndex","floor","upperIndex","ceil","lowerVal","upperVal","Scale","outputMin","outputMax","_outputMin","_outputMax","_scale","_add","_setRange","min","Time","Frequency","TransportTime","Ticks","NormalRange","AudioRange","Decibels","Interval","BPM","Positive","Cents","Degrees","MIDI","BarsBeatsSixteenths","Samples","Hertz","Note","Milliseconds","Seconds","Notation","TimeBase","toFrequency","freq","valueOf","toTicks","Transport","ticks","GainNode","createGainNode","_gainNode","Clock","Emitter","_nextTick","_lastState","frequency","_state","TimelineState","_boundLoop","_loop","on","lookAhead","offset","state","stop","setStateAtTime","pause","loopInterval","updateInterval","lag","currentState","event","tickTime","getStateAtTime","off","Infinity","toneConnect","B","outNum","inNum","nativeConnect","Error","nativeDisconnect","webkitAudioContext","prop","_context","_defineProperty","_latencyHint","_lookAhead","_updateInterval","_computedUpdateInterval","_worker","_createWorker","_constants","mixin","currentTime","URL","webkitURL","blob","Blob","toFixed","blobUrl","createObjectURL","worker","Worker","addEventListener","_lastUpdate","diff","buffer","createBuffer","arr","getChannelData","createBufferSource","channelCount","channelCountMode","loop","lA","blockTime","postMessage","hint","latencyHint","supported","Subtract","_neg","Negate","events","eventName","ev","eventList","args","slice","functions","func","emitterFunc","node","outputNumber","inputNumber","overridden","_plusNow","_unaryExpressions","quantize","regexp","method","rh","nextSubdivision","lh","subdiv","_expr","expr","subdivision","round","addNow","_defaultExpr","_noOp","copy","toNotation","retNotation","_toNotationHelper","retTripletNotation","testNotations","threshold","_notationToUnits","notationTime","multiple","notation","primaryExprs","_primaryExpressions","notationExprs","toBarsBeatsSixteenths","quarterTime","_beatsToUnits","quarters","measures","_timeSignature","sixteenths","parseFloat","PPQ","toSamples","toMilliseconds","_defaultUnits","exprString","_parseExprString","clone","instance","parseInt","_ticksToUnits","hz","_frequencyToUnits","tr","q","total","_secondsToUnits","samples","default","_binaryExpressions","+","precedence","-","*","/","neg","_syntaxGlue","(",")","_tokenize","position","tokens","token","getNextToken","trim","substr","expressions","group","opName","op","reg","SyntaxError","next","peek","_matchGroup","prec","test","_parseBinary","lexer","_parseUnary","_parsePrimary","matching","beats","bpm","seconds","timeSignature","_pushExpr","sub","mult","div","_lfo","lfo","LFO","currentVal","exponentialRampToValue","linearRampToValue","_timeline","_toRemove","_iterating","memory","index","_search","remove","shift","cancelBefore","beginning","end","midPoint","nextEvent","_iterate","lowerBound","upperBound","forEach","forEachBefore","forEachAfter","forEachFrom","forEachAtTime","_multiply","GreaterThanZero","_thresh","factory","__WEBPACK_AMD_DEFINE_FACTORY__","TapListener","element","_dragged","_element","_bindedMove","_moved","_bindedEnd","_ended","isStarted","source","resume","removeEventListener","promise","Promise","success","checkLoop","requestAnimationFrame","tapListeners","bindTapListener","NodeList","document","querySelectorAll","jquery","toArray","tap","body","then","CrossFade","initialFade","a","b","fade","_equalPowerA","EqualPowerGain","_equalPowerB","_invert","Expr","parameters","bufferSize","fill","processor","realm","exec","inputBuffer","outputBuffer","process","numberOfChannels","$$processors","$$context","AudioWorkletNode","self","createScriptProcessor","outputChannelCount","Map","properties","u","defaultValue","MessageChannel","port2","f","Processor","port","port1","onaudioprocess","$$audioWorklet","AudioWorklet","addModule","fetch","ok","status","text","AudioWorkletProcessor","registerProcessor","parameterDescriptors","createElement","style","cssText","appendChild","contentWindow","createTextNode","$hook","console","documentElement","transpile","String","fixSetTarget","setTargetValueAtTime","createDelay","createDelayNode","createJavaScriptNode","createPeriodicWave","createWaveTable","internal_createGain","internal_createDelay","maxDelayTime","delayTime","internal_createBufferSource","internal_start","when","noteGrainOn","noteOn","internal_stop","noteOff","playbackRate","internal_createDynamicsCompressor","createDynamicsCompressor","knee","ratio","reduction","attack","release","internal_createBiquadFilter","createBiquadFilter","detune","Q","createOscillator","internal_createOscillator","setPeriodicWave","setWaveTable","OfflineAudioContext","webkitOfflineAudioContext","navigator","getUserMedia","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","el","isSupported","canPlayType","isFileSupported","extension","toLowerCase","g","Function","__webpack_exports__","midi","midiToFrequency","note","pitch","octave","noteNumber","noteToScaleIndex","transpose","harmonize","intervals","toMidi","frequencyToMidi","toNote","A4","LN2","scaleIndexToNote","cbb","cb","c#","cx","dbb","d#","dx","ebb","eb","e#","ex","fbb","fb","f#","fx","gbb","gb","g#","gx","abb","ab","a#","ax","bbb","bb","b#","bx","_secondsToTicks","applyBinary","Constructor","_eval","applyUnary","getNumber","literalNumber","_replacements","inputCount","_parseInputs","_nodes","result","tree","_parseTree","_disposeNodes","_Expressions","signal","glue",",","abs","Abs","mod","modulus","Modulo","Pow","a2g","AudioToGain","binary","unary","!","NOT","inputArray","inputMax","replace","matchSyntax","syn","matchGroup","groupName","parseExpression","parseUnary","operator","parsePrimary","GreaterThan","_gtz","_abs","_subtract","_modSignal","_setWaveShaper","_exp","_expScaler","_expFunc","_norm","x","_eqPower","initial","p5sound","Main","_classCallCheck","limiter","meter","fftMeter","soundArray","parts","extensions","getOutputVolume","outputVolume","vol","undefined","tFromNow","currentVol","soundOut","_silentNode","freqToMidi","mathlog2","midiToFreq","noteToFreq","A","C","D","E","F","G","toUpperCase","convertToWav","audioBuffer","leftChannel","interleaved","interleave","ArrayBuffer","view","DataView","writeUTFBytes","setUint32","setUint16","lng","setInt16","rightChannel","inputIndex","string","setUint8","charCodeAt","safeBufferSize","idealBufferSize","tempAudioWorkletNode","processorNames","ScriptProcessorNode","CustomError","errorTrace","failedPath","tempStack","splitStack","err","originalStack","stack","filter","ln","moduleSources","require","ac","initializedAudioWorklets","registerMethod","preload","_incrementPreload","onWorkletModulesLoad","_decrementPreload","all","moduleSrc","objectURL","audioWorklet","panner","createStereoPanner","Panner","panner_classCallCheck","stereoPanner","_createClass","pan","obj","_Panner","numInputChannels","left","right","channelInterpretation","splitter","createChannelSplitter","createChannelMerger","v","rightVal","cos","leftVal","numChannels","Cue","id","soundfile_classCallCheck","SoundFile","paths","onload","onerror","whileLoading","path","_checkFileFormats","url","soundfile_typeof","File","FileReader","FileList","file","_onended","_looping","_playing","_paused","_pauseTime","_cues","_cueIDCounter","_lastPos","_counterNode","_workletNode","bufferSourceNodes","bufferSourceNode","reversed","pauseTime","startMillis","panPosition","load","_whileLoading","_clearOnEnd","thisBufferSourceNode","target","soundFile","_","reverse","amp","setVolume","errorCallback","request","XMLHttpRequest","evt","_updateProgress","open","responseType","decodeAudioData","response","buff","inputChannels","msg","statusText","message","send","reader","readAsArrayBuffer","lengthComputable","percentComplete","loaded","rate","_cueStart","cueStart","cueEnd","isPlaying","_initSourceNode","_initCounterNode","_arrayIndex","loopStart","loopEnd","str","pTime","play","bool","timeFromNow","stopAll","_time","pval","reverseBuffer","num","newPlaybackRate","_rampTime","_tFromNow","cueTime","cTime","dur","width","sampleSize","sampleStep","channels","peaks","chan","currentPos","curVol","getVolume","jump","buf","size","newBuffer","channelNum","_this","cNode","workletBufferSize","processorOptions","onmessage","data","_onTimeUpdate","audioBuf","arrayBuffer","_createCounterBuffer","_initThreshold","_minThreshold","_minPeaks","cue","cueLength","playbackTime","callbackTime","_prevUpdateTime","fileName","saveSound","dataView","Amplitude","smoothing","amplitude_classCallCheck","parameterData","normalize","volume","volNorm","stereoVol","stereoVolNorm","channel","FFT","bins","fft_classCallCheck","analyser","createAnalyser","defineProperties","fftSize","configurable","smoothingTimeConstant","smooth","freqDomain","Uint8Array","frequencyBinCount","timeDomain","bass","lowMid","mid","highMid","treble","normalArray","_isSafari","fft","timeToFloat","getFloatTimeDomainData","timeToInt","getByteTimeDomainData","scaled","freqToFloat","getFloatFrequencyData","freqToInt","getByteFrequencyData","frequency1","frequency2","nyquist","swap","lowIndex","highIndex","numFrequencies","freq1","freq2","getEnergy","cumulative_sum","centroid_normalization","mean_freq_index","_N","N","spectrum","spectrumLength","spectrumStep","linearAverages","groupIndex","specIndex","octaveBands","logAverages","octaveIndex","hi","_fCtr0","fCtr0","lastFrequencyBand","lo","ctr","newFrequencyBand","sigChain","mathObj","thisChain","nextChain","chainSource","oscillator","mathOps","Oscillator","oscillator_classCallCheck","started","phaseAmount","_freqMods","connection","freqNode","isNaN","phase","oscMods","osc2","delayAmt","dNode","Mult","inMin","inMax","outMin","outMax","mapOutMin","mapOutMax","scale","SinOsc","_possibleConstructorReturn","_getPrototypeOf","TriOsc","SawOsc","SqrOsc","Envelope","l1","t2","l2","t3","l3","aTime","aLevel","dTime","dLevel","rTime","rLevel","_rampHighPercentage","_rampLowPercentage","control","_init","isExponential","sourceToClear","wasTriggered","_setRampAD","setADSR","sPercent","setRange","_rampAttackTime","checkExpInput","_rampDecayTime","TCDenominator","_rampAttackTC","_rampDecayTC","setRampPercentages","p1","p2","setInput","setExp","isExp","secondsFromNow","susTime","triggerAttack","triggerRelease","lastAttack","valToSet","ramp","v2","destination1","destination2","AudioIn","Reverb","Noise","Filter","Delay","_mathChain","Env","_whiteNoiseBuffer","whiteBuffer","noiseData","random","_pinkNoiseBuffer","b0","b1","b2","b3","b4","b5","b6","pinkBuffer","white","_brownNoiseBuffer","brownBuffer","lastOut","assignType","noise_classCallCheck","noise_possibleConstructorReturn","noise_getPrototypeOf","noise","createDCOffset","bufferSource","Pulse","w","pulse_classCallCheck","pulse_possibleConstructorReturn","pulse_getPrototypeOf","dcOffset","dcGain","mW","sig","mult1","mult2","mods","currentFreq","freqMod","inputSources","audioin_classCallCheck","stream","mediaStream","currentSource","enabled","amplitude","MediaStreamTrack","mediaDevices","alert","successCallback","audioSource","constraints","audio","echoCancellation","deviceId","createMediaStreamSource","getTracks","track","getLevel","onSuccess","onError","resolve","reject","enumerateDevices","devices","device","kind","error","active","Effect","effect_classCallCheck","_drywet","wet","filter_classCallCheck","filter_possibleConstructorReturn","filter_getPrototypeOf","biquad","setType","_on","_untoggledType","src","res","_get","LowPass","HighPass","BandPass","EQFilter","eqFilter_classCallCheck","eqFilter_possibleConstructorReturn","eqFilter_getPrototypeOf","EQ","_eqsize","factor","eq_classCallCheck","eq_possibleConstructorReturn","eq_getPrototypeOf","bands","_newBand","eq_get","pop","Listener3D","listener3d_classCallCheck","listener","xVal","yVal","zVal","positionX","positionY","positionZ","xValF","yValF","zValF","xValU","yValU","zValU","orientForward","orientUp","forwardX","forwardY","forwardZ","upX","upY","upZ","Panner3D","panner3d_classCallCheck","panner3d_possibleConstructorReturn","panner3d_getPrototypeOf","createPanner","panningModel","distanceModel","orientX","orientY","orientZ","orientationX","orientationY","orientationZ","maxDistance","rolloffFactor","maxDist","rolloff","panner3d_get","delay_classCallCheck","delay_possibleConstructorReturn","delay_getPrototypeOf","_split","_merge","_leftGain","_rightGain","leftDelay","rightDelay","_leftFilter","_rightFilter","_maxDelay","maxValue","feedback","_delayTime","_feedback","_filter","delay_get","reverb_classCallCheck","reverb_possibleConstructorReturn","reverb_getPrototypeOf","_initConvolverNode","_seconds","_decay","_reverse","_buildImpulse","convolverNode","createConvolver","_teardownConvolverNode","decayRate","rebuild","decay","impulse","impulseL","impulseR","_setBuffer","reverb_get","Convolver","_this2","impulses","_loadBuffer","_path","chunks","location","origin","cordova","Metro","metro_classCallCheck","clock","ontick","syncedParts","prevTick","tatumTime","tickCallback","elapsedTime","thisPart","incrementStep","phrases","thisPhrase","phraseArray","sequence","bNum","metroTicks","looping","beatTime","tatums","getRate","part","setBPM","Phrase","looper_classCallCheck","phraseStep","Part","steps","bLength","partStep","noLoop","metro","beatLength","tempo","getBPM","resetSync","onended","array","Score","currentPart","thisScore","nextPart","resetPart","playNextPart","resetParts","scoreStep","aScore","SoundLoop","soundLoop_classCallCheck","_bpm","musicalTimeMode","_update","timeSig","_interval","maxIterations","iterations","_calcFreq","otherLoop","_convertNotation","Number","_measure","_note","Compressor","compressor_classCallCheck","compressor_possibleConstructorReturn","compressor_getPrototypeOf","compressor","number","compressor_get","PeakDetect","_framesPerPeak","peakDetect_classCallCheck","framesPerPeak","framesSinceLastPeak","cutoff","cutoffMult","energy","penergy","currentValue","isDetected","f1","f2","_onPeak","fftObject","nrg","SoundRecorder","soundRecorder_classCallCheck","_inputChannels","_outputChannels","buffers","leftBuffer","rightBuffer","_callback","sFile","setBuffer","makeDistortionCurve","amount","k","deg","Distortion","distortion_classCallCheck","distortion_possibleConstructorReturn","distortion_getPrototypeOf","curveAmount","waveShaperNode","distortion_get","gain_classCallCheck","AudioVoice","audioVoice_classCallCheck","velocity","sustime","MonoSynth","monosynth_classCallCheck","monosynth_possibleConstructorReturn","monosynth_getPrototypeOf","env","monosynth_assertThisInitialized","sustain","vel","monosynth_get","OnsetDetect","freqLow","freqHigh","onsetDetect_classCallCheck","treshold","sensitivity","setTimeout","PolySynth","audioVoice","maxVoices","polysynth_classCallCheck","audiovoices","notes","_newest","_oldest","_voicesInUse","_allocateVoices","noteAttack","noteRelease","voice","_velocity","currentVoice","acTime","oldestNote","previousVal","_updateAfter","maxRange","nextTime","Signal_classCallCheck","soundFormats","disposeSound","extTest","pathSplit","pathCore","_typeof","math","writeFile","loadSound","registerPreloadMethod","listener3D","cReverb","peakDetect"],"mappings":"aACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,oBAAAiB,eAAAC,aACAN,OAAAC,eAAAb,EAAAiB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAb,EAAA,cAAiDmB,OAAA,KAQjDrB,EAAAsB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAArB,EAAAqB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,iBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAX,OAAAY,OAAA,MAGA,GAFA1B,EAAAkB,EAAAO,GACAX,OAAAC,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAAAN,EAAArB,EAAAU,EAAAe,EAAAE,EAAA,SAAAA,GAAgH,OAAAN,EAAAM,IAAqBC,KAAA,KAAAD,IACrI,OAAAF,GAIAzB,EAAA6B,EAAA,SAAA1B,GACA,IAAAS,EAAAT,KAAAqB,WACA,WAA2B,OAAArB,EAAA,SAC3B,WAAiC,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GAGXx7B,GAAGq7B,OAASA,GACZr7B,GAAG4mC,UAAYA,GACf5mC,GAAG9I,UAAUgvC,gBd4eb,SAAyBxb,EAAM5qB,EAAU8sB,IAGQ,EAA7CtuB,OAAO4oC,SAASC,OAAOxuC,QAAQ,YACZ,cAAnB2F,OAAO8oC,SAEP1I,MACE,6FAGJ,IAAI9lB,EAAOlhB,KACP25C,EAAU,IAAIzK,GAChBlc,EACA,SAAU/e,GACgB,mBAAb7L,GACTA,EAAS6L,GAG2B,mBAA3BiN,EAAK4P,mBACd5P,EAAK4P,qBAGToE,GAGF,OADAykB,EAAQvK,SAAW,GACZuK,GcpgBTrxC,GAAG9I,UAAUi6C,sBAAsB,kBAAmBnxC,GAAG9I,WAGzD8I,GAAGqnC,MAAQA,GAGXrnC,GAAG4oC,OAASA,GACZ5oC,GAAG+oC,KAAOA,GACV/oC,GAAG2pC,MAAQA,GAGX3pC,GAAGoqC,UAAYA,GAGfpqC,GAAGmrC,WAAaA,GAGhBnrC,GAAGsxC,WAAaA,GAGhBtxC,GAAG0sC,cAAgBA,GAGnB1sC,GAAGwtC,WAAaA,GAGhBxtC,GAAGjB,KAAOA,GAGViB,GAAGguC,WAAaA,GAGhBhuC,GAAGouC,UAAYA,GAGfpuC,GAAG6uC,YAAcA,GAGjB7uC,GAAGovC,UAAYA,GAIfpvC,GAAG7G,OAASA","file":"p5.sound.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 40);\n","/**\n * Tone.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2014-2017 Yotam Mann\n */\ndefine(function(){\n\n\t\"use strict\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTONE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * @class Tone is the base class of all other classes. It provides \n\t * a lot of methods and functionality to all classes that extend\n\t * it. \n\t * \n\t * @constructor\n\t * @alias Tone\n\t * @param {number} [inputs=1] the number of input nodes\n\t * @param {number} [outputs=1] the number of output nodes\n\t */\n\tvar Tone = function(inputs, outputs){\n\n\t\t/**\n\t\t * the input node(s)\n\t\t * @type {GainNode|Array}\n\t\t */\n\t\tif (this.isUndef(inputs) || inputs === 1){\n\t\t\tthis.input = this.context.createGain();\n\t\t} else if (inputs > 1){\n\t\t\tthis.input = new Array(inputs);\n\t\t}\n\n\t\t/**\n\t\t * the output node(s)\n\t\t * @type {GainNode|Array}\n\t\t */\n\t\tif (this.isUndef(outputs) || outputs === 1){\n\t\t\tthis.output = this.context.createGain();\n\t\t} else if (outputs > 1){\n\t\t\tthis.output = new Array(inputs);\n\t\t}\n\t};\n\n\t/**\n\t * Set the parameters at once. Either pass in an\n\t * object mapping parameters to values, or to set a\n\t * single parameter, by passing in a string and value.\n\t * The last argument is an optional ramp time which \n\t * will ramp any signal values to their destination value\n\t * over the duration of the rampTime.\n\t * @param {Object|string} params\n\t * @param {number=} value\n\t * @param {Time=} rampTime\n\t * @returns {Tone} this\n\t * @example\n\t * //set values using an object\n\t * filter.set({\n\t * \t\"frequency\" : 300,\n\t * \t\"type\" : highpass\n\t * });\n\t * @example\n\t * filter.set(\"type\", \"highpass\");\n\t * @example\n\t * //ramp to the value 220 over 3 seconds. \n\t * oscillator.set({\n\t * \t\"frequency\" : 220\n\t * }, 3);\n\t */\n\tTone.prototype.set = function(params, value, rampTime){\n\t\tif (this.isObject(params)){\n\t\t\trampTime = value;\n\t\t} else if (this.isString(params)){\n\t\t\tvar tmpObj = {};\n\t\t\ttmpObj[params] = value;\n\t\t\tparams = tmpObj;\n\t\t}\n\n\t\tparamLoop:\n\t\tfor (var attr in params){\n\t\t\tvalue = params[attr];\n\t\t\tvar parent = this;\n\t\t\tif (attr.indexOf(\".\") !== -1){\n\t\t\t\tvar attrSplit = attr.split(\".\");\n\t\t\t\tfor (var i = 0; i < attrSplit.length - 1; i++){\n\t\t\t\t\tparent = parent[attrSplit[i]];\n\t\t\t\t\tif (parent instanceof Tone) {\n\t\t\t\t\t\tattrSplit.splice(0,i+1);\n\t\t\t\t\t\tvar innerParam = attrSplit.join(\".\");\n\t\t\t\t\t\tparent.set(innerParam, value);\n\t\t\t\t\t\tcontinue paramLoop;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tattr = attrSplit[attrSplit.length - 1];\n\t\t\t}\n\t\t\tvar param = parent[attr];\n\t\t\tif (this.isUndef(param)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((Tone.Signal && param instanceof Tone.Signal) || \n\t\t\t\t\t(Tone.Param && param instanceof Tone.Param)){\n\t\t\t\tif (param.value !== value){\n\t\t\t\t\tif (this.isUndef(rampTime)){\n\t\t\t\t\t\tparam.value = value;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparam.rampTo(value, rampTime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (param instanceof AudioParam){\n\t\t\t\tif (param.value !== value){\n\t\t\t\t\tparam.value = value;\n\t\t\t\t}\t\t\t\t\n\t\t\t} else if (param instanceof Tone){\n\t\t\t\tparam.set(value);\n\t\t\t} else if (param !== value){\n\t\t\t\tparent[attr] = value;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Get the object's attributes. Given no arguments get\n\t * will return all available object properties and their corresponding\n\t * values. Pass in a single attribute to retrieve or an array\n\t * of attributes. The attribute strings can also include a \".\"\n\t * to access deeper properties.\n\t * @example\n\t * osc.get();\n\t * //returns {\"type\" : \"sine\", \"frequency\" : 440, ...etc}\n\t * @example\n\t * osc.get(\"type\");\n\t * //returns { \"type\" : \"sine\"}\n\t * @example\n\t * //use dot notation to access deep properties\n\t * synth.get([\"envelope.attack\", \"envelope.release\"]);\n\t * //returns {\"envelope\" : {\"attack\" : 0.2, \"release\" : 0.4}}\n\t * @param {Array=|string|undefined} params the parameters to get, otherwise will return \n\t * \t\t\t\t\t all available.\n\t * @returns {Object}\n\t */\n\tTone.prototype.get = function(params){\n\t\tif (this.isUndef(params)){\n\t\t\tparams = this._collectDefaults(this.constructor);\n\t\t} else if (this.isString(params)){\n\t\t\tparams = [params];\n\t\t} \n\t\tvar ret = {};\n\t\tfor (var i = 0; i < params.length; i++){\n\t\t\tvar attr = params[i];\n\t\t\tvar parent = this;\n\t\t\tvar subRet = ret;\n\t\t\tif (attr.indexOf(\".\") !== -1){\n\t\t\t\tvar attrSplit = attr.split(\".\");\n\t\t\t\tfor (var j = 0; j < attrSplit.length - 1; j++){\n\t\t\t\t\tvar subAttr = attrSplit[j];\n\t\t\t\t\tsubRet[subAttr] = subRet[subAttr] || {};\n\t\t\t\t\tsubRet = subRet[subAttr];\n\t\t\t\t\tparent = parent[subAttr];\n\t\t\t\t}\n\t\t\t\tattr = attrSplit[attrSplit.length - 1];\n\t\t\t}\n\t\t\tvar param = parent[attr];\n\t\t\tif (this.isObject(params[attr])){\n\t\t\t\tsubRet[attr] = param.get();\n\t\t\t} else if (Tone.Signal && param instanceof Tone.Signal){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (Tone.Param && param instanceof Tone.Param){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (param instanceof AudioParam){\n\t\t\t\tsubRet[attr] = param.value;\n\t\t\t} else if (param instanceof Tone){\n\t\t\t\tsubRet[attr] = param.get();\n\t\t\t} else if (!this.isFunction(param) && !this.isUndef(param)){\n\t\t\t\tsubRet[attr] = param;\n\t\t\t} \n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * collect all of the default attributes in one\n\t * @private\n\t * @param {function} constr the constructor to find the defaults from\n\t * @return {Array} all of the attributes which belong to the class\n\t */\n\tTone.prototype._collectDefaults = function(constr){\n\t\tvar ret = [];\n\t\tif (!this.isUndef(constr.defaults)){\n\t\t\tret = Object.keys(constr.defaults);\n\t\t}\n\t\tif (!this.isUndef(constr._super)){\n\t\t\tvar superDefs = this._collectDefaults(constr._super);\n\t\t\t//filter out repeats\n\t\t\tfor (var i = 0; i < superDefs.length; i++){\n\t\t\t\tif (ret.indexOf(superDefs[i]) === -1){\n\t\t\t\t\tret.push(superDefs[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * @returns {string} returns the name of the class as a string\n\t */\n\tTone.prototype.toString = function(){\n\t\tfor (var className in Tone){\n\t\t\tvar isLetter = className[0].match(/^[A-Z]$/);\n\t\t\tvar sameConstructor = Tone[className] === this.constructor;\n\t\t\tif (this.isFunction(Tone[className]) && isLetter && sameConstructor){\n\t\t\t\treturn className;\n\t\t\t}\n\t\t}\n\t\treturn \"Tone\";\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCLASS VARS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The number of inputs feeding into the AudioNode. \n\t * For source nodes, this will be 0.\n\t * @memberOf Tone#\n\t * @name numberOfInputs\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"numberOfInputs\", {\n\t\tget : function(){\n\t\t\tif (this.input){\n\t\t\t\tif (this.isArray(this.input)){\n\t\t\t\t\treturn this.input.length;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * The number of outputs coming out of the AudioNode. \n\t * For source nodes, this will be 0.\n\t * @memberOf Tone#\n\t * @name numberOfInputs\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"numberOfOutputs\", {\n\t\tget : function(){\n\t\t\tif (this.output){\n\t\t\t\tif (this.isArray(this.output)){\n\t\t\t\t\treturn this.output.length;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\t\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCONNECTIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * disconnect and dispose\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.dispose = function(){\n\t\tif (!this.isUndef(this.input)){\n\t\t\tif (this.input instanceof AudioNode){\n\t\t\t\tthis.input.disconnect();\n\t\t\t} \n\t\t\tthis.input = null;\n\t\t}\n\t\tif (!this.isUndef(this.output)){\n\t\t\tif (this.output instanceof AudioNode){\n\t\t\t\tthis.output.disconnect();\n\t\t\t} \n\t\t\tthis.output = null;\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode\n\t * @param {Tone | AudioParam | AudioNode} unit \n\t * @param {number} [outputNum=0] optionally which output to connect from\n\t * @param {number} [inputNum=0] optionally which input to connect to\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.connect = function(unit, outputNum, inputNum){\n\t\tif (Array.isArray(this.output)){\n\t\t\toutputNum = this.defaultArg(outputNum, 0);\n\t\t\tthis.output[outputNum].connect(unit, 0, inputNum);\n\t\t} else {\n\t\t\tthis.output.connect(unit, outputNum, inputNum);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * disconnect the output\n\t * @param {Number|AudioNode} output Either the output index to disconnect\n\t * if the output is an array, or the\n\t * node to disconnect from.\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.disconnect = function(destination, outputNum, inputNum){\n\t\tif (this.isArray(this.output)){\n\t\t\tif (this.isNumber(destination)){\n\t\t\t\tthis.output[destination].disconnect();\n\t\t\t} else {\n\t\t\t\toutputNum = this.defaultArg(outputNum, 0);\n\t\t\t\tthis.output[outputNum].disconnect(destination, 0, inputNum);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.output.disconnect.apply(this.output, arguments);\n\t\t}\n\t};\n\n\t/**\n\t * connect together all of the arguments in series\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.connectSeries = function(){\n\t\tif (arguments.length > 1){\n\t\t\tvar currentUnit = arguments[0];\n\t\t\tfor (var i = 1; i < arguments.length; i++){\n\t\t\t\tvar toUnit = arguments[i];\n\t\t\t\tcurrentUnit.connect(toUnit);\n\t\t\t\tcurrentUnit = toUnit;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Connect the output of this node to the rest of the nodes in series.\n\t * @example\n\t * //connect a node to an effect, panVol and then to the master output\n\t * node.chain(effect, panVol, Tone.Master);\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.chain = function(){\n\t\tif (arguments.length > 0){\n\t\t\tvar currentUnit = this;\n\t\t\tfor (var i = 0; i < arguments.length; i++){\n\t\t\t\tvar toUnit = arguments[i];\n\t\t\t\tcurrentUnit.connect(toUnit);\n\t\t\t\tcurrentUnit = toUnit;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * connect the output of this node to the rest of the nodes in parallel.\n\t * @param {...AudioParam|Tone|AudioNode} nodes\n\t * @returns {Tone} this\n\t */\n\tTone.prototype.fan = function(){\n\t\tif (arguments.length > 0){\n\t\t\tfor (var i = 0; i < arguments.length; i++){\n\t\t\t\tthis.connect(arguments[i]);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t//give native nodes chain and fan methods\n\tAudioNode.prototype.chain = Tone.prototype.chain;\n\tAudioNode.prototype.fan = Tone.prototype.fan;\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUTILITIES / HELPERS / MATHS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * If the `given` parameter is undefined, use the `fallback`. \n\t * If both `given` and `fallback` are object literals, it will\n\t * return a deep copy which includes all of the parameters from both \n\t * objects. If a parameter is undefined in given, it will return\n\t * the fallback property. \n\t *

\n\t * WARNING: if object is self referential, it will go into an an \n\t * infinite recursive loop.\n\t * \n\t * @param {*} given \n\t * @param {*} fallback \n\t * @return {*} \n\t */\n\tTone.prototype.defaultArg = function(given, fallback){\n\t\tif (this.isObject(given) && this.isObject(fallback)){\n\t\t\tvar ret = {};\n\t\t\t//make a deep copy of the given object\n\t\t\tfor (var givenProp in given) {\n\t\t\t\tret[givenProp] = this.defaultArg(fallback[givenProp], given[givenProp]);\n\t\t\t}\n\t\t\tfor (var fallbackProp in fallback) {\n\t\t\t\tret[fallbackProp] = this.defaultArg(given[fallbackProp], fallback[fallbackProp]);\n\t\t\t}\n\t\t\treturn ret;\n\t\t} else {\n\t\t\treturn this.isUndef(given) ? fallback : given;\n\t\t}\n\t};\n\n\t/**\n\t * returns the args as an options object with given arguments\n\t * mapped to the names provided. \n\t *\n\t * if the args given is an array containing only one object, it is assumed\n\t * that that's already the options object and will just return it. \n\t * \n\t * @param {Array} values the 'arguments' object of the function\n\t * @param {Array} keys the names of the arguments as they\n\t * should appear in the options object\n\t * @param {Object=} defaults optional defaults to mixin to the returned \n\t * options object \n\t * @return {Object} the options object with the names mapped to the arguments\n\t */\n\tTone.prototype.optionsObject = function(values, keys, defaults){\n\t\tvar options = {};\n\t\tif (values.length === 1 && this.isObject(values[0])){\n\t\t\toptions = values[0];\n\t\t} else {\n\t\t\tfor (var i = 0; i < keys.length; i++){\n\t\t\t\toptions[keys[i]] = values[i];\n\t\t\t}\n\t\t}\n\t\tif (!this.isUndef(defaults)){\n\t\t\treturn this.defaultArg(options, defaults);\n\t\t} else {\n\t\t\treturn options;\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// TYPE CHECKING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * test if the arg is undefined\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is undefined\n\t * @function\n\t */\n\tTone.prototype.isUndef = function(val){\n\t\treturn typeof val === \"undefined\";\n\t};\n\n\t/**\n\t * test if the arg is a function\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a function\n\t * @function\n\t */\n\tTone.prototype.isFunction = function(val){\n\t\treturn typeof val === \"function\";\n\t};\n\n\t/**\n\t * Test if the argument is a number.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a number\n\t */\n\tTone.prototype.isNumber = function(arg){\n\t\treturn (typeof arg === \"number\");\n\t};\n\n\t/**\n\t * Test if the given argument is an object literal (i.e. `{}`);\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is an object literal.\n\t */\n\tTone.prototype.isObject = function(arg){\n\t\treturn (Object.prototype.toString.call(arg) === \"[object Object]\" && arg.constructor === Object);\n\t};\n\n\t/**\n\t * Test if the argument is a boolean.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a boolean\n\t */\n\tTone.prototype.isBoolean = function(arg){\n\t\treturn (typeof arg === \"boolean\");\n\t};\n\n\t/**\n\t * Test if the argument is an Array\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is an array\n\t */\n\tTone.prototype.isArray = function(arg){\n\t\treturn (Array.isArray(arg));\n\t};\n\n\t/**\n\t * Test if the argument is a string.\n\t * @param {*} arg the argument to test\n\t * @returns {boolean} true if the arg is a string\n\t */\n\tTone.prototype.isString = function(arg){\n\t\treturn (typeof arg === \"string\");\n\t};\n\n \t/**\n\t * An empty function.\n\t * @static\n\t */\n\tTone.noOp = function(){};\n\n\t/**\n\t * Make the property not writable. Internal use only. \n\t * @private\n\t * @param {string} property the property to make not writable\n\t */\n\tTone.prototype._readOnly = function(property){\n\t\tif (Array.isArray(property)){\n\t\t\tfor (var i = 0; i < property.length; i++){\n\t\t\t\tthis._readOnly(property[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tObject.defineProperty(this, property, { \n\t\t\t\twritable: false,\n\t\t\t\tenumerable : true,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Make an attribute writeable. Interal use only. \n\t * @private\n\t * @param {string} property the property to make writable\n\t */\n\tTone.prototype._writable = function(property){\n\t\tif (Array.isArray(property)){\n\t\t\tfor (var i = 0; i < property.length; i++){\n\t\t\t\tthis._writable(property[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tObject.defineProperty(this, property, { \n\t\t\t\twritable: true,\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * Possible play states. \n\t * @enum {string}\n\t */\n\tTone.State = {\n\t\tStarted : \"started\",\n\t\tStopped : \"stopped\",\n\t\tPaused : \"paused\",\n \t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Equal power gain scale. Good for cross-fading.\n\t * @param {NormalRange} percent (0-1)\n\t * @return {Number} output gain (0-1)\n\t */\n\tTone.prototype.equalPowerScale = function(percent){\n\t\tvar piFactor = 0.5 * Math.PI;\n\t\treturn Math.sin(percent * piFactor);\n\t};\n\n\t/**\n\t * Convert decibels into gain.\n\t * @param {Decibels} db\n\t * @return {Number} \n\t */\n\tTone.prototype.dbToGain = function(db) {\n\t\treturn Math.pow(2, db / 6);\n\t};\n\n\t/**\n\t * Convert gain to decibels.\n\t * @param {Number} gain (0-1)\n\t * @return {Decibels} \n\t */\n\tTone.prototype.gainToDb = function(gain) {\n\t\treturn 20 * (Math.log(gain) / Math.LN10);\n\t};\n\n\t/**\n\t * Convert an interval (in semitones) to a frequency ratio.\n\t * @param {Interval} interval the number of semitones above the base note\n\t * @return {number} the frequency ratio\n\t * @example\n\t * tone.intervalToFrequencyRatio(0); // 1\n\t * tone.intervalToFrequencyRatio(12); // 2\n\t * tone.intervalToFrequencyRatio(-12); // 0.5\n\t */\n\tTone.prototype.intervalToFrequencyRatio = function(interval){\n\t\treturn Math.pow(2,(interval/12));\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTIMING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Return the current time of the AudioContext clock.\n\t * @return {Number} the currentTime from the AudioContext\n\t */\n\tTone.prototype.now = function(){\n\t\treturn Tone.context.now();\n\t};\n\n\t/**\n\t * Return the current time of the AudioContext clock.\n\t * @return {Number} the currentTime from the AudioContext\n\t * @static\n\t */\n\tTone.now = function(){\n\t\treturn Tone.context.now();\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tINHERITANCE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * have a child inherit all of Tone's (or a parent's) prototype\n\t * to inherit the parent's properties, make sure to call \n\t * Parent.call(this) in the child's constructor\n\t *\n\t * based on closure library's inherit function\n\t *\n\t * @static\n\t * @param {function} \tchild \n\t * @param {function=} parent (optional) parent to inherit from\n\t * if no parent is supplied, the child\n\t * will inherit from Tone\n\t */\n\tTone.extend = function(child, parent){\n\t\tif (Tone.prototype.isUndef(parent)){\n\t\t\tparent = Tone;\n\t\t}\n\t\tfunction TempConstructor(){}\n\t\tTempConstructor.prototype = parent.prototype;\n\t\tchild.prototype = new TempConstructor();\n\t\t/** @override */\n\t\tchild.prototype.constructor = child;\n\t\tchild._super = parent;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tCONTEXT\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The private audio context shared by all Tone Nodes. \n\t * @private\n\t * @type {Tone.Context|undefined}\n\t */\n\tvar audioContext;\n\n\t/**\n\t * A static pointer to the audio context accessible as Tone.context. \n\t * @type {Tone.Context}\n\t * @name context\n\t * @memberOf Tone\n\t */\n\tObject.defineProperty(Tone, \"context\", {\n\t\tget : function(){\n\t\t\treturn audioContext;\n\t\t},\n\t\tset : function(context){\n\t\t\tif (Tone.Context && context instanceof Tone.Context){\n\t\t\t\taudioContext = context;\n\t\t\t} else {\n\t\t\t\taudioContext = new Tone.Context(context);\n\t\t\t}\n\t\t\t//initialize the new audio context\n\t\t\tif (Tone.Context){\n\t\t\t\tTone.Context.emit(\"init\", audioContext);\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * The AudioContext\n\t * @type {Tone.Context}\n\t * @name context\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"context\", {\n\t\tget : function(){\n\t\t\treturn Tone.context;\n\t\t}\n\t});\n\n\t/**\n\t * Tone automatically creates a context on init, but if you are working\n\t * with other libraries which also create an AudioContext, it can be\n\t * useful to set your own. If you are going to set your own context, \n\t * be sure to do it at the start of your code, before creating any objects.\n\t * @static\n\t * @param {AudioContext} ctx The new audio context to set\n\t */\n\tTone.setContext = function(ctx){\n\t\tTone.context = ctx;\n\t};\n\n\t/**\n\t * The number of seconds of 1 processing block (128 samples)\n\t * @type {Number}\n\t * @name blockTime\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"blockTime\", {\n\t\tget : function(){\n\t\t\treturn 128 / this.context.sampleRate;\n\t\t}\n\t});\n\n\t/**\n\t * The duration in seconds of one sample.\n\t * @type {Number}\n\t * @name sampleTime\n\t * @memberOf Tone#\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.prototype, \"sampleTime\", {\n\t\tget : function(){\n\t\t\treturn 1 / this.context.sampleRate;\n\t\t}\n\t});\n\n\t/**\n\t * Whether or not all the technologies that Tone.js relies on are supported by the current browser. \n\t * @type {Boolean}\n\t * @name supported\n\t * @memberOf Tone\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone, \"supported\", {\n\t\tget : function(){\n\t\t\tvar hasAudioContext = window.hasOwnProperty(\"AudioContext\") || window.hasOwnProperty(\"webkitAudioContext\");\n\t\t\tvar hasPromises = window.hasOwnProperty(\"Promise\");\n\t\t\tvar hasWorkers = window.hasOwnProperty(\"Worker\");\n\t\t\treturn hasAudioContext && hasPromises && hasWorkers;\n\t\t}\n\t});\n\n\tTone.version = \"r10\";\n\n\t// allow optional silencing of this log\n\tif (!window.TONE_SILENCE_VERSION_LOGGING) {\n\t\tconsole.log(\"%c * Tone.js \" + Tone.version + \" * \", \"background: #000; color: #fff\");\n\t}\n\n\treturn Tone;\n});\n","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Multiply two incoming signals. Or, if a number is given in the constructor, \n\t * multiplies the incoming signal by that value. \n\t *\n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number=} value Constant value to multiple. If no value is provided,\n\t * it will return the product of the first and second inputs\n\t * @example\n\t * var mult = new Tone.Multiply();\n\t * var sigA = new Tone.Signal(3);\n\t * var sigB = new Tone.Signal(4);\n\t * sigA.connect(mult, 0, 0);\n\t * sigB.connect(mult, 0, 1);\n\t * //output of mult is 12.\n\t * @example\n\t * var mult = new Tone.Multiply(10);\n\t * var sig = new Tone.Signal(2).connect(mult);\n\t * //the output of mult is 20. \n\t */\n\tTone.Multiply = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the input node is the same as the output node\n\t\t * it is also the GainNode which handles the scaling of incoming signal\n\t\t * \n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._mult = this.input[0] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * the scaling parameter\n\t\t * @type {AudioParam}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input[1] = this.output.gain;\n\t\t\n\t\tthis._param.value = this.defaultArg(value, 0);\n\t};\n\n\tTone.extend(Tone.Multiply, Tone.Signal);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Multiply} this\n\t */\n\tTone.Multiply.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._mult.dispose();\n\t\tthis._mult = null;\n\t\tthis._param = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Multiply;\n});\n","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/type/Type\", \"Tone/core/Param\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class A signal is an audio-rate value. Tone.Signal is a core component of the library.\n\t * Unlike a number, Signals can be scheduled with sample-level accuracy. Tone.Signal\n\t * has all of the methods available to native Web Audio \n\t * [AudioParam](http://webaudio.github.io/web-audio-api/#the-audioparam-interface)\n\t * as well as additional conveniences. Read more about working with signals \n\t * [here](https://github.com/Tonejs/Tone.js/wiki/Signals).\n\t *\n\t * @constructor\n\t * @extends {Tone.Param}\n\t * @param {Number|AudioParam} [value] Initial value of the signal. If an AudioParam\n\t * is passed in, that parameter will be wrapped\n\t * and controlled by the Signal. \n\t * @param {string} [units=Number] unit The units the signal is in. \n\t * @example\n\t * var signal = new Tone.Signal(10);\n\t */\n\tTone.Signal = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"value\", \"units\"], Tone.Signal.defaults);\n\n\t\t/**\n\t\t * The node where the constant signal value is scaled.\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis.output = this._gain = this.context.createGain();\n\n\t\toptions.param = this._gain.gain;\n\t\tTone.Param.call(this, options);\n\n\t\t/**\n\t\t * The node where the value is set.\n\t\t * @type {Tone.Param}\n\t\t * @private\n\t\t */\n\t\tthis.input = this._param = this._gain.gain;\n\n\t\t//connect the const output to the node output\n\t\tthis.context.getConstant(1).chain(this._gain);\n\t};\n\n\tTone.extend(Tone.Signal, Tone.Param);\n\n\t/**\n\t * The default values\n\t * @type {Object}\n\t * @static\n\t * @const\n\t */\n\tTone.Signal.defaults = {\n\t\t\"value\" : 0,\n\t\t\"units\" : Tone.Type.Default,\n\t\t\"convert\" : true,\n\t};\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.SignalBase} this\n\t * @method\n\t */\n\tTone.Signal.prototype.connect = Tone.SignalBase.prototype.connect;\n\n\t/**\n\t * dispose and disconnect\n\t * @returns {Tone.Signal} this\n\t */\n\tTone.Signal.prototype.dispose = function(){\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._param = null;\n\t\tthis._gain.disconnect();\n\t\tthis._gain = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Signal;\n});","global.TONE_SILENCE_VERSION_LOGGING = true;\n\nimport StartAudioContext from 'startaudiocontext';\nimport Tone from 'Tone/core/Tone';\nimport 'Tone/core/Context';\n\n// Create the Audio Context\nconst audiocontext = new window.AudioContext();\n\n// Tone and p5.sound share the same audio context\nTone.setContext(audiocontext);\n\n/**\n *

Returns the Audio Context for this sketch. Useful for users\n * who would like to dig deeper into the Web Audio API\n * .

\n *\n *

Some browsers require users to startAudioContext\n * with a user gesture, such as touchStarted in the example below.

\n *\n * @for p5\n * @method getAudioContext\n * @return {Object} AudioContext for this sketch\n * @example\n *
\n * function draw() {\n * background(255);\n * textAlign(CENTER);\n *\n * if (getAudioContext().state !== 'running') {\n * text('click to start audio', width/2, height/2);\n * } else {\n * text('audio is enabled', width/2, height/2);\n * }\n * }\n *\n * function touchStarted() {\n * if (getAudioContext().state !== 'running') {\n * getAudioContext().resume();\n * }\n * var synth = new p5.MonoSynth();\n * synth.play('A4', 0.5, 0, 0.2);\n * }\n *\n *
\n */\nexport function getAudioContext() {\n return audiocontext;\n}\n\n/**\n *

It is not only a good practice to give users control over starting\n * audio. This policy is enforced by many web browsers, including iOS and\n * Google Chrome, which create the Web Audio API's\n * Audio Context\n * in a suspended state.

\n *\n *

In these browser-specific policies, sound will not play until a user\n * interaction event (i.e. mousePressed()) explicitly resumes\n * the AudioContext, or starts an audio node. This can be accomplished by\n * calling start() on a p5.Oscillator,\n * play() on a p5.SoundFile, or simply\n * userStartAudio().

\n *\n *

userStartAudio() starts the AudioContext on a user\n * gesture. The default behavior will enable audio on any\n * mouseUp or touchEnd event. It can also be placed in a specific\n * interaction function, such as mousePressed() as in the\n * example below. This method utilizes\n * StartAudioContext\n * , a library by Yotam Mann (MIT Licence, 2016).

\n * @param {Element|Array} [element(s)] This argument can be an Element,\n * Selector String, NodeList, p5.Element,\n * jQuery Element, or an Array of any of those.\n * @param {Function} [callback] Callback to invoke when the AudioContext\n * has started\n * @return {Promise} Returns a Promise that resolves when\n * the AudioContext state is 'running'\n * @method userStartAudio\n * @for p5\n * @example\n *
\n * function setup() {\n * // mimics the autoplay policy\n * getAudioContext().suspend();\n *\n * let mySynth = new p5.MonoSynth();\n *\n * // This won't play until the context has resumed\n * mySynth.play('A6');\n * }\n * function draw() {\n * background(220);\n * textAlign(CENTER, CENTER);\n * text(getAudioContext().state, width/2, height/2);\n * }\n * function mousePressed() {\n * userStartAudio();\n * }\n *
\n */\nexport function userStartAudio(elements, callback) {\n var elt = elements;\n if (elements instanceof p5.Element) {\n elt = elements.elt;\n } else if (elements instanceof Array && elements[0] instanceof p5.Element) {\n elt = elements.map(function (e) {\n return e.elt;\n });\n }\n return StartAudioContext(audiocontext, elt, callback);\n}\n\nexport default audiocontext;\n","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Add a signal and a number or two signals. When no value is\n\t * passed into the constructor, Tone.Add will sum input[0]\n\t * and input[1]. If a value is passed into the constructor, \n\t * the it will be added to the input.\n\t * \n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number=} value If no value is provided, Tone.Add will sum the first\n\t * and second inputs. \n\t * @example\n\t * var signal = new Tone.Signal(2);\n\t * var add = new Tone.Add(2);\n\t * signal.connect(add);\n\t * //the output of add equals 4\n\t * @example\n\t * //if constructed with no arguments\n\t * //it will add the first and second inputs\n\t * var add = new Tone.Add();\n\t * var sig0 = new Tone.Signal(3).connect(add, 0, 0);\n\t * var sig1 = new Tone.Signal(4).connect(add, 0, 1);\n\t * //the output of add equals 7. \n\t */\n\tTone.Add = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the summing node\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._sum = this.input[0] = this.input[1] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * @private\n\t\t * @type {Tone.Signal}\n\t\t */\n\t\tthis._param = this.input[1] = new Tone.Signal(value);\n\n\t\tthis._param.connect(this._sum);\n\t};\n\n\tTone.extend(Tone.Add, Tone.Signal);\n\t\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Add} this\n\t */\n\tTone.Add.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._sum.dispose();\n\t\tthis._sum = null;\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Add;\n});","module.exports = {\n recorderProcessor: 'recorder-processor',\n soundFileProcessor: 'sound-file-processor',\n amplitudeProcessor: 'amplitude-processor',\n};\n","define([\"Tone/core/Tone\", \"Tone/signal/SignalBase\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Wraps the native Web Audio API \n\t * [WaveShaperNode](http://webaudio.github.io/web-audio-api/#the-waveshapernode-interface).\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {function|Array|Number} mapping The function used to define the values. \n\t * The mapping function should take two arguments: \n\t * the first is the value at the current position \n\t * and the second is the array position. \n\t * If the argument is an array, that array will be\n\t * set as the wave shaping function. The input\n\t * signal is an AudioRange [-1, 1] value and the output\n\t * signal can take on any numerical values. \n\t * \n\t * @param {Number} [bufferLen=1024] The length of the WaveShaperNode buffer.\n\t * @example\n\t * var timesTwo = new Tone.WaveShaper(function(val){\n\t * \treturn val * 2;\n\t * }, 2048);\n\t * @example\n\t * //a waveshaper can also be constructed with an array of values\n\t * var invert = new Tone.WaveShaper([1, -1]);\n\t */\n\tTone.WaveShaper = function(mapping, bufferLen){\n\n\t\t/**\n\t\t * the waveshaper\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._shaper = this.input = this.output = this.context.createWaveShaper();\n\n\t\t/**\n\t\t * the waveshapers curve\n\t\t * @type {Float32Array}\n\t\t * @private\n\t\t */\n\t\tthis._curve = null;\n\n\t\tif (Array.isArray(mapping)){\n\t\t\tthis.curve = mapping;\n\t\t} else if (isFinite(mapping) || this.isUndef(mapping)){\n\t\t\tthis._curve = new Float32Array(this.defaultArg(mapping, 1024));\n\t\t} else if (this.isFunction(mapping)){\n\t\t\tthis._curve = new Float32Array(this.defaultArg(bufferLen, 1024));\n\t\t\tthis.setMap(mapping);\n\t\t} \n\t};\n\n\tTone.extend(Tone.WaveShaper, Tone.SignalBase);\n\n\t/**\n\t * Uses a mapping function to set the value of the curve. \n\t * @param {function} mapping The function used to define the values. \n\t * The mapping function take two arguments: \n\t * the first is the value at the current position \n\t * which goes from -1 to 1 over the number of elements\n\t * in the curve array. The second argument is the array position. \n\t * @returns {Tone.WaveShaper} this\n\t * @example\n\t * //map the input signal from [-1, 1] to [0, 10]\n\t * shaper.setMap(function(val, index){\n\t * \treturn (val + 1) * 5;\n\t * })\n\t */\n\tTone.WaveShaper.prototype.setMap = function(mapping){\n\t\tfor (var i = 0, len = this._curve.length; i < len; i++){\n\t\t\tvar normalized = (i / (len - 1)) * 2 - 1;\n\t\t\tthis._curve[i] = mapping(normalized, i);\n\t\t}\n\t\tthis._shaper.curve = this._curve;\n\t\treturn this;\n\t};\n\n\t/**\n\t * The array to set as the waveshaper curve. For linear curves\n\t * array length does not make much difference, but for complex curves\n\t * longer arrays will provide smoother interpolation. \n\t * @memberOf Tone.WaveShaper#\n\t * @type {Array}\n\t * @name curve\n\t */\n\tObject.defineProperty(Tone.WaveShaper.prototype, \"curve\", {\n\t\tget : function(){\n\t\t\treturn this._shaper.curve;\n\t\t},\n\t\tset : function(mapping){\n\t\t\tthis._curve = new Float32Array(mapping);\n\t\t\tthis._shaper.curve = this._curve;\n\t\t}\n\t});\n\n\t/**\n\t * Specifies what type of oversampling (if any) should be used when \n\t * applying the shaping curve. Can either be \"none\", \"2x\" or \"4x\". \n\t * @memberOf Tone.WaveShaper#\n\t * @type {string}\n\t * @name oversample\n\t */\n\tObject.defineProperty(Tone.WaveShaper.prototype, \"oversample\", {\n\t\tget : function(){\n\t\t\treturn this._shaper.oversample;\n\t\t},\n\t\tset : function(oversampling){\n\t\t\tif ([\"none\", \"2x\", \"4x\"].indexOf(oversampling) !== -1){\n\t\t\t\tthis._shaper.oversample = oversampling;\n\t\t\t} else {\n\t\t\t\tthrow new RangeError(\"Tone.WaveShaper: oversampling must be either 'none', '2x', or '4x'\");\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.WaveShaper} this\n\t */\n\tTone.WaveShaper.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._shaper.disconnect();\n\t\tthis._shaper = null;\n\t\tthis._curve = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.WaveShaper;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/core/Timeline\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A signal which adds the method getValueAtTime. \n\t * Code and inspiration from https://github.com/jsantell/web-audio-automation-timeline\n\t * @extends {Tone.Param}\n\t * @param {Number=} value The initial value of the signal\n\t * @param {String=} units The conversion units of the signal.\n\t */\n\tTone.TimelineSignal = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"value\", \"units\"], Tone.Signal.defaults);\n\t\t\n\t\t/**\n\t\t * The scheduled events\n\t\t * @type {Tone.Timeline}\n\t\t * @private\n\t\t */\n\t\tthis._events = new Tone.Timeline(10);\n\n\t\t//constructors\n\t\tTone.Signal.apply(this, options);\n\t\toptions.param = this._param;\n\t\tTone.Param.call(this, options);\n\n\t\t/**\n\t\t * The initial scheduled value\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._initial = this._fromUnits(this._param.value);\n\t};\n\n\tTone.extend(Tone.TimelineSignal, Tone.Param);\n\n\t/**\n\t * The event types of a schedulable signal.\n\t * @enum {String}\n\t * @private\n\t */\n\tTone.TimelineSignal.Type = {\n\t\tLinear : \"linear\",\n\t\tExponential : \"exponential\",\n\t\tTarget : \"target\",\n\t\tCurve : \"curve\",\n\t\tSet : \"set\"\n\t};\n\n\t/**\n\t * The current value of the signal. \n\t * @memberOf Tone.TimelineSignal#\n\t * @type {Number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.TimelineSignal.prototype, \"value\", {\n\t\tget : function(){\n\t\t\tvar now = this.now();\n\t\t\tvar val = this.getValueAtTime(now);\n\t\t\treturn this._toUnits(val);\n\t\t},\n\t\tset : function(value){\n\t\t\tvar convertedVal = this._fromUnits(value);\n\t\t\tthis._initial = convertedVal;\n\t\t\tthis.cancelScheduledValues();\n\t\t\tthis._param.value = convertedVal;\n\t\t}\n\t});\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tSCHEDULING\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Schedules a parameter value change at the given time.\n\t * @param {*}\tvalue The value to set the signal.\n\t * @param {Time} time The time when the change should occur.\n\t * @returns {Tone.TimelineSignal} this\n\t * @example\n\t * //set the frequency to \"G4\" in exactly 1 second from now. \n\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t */\n\tTone.TimelineSignal.prototype.setValueAtTime = function (value, startTime) {\n\t\tvalue = this._fromUnits(value);\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Set,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : startTime\n\t\t});\n\t\t//invoke the original event\n\t\tthis._param.setValueAtTime(value, startTime);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules a linear continuous change in parameter value from the \n\t * previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.linearRampToValueAtTime = function (value, endTime) {\n\t\tvalue = this._fromUnits(value);\n\t\tendTime = this.toSeconds(endTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Linear,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : endTime\n\t\t});\n\t\tthis._param.linearRampToValueAtTime(value, endTime);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.exponentialRampToValueAtTime = function (value, endTime) {\n\t\t//get the previous event and make sure it's not starting from 0\n\t\tendTime = this.toSeconds(endTime);\n\t\tvar beforeEvent = this._searchBefore(endTime);\n\t\tif (beforeEvent && beforeEvent.value === 0){\n\t\t\t//reschedule that event\n\t\t\tthis.setValueAtTime(this._minOutput, beforeEvent.time);\n\t\t}\n\t\tvalue = this._fromUnits(value);\n\t\tvar setValue = Math.max(value, this._minOutput);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Exponential,\n\t\t\t\"value\" : setValue,\n\t\t\t\"time\" : endTime\n\t\t});\n\t\t//if the ramped to value is 0, make it go to the min output, and then set to 0.\n\t\tif (value < this._minOutput){\n\t\t\tthis._param.exponentialRampToValueAtTime(this._minOutput, endTime - this.sampleTime);\n\t\t\tthis.setValueAtTime(0, endTime);\n\t\t} else {\n\t\t\tthis._param.exponentialRampToValueAtTime(value, endTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Start exponentially approaching the target value at the given time with\n\t * a rate having the given time constant.\n\t * @param {number} value \n\t * @param {Time} startTime \n\t * @param {number} timeConstant \n\t * @returns {Tone.TimelineSignal} this \n\t */\n\tTone.TimelineSignal.prototype.setTargetAtTime = function (value, startTime, timeConstant) {\n\t\tvalue = this._fromUnits(value);\n\t\tvalue = Math.max(this._minOutput, value);\n\t\ttimeConstant = Math.max(this._minOutput, timeConstant);\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Target,\n\t\t\t\"value\" : value,\n\t\t\t\"time\" : startTime,\n\t\t\t\"constant\" : timeConstant\n\t\t});\n\t\tthis._param.setTargetAtTime(value, startTime, timeConstant);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Set an array of arbitrary values starting at the given time for the given duration.\n\t * @param {Float32Array} values \n\t * @param {Time} startTime \n\t * @param {Time} duration\n\t * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value\n\t * @returns {Tone.TimelineSignal} this \n\t */\n\tTone.TimelineSignal.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) {\n\t\tscaling = this.defaultArg(scaling, 1);\n\t\t//copy the array\n\t\tvar floats = new Array(values.length);\n\t\tfor (var i = 0; i < floats.length; i++){\n\t\t\tfloats[i] = this._fromUnits(values[i]) * scaling;\n\t\t}\n\t\tstartTime = this.toSeconds(startTime);\n\t\tduration = this.toSeconds(duration);\n\t\tthis._events.add({\n\t\t\t\"type\" : Tone.TimelineSignal.Type.Curve,\n\t\t\t\"value\" : floats,\n\t\t\t\"time\" : startTime,\n\t\t\t\"duration\" : duration\n\t\t});\n\t\t//set the first value\n\t\tthis._param.setValueAtTime(floats[0], startTime);\n\t\t//schedule a lienar ramp for each of the segments\n\t\tfor (var j = 1; j < floats.length; j++){\n\t\t\tvar segmentTime = startTime + (j / (floats.length - 1) * duration);\n\t\t\tthis._param.linearRampToValueAtTime(floats[j], segmentTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancels all scheduled parameter changes with times greater than or \n\t * equal to startTime.\n\t * \n\t * @param {Time} startTime\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.cancelScheduledValues = function (after) {\n\t\tafter = this.toSeconds(after);\n\t\tthis._events.cancel(after);\n\t\tthis._param.cancelScheduledValues(after);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Sets the computed value at the given time. This provides\n\t * a point from which a linear or exponential curve\n\t * can be scheduled after. Will cancel events after \n\t * the given time and shorten the currently scheduled\n\t * linear or exponential ramp so that it ends at `time` .\n\t * This is to avoid discontinuities and clicks in envelopes. \n\t * @param {Time} time When to set the ramp point\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.setRampPoint = function (time) {\n\t\ttime = this.toSeconds(time);\n\t\t//get the value at the given time\n\t\tvar val = this._toUnits(this.getValueAtTime(time));\n\t\t//if there is an event at the given time\n\t\t//and that even is not a \"set\"\n\t\tvar before = this._searchBefore(time);\n\t\tif (before && before.time === time){\n\t\t\t//remove everything after\n\t\t\tthis.cancelScheduledValues(time + this.sampleTime);\n\t\t} else if (before && \n\t\t\t\t before.type === Tone.TimelineSignal.Type.Curve &&\n\t\t\t\t before.time + before.duration > time){\n\t\t\t//if the curve is still playing\n\t\t\t//cancel the curve\n\t\t\tthis.cancelScheduledValues(time);\n\t\t\tthis.linearRampToValueAtTime(val, time);\n\t\t} else {\n\t\t\t//reschedule the next event to end at the given time\n\t\t\tvar after = this._searchAfter(time);\n\t\t\tif (after){\n\t\t\t\t//cancel the next event(s)\n\t\t\t\tthis.cancelScheduledValues(time);\n\t\t\t\tif (after.type === Tone.TimelineSignal.Type.Linear){\n\t\t\t\t\tthis.linearRampToValueAtTime(val, time);\n\t\t\t\t} else if (after.type === Tone.TimelineSignal.Type.Exponential){\n\t\t\t\t\tthis.exponentialRampToValueAtTime(val, time);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setValueAtTime(val, time);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Do a linear ramp to the given value between the start and finish times.\n\t * @param {Number} value The value to ramp to.\n\t * @param {Time} start The beginning anchor point to do the linear ramp\n\t * @param {Time} finish The ending anchor point by which the value of\n\t * the signal will equal the given value.\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.linearRampToValueBetween = function (value, start, finish) {\n\t\tthis.setRampPoint(start);\n\t\tthis.linearRampToValueAtTime(value, finish);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Do a exponential ramp to the given value between the start and finish times.\n\t * @param {Number} value The value to ramp to.\n\t * @param {Time} start The beginning anchor point to do the exponential ramp\n\t * @param {Time} finish The ending anchor point by which the value of\n\t * the signal will equal the given value.\n\t * @returns {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.exponentialRampToValueBetween = function (value, start, finish) {\n\t\tthis.setRampPoint(start);\n\t\tthis.exponentialRampToValueAtTime(value, finish);\n\t\treturn this;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tGETTING SCHEDULED VALUES\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value before or equal to the given time\n\t * @param {Number} time The time to query\n\t * @return {Object} The event at or before the given time.\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._searchBefore = function(time){\n\t\treturn this._events.get(time);\n\t};\n\n\t/**\n\t * The event after the given time\n\t * @param {Number} time The time to query.\n\t * @return {Object} The next event after the given time\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._searchAfter = function(time){\n\t\treturn this._events.getAfter(time);\n\t};\n\n\t/**\n\t * Get the scheduled value at the given time. This will\n\t * return the unconverted (raw) value.\n\t * @param {Number} time The time in seconds.\n\t * @return {Number} The scheduled value at the given time.\n\t */\n\tTone.TimelineSignal.prototype.getValueAtTime = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tvar after = this._searchAfter(time);\n\t\tvar before = this._searchBefore(time);\n\t\tvar value = this._initial;\n\t\t//if it was set by\n\t\tif (before === null){\n\t\t\tvalue = this._initial;\n\t\t} else if (before.type === Tone.TimelineSignal.Type.Target){\n\t\t\tvar previous = this._events.getBefore(before.time);\n\t\t\tvar previouVal;\n\t\t\tif (previous === null){\n\t\t\t\tpreviouVal = this._initial;\n\t\t\t} else {\n\t\t\t\tpreviouVal = previous.value;\n\t\t\t}\n\t\t\tvalue = this._exponentialApproach(before.time, previouVal, before.value, before.constant, time);\n\t\t} else if (before.type === Tone.TimelineSignal.Type.Curve){\n\t\t\tvalue = this._curveInterpolate(before.time, before.value, before.duration, time);\n\t\t} else if (after === null){\n\t\t\tvalue = before.value;\n\t\t} else if (after.type === Tone.TimelineSignal.Type.Linear){\n\t\t\tvalue = this._linearInterpolate(before.time, before.value, after.time, after.value, time);\n\t\t} else if (after.type === Tone.TimelineSignal.Type.Exponential){\n\t\t\tvalue = this._exponentialInterpolate(before.time, before.value, after.time, after.value, time);\n\t\t} else {\n\t\t\tvalue = before.value;\n\t\t}\n\t\treturn value;\n\t};\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.TimelineSignal} this\n\t * @method\n\t */\n\tTone.TimelineSignal.prototype.connect = Tone.SignalBase.prototype.connect;\n\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tAUTOMATION CURVE CALCULATIONS\n\t//\tMIT License, copyright (c) 2014 Jordan Santell\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Calculates the the value along the curve produced by setTargetAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._exponentialApproach = function (t0, v0, v1, timeConstant, t) {\n\t\treturn v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant);\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by linearRampToValueAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._linearInterpolate = function (t0, v0, t1, v1, t) {\n\t\treturn v0 + (v1 - v0) * ((t - t0) / (t1 - t0));\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by exponentialRampToValueAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._exponentialInterpolate = function (t0, v0, t1, v1, t) {\n\t\tv0 = Math.max(this._minOutput, v0);\n\t\treturn v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0));\n\t};\n\n\t/**\n\t * Calculates the the value along the curve produced by setValueCurveAtTime\n\t * @private\n\t */\n\tTone.TimelineSignal.prototype._curveInterpolate = function (start, curve, duration, time) {\n\t\tvar len = curve.length;\n\t\t// If time is after duration, return the last curve value\n\t\tif (time >= start + duration) {\n\t\t\treturn curve[len - 1];\n\t\t} else if (time <= start){\n\t\t\treturn curve[0];\n\t\t} else {\n\t\t\tvar progress = (time - start) / duration;\n\t\t\tvar lowerIndex = Math.floor((len - 1) * progress);\n\t\t\tvar upperIndex = Math.ceil((len - 1) * progress);\n\t\t\tvar lowerVal = curve[lowerIndex];\n\t\t\tvar upperVal = curve[upperIndex];\n\t\t\tif (upperIndex === lowerIndex){\n\t\t\t\treturn lowerVal;\n\t\t\t} else {\n\t\t\t\treturn this._linearInterpolate(lowerIndex, lowerVal, upperIndex, upperVal, progress * (len - 1));\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.TimelineSignal} this\n\t */\n\tTone.TimelineSignal.prototype.dispose = function(){\n\t\tTone.Signal.prototype.dispose.call(this);\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._events.dispose();\n\t\tthis._events = null;\n\t};\n\n\treturn Tone.TimelineSignal;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Multiply\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\t\n\t/**\n\t * @class Performs a linear scaling on an input signal.\n\t * Scales a NormalRange input to between\n\t * outputMin and outputMax.\n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @param {number} [outputMin=0] The output value when the input is 0. \n\t * @param {number} [outputMax=1]\tThe output value when the input is 1. \n\t * @example\n\t * var scale = new Tone.Scale(50, 100);\n\t * var signal = new Tone.Signal(0.5).connect(scale);\n\t * //the output of scale equals 75\n\t */\n\tTone.Scale = function(outputMin, outputMax){\n\n\t\t/** \n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._outputMin = this.defaultArg(outputMin, 0);\n\n\t\t/** \n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._outputMax = this.defaultArg(outputMax, 1);\n\n\n\t\t/** \n\t\t * @private\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._scale = this.input = new Tone.Multiply(1);\n\t\t\n\t\t/** \n\t\t * @private\n\t\t * @type {Tone.Add}\n\t\t * @private\n\t\t */\n\t\tthis._add = this.output = new Tone.Add(0);\n\n\t\tthis._scale.connect(this._add);\n\t\tthis._setRange();\n\t};\n\n\tTone.extend(Tone.Scale, Tone.SignalBase);\n\n\t/**\n\t * The minimum output value. This number is output when \n\t * the value input value is 0. \n\t * @memberOf Tone.Scale#\n\t * @type {number}\n\t * @name min\n\t */\n\tObject.defineProperty(Tone.Scale.prototype, \"min\", {\n\t\tget : function(){\n\t\t\treturn this._outputMin;\n\t\t},\n\t\tset : function(min){\n\t\t\tthis._outputMin = min;\n\t\t\tthis._setRange();\n\t\t}\n\t});\n\n\t/**\n\t * The maximum output value. This number is output when \n\t * the value input value is 1. \n\t * @memberOf Tone.Scale#\n\t * @type {number}\n\t * @name max\n\t */\n\tObject.defineProperty(Tone.Scale.prototype, \"max\", {\n\t\tget : function(){\n\t\t\treturn this._outputMax;\n\t\t},\n\t\tset : function(max){\n\t\t\tthis._outputMax = max;\n\t\t\tthis._setRange();\n\t\t}\n\t});\n\n\t/**\n\t * set the values\n\t * @private\n\t */\n\tTone.Scale.prototype._setRange = function() {\n\t\tthis._add.value = this._outputMin;\n\t\tthis._scale.value = this._outputMax - this._outputMin;\n\t};\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Scale} this\n\t */\n\tTone.Scale.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._add.dispose();\n\t\tthis._add = null;\n\t\tthis._scale.dispose();\n\t\tthis._scale = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Scale;\n});\n","define([\"Tone/core/Tone\", \"Tone/type/Time\", \"Tone/type/Frequency\", \"Tone/type/TransportTime\", \"Tone/core/Context\"],\nfunction (Tone) {\t\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tTYPES\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Units which a value can take on.\n\t * @enum {String}\n\t */\n\tTone.Type = {\n\t\t/** \n\t\t * Default units\n\t\t * @typedef {Default}\n\t\t */\n\t\tDefault : \"number\",\n\t\t/**\n\t\t * Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time).\n\t\t *\n\t\t *
    \n\t\t *
  • Numbers, which will be taken literally as the time (in seconds).
  • \n\t\t *
  • Notation, (\"4n\", \"8t\") describes time in BPM and time signature relative values.
  • \n\t\t *
  • TransportTime, (\"4:3:2\") will also provide tempo and time signature relative times \n\t\t * in the form BARS:QUARTERS:SIXTEENTHS.
  • \n\t\t *
  • Frequency, (\"8hz\") is converted to the length of the cycle in seconds.
  • \n\t\t *
  • Now-Relative, (\"+1\") prefix any of the above with \"+\" and it will be interpreted as \n\t\t * \"the current time plus whatever expression follows\".
  • \n\t\t *
  • Expressions, (\"3:0 + 2 - (1m / 7)\") any of the above can also be combined \n\t\t * into a mathematical expression which will be evaluated to compute the desired time.
  • \n\t\t *
  • No Argument, for methods which accept time, no argument will be interpreted as \n\t\t * \"now\" (i.e. the currentTime).
  • \n\t\t *
\n\t\t * \n\t\t * @typedef {Time}\n\t\t */\n\t\tTime : \"time\",\n\t\t/**\n\t\t * Frequency can be described similar to time, except ultimately the\n\t\t * values are converted to frequency instead of seconds. A number\n\t\t * is taken literally as the value in hertz. Additionally any of the \n\t\t * Time encodings can be used. Note names in the form\n\t\t * of NOTE OCTAVE (i.e. C4) are also accepted and converted to their\n\t\t * frequency value. \n\t\t * @typedef {Frequency}\n\t\t */\n\t\tFrequency : \"frequency\",\n\t\t/**\n\t\t * TransportTime describes a position along the Transport's timeline. It is\n\t\t * similar to Time in that it uses all the same encodings, but TransportTime specifically\n\t\t * pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable. \n\t\t * [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime)\n\t\t * @typedef {TransportTime}\n\t\t */\n\t\tTransportTime : \"transportTime\",\n\t\t/** \n\t\t * Ticks are the basic subunit of the Transport. They are\n\t\t * the smallest unit of time that the Transport supports.\n\t\t * @typedef {Ticks}\n\t\t */\n\t\tTicks : \"ticks\",\n\t\t/** \n\t\t * Normal values are within the range [0, 1].\n\t\t * @typedef {NormalRange}\n\t\t */\n\t\tNormalRange : \"normalRange\",\n\t\t/** \n\t\t * AudioRange values are between [-1, 1].\n\t\t * @typedef {AudioRange}\n\t\t */\n\t\tAudioRange : \"audioRange\",\n\t\t/** \n\t\t * Decibels are a logarithmic unit of measurement which is useful for volume\n\t\t * because of the logarithmic way that we perceive loudness. 0 decibels \n\t\t * means no change in volume. -10db is approximately half as loud and 10db \n\t\t * is twice is loud. \n\t\t * @typedef {Decibels}\n\t\t */\n\t\tDecibels : \"db\",\n\t\t/** \n\t\t * Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up.\n\t\t * @typedef {Interval}\n\t\t */\n\t\tInterval : \"interval\",\n\t\t/** \n\t\t * Beats per minute. \n\t\t * @typedef {BPM}\n\t\t */\n\t\tBPM : \"bpm\",\n\t\t/** \n\t\t * The value must be greater than or equal to 0.\n\t\t * @typedef {Positive}\n\t\t */\n\t\tPositive : \"positive\",\n\t\t/** \n\t\t * A cent is a hundredth of a semitone. \n\t\t * @typedef {Cents}\n\t\t */\n\t\tCents : \"cents\",\n\t\t/** \n\t\t * Angle between 0 and 360. \n\t\t * @typedef {Degrees}\n\t\t */\n\t\tDegrees : \"degrees\",\n\t\t/** \n\t\t * A number representing a midi note.\n\t\t * @typedef {MIDI}\n\t\t */\n\t\tMIDI : \"midi\",\n\t\t/** \n\t\t * A colon-separated representation of time in the form of\n\t\t * Bars:Beats:Sixteenths. \n\t\t * @typedef {BarsBeatsSixteenths}\n\t\t */\n\t\tBarsBeatsSixteenths : \"barsBeatsSixteenths\",\n\t\t/** \n\t\t * Sampling is the reduction of a continuous signal to a discrete signal.\n\t\t * Audio is typically sampled 44100 times per second. \n\t\t * @typedef {Samples}\n\t\t */\n\t\tSamples : \"samples\",\n\t\t/** \n\t\t * Hertz are a frequency representation defined as one cycle per second.\n\t\t * @typedef {Hertz}\n\t\t */\n\t\tHertz : \"hertz\",\n\t\t/** \n\t\t * A frequency represented by a letter name, \n\t\t * accidental and octave. This system is known as\n\t\t * [Scientific Pitch Notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation).\n\t\t * @typedef {Note}\n\t\t */\n\t\tNote : \"note\",\n\t\t/** \n\t\t * One millisecond is a thousandth of a second. \n\t\t * @typedef {Milliseconds}\n\t\t */\n\t\tMilliseconds : \"milliseconds\",\n\t\t/** \n\t\t * Seconds are the time unit of the AudioContext. In the end, \n\t\t * all values need to be evaluated to seconds. \n\t\t * @typedef {Seconds}\n\t\t */\n\t\tSeconds : \"seconds\",\n\t\t/** \n\t\t * A string representing a duration relative to a measure. \n\t\t *
    \n\t\t * \t
  • \"4n\" = quarter note
  • \n\t\t * \t
  • \"2m\" = two measures
  • \n\t\t * \t
  • \"8t\" = eighth-note triplet
  • \n\t\t *
\n\t\t * @typedef {Notation}\n\t\t */\n\t\tNotation : \"notation\",\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// AUGMENT TONE's PROTOTYPE\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Convert Time into seconds.\n\t * \n\t * Unlike the method which it overrides, this takes into account \n\t * transporttime and musical notation.\n\t *\n\t * Time : 1.40\n\t * Notation: 4n|1m|2t\n\t * Now Relative: +3n\n\t * Math: 3n+16n or even complicated expressions ((3n*2)/6 + 1)\n\t *\n\t * @param {Time} time \n\t * @return {Seconds} \n\t */\n\tTone.prototype.toSeconds = function(time){\n\t\tif (this.isNumber(time)){\n\t\t\treturn time;\n\t\t} else if (this.isUndef(time)){\n\t\t\treturn this.now();\t\t\t\n\t\t} else if (this.isString(time)){\n\t\t\treturn (new Tone.Time(time)).toSeconds();\n\t\t} else if (time instanceof Tone.TimeBase){\n\t\t\treturn time.toSeconds();\n\t\t}\n\t};\n\n\t/**\n\t * Convert a frequency representation into a number.\n\t * @param {Frequency} freq \n\t * @return {Hertz} the frequency in hertz\n\t */\n\tTone.prototype.toFrequency = function(freq){\n\t\tif (this.isNumber(freq)){\n\t\t\treturn freq;\n\t\t} else if (this.isString(freq) || this.isUndef(freq)){\n\t\t\treturn (new Tone.Frequency(freq)).valueOf();\n\t\t} else if (freq instanceof Tone.TimeBase){\n\t\t\treturn freq.toFrequency();\n\t\t}\n\t};\n\n\t/**\n\t * Convert a time representation into ticks.\n\t * @param {Time} time\n\t * @return {Ticks} the time in ticks\n\t */\n\tTone.prototype.toTicks = function(time){\n\t\tif (this.isNumber(time) || this.isString(time)){\n\t\t\treturn (new Tone.TransportTime(time)).toTicks();\n\t\t} else if (this.isUndef(time)){\n\t\t\treturn Tone.Transport.ticks;\t\t\t\n\t\t} else if (time instanceof Tone.TimeBase){\n\t\t\treturn time.toTicks();\n\t\t}\n\t};\n\n\treturn Tone;\n});","define([\"Tone/core/Tone\", \"Tone/core/Param\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * createGain shim\n\t * @private\n\t */\n\tif (window.GainNode && !AudioContext.prototype.createGain){\n\t\tAudioContext.prototype.createGain = AudioContext.prototype.createGainNode;\n\t}\n\n\t/**\n\t * @class A thin wrapper around the Native Web Audio GainNode.\n\t * The GainNode is a basic building block of the Web Audio\n\t * API and is useful for routing audio and adjusting gains. \n\t * @extends {Tone}\n\t * @param {Number=} gain The initial gain of the GainNode\n\t * @param {Tone.Type=} units The units of the gain parameter. \n\t */\n\tTone.Gain = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"gain\", \"units\"], Tone.Gain.defaults);\n\n\t\t/**\n\t\t * The GainNode\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis.input = this.output = this._gainNode = this.context.createGain();\n\n\t\t/**\n\t\t * The gain parameter of the gain node.\n\t\t * @type {Tone.Param}\n\t\t * @signal\n\t\t */\n\t\tthis.gain = new Tone.Param({\n\t\t\t\"param\" : this._gainNode.gain, \n\t\t\t\"units\" : options.units,\n\t\t\t\"value\" : options.gain,\n\t\t\t\"convert\" : options.convert\n\t\t});\n\t\tthis._readOnly(\"gain\");\n\t};\n\n\tTone.extend(Tone.Gain);\n\n\t/**\n\t * The defaults\n\t * @const\n\t * @type {Object}\n\t */\n\tTone.Gain.defaults = {\n\t\t\"gain\" : 1,\n\t\t\"convert\" : true,\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.Gain} this\n\t */\n\tTone.Gain.prototype.dispose = function(){\n\t\tTone.Param.prototype.dispose.call(this);\n\t\tthis._gainNode.disconnect();\n\t\tthis._gainNode = null;\n\t\tthis._writable(\"gain\");\n\t\tthis.gain.dispose();\n\t\tthis.gain = null;\n\t};\n\n\t//STATIC///////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Create input and outputs for this object.\n\t * @param {Number} input The number of inputs\n\t * @param {Number=} outputs The number of outputs\n\t * @return {Tone} this\n\t * @internal\n\t */\n\tTone.prototype.createInsOuts = function(inputs, outputs){\n\n\t\tif (inputs === 1){\n\t\t\tthis.input = new Tone.Gain();\n\t\t} else if (inputs > 1){\n\t\t\tthis.input = new Array(inputs);\n\t\t}\n\n\t\tif (outputs === 1){\n\t\t\tthis.output = new Tone.Gain();\n\t\t} else if (outputs > 1){\n\t\t\tthis.output = new Array(inputs);\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\n\treturn Tone.Gain;\n});","define([\"Tone/core/Tone\", \"Tone/signal/TimelineSignal\", \"Tone/core/TimelineState\", \n\t\"Tone/core/Emitter\", \"Tone/core/Context\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A sample accurate clock which provides a callback at the given rate. \n\t * While the callback is not sample-accurate (it is still susceptible to\n\t * loose JS timing), the time passed in as the argument to the callback\n\t * is precise. For most applications, it is better to use Tone.Transport\n\t * instead of the Clock by itself since you can synchronize multiple callbacks.\n\t *\n\t * \t@constructor\n\t * @extends {Tone.Emitter}\n\t * \t@param {function} callback The callback to be invoked with the time of the audio event\n\t * \t@param {Frequency} frequency The rate of the callback\n\t * \t@example\n\t * //the callback will be invoked approximately once a second\n\t * //and will print the time exactly once a second apart.\n\t * var clock = new Tone.Clock(function(time){\n\t * \tconsole.log(time);\n\t * }, 1);\n\t */\n\tTone.Clock = function(){\n\n\t\tTone.Emitter.call(this);\n\n\t\tvar options = this.optionsObject(arguments, [\"callback\", \"frequency\"], Tone.Clock.defaults);\n\n\t\t/**\n\t\t * The callback function to invoke at the scheduled tick.\n\t\t * @type {Function}\n\t\t */\n\t\tthis.callback = options.callback;\n\n\t\t/**\n\t\t * The next time the callback is scheduled.\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._nextTick = 0;\n\n\t\t/**\n\t\t * The last state of the clock.\n\t\t * @type {State}\n\t\t * @private\n\t\t */\n\t\tthis._lastState = Tone.State.Stopped;\n\n\t\t/**\n\t\t * The rate the callback function should be invoked. \n\t\t * @type {BPM}\n\t\t * @signal\n\t\t */\n\t\tthis.frequency = new Tone.TimelineSignal(options.frequency, Tone.Type.Frequency);\n\t\tthis._readOnly(\"frequency\");\n\n\t\t/**\n\t\t * The number of times the callback was invoked. Starts counting at 0\n\t\t * and increments after the callback was invoked. \n\t\t * @type {Ticks}\n\t\t * @readOnly\n\t\t */\n\t\tthis.ticks = 0;\n\n\t\t/**\n\t\t * The state timeline\n\t\t * @type {Tone.TimelineState}\n\t\t * @private\n\t\t */\n\t\tthis._state = new Tone.TimelineState(Tone.State.Stopped);\n\n\t\t/**\n\t\t * The loop function bound to its context. \n\t\t * This is necessary to remove the event in the end.\n\t\t * @type {Function}\n\t\t * @private\n\t\t */\n\t\tthis._boundLoop = this._loop.bind(this);\n\n\t\t//bind a callback to the worker thread\n \tthis.context.on(\"tick\", this._boundLoop);\n\t};\n\n\tTone.extend(Tone.Clock, Tone.Emitter);\n\n\t/**\n\t * The defaults\n\t * @const\n\t * @type {Object}\n\t */\n\tTone.Clock.defaults = {\n\t\t\"callback\" : Tone.noOp,\n\t\t\"frequency\" : 1,\n\t\t\"lookAhead\" : \"auto\",\n\t};\n\n\t/**\n\t * Returns the playback state of the source, either \"started\", \"stopped\" or \"paused\".\n\t * @type {Tone.State}\n\t * @readOnly\n\t * @memberOf Tone.Clock#\n\t * @name state\n\t */\n\tObject.defineProperty(Tone.Clock.prototype, \"state\", {\n\t\tget : function(){\n\t\t\treturn this._state.getValueAtTime(this.now());\n\t\t}\n\t});\n\n\t/**\n\t * Start the clock at the given time. Optionally pass in an offset\n\t * of where to start the tick counter from.\n\t * @param {Time} time The time the clock should start\n\t * @param {Ticks=} offset Where the tick counter starts counting from.\n\t * @return {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.start = function(time, offset){\n\t\ttime = this.toSeconds(time);\n\t\tif (this._state.getValueAtTime(time) !== Tone.State.Started){\n\t\t\tthis._state.add({\n\t\t\t\t\"state\" : Tone.State.Started, \n\t\t\t\t\"time\" : time,\n\t\t\t\t\"offset\" : offset\n\t\t\t});\n\t\t}\n\t\treturn this;\t\n\t};\n\n\t/**\n\t * Stop the clock. Stopping the clock resets the tick counter to 0.\n\t * @param {Time} [time=now] The time when the clock should stop.\n\t * @returns {Tone.Clock} this\n\t * @example\n\t * clock.stop();\n\t */\n\tTone.Clock.prototype.stop = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tthis._state.cancel(time);\n\t\tthis._state.setStateAtTime(Tone.State.Stopped, time);\n\t\treturn this;\t\n\t};\n\n\n\t/**\n\t * Pause the clock. Pausing does not reset the tick counter.\n\t * @param {Time} [time=now] The time when the clock should stop.\n\t * @returns {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.pause = function(time){\n\t\ttime = this.toSeconds(time);\n\t\tif (this._state.getValueAtTime(time) === Tone.State.Started){\n\t\t\tthis._state.setStateAtTime(Tone.State.Paused, time);\n\t\t}\n\t\treturn this;\t\n\t};\n\n\t/**\n\t * The scheduling loop.\n\t * @param {Number} time The current page time starting from 0\n\t * when the page was loaded.\n\t * @private\n\t */\n\tTone.Clock.prototype._loop = function(){\n\t\t//get the frequency value to compute the value of the next loop\n\t\tvar now = this.now();\n\t\t//if it's started\n\t\tvar lookAhead = this.context.lookAhead;\n\t\tvar updateInterval = this.context.updateInterval;\n\t\tvar lagCompensation = this.context.lag * 2;\n\t\tvar loopInterval = now + lookAhead + updateInterval + lagCompensation;\n\t\twhile (loopInterval > this._nextTick && this._state){\n\t\t\tvar currentState = this._state.getValueAtTime(this._nextTick);\n\t\t\tif (currentState !== this._lastState){\n\t\t\t\tthis._lastState = currentState;\n\t\t\t\tvar event = this._state.get(this._nextTick);\n\t\t\t\t// emit an event\n\t\t\t\tif (currentState === Tone.State.Started){\n\t\t\t\t\t//correct the time\n\t\t\t\t\tthis._nextTick = event.time;\n\t\t\t\t\tif (!this.isUndef(event.offset)){\n\t\t\t\t\t\tthis.ticks = event.offset;\n\t\t\t\t\t}\n\t\t\t\t\tthis.emit(\"start\", event.time, this.ticks);\n\t\t\t\t} else if (currentState === Tone.State.Stopped){\n\t\t\t\t\tthis.ticks = 0;\n\n\t\t\t\t\tthis.emit(\"stop\", event.time);\n\t\t\t\t} else if (currentState === Tone.State.Paused){\n\t\t\t\t\tthis.emit(\"pause\", event.time);\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar tickTime = this._nextTick;\n\t\t\tif (this.frequency){\n\t\t\t\tthis._nextTick += 1 / this.frequency.getValueAtTime(this._nextTick);\n\t\t\t\tif (currentState === Tone.State.Started){\n\t\t\t\t\tthis.callback(tickTime);\n\t\t\t\t\tthis.ticks++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Returns the scheduled state at the given time.\n\t * @param {Time} time The time to query.\n\t * @return {String} The name of the state input in setStateAtTime.\n\t * @example\n\t * clock.start(\"+0.1\");\n\t * clock.getStateAtTime(\"+0.1\"); //returns \"started\"\n\t */\n\tTone.Clock.prototype.getStateAtTime = function(time){\n\t\ttime = this.toSeconds(time);\n\t\treturn this._state.getValueAtTime(time);\n\t};\n\n\t/**\n\t * Clean up\n\t * @returns {Tone.Clock} this\n\t */\n\tTone.Clock.prototype.dispose = function(){\n\t\tTone.Emitter.prototype.dispose.call(this);\n\t\tthis.context.off(\"tick\", this._boundLoop);\n\t\tthis._writable(\"frequency\");\n\t\tthis.frequency.dispose();\n\t\tthis.frequency = null;\n\t\tthis._boundLoop = null;\n\t\tthis._nextTick = Infinity;\n\t\tthis.callback = null;\n\t\tthis._state.dispose();\n\t\tthis._state = null;\n\t};\n\n\treturn Tone.Clock;\n});","define([\"Tone/core/Tone\", \"Tone/core/Emitter\"], function (Tone) {\n\n\t/**\n\t * shim\n\t * @private\n\t */\n\tif (!window.hasOwnProperty(\"AudioContext\") && window.hasOwnProperty(\"webkitAudioContext\")){\n\t\twindow.AudioContext = window.webkitAudioContext;\n\t}\n\n\t/**\n\t * @class Wrapper around the native AudioContext.\n\t * @extends {Tone.Emitter}\n\t * @param {AudioContext=} context optionally pass in a context\n\t */\n\tTone.Context = function(context){\n\n\t\tTone.Emitter.call(this);\n\n\t\tif (!context){\n\t\t\tcontext = new window.AudioContext();\n\t\t}\n\t\tthis._context = context;\n\t\t// extend all of the methods\n\t\tfor (var prop in this._context){\n\t\t\tthis._defineProperty(this._context, prop);\n\t\t}\n\n\t\t///////////////////////////////////////////////////////////////////////\n\t\t// WORKER\n\t\t///////////////////////////////////////////////////////////////////////\n\n\t\t/**\n\t\t * The default latency hint\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t\tthis._latencyHint = \"interactive\";\n\n\t\t/**\n\t\t * The amount of time events are scheduled\n\t\t * into the future\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._lookAhead = 0.1;\n\n\t\t/**\n\t\t * How often the update look runs\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._updateInterval = this._lookAhead/3;\n\n\t\t/**\n\t\t * A reference to the actual computed update interval\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._computedUpdateInterval = 0;\n\n\t\t/**\n\t\t * The web worker which is used to update Tone.Clock\n\t\t * @private\n\t\t * @type {WebWorker}\n\t\t */\n\t\tthis._worker = this._createWorker();\n\n\t\t/**\n\t\t * An object containing all of the constants AudioBufferSourceNodes\n\t\t * @type {Object}\n\t\t * @private\n\t\t */\n\t\tthis._constants = {};\n\n\t};\n\n\tTone.extend(Tone.Context, Tone.Emitter);\n\tTone.Emitter.mixin(Tone.Context);\n\n\t/**\n\t * Define a property on this Tone.Context. \n\t * This is used to extend the native AudioContext\n\t * @param {AudioContext} context\n\t * @param {String} prop \n\t * @private\n\t */\n\tTone.Context.prototype._defineProperty = function(context, prop){\n\t\tif (this.isUndef(this[prop])){\n\t\t\tObject.defineProperty(this, prop, {\n\t\t\t\tget : function(){\n\t\t\t\t\tif (typeof context[prop] === \"function\"){\n\t\t\t\t\t\treturn context[prop].bind(context);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn context[prop];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tset : function(val){\n\t\t\t\t\tcontext[prop] = val;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\t/**\n\t * The current audio context time\n\t * @return {Number}\n\t */\n\tTone.Context.prototype.now = function(){\n\t\treturn this._context.currentTime;\n\t};\n\n\t/**\n\t * Generate a web worker\n\t * @return {WebWorker}\n\t * @private\n\t */\n\tTone.Context.prototype._createWorker = function(){\n\t\t\n\t\t//URL Shim\n\t\twindow.URL = window.URL || window.webkitURL;\n\n\t\tvar blob = new Blob([\n\t\t\t//the initial timeout time\n\t\t\t\"var timeoutTime = \"+(this._updateInterval * 1000).toFixed(1)+\";\" +\n\t\t\t//onmessage callback\n\t\t\t\"self.onmessage = function(msg){\" +\n\t\t\t\"\ttimeoutTime = parseInt(msg.data);\" + \n\t\t\t\"};\" + \n\t\t\t//the tick function which posts a message\n\t\t\t//and schedules a new tick\n\t\t\t\"function tick(){\" +\n\t\t\t\"\tsetTimeout(tick, timeoutTime);\" +\n\t\t\t\"\tself.postMessage('tick');\" +\n\t\t\t\"}\" +\n\t\t\t//call tick initially\n\t\t\t\"tick();\"\n\t\t]);\n\t\tvar blobUrl = URL.createObjectURL(blob);\n\t\tvar worker = new Worker(blobUrl);\n\n\t\tworker.addEventListener(\"message\", function(){\n\t\t\t// tick the clock\n\t\t\tthis.emit(\"tick\");\n\t\t}.bind(this));\n\n\t\t//lag compensation\n\t\tworker.addEventListener(\"message\", function(){\n\t\t\tvar now = this.now();\n\t\t\tif (this.isNumber(this._lastUpdate)){\n\t\t\t\tvar diff = now - this._lastUpdate;\n\t\t\t\tthis._computedUpdateInterval = Math.max(diff, this._computedUpdateInterval * 0.97);\n\t\t\t}\n\t\t\tthis._lastUpdate = now;\n\t\t}.bind(this));\n\n\t\treturn worker;\n\t};\n\n\t/**\n\t * Generate a looped buffer at some constant value.\n\t * @param {Number} val\n\t * @return {BufferSourceNode}\n\t */\n\tTone.Context.prototype.getConstant = function(val){\n\t\tif (this._constants[val]){\n\t\t\treturn this._constants[val];\n\t\t} else {\n\t\t\tvar buffer = this._context.createBuffer(1, 128, this._context.sampleRate);\n\t\t\tvar arr = buffer.getChannelData(0);\n\t\t\tfor (var i = 0; i < arr.length; i++){\n\t\t\t\tarr[i] = val;\n\t\t\t}\n\t\t\tvar constant = this._context.createBufferSource();\n\t\t\tconstant.channelCount = 1;\n\t\t\tconstant.channelCountMode = \"explicit\";\n\t\t\tconstant.buffer = buffer;\n\t\t\tconstant.loop = true;\n\t\t\tconstant.start(0);\n\t\t\tthis._constants[val] = constant;\n\t\t\treturn constant;\n\t\t}\n\t};\n\n\t/**\n\t * This is the time that the clock is falling behind\n\t * the scheduled update interval. The Context automatically\n\t * adjusts for the lag and schedules further in advance.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name lag\n\t * @static\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"lag\", {\n\t\tget : function(){\n\t\t\tvar diff = this._computedUpdateInterval - this._updateInterval;\n\t\t\tdiff = Math.max(diff, 0);\n\t\t\treturn diff;\n\t\t}\n\t});\n\n\t/**\n\t * The amount of time in advance that events are scheduled.\n\t * The lookAhead will adjust slightly in response to the \n\t * measured update time to try to avoid clicks.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name lookAhead\n\t * @static\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"lookAhead\", {\n\t\tget : function(){\n\t\t\treturn this._lookAhead;\n\t\t},\n\t\tset : function(lA){\n\t\t\tthis._lookAhead = lA;\n\t\t}\n\t});\n\n\t/**\n\t * How often the Web Worker callback is invoked.\n\t * This number corresponds to how responsive the scheduling\n\t * can be. Context.updateInterval + Context.lookAhead gives you the\n\t * total latency between scheduling an event and hearing it.\n\t * @type {Number}\n\t * @memberOf Tone.Context\n\t * @name updateInterval\n\t * @static\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"updateInterval\", {\n\t\tget : function(){\n\t\t\treturn this._updateInterval;\n\t\t},\n\t\tset : function(interval){\n\t\t\tthis._updateInterval = Math.max(interval, Tone.prototype.blockTime);\n\t\t\tthis._worker.postMessage(Math.max(interval * 1000, 1));\n\t\t}\n\t});\n\n\t/**\n\t * The type of playback, which affects tradeoffs between audio \n\t * output latency and responsiveness. \n\t * \n\t * In addition to setting the value in seconds, the latencyHint also\n\t * accepts the strings \"interactive\" (prioritizes low latency), \n\t * \"playback\" (prioritizes sustained playback), \"balanced\" (balances\n\t * latency and performance), and \"fastest\" (lowest latency, might glitch more often). \n\t * @type {String|Seconds}\n\t * @memberOf Tone.Context#\n\t * @name latencyHint\n\t * @static\n\t * @example\n\t * //set the lookAhead to 0.3 seconds\n\t * Tone.context.latencyHint = 0.3;\n\t */\n\tObject.defineProperty(Tone.Context.prototype, \"latencyHint\", {\n\t\tget : function(){\n\t\t\treturn this._latencyHint;\n\t\t},\n\t\tset : function(hint){\n\t\t\tvar lookAhead = hint;\n\t\t\tthis._latencyHint = hint;\n\t\t\tif (this.isString(hint)){\n\t\t\t\tswitch(hint){\n\t\t\t\t\tcase \"interactive\" :\n\t\t\t\t\t\tlookAhead = 0.1;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"playback\" :\n\t\t\t\t\t\tlookAhead = 0.8;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"balanced\" :\n\t\t\t\t\t\tlookAhead = 0.25;\n\t\t\t\t\t\tthis._context.latencyHint = hint;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fastest\" :\n\t\t\t\t\t\tlookAhead = 0.01;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.lookAhead = lookAhead;\n\t\t\tthis.updateInterval = lookAhead/3;\n\t\t}\n\t});\n\n\t/**\n\t * Shim all connect/disconnect and some deprecated methods which are still in\n\t * some older implementations.\n\t * @private\n\t */\n\tfunction shimConnect(){\n\n\t\tvar nativeConnect = AudioNode.prototype.connect;\n\t\tvar nativeDisconnect = AudioNode.prototype.disconnect;\n\n\t\t//replace the old connect method\n\t\tfunction toneConnect(B, outNum, inNum){\n\t\t\tif (B.input){\n\t\t\t\tif (Array.isArray(B.input)){\n\t\t\t\t\tif (Tone.prototype.isUndef(inNum)){\n\t\t\t\t\t\tinNum = 0;\n\t\t\t\t\t}\n\t\t\t\t\tthis.connect(B.input[inNum]);\n\t\t\t\t} else {\n\t\t\t\t\tthis.connect(B.input, outNum, inNum);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tif (B instanceof AudioNode){\n\t\t\t\t\t\tnativeConnect.call(this, B, outNum, inNum);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnativeConnect.call(this, B, outNum);\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new Error(\"error connecting to node: \"+B+\"\\n\"+e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//replace the old disconnect method\n\t\tfunction toneDisconnect(B, outNum, inNum){\n\t\t\tif (B && B.input && Array.isArray(B.input)){\n\t\t\t\tif (Tone.prototype.isUndef(inNum)){\n\t\t\t\t\tinNum = 0;\n\t\t\t\t}\n\t\t\t\tthis.disconnect(B.input[inNum], outNum, inNum);\n\t\t\t} else if (B && B.input){\n\t\t\t\tthis.disconnect(B.input, outNum, inNum);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tnativeDisconnect.apply(this, arguments);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tthrow new Error(\"error disconnecting node: \"+B+\"\\n\"+e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (AudioNode.prototype.connect !== toneConnect){\n\t\t\tAudioNode.prototype.connect = toneConnect;\n\t\t\tAudioNode.prototype.disconnect = toneDisconnect;\n\t\t}\n\t}\n\n\t// set the audio context initially\n\tif (Tone.supported){\n\t\tshimConnect();\n\t\tTone.context = new Tone.Context();\n\t} else {\n\t\tconsole.warn(\"This browser does not support Tone.js\");\n\t}\n\n\treturn Tone.Context;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Negate\", \"Tone/signal/Signal\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Subtract the signal connected to input[1] from the signal connected \n\t * to input[0]. If an argument is provided in the constructor, the \n\t * signals .value will be subtracted from the incoming signal.\n\t *\n\t * @extends {Tone.Signal}\n\t * @constructor\n\t * @param {number=} value The value to subtract from the incoming signal. If the value\n\t * is omitted, it will subtract the second signal from the first.\n\t * @example\n\t * var sub = new Tone.Subtract(1);\n\t * var sig = new Tone.Signal(4).connect(sub);\n\t * //the output of sub is 3. \n\t * @example\n\t * var sub = new Tone.Subtract();\n\t * var sigA = new Tone.Signal(10);\n\t * var sigB = new Tone.Signal(2.5);\n\t * sigA.connect(sub, 0, 0);\n\t * sigB.connect(sub, 0, 1);\n\t * //output of sub is 7.5\n\t */\n\tTone.Subtract = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\n\t\t/**\n\t\t * the summing node\n\t\t * @type {GainNode}\n\t\t * @private\n\t\t */\n\t\tthis._sum = this.input[0] = this.output = new Tone.Gain();\n\n\t\t/**\n\t\t * negate the input of the second input before connecting it\n\t\t * to the summing node.\n\t\t * @type {Tone.Negate}\n\t\t * @private\n\t\t */\n\t\tthis._neg = new Tone.Negate();\n\n\t\t/**\n\t\t * the node where the value is set\n\t\t * @private\n\t\t * @type {Tone.Signal}\n\t\t */\n\t\tthis._param = this.input[1] = new Tone.Signal(value);\n\n\t\tthis._param.chain(this._neg, this._sum);\n\t};\n\n\tTone.extend(Tone.Subtract, Tone.Signal);\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.SignalBase} this\n\t */\n\tTone.Subtract.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._neg.dispose();\n\t\tthis._neg = null;\n\t\tthis._sum.disconnect();\n\t\tthis._sum = null;\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Subtract;\n});","define([\"Tone/core/Tone\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Emitter gives classes which extend it\n\t * the ability to listen for and emit events. \n\t * Inspiration and reference from Jerome Etienne's [MicroEvent](https://github.com/jeromeetienne/microevent.js).\n\t * MIT (c) 2011 Jerome Etienne.\n\t * \n\t * @extends {Tone}\n\t */\n\tTone.Emitter = function(){\n\t\t/**\n\t\t * Contains all of the events.\n\t\t * @private\n\t\t * @type {Object}\n\t\t */\n\t\tthis._events = {};\n\t};\n\n\tTone.extend(Tone.Emitter);\n\n\t/**\n\t * Bind a callback to a specific event.\n\t * @param {String} event The name of the event to listen for.\n\t * @param {Function} callback The callback to invoke when the\n\t * event is emitted\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.on = function(event, callback){\n\t\t//split the event\n\t\tvar events = event.split(/\\W+/);\n\t\tfor (var i = 0; i < events.length; i++){\n\t\t\tvar eventName = events[i];\n\t\t\tif (!this._events.hasOwnProperty(eventName)){\n\t\t\t\tthis._events[eventName] = [];\n\t\t\t}\n\t\t\tthis._events[eventName].push(callback);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Remove the event listener.\n\t * @param {String} event The event to stop listening to.\n\t * @param {Function=} callback The callback which was bound to \n\t * the event with Tone.Emitter.on.\n\t * If no callback is given, all callbacks\n\t * events are removed.\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.off = function(event, callback){\n\t\tvar events = event.split(/\\W+/);\n\t\tfor (var ev = 0; ev < events.length; ev++){\n\t\t\tevent = events[ev];\n\t\t\tif (this._events.hasOwnProperty(event)){\n\t\t\t\tif (Tone.prototype.isUndef(callback)){\n\t\t\t\t\tthis._events[event] = [];\n\t\t\t\t} else {\n\t\t\t\t\tvar eventList = this._events[event];\n\t\t\t\t\tfor (var i = 0; i < eventList.length; i++){\n\t\t\t\t\t\tif (eventList[i] === callback){\n\t\t\t\t\t\t\teventList.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Invoke all of the callbacks bound to the event\n\t * with any arguments passed in. \n\t * @param {String} event The name of the event.\n\t * @param {*...} args The arguments to pass to the functions listening.\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.emit = function(event){\n\t\tif (this._events){\n\t\t\tvar args = Array.apply(null, arguments).slice(1);\n\t\t\tif (this._events.hasOwnProperty(event)){\n\t\t\t\tvar eventList = this._events[event];\n\t\t\t\tfor (var i = 0, len = eventList.length; i < len; i++){\n\t\t\t\t\teventList[i].apply(this, args);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Add Emitter functions (on/off/emit) to the object\n\t * @param {Object|Function} object The object or class to extend.\n\t */\n\tTone.Emitter.mixin = function(object){\n\t\tvar functions = [\"on\", \"off\", \"emit\"];\n\t\tobject._events = {};\n\t\tfor (var i = 0; i < functions.length; i++){\n\t\t\tvar func = functions[i];\n\t\t\tvar emitterFunc = Tone.Emitter.prototype[func];\n\t\t\tobject[func] = emitterFunc;\n\t\t}\n\t};\n\n\t/**\n\t * Clean up\n\t * @return {Tone.Emitter} this\n\t */\n\tTone.Emitter.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._events = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Emitter;\n});","define([\"Tone/core/Tone\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Base class for all Signals. Used Internally. \n\t *\n\t * @constructor\n\t * @extends {Tone}\n\t */\n\tTone.SignalBase = function(){};\n\n\tTone.extend(Tone.SignalBase);\n\n\t/**\n\t * When signals connect to other signals or AudioParams, \n\t * they take over the output value of that signal or AudioParam. \n\t * For all other nodes, the behavior is the same as a default connect. \n\t *\n\t * @override\n\t * @param {AudioParam|AudioNode|Tone.Signal|Tone} node \n\t * @param {number} [outputNumber=0] The output number to connect from.\n\t * @param {number} [inputNumber=0] The input number to connect to.\n\t * @returns {Tone.SignalBase} this\n\t */\n\tTone.SignalBase.prototype.connect = function(node, outputNumber, inputNumber){\n\t\t//zero it out so that the signal can have full control\n\t\tif ((Tone.Signal && Tone.Signal === node.constructor) || \n\t\t\t\t(Tone.Param && Tone.Param === node.constructor) || \n\t\t\t\t(Tone.TimelineSignal && Tone.TimelineSignal === node.constructor)){\n\t\t\t//cancel changes\n\t\t\tnode._param.cancelScheduledValues(0);\n\t\t\t//reset the value\n\t\t\tnode._param.value = 0;\n\t\t\t//mark the value as overridden\n\t\t\tnode.overridden = true;\n\t\t} else if (node instanceof AudioParam){\n\t\t\tnode.cancelScheduledValues(0);\n\t\t\tnode.value = 0;\n\t\t} \n\t\tTone.prototype.connect.call(this, node, outputNumber, inputNumber);\n\t\treturn this;\n\t};\n\n\treturn Tone.SignalBase;\n});","define([\"Tone/core/Tone\", \"Tone/type/TimeBase\"], function (Tone) {\n\n\t/**\n\t * @class Tone.Time is a primitive type for encoding Time values. \n\t * Eventually all time values are evaluated to seconds\n\t * using the `eval` method. Tone.Time can be constructed\n\t * with or without the `new` keyword. Tone.Time can be passed\n\t * into the parameter of any method which takes time as an argument. \n\t * @constructor\n\t * @extends {Tone.TimeBase}\n\t * @param {String|Number} val The time value.\n\t * @param {String=} units The units of the value.\n\t * @example\n\t * var t = Tone.Time(\"4n\");//encodes a quarter note\n\t * t.mult(4); // multiply that value by 4\n\t * t.toNotation(); //returns \"1m\"\n\t */\n\tTone.Time = function(val, units){\n\t\tif (this instanceof Tone.Time){\n\n\t\t\t/**\n\t\t\t * If the current clock time should\n\t\t\t * be added to the output\n\t\t\t * @type {Boolean}\n\t\t\t * @private\n\t\t\t */\n\t\t\tthis._plusNow = false;\n\t\t\t\n\t\t\tTone.TimeBase.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.Time(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.Time, Tone.TimeBase);\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.Time.prototype._unaryExpressions = Object.create(Tone.TimeBase.prototype._unaryExpressions);\n\n\t/*\n\t * Adds an additional unary expression\n\t * which quantizes values to the next subdivision\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Time.prototype._unaryExpressions.quantize = {\n\t\tregexp : /^@/,\n\t\tmethod : function(rh){\n\t\t\treturn Tone.Transport.nextSubdivision(rh());\n\t\t}\n\t};\n\n\t/*\n\t * Adds an additional unary expression\n\t * which adds the current clock time.\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Time.prototype._unaryExpressions.now = {\n\t\tregexp : /^\\+/,\n\t\tmethod : function(lh){\n\t\t\tthis._plusNow = true;\n\t\t\treturn lh();\n\t\t}\n\t};\n\n\t/**\n\t * Quantize the time by the given subdivision. Optionally add a\n\t * percentage which will move the time value towards the ideal\n\t * quantized value by that percentage. \n\t * @param {Number|Time} val The subdivision to quantize to\n\t * @param {NormalRange} [percent=1] Move the time value\n\t * towards the quantized value by\n\t * a percentage.\n\t * @return {Tone.Time} this\n\t * @example\n\t * Tone.Time(21).quantize(2) //returns 22\n\t * Tone.Time(0.6).quantize(\"4n\", 0.5) //returns 0.55\n\t */\n\tTone.Time.prototype.quantize = function(subdiv, percent){\n\t\tpercent = this.defaultArg(percent, 1);\n\t\tthis._expr = function(expr, subdivision, percent){\n\t\t\texpr = expr();\n\t\t\tsubdivision = subdivision.toSeconds();\n\t\t\tvar multiple = Math.round(expr / subdivision);\n\t\t\tvar ideal = multiple * subdivision;\n\t\t\tvar diff = ideal - expr;\n\t\t\treturn expr + diff * percent;\n\t\t}.bind(this, this._expr, new this.constructor(subdiv), percent);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Adds the clock time to the time expression at the \n\t * moment of evaluation. \n\t * @return {Tone.Time} this\n\t */\n\tTone.Time.prototype.addNow = function(){\n\t\tthis._plusNow = true;\n\t\treturn this;\n\t};\n\n\t/**\n\t * @override\n\t * Override the default value return when no arguments are passed in.\n\t * The default value is 'now'\n\t * @private\n\t */\n\tTone.Time.prototype._defaultExpr = function(){\n\t\tthis._plusNow = true;\n\t\treturn this._noOp;\n\t};\n\n\t/**\n\t * Copies the value of time to this Time\n\t * @param {Tone.Time} time\n\t * @return {Time}\n\t */\n\tTone.Time.prototype.copy = function(time){\n\t\tTone.TimeBase.prototype.copy.call(this, time);\n\t\tthis._plusNow = time._plusNow;\n\t\treturn this;\n\t};\n\n\t//CONVERSIONS//////////////////////////////////////////////////////////////\n\n\t/**\n\t * Convert a Time to Notation. Values will be thresholded to the nearest 128th note. \n\t * @return {Notation} \n\t * @example\n\t * //if the Transport is at 120bpm:\n\t * Tone.Time(2).toNotation();//returns \"1m\"\n\t */\n\tTone.Time.prototype.toNotation = function(){\n\t\tvar time = this.toSeconds();\n\t\tvar testNotations = [\"1m\", \"2n\", \"4n\", \"8n\", \"16n\", \"32n\", \"64n\", \"128n\"];\n\t\tvar retNotation = this._toNotationHelper(time, testNotations);\n\t\t//try the same thing but with tripelets\n\t\tvar testTripletNotations = [\"1m\", \"2n\", \"2t\", \"4n\", \"4t\", \"8n\", \"8t\", \"16n\", \"16t\", \"32n\", \"32t\", \"64n\", \"64t\", \"128n\"];\n\t\tvar retTripletNotation = this._toNotationHelper(time, testTripletNotations);\n\t\t//choose the simpler expression of the two\n\t\tif (retTripletNotation.split(\"+\").length < retNotation.split(\"+\").length){\n\t\t\treturn retTripletNotation;\n\t\t} else {\n\t\t\treturn retNotation;\n\t\t}\n\t};\n\n\t/**\n\t * Helper method for Tone.toNotation\n\t * @param {Number} units \n\t * @param {Array} testNotations\n\t * @return {String}\n\t * @private\n\t */\n\tTone.Time.prototype._toNotationHelper = function(units, testNotations){\n\t\t//the threshold is the last value in the array\n\t\tvar threshold = this._notationToUnits(testNotations[testNotations.length - 1]);\n\t\tvar retNotation = \"\";\n\t\tfor (var i = 0; i < testNotations.length; i++){\n\t\t\tvar notationTime = this._notationToUnits(testNotations[i]);\n\t\t\t//account for floating point errors (i.e. round up if the value is 0.999999)\n\t\t\tvar multiple = units / notationTime;\n\t\t\tvar floatingPointError = 0.000001;\n\t\t\tif (1 - multiple % 1 < floatingPointError){\n\t\t\t\tmultiple += floatingPointError;\n\t\t\t}\n\t\t\tmultiple = Math.floor(multiple);\n\t\t\tif (multiple > 0){\n\t\t\t\tif (multiple === 1){\n\t\t\t\t\tretNotation += testNotations[i];\n\t\t\t\t} else {\n\t\t\t\t\tretNotation += multiple.toString() + \"*\" + testNotations[i];\n\t\t\t\t}\n\t\t\t\tunits -= multiple * notationTime;\n\t\t\t\tif (units < threshold){\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tretNotation += \" + \";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (retNotation === \"\"){\n\t\t\tretNotation = \"0\";\n\t\t}\n\t\treturn retNotation;\n\t};\n\n\t/**\n\t * Convert a notation value to the current units\n\t * @param {Notation} notation \n\t * @return {Number} \n\t * @private\n\t */\n\tTone.Time.prototype._notationToUnits = function(notation){\n\t\tvar primaryExprs = this._primaryExpressions;\n\t\tvar notationExprs = [primaryExprs.n, primaryExprs.t, primaryExprs.m];\n\t\tfor (var i = 0; i < notationExprs.length; i++){\n\t\t\tvar expr = notationExprs[i];\n\t\t\tvar match = notation.match(expr.regexp);\n\t\t\tif (match){\n\t\t\t\treturn expr.method.call(this, match[1]);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Return the time encoded as Bars:Beats:Sixteenths.\n\t * @return {BarsBeatsSixteenths}\n\t */\n\tTone.Time.prototype.toBarsBeatsSixteenths = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.toSeconds() / quarterTime;\n\t\tvar measures = Math.floor(quarters / this._timeSignature());\n\t\tvar sixteenths = (quarters % 1) * 4;\n\t\tquarters = Math.floor(quarters) % this._timeSignature();\n\t\tsixteenths = sixteenths.toString();\n\t\tif (sixteenths.length > 3){\n\t\t\tsixteenths = parseFloat(sixteenths).toFixed(3);\n\t\t}\n\t\tvar progress = [measures, quarters, sixteenths];\n\t\treturn progress.join(\":\");\n\t};\n\n\t/**\n\t * Return the time in ticks.\n\t * @return {Ticks}\n\t */\n\tTone.Time.prototype.toTicks = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.valueOf() / quarterTime;\n\t\treturn Math.floor(quarters * Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Return the time in samples\n\t * @return {Samples} \n\t */\n\tTone.Time.prototype.toSamples = function(){\n\t\treturn this.toSeconds() * this.context.sampleRate;\n\t};\n\n\t/**\n\t * Return the time as a frequency value\n\t * @return {Frequency} \n\t * @example\n\t * Tone.Time(2).toFrequency(); //0.5\n\t */\n\tTone.Time.prototype.toFrequency = function(){\n\t\treturn 1/this.toSeconds();\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.Time.prototype.toSeconds = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the time in milliseconds.\n\t * @return {Milliseconds} \n\t */\n\tTone.Time.prototype.toMilliseconds = function(){\n\t\treturn this.toSeconds() * 1000;\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.Time.prototype.valueOf = function(){\n\t\tvar val = this._expr();\n\t\treturn val + (this._plusNow?this.now():0);\n\t};\n\n\treturn Tone.Time;\n});","define([\"Tone/core/Tone\"], function (Tone) {\n\n\t/**\n\t * @class Tone.TimeBase is a flexible encoding of time\n\t * which can be evaluated to and from a string.\n\t * Parsing code modified from https://code.google.com/p/tapdigit/\n\t * Copyright 2011 2012 Ariya Hidayat, New BSD License\n\t * @extends {Tone}\n\t * @param {Time} val The time value as a number or string\n\t * @param {String=} units Unit values\n\t * @example\n\t * Tone.TimeBase(4, \"n\")\n\t * Tone.TimeBase(2, \"t\")\n\t * Tone.TimeBase(\"2t\").add(\"1m\")\n\t * Tone.TimeBase(\"2t + 1m\");\n\t */\n\tTone.TimeBase = function(val, units){\n\n\t\t//allows it to be constructed with or without 'new'\n\t\tif (this instanceof Tone.TimeBase) {\n\n\t\t\t/**\n\t\t\t * Any expressions parsed from the Time\n\t\t\t * @type {Array}\n\t\t\t * @private\n\t\t\t */\n\t\t\tthis._expr = this._noOp;\n\n\t\t\tif (val instanceof Tone.TimeBase){\n\t\t\t\tthis.copy(val);\n\t\t\t} else if (!this.isUndef(units) || this.isNumber(val)){\n\t\t\t\t//default units\n\t\t\t\tunits = this.defaultArg(units, this._defaultUnits);\n\t\t\t\tvar method = this._primaryExpressions[units].method;\n\t\t\t\tthis._expr = method.bind(this, val);\n\t\t\t} else if (this.isString(val)){\n\t\t\t\tthis.set(val);\n\t\t\t} else if (this.isUndef(val)){\n\t\t\t\t//default expression\n\t\t\t\tthis._expr = this._defaultExpr();\n\t\t\t}\n\t\t} else {\n\n\t\t\treturn new Tone.TimeBase(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.TimeBase);\n\n\t/**\n\t * Repalce the current time value with the value\n\t * given by the expression string.\n\t * @param {String} exprString\n\t * @return {Tone.TimeBase} this\n\t */\n\tTone.TimeBase.prototype.set = function(exprString){\n\t\tthis._expr = this._parseExprString(exprString);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Return a clone of the TimeBase object.\n\t * @return {Tone.TimeBase} The new cloned Tone.TimeBase\n\t */\n\tTone.TimeBase.prototype.clone = function(){\n\t\tvar instance = new this.constructor();\n\t\tinstance.copy(this);\n\t\treturn instance;\n\t};\n\n\t/**\n\t * Copies the value of time to this Time\n\t * @param {Tone.TimeBase} time\n\t * @return {TimeBase}\n\t */\n\tTone.TimeBase.prototype.copy = function(time){\n\t\tvar val = time._expr();\n\t\treturn this.set(val);\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tABSTRACT SYNTAX TREE PARSER\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * All the primary expressions.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._primaryExpressions = {\n\t\t\"n\" : {\n\t\t\tregexp : /^(\\d+)n/i,\n\t\t\tmethod : function(value){\n\t\t\t\tvalue = parseInt(value);\n\t\t\t\tif (value === 1){\n\t\t\t\t\treturn this._beatsToUnits(this._timeSignature());\n\t\t\t\t} else {\n\t\t\t\t\treturn this._beatsToUnits(4 / value);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"t\" : {\n\t\t\tregexp : /^(\\d+)t/i,\n\t\t\tmethod : function(value){\n\t\t\t\tvalue = parseInt(value);\n\t\t\t\treturn this._beatsToUnits(8 / (parseInt(value) * 3));\n\t\t\t}\n\t\t},\n\t\t\"m\" : {\n\t\t\tregexp : /^(\\d+)m/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._beatsToUnits(parseInt(value) * this._timeSignature());\n\t\t\t}\n\t\t},\n\t\t\"i\" : {\n\t\t\tregexp : /^(\\d+)i/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._ticksToUnits(parseInt(value));\n\t\t\t}\n\t\t},\n\t\t\"hz\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?)hz/i,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._frequencyToUnits(parseFloat(value));\n\t\t\t}\n\t\t},\n\t\t\"tr\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t\t\tmethod : function(m, q, s){\n\t\t\t\tvar total = 0;\n\t\t\t\tif (m && m !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(this._timeSignature() * parseFloat(m));\n\t\t\t\t}\n\t\t\t\tif (q && q !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(parseFloat(q));\n\t\t\t\t}\n\t\t\t\tif (s && s !== \"0\"){\n\t\t\t\t\ttotal += this._beatsToUnits(parseFloat(s) / 4);\n\t\t\t\t}\n\t\t\t\treturn total;\n\t\t\t}\n\t\t},\n\t\t\"s\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?s)/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._secondsToUnits(parseFloat(value));\n\t\t\t}\n\t\t},\n\t\t\"samples\" : {\n\t\t\tregexp : /^(\\d+)samples/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn parseInt(value) / this.context.sampleRate;\n\t\t\t}\n\t\t},\n\t\t\"default\" : {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?)/,\n\t\t\tmethod : function(value){\n\t\t\t\treturn this._primaryExpressions[this._defaultUnits].method.call(this, value);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * All the binary expressions that TimeBase can accept.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._binaryExpressions = {\n\t\t\"+\" : {\n\t\t\tregexp : /^\\+/,\n\t\t\tprecedence : 2,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() + rh();\n\t\t\t}\n\t\t},\n\t\t\"-\" : {\n\t\t\tregexp : /^\\-/,\n\t\t\tprecedence : 2,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() - rh();\n\t\t\t}\n\t\t},\n\t\t\"*\" : {\n\t\t\tregexp : /^\\*/,\n\t\t\tprecedence : 1,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() * rh();\n\t\t\t}\n\t\t},\n\t\t\"/\" : {\n\t\t\tregexp : /^\\//,\n\t\t\tprecedence : 1,\n\t\t\tmethod : function(lh, rh){\n\t\t\t\treturn lh() / rh();\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * All the unary expressions.\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._unaryExpressions = {\n\t\t\"neg\" : {\n\t\t\tregexp : /^\\-/,\n\t\t\tmethod : function(lh){\n\t\t\t\treturn -lh();\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Syntactic glue which holds expressions together\n\t * @private\n\t * @type {Object}\n\t */\n\tTone.TimeBase.prototype._syntaxGlue = {\n\t\t\"(\" : {\n\t\t\tregexp : /^\\(/\n\t\t},\n\t\t\")\" : {\n\t\t\tregexp : /^\\)/\n\t\t}\n\t};\n\n\t/**\n\t * tokenize the expression based on the Expressions object\n\t * @param {string} expr \n\t * @return {Object} returns two methods on the tokenized list, next and peek\n\t * @private\n\t */\n\tTone.TimeBase.prototype._tokenize = function(expr){\n\t\tvar position = -1;\n\t\tvar tokens = [];\n\n\t\twhile(expr.length > 0){\n\t\t\texpr = expr.trim();\n\t\t\tvar token = getNextToken(expr, this);\n\t\t\ttokens.push(token);\n\t\t\texpr = expr.substr(token.value.length);\n\t\t}\n\n\t\tfunction getNextToken(expr, context){\n\t\t\tvar expressions = [\"_binaryExpressions\", \"_unaryExpressions\", \"_primaryExpressions\", \"_syntaxGlue\"];\n\t\t\tfor (var i = 0; i < expressions.length; i++){\n\t\t\t\tvar group = context[expressions[i]];\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tvar reg = op.regexp;\n\t\t\t\t\tvar match = expr.match(reg);\n\t\t\t\t\tif (match !== null){\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tmethod : op.method,\n\t\t\t\t\t\t\tprecedence : op.precedence,\n\t\t\t\t\t\t\tregexp : op.regexp,\n\t\t\t\t\t\t\tvalue : match[0],\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.TimeBase: Unexpected token \"+expr);\n\t\t}\n\n\t\treturn {\n\t\t\tnext : function(){\n\t\t\t\treturn tokens[++position];\n\t\t\t},\n\t\t\tpeek : function(){\n\t\t\t\treturn tokens[position + 1];\n\t\t\t}\n\t\t};\n\t};\n\n\t/**\n\t * Given a token, find the value within the groupName\n\t * @param {Object} token\n\t * @param {String} groupName\n\t * @param {Number} precedence\n\t * @private\n\t */\n\tTone.TimeBase.prototype._matchGroup = function(token, group, prec) {\n\t\tvar ret = false;\n\t\tif (!this.isUndef(token)){\n\t\t\tfor (var opName in group){\n\t\t\t\tvar op = group[opName];\n\t\t\t\tif (op.regexp.test(token.value)){\n\t\t\t\t\tif (!this.isUndef(prec)){\n\t\t\t\t\t\tif(op.precedence === prec){\t\n\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn op;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/**\n\t * Match a binary expression given the token and the precedence\n\t * @param {Lexer} lexer\n\t * @param {Number} precedence\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseBinary = function(lexer, precedence){\n\t\tif (this.isUndef(precedence)){\n\t\t\tprecedence = 2;\n\t\t}\n\t\tvar expr;\n\t\tif (precedence < 0){\n\t\t\texpr = this._parseUnary(lexer);\n\t\t} else {\n\t\t\texpr = this._parseBinary(lexer, precedence - 1);\n\t\t}\n\t\tvar token = lexer.peek();\n\t\twhile (token && this._matchGroup(token, this._binaryExpressions, precedence)){\n\t\t\ttoken = lexer.next();\n\t\t\texpr = token.method.bind(this, expr, this._parseBinary(lexer, precedence - 1));\n\t\t\ttoken = lexer.peek();\n\t\t}\n\t\treturn expr;\n\t};\n\n\t/**\n\t * Match a unary expression.\n\t * @param {Lexer} lexer\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseUnary = function(lexer){\n\t\tvar token, expr;\n\t\ttoken = lexer.peek();\n\t\tvar op = this._matchGroup(token, this._unaryExpressions);\n\t\tif (op) {\n\t\t\ttoken = lexer.next();\n\t\t\texpr = this._parseUnary(lexer);\n\t\t\treturn op.method.bind(this, expr);\n\t\t}\n\t\treturn this._parsePrimary(lexer);\n\t};\n\n\t/**\n\t * Match a primary expression (a value).\n\t * @param {Lexer} lexer\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parsePrimary = function(lexer){\n\t\tvar token, expr;\n\t\ttoken = lexer.peek();\n\t\tif (this.isUndef(token)) {\n\t\t\tthrow new SyntaxError(\"Tone.TimeBase: Unexpected end of expression\");\n\t\t}\n\t\tif (this._matchGroup(token, this._primaryExpressions)) {\n\t\t\ttoken = lexer.next();\n\t\t\tvar matching = token.value.match(token.regexp);\n\t\t\treturn token.method.bind(this, matching[1], matching[2], matching[3]);\n\t\t}\n\t\tif (token && token.value === \"(\"){\n\t\t\tlexer.next();\n\t\t\texpr = this._parseBinary(lexer);\n\t\t\ttoken = lexer.next();\n\t\t\tif (!(token && token.value === \")\")) {\n\t\t\t\tthrow new SyntaxError(\"Expected )\");\n\t\t\t}\n\t\t\treturn expr;\n\t\t}\n\t\tthrow new SyntaxError(\"Tone.TimeBase: Cannot process token \" + token.value);\n\t};\n\n\t/**\n\t * Recursively parse the string expression into a syntax tree.\n\t * @param {string} expr \n\t * @return {Function} the bound method to be evaluated later\n\t * @private\n\t */\n\tTone.TimeBase.prototype._parseExprString = function(exprString){\n\t\tif (!this.isString(exprString)){\n\t\t\texprString = exprString.toString();\n\t\t}\n\t\tvar lexer = this._tokenize(exprString);\n\t\tvar tree = this._parseBinary(lexer);\n\t\treturn tree;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tDEFAULTS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * The initial expression value\n\t * @return {Number} The initial value 0\n\t * @private\n\t */\n\tTone.TimeBase.prototype._noOp = function(){\n\t\treturn 0;\n\t};\n\n\t/**\n\t * The default expression value if no arguments are given\n\t * @private\n\t */\n\tTone.TimeBase.prototype._defaultExpr = function(){\n\t\treturn this._noOp;\n\t};\n\n\t/**\n\t * The default units if none are given.\n\t * @private\n\t */\n\tTone.TimeBase.prototype._defaultUnits = \"s\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value of a frequency in the current units\n\t * @param {Frequency} freq\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._frequencyToUnits = function(freq){\n\t\treturn 1/freq;\n\t};\n\n\t/**\n\t * Return the value of the beats in the current units\n\t * @param {Number} beats\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._beatsToUnits = function(beats){\n\t\treturn (60 / Tone.Transport.bpm.value) * beats;\n\t};\n\n\t/**\n\t * Returns the value of a second in the current units\n\t * @param {Seconds} seconds\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._secondsToUnits = function(seconds){\n\t\treturn seconds;\n\t};\n\n\t/**\n\t * Returns the value of a tick in the current time units\n\t * @param {Ticks} ticks\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._ticksToUnits = function(ticks){\n\t\treturn ticks * (this._beatsToUnits(1) / Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Return the time signature.\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.TimeBase.prototype._timeSignature = function(){\n\t\treturn Tone.Transport.timeSignature;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tEXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Push an expression onto the expression list\n\t * @param {Time} val\n\t * @param {String} type\n\t * @param {String} units\n\t * @return {Tone.TimeBase} \n\t * @private\n\t */\n\tTone.TimeBase.prototype._pushExpr = function(val, name, units){\n\t\t//create the expression\n\t\tif (!(val instanceof Tone.TimeBase)){\n\t\t\tval = new this.constructor(val, units);\n\t\t}\n\t\tthis._expr = this._binaryExpressions[name].method.bind(this, this._expr, val._expr);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Add to the current value.\n\t * @param {Time} val The value to add\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").add(\"1m\"); //\"3m\"\n\t */\n\tTone.TimeBase.prototype.add = function(val, units){\n\t\treturn this._pushExpr(val, \"+\", units);\n\t};\n\n\t/**\n\t * Subtract the value from the current time.\n\t * @param {Time} val The value to subtract\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").sub(\"1m\"); //\"1m\"\n\t */\n\tTone.TimeBase.prototype.sub = function(val, units){\n\t\treturn this._pushExpr(val, \"-\", units);\n\t};\n\n\t/**\n\t * Multiply the current value by the given time.\n\t * @param {Time} val The value to multiply\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").mult(\"2\"); //\"4m\"\n\t */\n\tTone.TimeBase.prototype.mult = function(val, units){\n\t\treturn this._pushExpr(val, \"*\", units);\n\t};\n\n\t/**\n\t * Divide the current value by the given time.\n\t * @param {Time} val The value to divide by\n\t * @param {String=} units Optional units to use with the value.\n\t * @return {Tone.TimeBase} this\n\t * @example\n\t * Tone.TimeBase(\"2m\").div(2); //\"1m\"\n\t */\n\tTone.TimeBase.prototype.div = function(val, units){\n\t\treturn this._pushExpr(val, \"/\", units);\n\t};\n\n\t/**\n\t * Evaluate the time value. Returns the time\n\t * in seconds.\n\t * @return {Seconds} \n\t */\n\tTone.TimeBase.prototype.valueOf = function(){\n\t\treturn this._expr();\n\t};\n\n\t/**\n\t * Clean up\n\t * @return {Tone.TimeBase} this\n\t */\n\tTone.TimeBase.prototype.dispose = function(){\n\t\tthis._expr = null;\n\t};\n\n\treturn Tone.TimeBase;\n});","define([\"Tone/core/Tone\", \"Tone/type/Type\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Param wraps the native Web Audio's AudioParam to provide\n\t * additional unit conversion functionality. It also\n\t * serves as a base-class for classes which have a single,\n\t * automatable parameter. \n\t * @extends {Tone}\n\t * @param {AudioParam} param The parameter to wrap.\n\t * @param {Tone.Type} units The units of the audio param.\n\t * @param {Boolean} convert If the param should be converted.\n\t */\n\tTone.Param = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"param\", \"units\", \"convert\"], Tone.Param.defaults);\n\n\t\t/**\n\t\t * The native parameter to control\n\t\t * @type {AudioParam}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input = options.param;\n\n\t\t/**\n\t\t * The units of the parameter\n\t\t * @type {Tone.Type}\n\t\t */\n\t\tthis.units = options.units;\n\n\t\t/**\n\t\t * If the value should be converted or not\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.convert = options.convert;\n\n\t\t/**\n\t\t * True if the signal value is being overridden by \n\t\t * a connected signal.\n\t\t * @readOnly\n\t\t * @type {boolean}\n\t\t * @private\n\t\t */\n\t\tthis.overridden = false;\n\n\t\t/**\n\t\t * If there is an LFO, this is where it is held.\n\t\t * @type {Tone.LFO}\n\t\t * @private\n\t\t */\n\t\tthis._lfo = null;\n\n\t\tif (this.isObject(options.lfo)){\n\t\t\tthis.value = options.lfo;\n\t\t} else if (!this.isUndef(options.value)){\n\t\t\tthis.value = options.value;\n\t\t}\n\t};\n\n\tTone.extend(Tone.Param);\n\t\n\t/**\n\t * Defaults\n\t * @type {Object}\n\t * @const\n\t */\n\tTone.Param.defaults = {\n\t\t\"units\" : Tone.Type.Default,\n\t\t\"convert\" : true,\n\t\t\"param\" : undefined\n\t};\n\n\t/**\n\t * The current value of the parameter. \n\t * @memberOf Tone.Param#\n\t * @type {Number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Param.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._toUnits(this._param.value);\n\t\t},\n\t\tset : function(value){\n\t\t\tif (this.isObject(value)){\n\t\t\t\t//throw an error if the LFO needs to be included\n\t\t\t\tif (this.isUndef(Tone.LFO)){\n\t\t\t\t\tthrow new Error(\"Include 'Tone.LFO' to use an LFO as a Param value.\");\n\t\t\t\t}\n\t\t\t\t//remove the old one\n\t\t\t\tif (this._lfo){\n\t\t\t\t\tthis._lfo.dispose();\n\t\t\t\t}\n\t\t\t\tthis._lfo = new Tone.LFO(value).start();\n\t\t\t\tthis._lfo.connect(this.input);\n\t\t\t} else {\n\t\t\t\tvar convertedVal = this._fromUnits(value);\n\t\t\t\tthis._param.cancelScheduledValues(0);\n\t\t\t\tthis._param.value = convertedVal;\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Convert the given value from the type specified by Tone.Param.units\n\t * into the destination value (such as Gain or Frequency).\n\t * @private\n\t * @param {*} val the value to convert\n\t * @return {number} the number which the value should be set to\n\t */\n\tTone.Param.prototype._fromUnits = function(val){\n\t\tif (this.convert || this.isUndef(this.convert)){\n\t\t\tswitch(this.units){\n\t\t\t\tcase Tone.Type.Time: \n\t\t\t\t\treturn this.toSeconds(val);\n\t\t\t\tcase Tone.Type.Frequency: \n\t\t\t\t\treturn this.toFrequency(val);\n\t\t\t\tcase Tone.Type.Decibels: \n\t\t\t\t\treturn this.dbToGain(val);\n\t\t\t\tcase Tone.Type.NormalRange: \n\t\t\t\t\treturn Math.min(Math.max(val, 0), 1);\n\t\t\t\tcase Tone.Type.AudioRange: \n\t\t\t\t\treturn Math.min(Math.max(val, -1), 1);\n\t\t\t\tcase Tone.Type.Positive: \n\t\t\t\t\treturn Math.max(val, 0);\n\t\t\t\tdefault:\n\t\t\t\t\treturn val;\n\t\t\t}\n\t\t} else {\n\t\t\treturn val;\n\t\t}\n\t};\n\n\t/**\n\t * Convert the parameters value into the units specified by Tone.Param.units.\n\t * @private\n\t * @param {number} val the value to convert\n\t * @return {number}\n\t */\n\tTone.Param.prototype._toUnits = function(val){\n\t\tif (this.convert || this.isUndef(this.convert)){\n\t\t\tswitch(this.units){\n\t\t\t\tcase Tone.Type.Decibels: \n\t\t\t\t\treturn this.gainToDb(val);\n\t\t\t\tdefault:\n\t\t\t\t\treturn val;\n\t\t\t}\n\t\t} else {\n\t\t\treturn val;\n\t\t}\n\t};\n\n\t/**\n\t * the minimum output value\n\t * @type {Number}\n\t * @private\n\t */\n\tTone.Param.prototype._minOutput = 0.00001;\n\n\t/**\n\t * Schedules a parameter value change at the given time.\n\t * @param {*}\tvalue The value to set the signal.\n\t * @param {Time} time The time when the change should occur.\n\t * @returns {Tone.Param} this\n\t * @example\n\t * //set the frequency to \"G4\" in exactly 1 second from now. \n\t * freq.setValueAtTime(\"G4\", \"+1\");\n\t */\n\tTone.Param.prototype.setValueAtTime = function(value, time){\n\t\tvalue = this._fromUnits(value);\n\t\ttime = this.toSeconds(time);\n\t\tif (time <= this.now() + this.blockTime){\n\t\t\tthis._param.value = value;\n\t\t} else {\n\t\t\tthis._param.setValueAtTime(value, time);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Creates a schedule point with the current value at the current time.\n\t * This is useful for creating an automation anchor point in order to \n\t * schedule changes from the current value. \n\t *\n\t * @param {number=} now (Optionally) pass the now value in. \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.setRampPoint = function(now){\n\t\tnow = this.defaultArg(now, this.now());\n\t\tvar currentVal = this._param.value;\n\t\t// exponentialRampToValueAt cannot ever ramp from or to 0\n\t\t// More info: https://bugzilla.mozilla.org/show_bug.cgi?id=1125600#c2\n\t\tif (currentVal === 0){\n\t\t\tcurrentVal = this._minOutput;\n\t\t}\n\t\tthis._param.setValueAtTime(currentVal, now);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules a linear continuous change in parameter value from the \n\t * previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.linearRampToValueAtTime = function(value, endTime){\n\t\tvalue = this._fromUnits(value);\n\t\tthis._param.linearRampToValueAtTime(value, this.toSeconds(endTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the previous scheduled parameter value to the given value.\n\t * \n\t * @param {number} value \n\t * @param {Time} endTime \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.exponentialRampToValueAtTime = function(value, endTime){\n\t\tvalue = this._fromUnits(value);\n\t\tvalue = Math.max(this._minOutput, value);\n\t\tthis._param.exponentialRampToValueAtTime(value, this.toSeconds(endTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an exponential continuous change in parameter value from \n\t * the current time and current value to the given value over the \n\t * duration of the rampTime.\n\t * \n\t * @param {number} value The value to ramp to.\n\t * @param {Time} rampTime the time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //exponentially ramp to the value 2 over 4 seconds. \n\t * signal.exponentialRampToValue(2, 4);\n\t */\n\tTone.Param.prototype.exponentialRampToValue = function(value, rampTime, startTime){\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis.setRampPoint(startTime);\n\t\tthis.exponentialRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Schedules an linear continuous change in parameter value from \n\t * the current time and current value to the given value over the \n\t * duration of the rampTime.\n\t * \n\t * @param {number} value The value to ramp to.\n\t * @param {Time} rampTime the time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //linearly ramp to the value 4 over 3 seconds. \n\t * signal.linearRampToValue(4, 3);\n\t */\n\tTone.Param.prototype.linearRampToValue = function(value, rampTime, startTime){\n\t\tstartTime = this.toSeconds(startTime);\n\t\tthis.setRampPoint(startTime);\n\t\tthis.linearRampToValueAtTime(value, startTime + this.toSeconds(rampTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Start exponentially approaching the target value at the given time with\n\t * a rate having the given time constant.\n\t * @param {number} value \n\t * @param {Time} startTime \n\t * @param {number} timeConstant \n\t * @returns {Tone.Param} this \n\t */\n\tTone.Param.prototype.setTargetAtTime = function(value, startTime, timeConstant){\n\t\tvalue = this._fromUnits(value);\n\t\t// The value will never be able to approach without timeConstant > 0.\n\t\t// http://www.w3.org/TR/webaudio/#dfn-setTargetAtTime, where the equation\n\t\t// is described. 0 results in a division by 0.\n\t\tvalue = Math.max(this._minOutput, value);\n\t\ttimeConstant = Math.max(this._minOutput, timeConstant);\n\t\tthis._param.setTargetAtTime(value, this.toSeconds(startTime), timeConstant);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Sets an array of arbitrary parameter values starting at the given time\n\t * for the given duration.\n\t * \t\n\t * @param {Array} values \n\t * @param {Time} startTime \n\t * @param {Time} duration \n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.setValueCurveAtTime = function(values, startTime, duration){\n\t\tfor (var i = 0; i < values.length; i++){\n\t\t\tvalues[i] = this._fromUnits(values[i]);\n\t\t}\n\t\tthis._param.setValueCurveAtTime(values, this.toSeconds(startTime), this.toSeconds(duration));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancels all scheduled parameter changes with times greater than or \n\t * equal to startTime.\n\t * \n\t * @param {Time} startTime\n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.cancelScheduledValues = function(startTime){\n\t\tthis._param.cancelScheduledValues(this.toSeconds(startTime));\n\t\treturn this;\n\t};\n\n\t/**\n\t * Ramps to the given value over the duration of the rampTime. \n\t * Automatically selects the best ramp type (exponential or linear)\n\t * depending on the `units` of the signal\n\t * \n\t * @param {number} value \n\t * @param {Time} rampTime \tThe time that it takes the \n\t * value to ramp from it's current value\n\t * @param {Time}\t[startTime=now] \tWhen the ramp should start. \n\t * @returns {Tone.Param} this\n\t * @example\n\t * //ramp to the value either linearly or exponentially \n\t * //depending on the \"units\" value of the signal\n\t * signal.rampTo(0, 10);\n\t * @example\n\t * //schedule it to ramp starting at a specific time\n\t * signal.rampTo(0, 10, 5)\n\t */\n\tTone.Param.prototype.rampTo = function(value, rampTime, startTime){\n\t\trampTime = this.defaultArg(rampTime, 0);\n\t\tif (this.units === Tone.Type.Frequency || this.units === Tone.Type.BPM || this.units === Tone.Type.Decibels){\n\t\t\tthis.exponentialRampToValue(value, rampTime, startTime);\n\t\t} else {\n\t\t\tthis.linearRampToValue(value, rampTime, startTime);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * The LFO created by the signal instance. If none\n\t * was created, this is null.\n\t * @type {Tone.LFO}\n\t * @readOnly\n\t * @memberOf Tone.Param#\n\t * @name lfo\n\t */\n\tObject.defineProperty(Tone.Param.prototype, \"lfo\", {\n\t\tget : function(){\n\t\t\treturn this._lfo;\n\t\t}\n\t});\n\n\t/**\n\t * Clean up\n\t * @returns {Tone.Param} this\n\t */\n\tTone.Param.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._param = null;\n\t\tif (this._lfo){\n\t\t\tthis._lfo.dispose();\n\t\t\tthis._lfo = null;\n\t\t}\n\t\treturn this;\n\t};\n\n\treturn Tone.Param;\n});","define([\"Tone/core/Tone\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A Timeline class for scheduling and maintaining state\n\t * along a timeline. All events must have a \"time\" property. \n\t * Internally, events are stored in time order for fast \n\t * retrieval.\n\t * @extends {Tone}\n\t * @param {Positive} [memory=Infinity] The number of previous events that are retained.\n\t */\n\tTone.Timeline = function(){\n\n\t\tvar options = this.optionsObject(arguments, [\"memory\"], Tone.Timeline.defaults);\n\n\t\t/**\n\t\t * The array of scheduled timeline events\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._timeline = [];\n\n\t\t/**\n\t\t * An array of items to remove from the list. \n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._toRemove = [];\n\n\t\t/**\n\t\t * Flag if the tieline is mid iteration\n\t\t * @private\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis._iterating = false;\n\n\t\t/**\n\t\t * The memory of the timeline, i.e.\n\t\t * how many events in the past it will retain\n\t\t * @type {Positive}\n\t\t */\n\t\tthis.memory = options.memory;\n\t};\n\n\tTone.extend(Tone.Timeline);\n\n\t/**\n\t * the default parameters\n\t * @static\n\t * @const\n\t */\n\tTone.Timeline.defaults = {\n\t\t\"memory\" : Infinity\n\t};\n\n\t/**\n\t * The number of items in the timeline.\n\t * @type {Number}\n\t * @memberOf Tone.Timeline#\n\t * @name length\n\t * @readOnly\n\t */\n\tObject.defineProperty(Tone.Timeline.prototype, \"length\", {\n\t\tget : function(){\n\t\t\treturn this._timeline.length;\n\t\t}\n\t});\n\n\t/**\n\t * Insert an event object onto the timeline. Events must have a \"time\" attribute.\n\t * @param {Object} event The event object to insert into the \n\t * timeline. \n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.add = function(event){\n\t\t//the event needs to have a time attribute\n\t\tif (this.isUndef(event.time)){\n\t\t\tthrow new Error(\"Tone.Timeline: events must have a time attribute\");\n\t\t}\n\t\tif (this._timeline.length){\n\t\t\tvar index = this._search(event.time);\n\t\t\tthis._timeline.splice(index + 1, 0, event);\n\t\t} else {\n\t\t\tthis._timeline.push(event);\t\t\t\n\t\t}\n\t\t//if the length is more than the memory, remove the previous ones\n\t\tif (this.length > this.memory){\n\t\t\tvar diff = this.length - this.memory;\n\t\t\tthis._timeline.splice(0, diff);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Remove an event from the timeline.\n\t * @param {Object} event The event object to remove from the list.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.remove = function(event){\n\t\tif (this._iterating){\n\t\t\tthis._toRemove.push(event);\n\t\t} else {\n\t\t\tvar index = this._timeline.indexOf(event);\n\t\t\tif (index !== -1){\n\t\t\t\tthis._timeline.splice(index, 1);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Get the nearest event whose time is less than or equal to the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object set after that time.\n\t */\n\tTone.Timeline.prototype.get = function(time){\n\t\tvar index = this._search(time);\n\t\tif (index !== -1){\n\t\t\treturn this._timeline[index];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Return the first event in the timeline without removing it\n\t * @returns {Object} The first event object\n\t */\n\tTone.Timeline.prototype.peek = function(){\n\t\treturn this._timeline[0];\n\t};\n\n\t/**\n\t * Return the first event in the timeline and remove it\n\t * @returns {Object} The first event object\n\t */\n\tTone.Timeline.prototype.shift = function(){\n\t\treturn this._timeline.shift();\n\t};\n\n\t/**\n\t * Get the event which is scheduled after the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object after the given time\n\t */\n\tTone.Timeline.prototype.getAfter = function(time){\n\t\tvar index = this._search(time);\n\t\tif (index + 1 < this._timeline.length){\n\t\t\treturn this._timeline[index + 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Get the event before the event at the given time.\n\t * @param {Number} time The time to query.\n\t * @returns {Object} The event object before the given time\n\t */\n\tTone.Timeline.prototype.getBefore = function(time){\n\t\tvar len = this._timeline.length;\n\t\t//if it's after the last item, return the last item\n\t\tif (len > 0 && this._timeline[len - 1].time < time){\n\t\t\treturn this._timeline[len - 1];\n\t\t}\n\t\tvar index = this._search(time);\n\t\tif (index - 1 >= 0){\n\t\t\treturn this._timeline[index - 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t/**\n\t * Cancel events after the given time\n\t * @param {Number} time The time to query.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.cancel = function(after){\n\t\tif (this._timeline.length > 1){\n\t\t\tvar index = this._search(after);\n\t\t\tif (index >= 0){\n\t\t\t\tif (this._timeline[index].time === after){\n\t\t\t\t\t//get the first item with that time\n\t\t\t\t\tfor (var i = index; i >= 0; i--){\n\t\t\t\t\t\tif (this._timeline[i].time === after){\n\t\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis._timeline = this._timeline.slice(0, index);\n\t\t\t\t} else {\n\t\t\t\t\tthis._timeline = this._timeline.slice(0, index + 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis._timeline = [];\n\t\t\t}\n\t\t} else if (this._timeline.length === 1){\n\t\t\t//the first item's time\n\t\t\tif (this._timeline[0].time >= after){\n\t\t\t\tthis._timeline = [];\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Cancel events before or equal to the given time.\n\t * @param {Number} time The time to cancel before.\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.cancelBefore = function(time){\n\t\tif (this._timeline.length){\n\t\t\tvar index = this._search(time);\n\t\t\tif (index >= 0){\n\t\t\t\tthis._timeline = this._timeline.slice(index + 1);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Does a binary serach on the timeline array and returns the \n\t * nearest event index whose time is after or equal to the given time.\n\t * If a time is searched before the first index in the timeline, -1 is returned.\n\t * If the time is after the end, the index of the last item is returned.\n\t * @param {Number} time \n\t * @return {Number} the index in the timeline array \n\t * @private\n\t */\n\tTone.Timeline.prototype._search = function(time){\n\t\tvar beginning = 0;\n\t\tvar len = this._timeline.length;\n\t\tvar end = len;\n\t\tif (len > 0 && this._timeline[len - 1].time <= time){\n\t\t\treturn len - 1;\n\t\t}\n\t\twhile (beginning < end){\n\t\t\t// calculate the midpoint for roughly equal partition\n\t\t\tvar midPoint = Math.floor(beginning + (end - beginning) / 2);\n\t\t\tvar event = this._timeline[midPoint];\n\t\t\tvar nextEvent = this._timeline[midPoint + 1];\n\t\t\tif (event.time === time){\n\t\t\t\t//choose the last one that has the same time\n\t\t\t\tfor (var i = midPoint; i < this._timeline.length; i++){\n\t\t\t\t\tvar testEvent = this._timeline[i];\n\t\t\t\t\tif (testEvent.time === time){\n\t\t\t\t\t\tmidPoint = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn midPoint;\n\t\t\t} else if (event.time < time && nextEvent.time > time){\n\t\t\t\treturn midPoint;\n\t\t\t} else if (event.time > time){\n\t\t\t\t//search lower\n\t\t\t\tend = midPoint;\n\t\t\t} else if (event.time < time){\n\t\t\t\t//search upper\n\t\t\t\tbeginning = midPoint + 1;\n\t\t\t} \n\t\t}\n\t\treturn -1;\n\t};\n\n\t/**\n\t * Internal iterator. Applies extra safety checks for \n\t * removing items from the array. \n\t * @param {Function} callback \n\t * @param {Number=} lowerBound \n\t * @param {Number=} upperBound \n\t * @private\n\t */\n\tTone.Timeline.prototype._iterate = function(callback, lowerBound, upperBound){\n\t\tthis._iterating = true;\n\t\tlowerBound = this.defaultArg(lowerBound, 0);\n\t\tupperBound = this.defaultArg(upperBound, this._timeline.length - 1);\n\t\tfor (var i = lowerBound; i <= upperBound; i++){\n\t\t\tcallback(this._timeline[i]);\n\t\t}\n\t\tthis._iterating = false;\n\t\tif (this._toRemove.length > 0){\n\t\t\tfor (var j = 0; j < this._toRemove.length; j++){\n\t\t\t\tvar index = this._timeline.indexOf(this._toRemove[j]);\n\t\t\t\tif (index !== -1){\n\t\t\t\t\tthis._timeline.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._toRemove = [];\n\t\t}\n\t};\n\n\t/**\n\t * Iterate over everything in the array\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEach = function(callback){\n\t\tthis._iterate(callback);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at or before the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachBefore = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar upperBound = this._search(time);\n\t\tif (upperBound !== -1){\n\t\t\tthis._iterate(callback, 0, upperBound);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array after the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachAfter = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar lowerBound = this._search(time);\n\t\tthis._iterate(callback, lowerBound + 1);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at or after the given time. Similar to \n\t * forEachAfter, but includes the item(s) at the given time.\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachFrom = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar lowerBound = this._search(time);\n\t\t//work backwards until the event time is less than time\n\t\twhile (lowerBound >= 0 && this._timeline[lowerBound].time >= time){\n\t\t\tlowerBound--;\n\t\t}\n\t\tthis._iterate(callback, lowerBound + 1);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Iterate over everything in the array at the given time\n\t * @param {Number} time The time to check if items are before\n\t * @param {Function} callback The callback to invoke with every item\n\t * @returns {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.forEachAtTime = function(time, callback){\n\t\t//iterate over the items in reverse so that removing an item doesn't break things\n\t\tvar upperBound = this._search(time);\n\t\tif (upperBound !== -1){\n\t\t\tthis._iterate(function(event){\n\t\t\t\tif (event.time === time){\n\t\t\t\t\tcallback(event);\n\t\t\t\t} \n\t\t\t}, 0, upperBound);\n\t\t}\n\t\treturn this;\n\t};\n\n\t/**\n\t * Clean up.\n\t * @return {Tone.Timeline} this\n\t */\n\tTone.Timeline.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._timeline = null;\n\t\tthis._toRemove = null;\n\t};\n\n\treturn Tone.Timeline;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Multiply\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Negate the incoming signal. i.e. an input signal of 10 will output -10\n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var neg = new Tone.Negate();\n\t * var sig = new Tone.Signal(-2).connect(neg);\n\t * //output of neg is positive 2. \n\t */\n\tTone.Negate = function(){\n\t\t/**\n\t\t * negation is done by multiplying by -1\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._multiply = this.input = this.output = new Tone.Multiply(-1);\n\t};\n\n\tTone.extend(Tone.Negate, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Negate} this\n\t */\n\tTone.Negate.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._multiply.dispose();\n\t\tthis._multiply = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Negate;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/signal/Multiply\", \"Tone/signal/WaveShaper\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class GreaterThanZero outputs 1 when the input is strictly greater than zero\n\t * \n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var gt0 = new Tone.GreaterThanZero();\n\t * var sig = new Tone.Signal(0.01).connect(gt0);\n\t * //the output of gt0 is 1. \n\t * sig.value = 0;\n\t * //the output of gt0 is 0. \n\t */\n\tTone.GreaterThanZero = function(){\n\t\t\n\t\t/**\n\t\t * @type {Tone.WaveShaper}\n\t\t * @private\n\t\t */\n\t\tthis._thresh = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (val <= 0){\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}, 127);\n\n\t\t/**\n\t\t * scale the first thresholded signal by a large value.\n\t\t * this will help with values which are very close to 0\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._scale = this.input = new Tone.Multiply(10000);\n\n\t\t//connections\n\t\tthis._scale.connect(this._thresh);\n\t};\n\n\tTone.extend(Tone.GreaterThanZero, Tone.SignalBase);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.GreaterThanZero} this\n\t */\n\tTone.GreaterThanZero.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._scale.dispose();\n\t\tthis._scale = null;\n\t\tthis._thresh.dispose();\n\t\tthis._thresh = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.GreaterThanZero;\n});","/**\n * StartAudioContext.js\n * @author Yotam Mann\n * @license http://opensource.org/licenses/MIT MIT License\n * @copyright 2016 Yotam Mann\n */\n(function (root, factory) {\n\tif (typeof define === \"function\" && define.amd) {\n\t\tdefine([], factory)\n\t } else if (typeof module === \"object\" && module.exports) {\n module.exports = factory()\n\t} else {\n\t\troot.StartAudioContext = factory()\n }\n}(this, function () {\n\n\t//TAP LISTENER/////////////////////////////////////////////////////////////\n\n\t/**\n\t * @class Listens for non-dragging tap ends on the given element\n\t * @param {Element} element\n\t * @internal\n\t */\n\tvar TapListener = function(element, context){\n\n\t\tthis._dragged = false\n\n\t\tthis._element = element\n\n\t\tthis._bindedMove = this._moved.bind(this)\n\t\tthis._bindedEnd = this._ended.bind(this, context)\n\n\t\telement.addEventListener(\"touchstart\", this._bindedEnd)\n\t\telement.addEventListener(\"touchmove\", this._bindedMove)\n\t\telement.addEventListener(\"touchend\", this._bindedEnd)\n\t\telement.addEventListener(\"mouseup\", this._bindedEnd)\n\t}\n\n\t/**\n\t * drag move event\n\t */\n\tTapListener.prototype._moved = function(e){\n\t\tthis._dragged = true\n\t};\n\n\t/**\n\t * tap ended listener\n\t */\n\tTapListener.prototype._ended = function(context){\n\t\tif (!this._dragged){\n\t\t\tstartContext(context)\n\t\t}\n\t\tthis._dragged = false\n\t};\n\n\t/**\n\t * remove all the bound events\n\t */\n\tTapListener.prototype.dispose = function(){\n\t\tthis._element.removeEventListener(\"touchstart\", this._bindedEnd)\n\t\tthis._element.removeEventListener(\"touchmove\", this._bindedMove)\n\t\tthis._element.removeEventListener(\"touchend\", this._bindedEnd)\n\t\tthis._element.removeEventListener(\"mouseup\", this._bindedEnd)\n\t\tthis._bindedMove = null\n\t\tthis._bindedEnd = null\n\t\tthis._element = null\n\t};\n\n\t//END TAP LISTENER/////////////////////////////////////////////////////////\n\n\t/**\n\t * Plays a silent sound and also invoke the \"resume\" method\n\t * @param {AudioContext} context\n\t * @private\n\t */\n\tfunction startContext(context){\n\t\t// this accomplishes the iOS specific requirement\n\t\tvar buffer = context.createBuffer(1, 1, context.sampleRate)\n\t\tvar source = context.createBufferSource()\n\t\tsource.buffer = buffer\n\t\tsource.connect(context.destination)\n\t\tsource.start(0)\n\n\t\t// resume the audio context\n\t\tif (context.resume){\n\t\t\tcontext.resume()\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if the audio context is started\n\t * @param {AudioContext} context\n\t * @return {Boolean}\n\t * @private\n\t */\n\tfunction isStarted(context){\n\t\t return context.state === \"running\"\n\t}\n\n\t/**\n\t * Invokes the callback as soon as the AudioContext\n\t * is started\n\t * @param {AudioContext} context\n\t * @param {Function} callback\n\t */\n\tfunction onStarted(context, callback){\n\n\t\tfunction checkLoop(){\n\t\t\tif (isStarted(context)){\n\t\t\t\tcallback()\n\t\t\t} else {\n\t\t\t\trequestAnimationFrame(checkLoop)\n\t\t\t\tif (context.resume){\n\t\t\t\t\tcontext.resume()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (isStarted(context)){\n\t\t\tcallback()\n\t\t} else {\n\t\t\tcheckLoop()\n\t\t}\n\t}\n\n\t/**\n\t * Add a tap listener to the audio context\n\t * @param {Array|Element|String|jQuery} element\n\t * @param {Array} tapListeners\n\t */\n\tfunction bindTapListener(element, tapListeners, context){\n\t\tif (Array.isArray(element) || (NodeList && element instanceof NodeList)){\n\t\t\tfor (var i = 0; i < element.length; i++){\n\t\t\t\tbindTapListener(element[i], tapListeners, context)\n\t\t\t}\n\t\t} else if (typeof element === \"string\"){\n\t\t\tbindTapListener(document.querySelectorAll(element), tapListeners, context)\n\t\t} else if (element.jquery && typeof element.toArray === \"function\"){\n\t\t\tbindTapListener(element.toArray(), tapListeners, context)\n\t\t} else if (Element && element instanceof Element){\n\t\t\t//if it's an element, create a TapListener\n\t\t\tvar tap = new TapListener(element, context)\n\t\t\ttapListeners.push(tap)\n\t\t} \n\t}\n\n\t/**\n\t * @param {AudioContext} context The AudioContext to start.\n\t * @param {Array|String|Element|jQuery=} elements For iOS, the list of elements\n\t * to bind tap event listeners\n\t * which will start the AudioContext. If\n\t * no elements are given, it will bind\n\t * to the document.body.\n\t * @param {Function=} callback The callback to invoke when the AudioContext is started.\n\t * @return {Promise} The promise is invoked when the AudioContext\n\t * is started.\n\t */\n\tfunction StartAudioContext(context, elements, callback){\n\n\t\t//the promise is invoked when the AudioContext is started\n\t\tvar promise = new Promise(function(success) {\n\t\t\tonStarted(context, success)\n\t\t})\n\n\t\t// The TapListeners bound to the elements\n\t\tvar tapListeners = []\n\n\t\t// add all the tap listeners\n\t\tif (!elements){\n\t\t\telements = document.body\n\t\t}\n\t\tbindTapListener(elements, tapListeners, context)\n\n\t\t//dispose all these tap listeners when the context is started\n\t\tpromise.then(function(){\n\t\t\tfor (var i = 0; i < tapListeners.length; i++){\n\t\t\t\ttapListeners[i].dispose()\n\t\t\t}\n\t\t\ttapListeners = null\n\n\t\t\tif (callback){\n\t\t\t\tcallback()\n\t\t\t}\n\t\t})\n\n\t\treturn promise\n\t}\n\n\treturn StartAudioContext\n}))","define([\"Tone/core/Tone\", \"Tone/signal/Signal\", \"Tone/signal/Expr\", \n\t\"Tone/signal/EqualPowerGain\", \"Tone/core/Gain\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Tone.Crossfade provides equal power fading between two inputs. \n\t * More on crossfading technique [here](https://en.wikipedia.org/wiki/Fade_(audio_engineering)#Crossfading).\n\t *\n\t * @constructor\n\t * @extends {Tone}\n\t * @param {NormalRange} [initialFade=0.5]\n\t * @example\n\t * var crossFade = new Tone.CrossFade(0.5);\n\t * //connect effect A to crossfade from\n\t * //effect output 0 to crossfade input 0\n\t * effectA.connect(crossFade, 0, 0);\n\t * //connect effect B to crossfade from\n\t * //effect output 0 to crossfade input 1\n\t * effectB.connect(crossFade, 0, 1);\n\t * crossFade.fade.value = 0;\n\t * // ^ only effectA is output\n\t * crossFade.fade.value = 1;\n\t * // ^ only effectB is output\n\t * crossFade.fade.value = 0.5;\n\t * // ^ the two signals are mixed equally. \n\t */\t\t\n\tTone.CrossFade = function(initialFade){\n\n\t\tthis.createInsOuts(2, 1);\n\n\t\t/**\n\t\t * Alias for input[0]. \n\t\t * @type {Tone.Gain}\n\t\t */\n\t\tthis.a = this.input[0] = new Tone.Gain();\n\n\t\t/**\n\t\t * Alias for input[1]. \n\t\t * @type {Tone.Gain}\n\t\t */\n\t\tthis.b = this.input[1] = new Tone.Gain();\n\n\t\t/**\n\t\t * \tThe mix between the two inputs. A fade value of 0\n\t\t * \twill output 100% input[0] and \n\t\t * \ta value of 1 will output 100% input[1]. \n\t\t * @type {NormalRange}\n\t\t * @signal\n\t\t */\n\t\tthis.fade = new Tone.Signal(this.defaultArg(initialFade, 0.5), Tone.Type.NormalRange);\n\n\t\t/**\n\t\t * equal power gain cross fade\n\t\t * @private\n\t\t * @type {Tone.EqualPowerGain}\n\t\t */\n\t\tthis._equalPowerA = new Tone.EqualPowerGain();\n\n\t\t/**\n\t\t * equal power gain cross fade\n\t\t * @private\n\t\t * @type {Tone.EqualPowerGain}\n\t\t */\n\t\tthis._equalPowerB = new Tone.EqualPowerGain();\n\t\t\n\t\t/**\n\t\t * invert the incoming signal\n\t\t * @private\n\t\t * @type {Tone}\n\t\t */\n\t\tthis._invert = new Tone.Expr(\"1 - $0\");\n\n\t\t//connections\n\t\tthis.a.connect(this.output);\n\t\tthis.b.connect(this.output);\n\t\tthis.fade.chain(this._equalPowerB, this.b.gain);\n\t\tthis.fade.chain(this._invert, this._equalPowerA, this.a.gain);\n\t\tthis._readOnly(\"fade\");\n\t};\n\n\tTone.extend(Tone.CrossFade);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.CrossFade} this\n\t */\n\tTone.CrossFade.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._writable(\"fade\");\n\t\tthis._equalPowerA.dispose();\n\t\tthis._equalPowerA = null;\n\t\tthis._equalPowerB.dispose();\n\t\tthis._equalPowerB = null;\n\t\tthis.fade.dispose();\n\t\tthis.fade = null;\n\t\tthis._invert.dispose();\n\t\tthis._invert = null;\n\t\tthis.a.dispose();\n\t\tthis.a = null;\n\t\tthis.b.dispose();\n\t\tthis.b = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.CrossFade;\n});\n","!function(){var e,t=[];function r(e){var r=this,n={},i=-1;this.parameters.forEach(function(e,o){var s=t[++i]||(t[i]=new Float32Array(r.bufferSize));s.fill(e.value),n[o]=s}),this.processor.realm.exec(\"self.sampleRate=sampleRate=\"+this.context.sampleRate+\";self.currentTime=currentTime=\"+this.context.currentTime);var s=o(e.inputBuffer),a=o(e.outputBuffer);this.instance.process([s],[a],n)}function o(e){for(var t=[],r=0;r= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar RecorderProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(RecorderProcessor, _AudioWorkletProcesso);\\n\\n function RecorderProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, RecorderProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(RecorderProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.numOutputChannels = options.outputChannelCount || 2;\\n _this.numInputChannels = processorOptions.numInputChannels || 2;\\n _this.bufferSize = processorOptions.bufferSize || 1024;\\n _this.recording = false;\\n\\n _this.clear();\\n\\n _this.port.onmessage = function (event) {\\n var data = event.data;\\n\\n if (data.name === 'start') {\\n _this.record(data.duration);\\n } else if (data.name === 'stop') {\\n _this.stop();\\n }\\n };\\n\\n return _this;\\n }\\n\\n _createClass(RecorderProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs) {\\n if (!this.recording) {\\n return true;\\n } else if (this.sampleLimit && this.recordedSamples >= this.sampleLimit) {\\n this.stop();\\n return true;\\n }\\n\\n var input = inputs[0];\\n this.inputRingBuffer.push(input);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n\\n for (var channel = 0; channel < this.numOutputChannels; ++channel) {\\n var inputChannelCopy = this.inputRingBufferArraySequence[channel].slice();\\n\\n if (channel === 0) {\\n this.leftBuffers.push(inputChannelCopy);\\n\\n if (this.numInputChannels === 1) {\\n this.rightBuffers.push(inputChannelCopy);\\n }\\n } else if (channel === 1 && this.numInputChannels > 1) {\\n this.rightBuffers.push(inputChannelCopy);\\n }\\n }\\n\\n this.recordedSamples += this.bufferSize;\\n }\\n\\n return true;\\n }\\n }, {\\n key: \\\"record\\\",\\n value: function record(duration) {\\n if (duration) {\\n this.sampleLimit = Math.round(duration * sampleRate);\\n }\\n\\n this.recording = true;\\n }\\n }, {\\n key: \\\"stop\\\",\\n value: function stop() {\\n this.recording = false;\\n var buffers = this.getBuffers();\\n var leftBuffer = buffers[0].buffer;\\n var rightBuffer = buffers[1].buffer;\\n this.port.postMessage({\\n name: 'buffers',\\n leftBuffer: leftBuffer,\\n rightBuffer: rightBuffer\\n }, [leftBuffer, rightBuffer]);\\n this.clear();\\n }\\n }, {\\n key: \\\"getBuffers\\\",\\n value: function getBuffers() {\\n var buffers = [];\\n buffers.push(this.mergeBuffers(this.leftBuffers));\\n buffers.push(this.mergeBuffers(this.rightBuffers));\\n return buffers;\\n }\\n }, {\\n key: \\\"mergeBuffers\\\",\\n value: function mergeBuffers(channelBuffer) {\\n var result = new Float32Array(this.recordedSamples);\\n var offset = 0;\\n var lng = channelBuffer.length;\\n\\n for (var i = 0; i < lng; i++) {\\n var buffer = channelBuffer[i];\\n result.set(buffer, offset);\\n offset += buffer.length;\\n }\\n\\n return result;\\n }\\n }, {\\n key: \\\"clear\\\",\\n value: function clear() {\\n var _this2 = this;\\n\\n this.leftBuffers = [];\\n this.rightBuffers = [];\\n this.inputRingBuffer = new RingBuffer(this.bufferSize, this.numInputChannels);\\n this.inputRingBufferArraySequence = new Array(this.numInputChannels).fill(null).map(function () {\\n return new Float32Array(_this2.bufferSize);\\n });\\n this.recordedSamples = 0;\\n this.sampleLimit = null;\\n }\\n }]);\\n\\n return RecorderProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.recorderProcessor, RecorderProcessor);\";","export default \"function _typeof(obj) { if (typeof Symbol === \\\"function\\\" && typeof Symbol.iterator === \\\"symbol\\\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \\\"function\\\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \\\"symbol\\\" : typeof obj; }; } return _typeof(obj); }\\n\\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \\\"object\\\" || typeof call === \\\"function\\\")) { return call; } return _assertThisInitialized(self); }\\n\\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\"); } return self; }\\n\\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \\\"function\\\" && superClass !== null) { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\\n\\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \\\"function\\\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \\\"function\\\") { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } if (typeof _cache !== \\\"undefined\\\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\\n\\nfunction isNativeReflectConstruct() { if (typeof Reflect === \\\"undefined\\\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \\\"function\\\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\\n\\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\\n\\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\\\"[native code]\\\") !== -1; }\\n\\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\\n\\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\\n\\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\\"Cannot call a class as a function\\\"); } }\\n\\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\\\"value\\\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\\n\\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\\n\\n// import dependencies via preval.require so that they're available as values at compile time\\nvar processorNames = {\\n \\\"recorderProcessor\\\": \\\"recorder-processor\\\",\\n \\\"soundFileProcessor\\\": \\\"sound-file-processor\\\",\\n \\\"amplitudeProcessor\\\": \\\"amplitude-processor\\\"\\n};\\nvar RingBuffer = {\\n \\\"default\\\":\\n /*#__PURE__*/\\n function () {\\n /**\\n * @constructor\\n * @param {number} length Buffer length in frames.\\n * @param {number} channelCount Buffer channel count.\\n */\\n function RingBuffer(length, channelCount) {\\n _classCallCheck(this, RingBuffer);\\n\\n this._readIndex = 0;\\n this._writeIndex = 0;\\n this._framesAvailable = 0;\\n this._channelCount = channelCount;\\n this._length = length;\\n this._channelData = [];\\n\\n for (var i = 0; i < this._channelCount; ++i) {\\n this._channelData[i] = new Float32Array(length);\\n }\\n }\\n /**\\n * Getter for Available frames in buffer.\\n *\\n * @return {number} Available frames in buffer.\\n */\\n\\n\\n _createClass(RingBuffer, [{\\n key: \\\"push\\\",\\n\\n /**\\n * Push a sequence of Float32Arrays to buffer.\\n *\\n * @param {array} arraySequence A sequence of Float32Arrays.\\n */\\n value: function push(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // Transfer data from the |arraySequence| storage to the internal buffer.\\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\\n\\n for (var i = 0; i < sourceLength; ++i) {\\n var writeIndex = (this._writeIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\\n }\\n }\\n\\n this._writeIndex += sourceLength;\\n\\n if (this._writeIndex >= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar SoundFileProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(SoundFileProcessor, _AudioWorkletProcesso);\\n\\n function SoundFileProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, SoundFileProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SoundFileProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.bufferSize = processorOptions.bufferSize || 256;\\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, 1);\\n _this.inputRingBufferArraySequence = [new Float32Array(_this.bufferSize)];\\n return _this;\\n }\\n\\n _createClass(SoundFileProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs) {\\n var input = inputs[0]; // we only care about the first input channel, because that contains the position data\\n\\n this.inputRingBuffer.push([input[0]]);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n var inputChannel = this.inputRingBufferArraySequence[0];\\n var position = inputChannel[inputChannel.length - 1] || 0;\\n this.port.postMessage({\\n name: 'position',\\n position: position\\n });\\n }\\n\\n return true;\\n }\\n }]);\\n\\n return SoundFileProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.soundFileProcessor, SoundFileProcessor);\";","export default \"function _typeof(obj) { if (typeof Symbol === \\\"function\\\" && typeof Symbol.iterator === \\\"symbol\\\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \\\"function\\\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \\\"symbol\\\" : typeof obj; }; } return _typeof(obj); }\\n\\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \\\"object\\\" || typeof call === \\\"function\\\")) { return call; } return _assertThisInitialized(self); }\\n\\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\"); } return self; }\\n\\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \\\"function\\\" && superClass !== null) { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\\n\\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \\\"function\\\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \\\"function\\\") { throw new TypeError(\\\"Super expression must either be null or a function\\\"); } if (typeof _cache !== \\\"undefined\\\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\\n\\nfunction isNativeReflectConstruct() { if (typeof Reflect === \\\"undefined\\\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \\\"function\\\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\\n\\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\\n\\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\\\"[native code]\\\") !== -1; }\\n\\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\\n\\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\\n\\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\\"Cannot call a class as a function\\\"); } }\\n\\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\\\"value\\\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\\n\\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\\n\\n// import dependencies via preval.require so that they're available as values at compile time\\nvar processorNames = {\\n \\\"recorderProcessor\\\": \\\"recorder-processor\\\",\\n \\\"soundFileProcessor\\\": \\\"sound-file-processor\\\",\\n \\\"amplitudeProcessor\\\": \\\"amplitude-processor\\\"\\n};\\nvar RingBuffer = {\\n \\\"default\\\":\\n /*#__PURE__*/\\n function () {\\n /**\\n * @constructor\\n * @param {number} length Buffer length in frames.\\n * @param {number} channelCount Buffer channel count.\\n */\\n function RingBuffer(length, channelCount) {\\n _classCallCheck(this, RingBuffer);\\n\\n this._readIndex = 0;\\n this._writeIndex = 0;\\n this._framesAvailable = 0;\\n this._channelCount = channelCount;\\n this._length = length;\\n this._channelData = [];\\n\\n for (var i = 0; i < this._channelCount; ++i) {\\n this._channelData[i] = new Float32Array(length);\\n }\\n }\\n /**\\n * Getter for Available frames in buffer.\\n *\\n * @return {number} Available frames in buffer.\\n */\\n\\n\\n _createClass(RingBuffer, [{\\n key: \\\"push\\\",\\n\\n /**\\n * Push a sequence of Float32Arrays to buffer.\\n *\\n * @param {array} arraySequence A sequence of Float32Arrays.\\n */\\n value: function push(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // Transfer data from the |arraySequence| storage to the internal buffer.\\n var sourceLength = arraySequence[0] ? arraySequence[0].length : 0;\\n\\n for (var i = 0; i < sourceLength; ++i) {\\n var writeIndex = (this._writeIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n this._channelData[channel][writeIndex] = arraySequence[channel][i];\\n }\\n }\\n\\n this._writeIndex += sourceLength;\\n\\n if (this._writeIndex >= this._length) {\\n this._writeIndex = 0;\\n } // For excessive frames, the buffer will be overwritten.\\n\\n\\n this._framesAvailable += sourceLength;\\n\\n if (this._framesAvailable > this._length) {\\n this._framesAvailable = this._length;\\n }\\n }\\n /**\\n * Pull data out of buffer and fill a given sequence of Float32Arrays.\\n *\\n * @param {array} arraySequence An array of Float32Arrays.\\n */\\n\\n }, {\\n key: \\\"pull\\\",\\n value: function pull(arraySequence) {\\n // The channel count of arraySequence and the length of each channel must\\n // match with this buffer obejct.\\n // If the FIFO is completely empty, do nothing.\\n if (this._framesAvailable === 0) {\\n return;\\n }\\n\\n var destinationLength = arraySequence[0].length; // Transfer data from the internal buffer to the |arraySequence| storage.\\n\\n for (var i = 0; i < destinationLength; ++i) {\\n var readIndex = (this._readIndex + i) % this._length;\\n\\n for (var channel = 0; channel < this._channelCount; ++channel) {\\n arraySequence[channel][i] = this._channelData[channel][readIndex];\\n }\\n }\\n\\n this._readIndex += destinationLength;\\n\\n if (this._readIndex >= this._length) {\\n this._readIndex = 0;\\n }\\n\\n this._framesAvailable -= destinationLength;\\n\\n if (this._framesAvailable < 0) {\\n this._framesAvailable = 0;\\n }\\n }\\n }, {\\n key: \\\"framesAvailable\\\",\\n get: function get() {\\n return this._framesAvailable;\\n }\\n }]);\\n\\n return RingBuffer;\\n }()\\n}[\\\"default\\\"];\\n\\nvar AmplitudeProcessor =\\n/*#__PURE__*/\\nfunction (_AudioWorkletProcesso) {\\n _inherits(AmplitudeProcessor, _AudioWorkletProcesso);\\n\\n function AmplitudeProcessor(options) {\\n var _this;\\n\\n _classCallCheck(this, AmplitudeProcessor);\\n\\n _this = _possibleConstructorReturn(this, _getPrototypeOf(AmplitudeProcessor).call(this));\\n var processorOptions = options.processorOptions || {};\\n _this.numOutputChannels = options.outputChannelCount || 1;\\n _this.numInputChannels = processorOptions.numInputChannels || 2;\\n _this.normalize = processorOptions.normalize || false;\\n _this.smoothing = processorOptions.smoothing || 0;\\n _this.bufferSize = processorOptions.bufferSize || 2048;\\n _this.inputRingBuffer = new RingBuffer(_this.bufferSize, _this.numInputChannels);\\n _this.outputRingBuffer = new RingBuffer(_this.bufferSize, _this.numOutputChannels);\\n _this.inputRingBufferArraySequence = new Array(_this.numInputChannels).fill(null).map(function () {\\n return new Float32Array(_this.bufferSize);\\n });\\n _this.stereoVol = [0, 0];\\n _this.stereoVolNorm = [0, 0];\\n _this.volMax = 0.001;\\n\\n _this.port.onmessage = function (event) {\\n var data = event.data;\\n\\n if (data.name === 'toggleNormalize') {\\n _this.normalize = data.normalize;\\n } else if (data.name === 'smoothing') {\\n _this.smoothing = Math.max(0, Math.min(1, data.smoothing));\\n }\\n };\\n\\n return _this;\\n } // TO DO make this stereo / dependent on # of audio channels\\n\\n\\n _createClass(AmplitudeProcessor, [{\\n key: \\\"process\\\",\\n value: function process(inputs, outputs) {\\n var input = inputs[0];\\n var output = outputs[0];\\n var smoothing = this.smoothing;\\n this.inputRingBuffer.push(input);\\n\\n if (this.inputRingBuffer.framesAvailable >= this.bufferSize) {\\n this.inputRingBuffer.pull(this.inputRingBufferArraySequence);\\n\\n for (var channel = 0; channel < this.numInputChannels; ++channel) {\\n var inputBuffer = this.inputRingBufferArraySequence[channel];\\n var bufLength = inputBuffer.length;\\n var sum = 0;\\n\\n for (var i = 0; i < bufLength; i++) {\\n var x = inputBuffer[i];\\n\\n if (this.normalize) {\\n sum += Math.max(Math.min(x / this.volMax, 1), -1) * Math.max(Math.min(x / this.volMax, 1), -1);\\n } else {\\n sum += x * x;\\n }\\n } // ... then take the square root of the sum.\\n\\n\\n var rms = Math.sqrt(sum / bufLength);\\n this.stereoVol[channel] = Math.max(rms, this.stereoVol[channel] * smoothing);\\n this.volMax = Math.max(this.stereoVol[channel], this.volMax);\\n } // calculate stero normalized volume and add volume from all channels together\\n\\n\\n var volSum = 0;\\n\\n for (var index = 0; index < this.stereoVol.length; index++) {\\n this.stereoVolNorm[index] = Math.max(Math.min(this.stereoVol[index] / this.volMax, 1), 0);\\n volSum += this.stereoVol[index];\\n } // volume is average of channels\\n\\n\\n var volume = volSum / this.stereoVol.length; // normalized value\\n\\n var volNorm = Math.max(Math.min(volume / this.volMax, 1), 0);\\n this.port.postMessage({\\n name: 'amplitude',\\n volume: volume,\\n volNorm: volNorm,\\n stereoVol: this.stereoVol,\\n stereoVolNorm: this.stereoVolNorm\\n }); // pass input through to output\\n\\n this.outputRingBuffer.push(this.inputRingBufferArraySequence);\\n } // pull 128 frames out of the ring buffer\\n // if the ring buffer does not have enough frames, the output will be silent\\n\\n\\n this.outputRingBuffer.pull(output);\\n return true;\\n }\\n }]);\\n\\n return AmplitudeProcessor;\\n}(_wrapNativeSuper(AudioWorkletProcessor));\\n\\nregisterProcessor(processorNames.amplitudeProcessor, AmplitudeProcessor);\";","define([\"Tone/core/Tone\", \"Tone/type/TimeBase\"], function (Tone) {\n\n\t/**\n\t * @class Tone.Frequency is a primitive type for encoding Frequency values. \n\t * Eventually all time values are evaluated to hertz\n\t * using the `eval` method. \n\t * @constructor\n\t * @extends {Tone.TimeBase}\n\t * @param {String|Number} val The time value.\n\t * @param {String=} units The units of the value.\n\t * @example\n\t * Tone.Frequency(\"C3\") // 261\n\t * Tone.Frequency(38, \"midi\") //\n\t * Tone.Frequency(\"C3\").transpose(4);\n\t */\n\tTone.Frequency = function(val, units){\n\t\tif (this instanceof Tone.Frequency){\n\t\t\t\n\t\t\tTone.TimeBase.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.Frequency(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.Frequency, Tone.TimeBase);\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tAUGMENT BASE EXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.Frequency.prototype._primaryExpressions = Object.create(Tone.TimeBase.prototype._primaryExpressions);\n\n\t/*\n\t * midi type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.midi = {\n\t\tregexp : /^(\\d+(?:\\.\\d+)?midi)/,\n\t\tmethod : function(value){\n\t\t\treturn this.midiToFrequency(value);\n\t\t}\t\n\t};\n\n\t/*\n\t * note type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.note = {\n\t\tregexp : /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,\n\t\tmethod : function(pitch, octave){\n\t\t\tvar index = noteToScaleIndex[pitch.toLowerCase()];\n\t\t\tvar noteNumber = index + (parseInt(octave) + 1) * 12;\n\t\t\treturn this.midiToFrequency(noteNumber);\n\t\t}\t\n\t};\n\n\t/*\n\t * BeatsBarsSixteenths type primary expression\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Frequency.prototype._primaryExpressions.tr = {\n\t\t\tregexp : /^(\\d+(?:\\.\\d+)?):(\\d+(?:\\.\\d+)?):?(\\d+(?:\\.\\d+)?)?/,\n\t\t\tmethod : function(m, q, s){\n\t\t\tvar total = 1;\n\t\t\tif (m && m !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(this._timeSignature() * parseFloat(m));\n\t\t\t}\n\t\t\tif (q && q !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(parseFloat(q));\n\t\t\t}\n\t\t\tif (s && s !== \"0\"){\n\t\t\t\ttotal *= this._beatsToUnits(parseFloat(s) / 4);\n\t\t\t}\n\t\t\treturn total;\n\t\t}\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tEXPRESSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Transposes the frequency by the given number of semitones.\n\t * @param {Interval} interval\n\t * @return {Tone.Frequency} this\n\t * @example\n\t * Tone.Frequency(\"A4\").transpose(3); //\"C5\"\n\t */\n\tTone.Frequency.prototype.transpose = function(interval){\n\t\tthis._expr = function(expr, interval){\n\t\t\tvar val = expr();\n\t\t\treturn val * this.intervalToFrequencyRatio(interval);\n\t\t}.bind(this, this._expr, interval);\n\t\treturn this;\n\t};\n\n\t/**\n\t * Takes an array of semitone intervals and returns\n\t * an array of frequencies transposed by those intervals.\n\t * @param {Array} intervals\n\t * @return {Tone.Frequency} this\n\t * @example\n\t * Tone.Frequency(\"A4\").harmonize([0, 3, 7]); //[\"A4\", \"C5\", \"E5\"]\n\t */\n\tTone.Frequency.prototype.harmonize = function(intervals){\n\t\tthis._expr = function(expr, intervals){\n\t\t\tvar val = expr();\n\t\t\tvar ret = [];\n\t\t\tfor (var i = 0; i < intervals.length; i++){\n\t\t\t\tret[i] = val * this.intervalToFrequencyRatio(intervals[i]);\n\t\t\t}\n\t\t\treturn ret;\n\t\t}.bind(this, this._expr, intervals);\n\t\treturn this;\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Return the value of the frequency as a MIDI note\n\t * @return {MIDI}\n\t * @example\n\t * Tone.Frequency(\"C4\").toMidi(); //60\n\t */\n\tTone.Frequency.prototype.toMidi = function(){\n\t\treturn this.frequencyToMidi(this.valueOf());\n\t};\n\n\t/**\n\t * Return the value of the frequency in Scientific Pitch Notation\n\t * @return {Note}\n\t * @example\n\t * Tone.Frequency(69, \"midi\").toNote(); //\"A4\"\n\t */\n\tTone.Frequency.prototype.toNote = function(){\n\t\tvar freq = this.valueOf();\n\t\tvar log = Math.log(freq / Tone.Frequency.A4) / Math.LN2;\n\t\tvar noteNumber = Math.round(12 * log) + 57;\n\t\tvar octave = Math.floor(noteNumber/12);\n\t\tif(octave < 0){\n\t\t\tnoteNumber += -12 * octave;\n\t\t}\n\t\tvar noteName = scaleIndexToNote[noteNumber % 12];\n\t\treturn noteName + octave.toString();\n\t};\n\n\t/**\n\t * Return the duration of one cycle in seconds.\n\t * @return {Seconds}\n\t */\n\tTone.Frequency.prototype.toSeconds = function(){\n\t\treturn 1 / this.valueOf();\n\t};\n\n\t/**\n\t * Return the value in Hertz\n\t * @return {Frequency}\n\t */\n\tTone.Frequency.prototype.toFrequency = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the duration of one cycle in ticks\n\t * @return {Ticks}\n\t */\n\tTone.Frequency.prototype.toTicks = function(){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = this.valueOf() / quarterTime;\n\t\treturn Math.floor(quarters * Tone.Transport.PPQ);\n\t};\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tUNIT CONVERSIONS HELPERS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Returns the value of a frequency in the current units\n\t * @param {Frequency} freq\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._frequencyToUnits = function(freq){\n\t\treturn freq;\n\t};\n\n\t/**\n\t * Returns the value of a tick in the current time units\n\t * @param {Ticks} ticks\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._ticksToUnits = function(ticks){\n\t\treturn 1 / ((ticks * 60) / (Tone.Transport.bpm.value * Tone.Transport.PPQ));\n\t};\n\n\t/**\n\t * Return the value of the beats in the current units\n\t * @param {Number} beats\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._beatsToUnits = function(beats){\n\t\treturn 1 / Tone.TimeBase.prototype._beatsToUnits.call(this, beats);\n\t};\n\n\t/**\n\t * Returns the value of a second in the current units\n\t * @param {Seconds} seconds\n\t * @return {Number}\n\t * @private\n\t */\n\tTone.Frequency.prototype._secondsToUnits = function(seconds){\n\t\treturn 1 / seconds;\n\t};\n\n\t/**\n\t * The default units if none are given.\n\t * @private\n\t */\n\tTone.Frequency.prototype._defaultUnits = \"hz\";\n\n\t///////////////////////////////////////////////////////////////////////////\n\t//\tFREQUENCY CONVERSIONS\n\t///////////////////////////////////////////////////////////////////////////\n\n\t/**\n\t * Note to scale index\n\t * @type {Object}\n\t */\n\tvar noteToScaleIndex = {\n\t\t\"cbb\" : -2, \"cb\" : -1, \"c\" : 0, \"c#\" : 1, \"cx\" : 2, \n\t\t\"dbb\" : 0, \"db\" : 1, \"d\" : 2, \"d#\" : 3, \"dx\" : 4,\n\t\t\"ebb\" : 2, \"eb\" : 3, \"e\" : 4, \"e#\" : 5, \"ex\" : 6, \n\t\t\"fbb\" : 3, \"fb\" : 4, \"f\" : 5, \"f#\" : 6, \"fx\" : 7,\n\t\t\"gbb\" : 5, \"gb\" : 6, \"g\" : 7, \"g#\" : 8, \"gx\" : 9,\n\t\t\"abb\" : 7, \"ab\" : 8, \"a\" : 9, \"a#\" : 10, \"ax\" : 11,\n\t\t\"bbb\" : 9, \"bb\" : 10, \"b\" : 11, \"b#\" : 12, \"bx\" : 13,\n\t};\n\n\t/**\n\t * scale index to note (sharps)\n\t * @type {Array}\n\t */\n\tvar scaleIndexToNote = [\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"A#\", \"B\"];\n\n\t/**\n\t * The [concert pitch](https://en.wikipedia.org/wiki/Concert_pitch)\n\t * A4's values in Hertz. \n\t * @type {Frequency}\n\t * @static\n\t */\n\tTone.Frequency.A4 = 440;\n\n\t/**\n\t * Convert a MIDI note to frequency value. \n\t * @param {MIDI} midi The midi number to convert.\n\t * @return {Frequency} the corresponding frequency value\n\t * @example\n\t * tone.midiToFrequency(69); // returns 440\n\t */\n\tTone.Frequency.prototype.midiToFrequency = function(midi){\n\t\treturn Tone.Frequency.A4 * Math.pow(2, (midi - 69) / 12);\n\t};\n\n\t/**\n\t * Convert a frequency value to a MIDI note.\n\t * @param {Frequency} frequency The value to frequency value to convert.\n\t * @returns {MIDI}\n\t * @example\n\t * tone.midiToFrequency(440); // returns 69\n\t */\n\tTone.Frequency.prototype.frequencyToMidi = function(frequency){\n\t\treturn 69 + 12 * Math.log(frequency / Tone.Frequency.A4) / Math.LN2;\n\t};\n\n\treturn Tone.Frequency;\n});","define([\"Tone/core/Tone\", \"Tone/type/Time\"], function (Tone) {\n\n\t/**\n\t * @class Tone.TransportTime is a the time along the Transport's\n\t * timeline. It is similar to Tone.Time, but instead of evaluating\n\t * against the AudioContext's clock, it is evaluated against\n\t * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime).\n\t * @constructor\n\t * @param {Time} val The time value as a number or string\n\t * @param {String=} units Unit values\n\t * @extends {Tone.Time}\n\t */\n\tTone.TransportTime = function(val, units){\n\t\tif (this instanceof Tone.TransportTime){\n\t\t\t\n\t\t\tTone.Time.call(this, val, units);\n\n\t\t} else {\n\t\t\treturn new Tone.TransportTime(val, units);\n\t\t}\n\t};\n\n\tTone.extend(Tone.TransportTime, Tone.Time);\n\n\t//clone the expressions so that \n\t//we can add more without modifying the original\n\tTone.TransportTime.prototype._unaryExpressions = Object.create(Tone.Time.prototype._unaryExpressions);\n\n\t/**\n\t * Adds an additional unary expression\n\t * which quantizes values to the next subdivision\n\t * @type {Object}\n\t * @private\n\t */\n\tTone.TransportTime.prototype._unaryExpressions.quantize = {\n\t\tregexp : /^@/,\n\t\tmethod : function(rh){\n\t\t\tvar subdivision = this._secondsToTicks(rh());\n\t\t\tvar multiple = Math.ceil(Tone.Transport.ticks / subdivision);\n\t\t\treturn this._ticksToUnits(multiple * subdivision);\n\t\t}\n\t};\n\n\t/**\n\t * Convert seconds into ticks\n\t * @param {Seconds} seconds\n\t * @return {Ticks}\n\t * @private\n\t */\n\tTone.TransportTime.prototype._secondsToTicks = function(seconds){\n\t\tvar quarterTime = this._beatsToUnits(1);\n\t\tvar quarters = seconds / quarterTime;\n\t\treturn Math.round(quarters * Tone.Transport.PPQ);\n\t};\n\n\t/**\n\t * Evaluate the time expression. Returns values in ticks\n\t * @return {Ticks}\n\t */\n\tTone.TransportTime.prototype.valueOf = function(){\n\t\tvar val = this._secondsToTicks(this._expr());\n\t\treturn val + (this._plusNow ? Tone.Transport.ticks : 0);\n\t};\n\n\t/**\n\t * Return the time in ticks.\n\t * @return {Ticks}\n\t */\n\tTone.TransportTime.prototype.toTicks = function(){\n\t\treturn this.valueOf();\n\t};\n\n\t/**\n\t * Return the time in seconds.\n\t * @return {Seconds}\n\t */\n\tTone.TransportTime.prototype.toSeconds = function(){\n\t\tvar val = this._expr();\n\t\treturn val + (this._plusNow ? Tone.Transport.seconds : 0);\n\t};\n\n\t/**\n\t * Return the time as a frequency value\n\t * @return {Frequency} \n\t */\n\tTone.TransportTime.prototype.toFrequency = function(){\n\t\treturn 1/this.toSeconds();\n\t};\n\n\treturn Tone.TransportTime;\n});","define([\"Tone/core/Tone\", \"Tone/signal/Add\", \"Tone/signal/Subtract\", \"Tone/signal/Multiply\", \n\t\"Tone/signal/GreaterThan\", \"Tone/signal/GreaterThanZero\", \"Tone/signal/Abs\", \"Tone/signal/Negate\", \n\t\"Tone/signal/Modulo\", \"Tone/signal/Pow\", \"Tone/signal/AudioToGain\"], \n\tfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Evaluate an expression at audio rate.

\n\t * Parsing code modified from https://code.google.com/p/tapdigit/\n\t * Copyright 2011 2012 Ariya Hidayat, New BSD License\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {string} expr the expression to generate\n\t * @example\n\t * //adds the signals from input[0] and input[1].\n\t * var expr = new Tone.Expr(\"$0 + $1\");\n\t */\n\tTone.Expr = function(){\n\n\t\tvar expr = this._replacements(Array.prototype.slice.call(arguments));\n\t\tvar inputCount = this._parseInputs(expr);\n\n\t\t/**\n\t\t * hold onto all of the nodes for disposal\n\t\t * @type {Array}\n\t\t * @private\n\t\t */\n\t\tthis._nodes = [];\n\n\t\t/**\n\t\t * The inputs. The length is determined by the expression. \n\t\t * @type {Array}\n\t\t */\n\t\tthis.input = new Array(inputCount);\n\n\t\t//create a gain for each input\n\t\tfor (var i = 0; i < inputCount; i++){\n\t\t\tthis.input[i] = this.context.createGain();\n\t\t}\n\n\t\t//parse the syntax tree\n\t\tvar tree = this._parseTree(expr);\n\t\t//evaluate the results\n\t\tvar result;\n\t\ttry {\n\t\t\tresult = this._eval(tree);\n\t\t} catch (e){\n\t\t\tthis._disposeNodes();\n\t\t\tthrow new Error(\"Tone.Expr: Could evaluate expression: \"+expr);\n\t\t}\n\n\t\t/**\n\t\t * The output node is the result of the expression\n\t\t * @type {Tone}\n\t\t */\n\t\tthis.output = result;\n\t};\n\n\tTone.extend(Tone.Expr, Tone.SignalBase);\n\n\t//some helpers to cut down the amount of code\n\tfunction applyBinary(Constructor, args, self){\n\t\tvar op = new Constructor();\n\t\tself._eval(args[0]).connect(op, 0, 0);\n\t\tself._eval(args[1]).connect(op, 0, 1);\n\t\treturn op;\n\t}\n\tfunction applyUnary(Constructor, args, self){\n\t\tvar op = new Constructor();\n\t\tself._eval(args[0]).connect(op, 0, 0);\n\t\treturn op;\n\t}\n\tfunction getNumber(arg){\n\t\treturn arg ? parseFloat(arg) : undefined;\n\t}\n\tfunction literalNumber(arg){\n\t\treturn arg && arg.args ? parseFloat(arg.args) : undefined;\n\t}\n\n\t/*\n\t * the Expressions that Tone.Expr can parse.\n\t *\n\t * each expression belongs to a group and contains a regexp \n\t * for selecting the operator as well as that operators method\n\t * \n\t * @type {Object}\n\t * @private\n\t */\n\tTone.Expr._Expressions = {\n\t\t//values\n\t\t\"value\" : {\n\t\t\t\"signal\" : {\n\t\t\t\tregexp : /^\\d+\\.\\d+|^\\d+/,\n\t\t\t\tmethod : function(arg){\n\t\t\t\t\tvar sig = new Tone.Signal(getNumber(arg));\n\t\t\t\t\treturn sig;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"input\" : {\n\t\t\t\tregexp : /^\\$\\d/,\n\t\t\t\tmethod : function(arg, self){\n\t\t\t\t\treturn self.input[getNumber(arg.substr(1))];\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t//syntactic glue\n\t\t\"glue\" : {\n\t\t\t\"(\" : {\n\t\t\t\tregexp : /^\\(/,\n\t\t\t},\n\t\t\t\")\" : {\n\t\t\t\tregexp : /^\\)/,\n\t\t\t},\n\t\t\t\",\" : {\n\t\t\t\tregexp : /^,/,\n\t\t\t}\n\t\t},\n\t\t//functions\n\t\t\"func\" : {\n\t\t\t\"abs\" : {\n\t\t\t\tregexp : /^abs/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.Abs)\n\t\t\t},\n\t\t\t\"mod\" : {\n\t\t\t\tregexp : /^mod/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar modulus = literalNumber(args[1]);\n\t\t\t\t\tvar op = new Tone.Modulo(modulus);\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"pow\" : {\n\t\t\t\tregexp : /^pow/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar exp = literalNumber(args[1]);\n\t\t\t\t\tvar op = new Tone.Pow(exp);\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"a2g\" : {\n\t\t\t\tregexp : /^a2g/,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\tvar op = new Tone.AudioToGain();\n\t\t\t\t\tself._eval(args[0]).connect(op);\n\t\t\t\t\treturn op;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t//binary expressions\n\t\t\"binary\" : {\n\t\t\t\"+\" : {\n\t\t\t\tregexp : /^\\+/,\n\t\t\t\tprecedence : 1,\n\t\t\t\tmethod : applyBinary.bind(this, Tone.Add)\n\t\t\t},\n\t\t\t\"-\" : {\n\t\t\t\tregexp : /^\\-/,\n\t\t\t\tprecedence : 1,\n\t\t\t\tmethod : function(args, self){\n\t\t\t\t\t//both unary and binary op\n\t\t\t\t\tif (args.length === 1){\n\t\t\t\t\t\treturn applyUnary(Tone.Negate, args, self);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn applyBinary(Tone.Subtract, args, self);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"*\" : {\n\t\t\t\tregexp : /^\\*/,\n\t\t\t\tprecedence : 0,\n\t\t\t\tmethod : applyBinary.bind(this, Tone.Multiply)\n\t\t\t}\n\t\t},\n\t\t//unary expressions\n\t\t\"unary\" : {\n\t\t\t\"-\" : {\n\t\t\t\tregexp : /^\\-/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.Negate)\n\t\t\t},\n\t\t\t\"!\" : {\n\t\t\t\tregexp : /^\\!/,\n\t\t\t\tmethod : applyUnary.bind(this, Tone.NOT)\n\t\t\t},\n\t\t},\n\t};\n\t\t\n\t/**\n\t * @param {string} expr the expression string\n\t * @return {number} the input count\n\t * @private\n\t */\n\tTone.Expr.prototype._parseInputs = function(expr){\n\t\tvar inputArray = expr.match(/\\$\\d/g);\n\t\tvar inputMax = 0;\n\t\tif (inputArray !== null){\n\t\t\tfor (var i = 0; i < inputArray.length; i++){\n\t\t\t\tvar inputNum = parseInt(inputArray[i].substr(1)) + 1;\n\t\t\t\tinputMax = Math.max(inputMax, inputNum);\n\t\t\t}\n\t\t}\n\t\treturn inputMax;\n\t};\n\n\t/**\n\t * @param {Array} args \tan array of arguments\n\t * @return {string} the results of the replacements being replaced\n\t * @private\n\t */\n\tTone.Expr.prototype._replacements = function(args){\n\t\tvar expr = args.shift();\n\t\tfor (var i = 0; i < args.length; i++){\n\t\t\texpr = expr.replace(/\\%/i, args[i]);\n\t\t}\n\t\treturn expr;\n\t};\n\n\t/**\n\t * tokenize the expression based on the Expressions object\n\t * @param {string} expr \n\t * @return {Object} returns two methods on the tokenized list, next and peek\n\t * @private\n\t */\n\tTone.Expr.prototype._tokenize = function(expr){\n\t\tvar position = -1;\n\t\tvar tokens = [];\n\n\t\twhile(expr.length > 0){\n\t\t\texpr = expr.trim();\n\t\t\tvar token = getNextToken(expr);\n\t\t\ttokens.push(token);\n\t\t\texpr = expr.substr(token.value.length);\n\t\t}\n\n\t\tfunction getNextToken(expr){\n\t\t\tfor (var type in Tone.Expr._Expressions){\n\t\t\t\tvar group = Tone.Expr._Expressions[type];\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tvar reg = op.regexp;\n\t\t\t\t\tvar match = expr.match(reg);\n\t\t\t\t\tif (match !== null){\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype : type,\n\t\t\t\t\t\t\tvalue : match[0],\n\t\t\t\t\t\t\tmethod : op.method\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.Expr: Unexpected token \"+expr);\n\t\t}\n\n\t\treturn {\n\t\t\tnext : function(){\n\t\t\t\treturn tokens[++position];\n\t\t\t},\n\t\t\tpeek : function(){\n\t\t\t\treturn tokens[position + 1];\n\t\t\t}\n\t\t};\n\t};\n\n\t/**\n\t * recursively parse the string expression into a syntax tree\n\t * \n\t * @param {string} expr \n\t * @return {Object}\n\t * @private\n\t */\n\tTone.Expr.prototype._parseTree = function(expr){\n\t\tvar lexer = this._tokenize(expr);\n\t\tvar isUndef = this.isUndef.bind(this);\n\n\t\tfunction matchSyntax(token, syn) {\n\t\t\treturn !isUndef(token) && \n\t\t\t\ttoken.type === \"glue\" &&\n\t\t\t\ttoken.value === syn;\n\t\t}\n\n\t\tfunction matchGroup(token, groupName, prec) {\n\t\t\tvar ret = false;\n\t\t\tvar group = Tone.Expr._Expressions[groupName];\n\t\t\tif (!isUndef(token)){\n\t\t\t\tfor (var opName in group){\n\t\t\t\t\tvar op = group[opName];\n\t\t\t\t\tif (op.regexp.test(token.value)){\n\t\t\t\t\t\tif (!isUndef(prec)){\n\t\t\t\t\t\t\tif(op.precedence === prec){\t\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\n\t\tfunction parseExpression(precedence) {\n\t\t\tif (isUndef(precedence)){\n\t\t\t\tprecedence = 5;\n\t\t\t}\n\t\t\tvar expr;\n\t\t\tif (precedence < 0){\n\t\t\t\texpr = parseUnary();\n\t\t\t} else {\n\t\t\t\texpr = parseExpression(precedence-1);\n\t\t\t}\n\t\t\tvar token = lexer.peek();\n\t\t\twhile (matchGroup(token, \"binary\", precedence)) {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\texpr = {\n\t\t\t\t\toperator: token.value,\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : [\n\t\t\t\t\t\texpr,\n\t\t\t\t\t\tparseExpression(precedence-1)\n\t\t\t\t\t]\n\t\t\t\t};\n\t\t\t\ttoken = lexer.peek();\n\t\t\t}\n\t\t\treturn expr;\n\t\t}\n\n\t\tfunction parseUnary() {\n\t\t\tvar token, expr;\n\t\t\ttoken = lexer.peek();\n\t\t\tif (matchGroup(token, \"unary\")) {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\texpr = parseUnary();\n\t\t\t\treturn {\n\t\t\t\t\toperator: token.value,\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : [expr]\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn parsePrimary();\n\t\t}\n\n\t\tfunction parsePrimary() {\n\t\t\tvar token, expr;\n\t\t\ttoken = lexer.peek();\n\t\t\tif (isUndef(token)) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Unexpected termination of expression\");\n\t\t\t}\n\t\t\tif (token.type === \"func\") {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\treturn parseFunctionCall(token);\n\t\t\t}\n\t\t\tif (token.type === \"value\") {\n\t\t\t\ttoken = lexer.next();\n\t\t\t\treturn {\n\t\t\t\t\tmethod : token.method,\n\t\t\t\t\targs : token.value\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (matchSyntax(token, \"(\")) {\n\t\t\t\tlexer.next();\n\t\t\t\texpr = parseExpression();\n\t\t\t\ttoken = lexer.next();\n\t\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\t\tthrow new SyntaxError(\"Expected )\");\n\t\t\t\t}\n\t\t\t\treturn expr;\n\t\t\t}\n\t\t\tthrow new SyntaxError(\"Tone.Expr: Parse error, cannot process token \" + token.value);\n\t\t}\n\n\t\tfunction parseFunctionCall(func) {\n\t\t\tvar token, args = [];\n\t\t\ttoken = lexer.next();\n\t\t\tif (!matchSyntax(token, \"(\")) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Expected ( in a function call \\\"\" + func.value + \"\\\"\");\n\t\t\t}\n\t\t\ttoken = lexer.peek();\n\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\targs = parseArgumentList();\n\t\t\t}\n\t\t\ttoken = lexer.next();\n\t\t\tif (!matchSyntax(token, \")\")) {\n\t\t\t\tthrow new SyntaxError(\"Tone.Expr: Expected ) in a function call \\\"\" + func.value + \"\\\"\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tmethod : func.method,\n\t\t\t\targs : args,\n\t\t\t\tname : name\n\t\t\t};\n\t\t}\n\n\t\tfunction parseArgumentList() {\n\t\t\tvar token, expr, args = [];\n\t\t\twhile (true) {\n\t\t\t\texpr = parseExpression();\n\t\t\t\tif (isUndef(expr)) {\n\t\t\t\t\t// TODO maybe throw exception?\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\targs.push(expr);\n\t\t\t\ttoken = lexer.peek();\n\t\t\t\tif (!matchSyntax(token, \",\")) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tlexer.next();\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\n\t\treturn parseExpression();\n\t};\n\n\t/**\n\t * recursively evaluate the expression tree\n\t * @param {Object} tree \n\t * @return {AudioNode} the resulting audio node from the expression\n\t * @private\n\t */\n\tTone.Expr.prototype._eval = function(tree){\n\t\tif (!this.isUndef(tree)){\n\t\t\tvar node = tree.method(tree.args, this);\n\t\t\tthis._nodes.push(node);\n\t\t\treturn node;\n\t\t} \n\t};\n\n\t/**\n\t * dispose all the nodes\n\t * @private\n\t */\n\tTone.Expr.prototype._disposeNodes = function(){\n\t\tfor (var i = 0; i < this._nodes.length; i++){\n\t\t\tvar node = this._nodes[i];\n\t\t\tif (this.isFunction(node.dispose)) {\n\t\t\t\tnode.dispose();\n\t\t\t} else if (this.isFunction(node.disconnect)) {\n\t\t\t\tnode.disconnect();\n\t\t\t}\n\t\t\tnode = null;\n\t\t\tthis._nodes[i] = null;\n\t\t}\n\t\tthis._nodes = null;\n\t};\n\n\t/**\n\t * clean up\n\t */\n\tTone.Expr.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._disposeNodes();\n\t};\n\n\treturn Tone.Expr;\n});","define([\"Tone/core/Tone\", \"Tone/signal/GreaterThanZero\", \"Tone/signal/Subtract\", \"Tone/signal/Signal\"], \n\tfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Output 1 if the signal is greater than the value, otherwise outputs 0.\n\t * can compare two signals or a signal and a number. \n\t * \n\t * @constructor\n\t * @extends {Tone.Signal}\n\t * @param {number} [value=0] the value to compare to the incoming signal\n\t * @example\n\t * var gt = new Tone.GreaterThan(2);\n\t * var sig = new Tone.Signal(4).connect(gt);\n\t * //output of gt is equal 1. \n\t */\n\tTone.GreaterThan = function(value){\n\n\t\tthis.createInsOuts(2, 0);\n\t\t\n\t\t/**\n\t\t * subtract the amount from the incoming signal\n\t\t * @type {Tone.Subtract}\n\t\t * @private\n\t\t */\n\t\tthis._param = this.input[0] = new Tone.Subtract(value);\n\t\tthis.input[1] = this._param.input[1];\n\n\t\t/**\n\t\t * compare that amount to zero\n\t\t * @type {Tone.GreaterThanZero}\n\t\t * @private\n\t\t */\n\t\tthis._gtz = this.output = new Tone.GreaterThanZero();\n\n\t\t//connect\n\t\tthis._param.connect(this._gtz);\n\t};\n\n\tTone.extend(Tone.GreaterThan, Tone.Signal);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.GreaterThan} this\n\t */\n\tTone.GreaterThan.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._param.dispose();\n\t\tthis._param = null;\n\t\tthis._gtz.dispose();\n\t\tthis._gtz = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.GreaterThan;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/SignalBase\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Return the absolute value of an incoming signal. \n\t * \n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @example\n\t * var signal = new Tone.Signal(-1);\n\t * var abs = new Tone.Abs();\n\t * signal.connect(abs);\n\t * //the output of abs is 1. \n\t */\n\tTone.Abs = function(){\n\t\t/**\n\t\t * @type {Tone.LessThan}\n\t\t * @private\n\t\t */\n\t\tthis._abs = this.input = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (val === 0){\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn Math.abs(val);\n\t\t\t}\n\t\t}, 127);\n\t};\n\n\tTone.extend(Tone.Abs, Tone.SignalBase);\n\n\t/**\n\t * dispose method\n\t * @returns {Tone.Abs} this\n\t */\n\tTone.Abs.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._abs.dispose();\n\t\tthis._abs = null;\n\t\treturn this;\n\t}; \n\n\treturn Tone.Abs;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/Multiply\", \"Tone/signal/Subtract\"], \nfunction(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Signal-rate modulo operator. Only works in AudioRange [-1, 1] and for modulus\n\t * values in the NormalRange. \n\t *\n\t * @constructor\n\t * @extends {Tone.SignalBase}\n\t * @param {NormalRange} modulus The modulus to apply.\n\t * @example\n\t * var mod = new Tone.Modulo(0.2)\n\t * var sig = new Tone.Signal(0.5).connect(mod);\n\t * //mod outputs 0.1\n\t */\n\tTone.Modulo = function(modulus){\n\n\t\tthis.createInsOuts(1, 0);\n\n\t\t/**\n\t\t * A waveshaper gets the integer multiple of \n\t\t * the input signal and the modulus.\n\t\t * @private\n\t\t * @type {Tone.WaveShaper}\n\t\t */\n\t\tthis._shaper = new Tone.WaveShaper(Math.pow(2, 16));\n\n\t\t/**\n\t\t * the integer multiple is multiplied by the modulus\n\t\t * @type {Tone.Multiply}\n\t\t * @private\n\t\t */\n\t\tthis._multiply = new Tone.Multiply();\n\n\t\t/**\n\t\t * and subtracted from the input signal\n\t\t * @type {Tone.Subtract}\n\t\t * @private\n\t\t */\n\t\tthis._subtract = this.output = new Tone.Subtract();\n\n\t\t/**\n\t\t * the modulus signal\n\t\t * @type {Tone.Signal}\n\t\t * @private\n\t\t */\n\t\tthis._modSignal = new Tone.Signal(modulus);\n\n\t\t//connections\n\t\tthis.input.fan(this._shaper, this._subtract);\n\t\tthis._modSignal.connect(this._multiply, 0, 0);\n\t\tthis._shaper.connect(this._multiply, 0, 1);\n\t\tthis._multiply.connect(this._subtract, 0, 1);\n\t\tthis._setWaveShaper(modulus);\n\t};\n\n\tTone.extend(Tone.Modulo, Tone.SignalBase);\n\n\t/**\n\t * @param {number} mod the modulus to apply\n\t * @private\n\t */\n\tTone.Modulo.prototype._setWaveShaper = function(mod){\n\t\tthis._shaper.setMap(function(val){\n\t\t\tvar multiple = Math.floor((val + 0.0001) / mod);\n\t\t\treturn multiple;\n\t\t});\n\t};\n\n\t/**\n\t * The modulus value.\n\t * @memberOf Tone.Modulo#\n\t * @type {NormalRange}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Modulo.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._modSignal.value;\n\t\t},\n\t\tset : function(mod){\n\t\t\tthis._modSignal.value = mod;\n\t\t\tthis._setWaveShaper(mod);\n\t\t}\n\t});\n\n\t/**\n\t * clean up\n\t * @returns {Tone.Modulo} this\n\t */\n\tTone.Modulo.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._shaper.dispose();\n\t\tthis._shaper = null;\n\t\tthis._multiply.dispose();\n\t\tthis._multiply = null;\n\t\tthis._subtract.dispose();\n\t\tthis._subtract = null;\n\t\tthis._modSignal.dispose();\n\t\tthis._modSignal = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Modulo;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Pow applies an exponent to the incoming signal. The incoming signal\n\t * must be AudioRange.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @param {Positive} exp The exponent to apply to the incoming signal, must be at least 2. \n\t * @example\n\t * var pow = new Tone.Pow(2);\n\t * var sig = new Tone.Signal(0.5).connect(pow);\n\t * //output of pow is 0.25. \n\t */\n\tTone.Pow = function(exp){\n\n\t\t/**\n\t\t * the exponent\n\t\t * @private\n\t\t * @type {number}\n\t\t */\n\t\tthis._exp = this.defaultArg(exp, 1);\n\n\t\t/**\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._expScaler = this.input = this.output = new Tone.WaveShaper(this._expFunc(this._exp), 8192);\n\t};\n\n\tTone.extend(Tone.Pow, Tone.SignalBase);\n\n\t/**\n\t * The value of the exponent.\n\t * @memberOf Tone.Pow#\n\t * @type {number}\n\t * @name value\n\t */\n\tObject.defineProperty(Tone.Pow.prototype, \"value\", {\n\t\tget : function(){\n\t\t\treturn this._exp;\n\t\t},\n\t\tset : function(exp){\n\t\t\tthis._exp = exp;\n\t\t\tthis._expScaler.setMap(this._expFunc(this._exp));\n\t\t}\n\t});\n\n\n\t/**\n\t * the function which maps the waveshaper\n\t * @param {number} exp\n\t * @return {function}\n\t * @private\n\t */\n\tTone.Pow.prototype._expFunc = function(exp){\n\t\treturn function(val){\n\t\t\treturn Math.pow(Math.abs(val), exp);\n\t\t};\n\t};\n\n\t/**\n\t * Clean up.\n\t * @returns {Tone.Pow} this\n\t */\n\tTone.Pow.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._expScaler.dispose();\n\t\tthis._expScaler = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.Pow;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\", \"Tone/signal/Signal\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1]. \n\t * See Tone.GainToAudio.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @example\n\t * var a2g = new Tone.AudioToGain();\n\t */\n\tTone.AudioToGain = function(){\n\n\t\t/**\n\t\t * @type {WaveShaperNode}\n\t\t * @private\n\t\t */\n\t\tthis._norm = this.input = this.output = new Tone.WaveShaper(function(x){\n\t\t\treturn (x + 1) / 2;\n\t\t});\n\t};\n\n\tTone.extend(Tone.AudioToGain, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.AudioToGain} this\n\t */\n\tTone.AudioToGain.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._norm.dispose();\n\t\tthis._norm = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.AudioToGain;\n});","define([\"Tone/core/Tone\", \"Tone/signal/WaveShaper\"], function(Tone){\n\n\t\"use strict\";\n\n\t/**\n\t * @class Convert an incoming signal between 0, 1 to an equal power gain scale.\n\t *\n\t * @extends {Tone.SignalBase}\n\t * @constructor\n\t * @example\n\t * var eqPowGain = new Tone.EqualPowerGain();\n\t */\n\tTone.EqualPowerGain = function(){\n\n\t\t/**\n\t\t * @type {Tone.WaveShaper}\n\t\t * @private\n\t\t */\n\t\tthis._eqPower = this.input = this.output = new Tone.WaveShaper(function(val){\n\t\t\tif (Math.abs(val) < 0.001){\n\t\t\t\t//should output 0 when input is 0\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn this.equalPowerScale(val);\n\t\t\t}\n\t\t}.bind(this), 4096);\n\t};\n\n\tTone.extend(Tone.EqualPowerGain, Tone.SignalBase);\n\n\t/**\n\t * clean up\n\t * @returns {Tone.EqualPowerGain} this\n\t */\n\tTone.EqualPowerGain.prototype.dispose = function(){\n\t\tTone.prototype.dispose.call(this);\n\t\tthis._eqPower.dispose();\n\t\tthis._eqPower = null;\n\t\treturn this;\n\t};\n\n\treturn Tone.EqualPowerGain;\n});","define([\"Tone/core/Tone\", \"Tone/core/Timeline\", \"Tone/type/Type\"], function (Tone) {\n\n\t\"use strict\";\n\n\t/**\n\t * @class A Timeline State. Provides the methods: setStateAtTime(\"state\", time)\n\t * and getValueAtTime(time).\n\t *\n\t * @extends {Tone.Timeline}\n\t * @param {String} initial The initial state of the TimelineState. \n\t * Defaults to undefined\n\t */\n\tTone.TimelineState = function(initial){\n\n\t\tTone.Timeline.call(this);\n\n\t\t/**\n\t\t * The initial state\n\t\t * @private\n\t\t * @type {String}\n\t\t */\n\t\tthis._initial = initial;\n\t};\n\n\tTone.extend(Tone.TimelineState, Tone.Timeline);\n\n\t/**\n\t * Returns the scheduled state scheduled before or at\n\t * the given time.\n\t * @param {Number} time The time to query.\n\t * @return {String} The name of the state input in setStateAtTime.\n\t */\n\tTone.TimelineState.prototype.getValueAtTime = function(time){\n\t\tvar event = this.get(time);\n\t\tif (event !== null){\n\t\t\treturn event.state;\n\t\t} else {\n\t\t\treturn this._initial;\n\t\t}\n\t};\n\n\t/**\n\t * Returns the scheduled state scheduled before or at\n\t * the given time.\n\t * @param {String} state The name of the state to set.\n\t * @param {Number} time The time to query.\n\t */\n\tTone.TimelineState.prototype.setStateAtTime = function(state, time){\n\t\tthis.add({\n\t\t\t\"state\" : state,\n\t\t\t\"time\" : time\n\t\t});\n\t};\n\n\treturn Tone.TimelineState;\n});","import audiocontext from './audiocontext.js';\n\n// P5Sound contains the final sound output bus.\nclass Main {\n constructor() {\n this.input = audiocontext.createGain();\n this.output = audiocontext.createGain();\n\n //put a hard limiter on the output\n this.limiter = audiocontext.createDynamicsCompressor();\n this.limiter.threshold.value = -3;\n this.limiter.ratio.value = 20;\n this.limiter.knee.value = 1;\n\n this.audiocontext = audiocontext;\n\n this.output.disconnect();\n\n // connect input to limiter\n this.input.connect(this.limiter);\n\n // connect limiter to output\n this.limiter.connect(this.output);\n\n // meter is just for global Amplitude / FFT analysis\n this.meter = audiocontext.createGain();\n this.fftMeter = audiocontext.createGain();\n this.output.connect(this.meter);\n this.output.connect(this.fftMeter);\n\n // connect output to destination\n this.output.connect(this.audiocontext.destination);\n\n // an array of all sounds in the sketch\n this.soundArray = [];\n // an array of all musical parts in the sketch\n this.parts = [];\n\n // file extensions to search for\n this.extensions = [];\n }\n}\n\n// create a single instance of the p5Sound main output for use within this sketch\nconst p5sound = new Main();\n\n/**\n * Returns a number representing the output volume for sound\n * in this sketch.\n *\n * @method getOutputVolume\n * @return {Number} Output volume for sound in this sketch.\n * Should be between 0.0 (silence) and 1.0.\n */\np5.prototype.getOutputVolume = function () {\n return p5sound.output.gain.value;\n};\n\n/**\n *

Scale the output of all sound in this sketch

\n * Scaled between 0.0 (silence) and 1.0 (full volume).\n * 1.0 is the maximum amplitude of a digital sound, so multiplying\n * by greater than 1.0 may cause digital distortion. To\n * fade, provide a rampTime parameter. For more\n * complex fades, see the Envelope class.\n *\n * Alternately, you can pass in a signal source such as an\n * oscillator to modulate the amplitude with an audio signal.\n *\n *

How This Works: When you load the p5.sound module, it\n * creates a single instance of p5sound. All sound objects in this\n * module output to p5sound before reaching your computer's output.\n * So if you change the amplitude of p5sound, it impacts all of the\n * sound in this module.

\n *\n *

If no value is provided, returns a Web Audio API Gain Node

\n *\n * @method outputVolume\n * @param {Number|Object} volume Volume (amplitude) between 0.0\n * and 1.0 or modulating signal/oscillator\n * @param {Number} [rampTime] Fade for t seconds\n * @param {Number} [timeFromNow] Schedule this event to happen at\n * t seconds in the future\n */\np5.prototype.outputVolume = function (vol, rampTime = 0, tFromNow = 0) {\n if (typeof vol === 'number') {\n var now = p5sound.audiocontext.currentTime;\n var currentVol = p5sound.output.gain.value;\n p5sound.output.gain.cancelScheduledValues(now + tFromNow);\n p5sound.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n p5sound.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(p5sound.output.gain);\n } else {\n // return the Gain Node\n return p5sound.output.gain;\n }\n};\n\n/**\n * `p5.soundOut` is the p5.sound final output bus. It sends output to\n * the destination of this window's web audio context. It contains\n * Web Audio API nodes including a dyanmicsCompressor (.limiter),\n * and Gain Nodes for .input and .output.\n *\n * @property {Object} soundOut\n */\np5.prototype.soundOut = p5.soundOut = p5sound;\n\n// a silent connection to the DesinationNode\n// which will ensure that anything connected to it\n// will not be garbage collected\np5.soundOut._silentNode = p5sound.audiocontext.createGain();\np5.soundOut._silentNode.gain.value = 0;\np5.soundOut._silentNode.connect(p5sound.audiocontext.destination);\n\nexport default p5sound;\n","import p5sound from './main';\nimport processorNames from './audioWorklet/processorNames';\n/**\n * @for p5\n */\n\n/**\n * Returns a number representing the sample rate, in samples per second,\n * of all sound objects in this audio context. It is determined by the\n * sampling rate of your operating system's sound card, and it is not\n * currently possile to change.\n * It is often 44100, or twice the range of human hearing.\n *\n * @method sampleRate\n * @return {Number} samplerate samples per second\n */\nfunction sampleRate() {\n return p5sound.audiocontext.sampleRate;\n}\n\n/**\n * Returns the closest MIDI note value for\n * a given frequency.\n *\n * @method freqToMidi\n * @param {Number} frequency A freqeuncy, for example, the \"A\"\n * above Middle C is 440Hz\n * @return {Number} MIDI note value\n */\nfunction freqToMidi(f) {\n var mathlog2 = Math.log(f / 440) / Math.log(2);\n var m = Math.round(12 * mathlog2) + 69;\n return m;\n}\n\n/**\n * Returns the frequency value of a MIDI note value.\n * General MIDI treats notes as integers where middle C\n * is 60, C# is 61, D is 62 etc. Useful for generating\n * musical frequencies with oscillators.\n *\n * @method midiToFreq\n * @param {Number} midiNote The number of a MIDI note\n * @return {Number} Frequency value of the given MIDI note\n * @example\n *
\n * let midiNotes = [60, 64, 67, 72];\n * let noteIndex = 0;\n * let midiVal, freq;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startSound);\n * osc = new p5.TriOsc();\n * env = new p5.Envelope();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 10, 20);\n * if (midiVal) {\n * text('MIDI: ' + midiVal, 10, 40);\n * text('Freq: ' + freq, 10, 60);\n * }\n * }\n *\n * function startSound() {\n * // see also: userStartAudio();\n * osc.start();\n *\n * midiVal = midiNotes[noteIndex % midiNotes.length];\n * freq = midiToFreq(midiVal);\n * osc.freq(freq);\n * env.ramp(osc, 0, 1.0, 0);\n *\n * noteIndex++;\n * }\n *
\n */\nfunction midiToFreq(m) {\n return 440 * Math.pow(2, (m - 69) / 12.0);\n}\n\n// This method converts ANSI notes specified as a string \"C4\", \"Eb3\" to a frequency\nfunction noteToFreq(note) {\n if (typeof note !== 'string') {\n return note;\n }\n var wholeNotes = { A: 21, B: 23, C: 24, D: 26, E: 28, F: 29, G: 31 };\n var value = wholeNotes[note[0].toUpperCase()];\n var octave = ~~note.slice(-1);\n value += 12 * (octave - 1);\n\n switch (note[1]) {\n case '#':\n value += 1;\n break;\n case 'b':\n value -= 1;\n break;\n default:\n break;\n }\n return midiToFreq(value);\n}\n\n/**\n * List the SoundFile formats that you will include. LoadSound\n * will search your directory for these extensions, and will pick\n * a format that is compatable with the client's web browser.\n * Here is a free online file\n * converter.\n *\n * @method soundFormats\n * @param {String} [...formats] i.e. 'mp3', 'wav', 'ogg'\n * @example\n *
\n * function preload() {\n * // set the global sound formats\n * soundFormats('mp3', 'ogg');\n *\n * // load either beatbox.mp3, or .ogg, depending on browser\n * mySound = loadSound('assets/beatbox.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * text('sound loaded! tap to play', 10, 20, width - 20);\n * cnv.mousePressed(function() {\n * mySound.play();\n * });\n * }\n *
\n */\n\nfunction soundFormats() {\n // reset extensions array\n p5sound.extensions = [];\n // add extensions\n for (var i = 0; i < arguments.length; i++) {\n arguments[i] = arguments[i].toLowerCase();\n if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(arguments[i]) > -1) {\n p5sound.extensions.push(arguments[i]);\n } else {\n throw arguments[i] + ' is not a valid sound format!';\n }\n }\n}\n\nfunction disposeSound() {\n for (var i = 0; i < p5sound.soundArray.length; i++) {\n p5sound.soundArray[i].dispose();\n }\n}\n\nfunction _checkFileFormats(paths) {\n var path;\n // if path is a single string, check to see if extension is provided\n if (typeof paths === 'string') {\n path = paths;\n // see if extension is provided\n var extTest = path.split('.').pop();\n // if an extension is provided...\n if (['mp3', 'wav', 'ogg', 'm4a', 'aac'].indexOf(extTest) > -1) {\n if (!p5.prototype.isFileSupported(extTest)) {\n var pathSplit = path.split('.');\n var pathCore = pathSplit[pathSplit.length - 1];\n for (let i = 0; i < p5sound.extensions.length; i++) {\n const extension = p5sound.extensions[i];\n const supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n pathCore = '';\n if (pathSplit.length === 2) {\n pathCore += pathSplit[0];\n }\n for (let i = 1; i <= pathSplit.length - 2; i++) {\n var p = pathSplit[i];\n pathCore += '.' + p;\n }\n path = pathCore += '.';\n path = path += extension;\n break;\n }\n }\n }\n }\n // if no extension is provided...\n else {\n for (let i = 0; i < p5sound.extensions.length; i++) {\n const extension = p5sound.extensions[i];\n const supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n path = path + '.' + extension;\n break;\n }\n }\n }\n } // end 'if string'\n\n // path can either be a single string, or an array\n else if (typeof paths === 'object') {\n for (var i = 0; i < paths.length; i++) {\n var extension = paths[i].split('.').pop();\n var supported = p5.prototype.isFileSupported(extension);\n if (supported) {\n // console.log('.'+extension + ' is ' + supported +\n // ' supported by your browser.');\n path = paths[i];\n break;\n }\n }\n }\n return path;\n}\n\n/**\n * Used by Osc and Envelope to chain signal math\n */\nfunction _mathChain(o, math, thisChain, nextChain, type) {\n // if this type of math already exists in the chain, replace it\n for (var i in o.mathOps) {\n if (o.mathOps[i] instanceof type) {\n o.mathOps[i].dispose();\n thisChain = i;\n if (thisChain < o.mathOps.length - 1) {\n nextChain = o.mathOps[i + 1];\n }\n }\n }\n o.mathOps[thisChain - 1].disconnect();\n o.mathOps[thisChain - 1].connect(math);\n math.connect(nextChain);\n o.mathOps[thisChain] = math;\n return o;\n}\n\n// helper methods to convert audio file as .wav format,\n// will use as saving .wav file and saving blob object\n// Thank you to Matt Diamond's RecorderJS (MIT License)\n// https://github.com/mattdiamond/Recorderjs\nfunction convertToWav(audioBuffer) {\n var leftChannel, rightChannel;\n leftChannel = audioBuffer.getChannelData(0);\n\n // handle mono files\n if (audioBuffer.numberOfChannels > 1) {\n rightChannel = audioBuffer.getChannelData(1);\n } else {\n rightChannel = leftChannel;\n }\n\n var interleaved = interleave(leftChannel, rightChannel);\n\n // create the buffer and view to create the .WAV file\n var buffer = new window.ArrayBuffer(44 + interleaved.length * 2);\n var view = new window.DataView(buffer);\n\n // write the WAV container,\n // check spec at: https://web.archive.org/web/20171215131933/http://tiny.systems/software/soundProgrammer/WavFormatDocs.pdf\n\n // RIFF chunk descriptor\n writeUTFBytes(view, 0, 'RIFF');\n view.setUint32(4, 36 + interleaved.length * 2, true);\n writeUTFBytes(view, 8, 'WAVE');\n // FMT sub-chunk\n writeUTFBytes(view, 12, 'fmt ');\n view.setUint32(16, 16, true);\n view.setUint16(20, 1, true);\n // stereo (2 channels)\n view.setUint16(22, 2, true);\n view.setUint32(24, p5sound.audiocontext.sampleRate, true);\n view.setUint32(28, p5sound.audiocontext.sampleRate * 4, true);\n view.setUint16(32, 4, true);\n view.setUint16(34, 16, true);\n // data sub-chunk\n writeUTFBytes(view, 36, 'data');\n view.setUint32(40, interleaved.length * 2, true);\n\n // write the PCM samples\n var lng = interleaved.length;\n var index = 44;\n var volume = 1;\n for (var i = 0; i < lng; i++) {\n view.setInt16(index, interleaved[i] * (0x7fff * volume), true);\n index += 2;\n }\n\n return view;\n}\n\n// helper methods to save waves\nfunction interleave(leftChannel, rightChannel) {\n var length = leftChannel.length + rightChannel.length;\n var result = new Float32Array(length);\n\n var inputIndex = 0;\n\n for (var index = 0; index < length; ) {\n result[index++] = leftChannel[inputIndex];\n result[index++] = rightChannel[inputIndex];\n inputIndex++;\n }\n return result;\n}\n\nfunction writeUTFBytes(view, offset, string) {\n var lng = string.length;\n for (var i = 0; i < lng; i++) {\n view.setUint8(offset + i, string.charCodeAt(i));\n }\n}\n\nfunction safeBufferSize(idealBufferSize) {\n let bufferSize = idealBufferSize;\n\n // if the AudioWorkletNode is actually a ScriptProcessorNode created via polyfill,\n // make sure that our chosen buffer size isn't smaller than the buffer size automatically\n // selected by the polyfill\n // reference: https://github.com/GoogleChromeLabs/audioworklet-polyfill/issues/13#issuecomment-425014930\n let tempAudioWorkletNode = new AudioWorkletNode(\n p5sound.audiocontext,\n processorNames.soundFileProcessor\n );\n if (tempAudioWorkletNode instanceof ScriptProcessorNode) {\n bufferSize = tempAudioWorkletNode.bufferSize;\n }\n tempAudioWorkletNode.disconnect();\n tempAudioWorkletNode = null;\n\n return bufferSize;\n}\n\n/**\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\n * to download the file to their device.\n * For uploading audio to a server, use\n * `p5.SoundFile.saveBlob`.\n *\n * @for p5\n * @method saveSound\n * @param {p5.SoundFile} soundFile p5.SoundFile that you wish to save\n * @param {String} fileName name of the resulting .wav file.\n */\n// add to p5.prototype as this is used by the p5 `save()` method.\nfunction saveSound(soundFile, fileName) {\n const dataView = convertToWav(soundFile.buffer);\n p5.prototype.writeFile([dataView], fileName, 'wav');\n}\n\nexport {\n sampleRate,\n freqToMidi,\n midiToFreq,\n noteToFreq,\n soundFormats,\n disposeSound,\n _checkFileFormats,\n _mathChain,\n convertToWav,\n interleave,\n writeUTFBytes,\n safeBufferSize,\n saveSound,\n};\n","/*\n Helper function to generate an error\n with a custom stack trace that points to the sketch\n and removes other parts of the stack trace.\n\n @private\n @class customError\n @constructor\n @param {String} name custom error name\n @param {String} errorTrace custom error trace\n @param {String} failedPath path to the file that failed to load\n @property {String} name custom error name\n @property {String} message custom error message\n @property {String} stack trace the error back to a line in the user's sketch.\n Note: this edits out stack trace within p5.js and p5.sound.\n @property {String} originalStack unedited, original stack trace\n @property {String} failedPath path to the file that failed to load\n @return {Error} returns a custom Error object\n */\nvar CustomError = function (name, errorTrace, failedPath) {\n var err = new Error();\n var tempStack, splitStack;\n\n err.name = name;\n err.originalStack = err.stack + errorTrace;\n tempStack = err.stack + errorTrace;\n err.failedPath = failedPath;\n\n // only print the part of the stack trace that refers to the user code:\n splitStack = tempStack.split('\\n').filter(function (ln) {\n return !ln.match(/(p5.|native code|globalInit)/g);\n });\n err.stack = splitStack.join('\\n');\n\n return err; // TODO: is this really a constructor?\n};\nexport default CustomError;\n","import p5sound from '../main.js';\nconst moduleSources = [\n require('raw-loader!./recorderProcessor').default,\n require('raw-loader!./soundFileProcessor').default,\n require('raw-loader!./amplitudeProcessor').default,\n];\nconst ac = p5sound.audiocontext;\nlet initializedAudioWorklets = false;\n\nfunction loadAudioWorkletModules() {\n return Promise.all(\n moduleSources.map(function (moduleSrc) {\n const blob = new Blob([moduleSrc], { type: 'application/javascript' });\n const objectURL = URL.createObjectURL(blob);\n return ac.audioWorklet.addModule(objectURL);\n })\n );\n}\n\np5.prototype.registerMethod('init', function () {\n if (initializedAudioWorklets) return;\n // ensure that a preload function exists so that p5 will wait for preloads to finish\n if (!this.preload && !window.preload) {\n this.preload = function () {};\n }\n\n // use p5's preload system to load necessary AudioWorklet modules before setup()\n this._incrementPreload();\n const onWorkletModulesLoad = function () {\n initializedAudioWorklets = true;\n this._decrementPreload();\n }.bind(this);\n loadAudioWorkletModules().then(onWorkletModulesLoad);\n});\n","import p5sound from './main';\nvar ac = p5sound.audiocontext;\nvar panner;\n// Stereo panner\n// if there is a stereo panner node use it\nif (typeof ac.createStereoPanner !== 'undefined') {\n class Panner {\n constructor(input, output) {\n this.stereoPanner = this.input = ac.createStereoPanner();\n input.connect(this.stereoPanner);\n this.stereoPanner.connect(output);\n }\n\n pan(val, tFromNow) {\n var time = tFromNow || 0;\n var t = ac.currentTime + time;\n\n this.stereoPanner.pan.linearRampToValueAtTime(val, t);\n }\n\n //not implemented because stereopanner\n //node does not require this and will automatically\n //convert single channel or multichannel to stereo.\n //tested with single and stereo, not with (>2) multichannel\n inputChannels() {}\n\n connect(obj) {\n this.stereoPanner.connect(obj);\n }\n\n disconnect() {\n if (this.stereoPanner) {\n this.stereoPanner.disconnect();\n }\n }\n }\n\n panner = Panner;\n} else {\n // if there is no createStereoPanner object\n // such as in safari 7.1.7 at the time of writing this\n // use this method to create the effect\n class Panner {\n constructor(input, output, numInputChannels) {\n this.input = ac.createGain();\n input.connect(this.input);\n\n this.left = ac.createGain();\n this.right = ac.createGain();\n this.left.channelInterpretation = 'discrete';\n this.right.channelInterpretation = 'discrete';\n\n // if input is stereo\n if (numInputChannels > 1) {\n this.splitter = ac.createChannelSplitter(2);\n this.input.connect(this.splitter);\n\n this.splitter.connect(this.left, 1);\n this.splitter.connect(this.right, 0);\n } else {\n this.input.connect(this.left);\n this.input.connect(this.right);\n }\n\n this.output = ac.createChannelMerger(2);\n this.left.connect(this.output, 0, 1);\n this.right.connect(this.output, 0, 0);\n this.output.connect(output);\n }\n\n // -1 is left, +1 is right\n pan(val, tFromNow) {\n var time = tFromNow || 0;\n var t = ac.currentTime + time;\n var v = (val + 1) / 2;\n var rightVal = Math.cos((v * Math.PI) / 2);\n var leftVal = Math.sin((v * Math.PI) / 2);\n this.left.gain.linearRampToValueAtTime(leftVal, t);\n this.right.gain.linearRampToValueAtTime(rightVal, t);\n }\n\n inputChannels(numChannels) {\n if (numChannels === 1) {\n this.input.disconnect();\n this.input.connect(this.left);\n this.input.connect(this.right);\n } else if (numChannels === 2) {\n if (typeof this.splitter === 'undefined') {\n this.splitter = ac.createChannelSplitter(2);\n }\n this.input.disconnect();\n this.input.connect(this.splitter);\n this.splitter.connect(this.left, 1);\n this.splitter.connect(this.right, 0);\n }\n }\n\n connect(obj) {\n this.output.connect(obj);\n }\n\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n }\n panner = Panner;\n}\n\nexport default panner;\n","import CustomError from './errorHandler';\nimport p5sound from './main';\nimport { midiToFreq, convertToWav, safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\nimport Panner from './panner';\n\nconst ac = p5sound.audiocontext;\n\nvar _createCounterBuffer = function (buffer) {\n const len = buffer.length;\n const audioBuf = ac.createBuffer(1, buffer.length, ac.sampleRate);\n const arrayBuffer = audioBuf.getChannelData(0);\n for (var index = 0; index < len; index++) {\n arrayBuffer[index] = index;\n }\n return audioBuf;\n};\n\n/*** SCHEDULE EVENTS ***/\n\n// Cue inspired by JavaScript setTimeout, and the\n// Tone.js Transport Timeline Event, MIT License Yotam Mann 2015 tonejs.org\nclass Cue {\n constructor(callback, time, id, val) {\n this.callback = callback;\n this.time = time;\n this.id = id;\n this.val = val;\n }\n}\n\n// event handler to remove references to the bufferSourceNode when it is done playing\nfunction _clearOnEnd(e) {\n const thisBufferSourceNode = e.target;\n const soundFile = this;\n\n // delete this.bufferSourceNode from the sources array when it is done playing:\n thisBufferSourceNode._playing = false;\n thisBufferSourceNode.removeEventListener('ended', soundFile._clearOnEnd);\n\n // call the onended callback\n soundFile._onended(soundFile);\n\n // delete bufferSourceNode(s) in soundFile.bufferSourceNodes\n // iterate in reverse order because the index changes by splice\n soundFile.bufferSourceNodes\n .map((_, i) => i)\n .reverse()\n .forEach(function (i) {\n const n = soundFile.bufferSourceNodes[i];\n\n if (n._playing === false) {\n soundFile.bufferSourceNodes.splice(i, 1);\n }\n });\n\n if (soundFile.bufferSourceNodes.length === 0) {\n soundFile._playing = false;\n }\n}\n\n/**\n *

SoundFile object with a path to a file.

\n *\n *

The p5.SoundFile may not be available immediately because\n * it loads the file information asynchronously.

\n *\n *

To do something with the sound as soon as it loads\n * pass the name of a function as the second parameter.

\n *\n *

Only one file path is required. However, audio file formats\n * (i.e. mp3, ogg, wav and m4a/aac) are not supported by all\n * web browsers. If you want to ensure compatability, instead of a single\n * file path, you may include an Array of filepaths, and the browser will\n * choose a format that works.

\n *\n * @class p5.SoundFile\n * @constructor\n * @param {String|Array} path path to a sound file (String). Optionally,\n * you may include multiple file formats in\n * an array. Alternately, accepts an object\n * from the HTML5 File API, or a p5.File.\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if file fails to\n * load. This function will receive an error or\n * XMLHttpRequest object with information\n * about what went wrong.\n * @param {Function} [whileLoadingCallback] Name of a function to call while file\n * is loading. That function will\n * receive progress of the request to\n * load the sound file\n * (between 0 and 1) as its first\n * parameter. This progress\n * does not account for the additional\n * time needed to decode the audio data.\n *\n * @example\n *
\n * let mySound;\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * mySound = loadSound('assets/doorbell');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap here to play', 10, 20);\n * }\n *\n * function canvasPressed() {\n * // playing a sound file on a user gesture\n * // is equivalent to `userStartAudio()`\n * mySound.play();\n * }\n *
\n */\nclass SoundFile {\n constructor(paths, onload, onerror, whileLoading) {\n if (typeof paths !== 'undefined') {\n if (typeof paths === 'string' || typeof paths[0] === 'string') {\n var path = p5.prototype._checkFileFormats(paths);\n this.url = path;\n } else if (typeof paths === 'object') {\n if (\n !(window.File && window.FileReader && window.FileList && window.Blob)\n ) {\n // The File API isn't supported in this browser\n throw 'Unable to load file because the File API is not supported';\n }\n }\n\n // if type is a p5.File...get the actual file\n if (paths.file) {\n paths = paths.file;\n }\n\n this.file = paths;\n }\n\n // private _onended callback, set by the method: onended(callback)\n this._onended = function () {};\n\n this._looping = false;\n this._playing = false;\n this._paused = false;\n this._pauseTime = 0;\n\n // cues for scheduling events with addCue() removeCue()\n this._cues = [];\n this._cueIDCounter = 0;\n\n // position of the most recently played sample\n this._lastPos = 0;\n this._counterNode = null;\n this._workletNode = null;\n\n // array of sources so that they can all be stopped!\n this.bufferSourceNodes = [];\n\n // current source\n this.bufferSourceNode = null;\n\n this.buffer = null;\n this.playbackRate = 1;\n\n this.input = p5sound.audiocontext.createGain();\n this.output = p5sound.audiocontext.createGain();\n\n this.reversed = false;\n\n // start and end of playback / loop\n this.startTime = 0;\n this.endTime = null;\n this.pauseTime = 0;\n\n // \"restart\" would stop playback before retriggering\n this.mode = 'sustain';\n\n // time that playback was started, in millis\n this.startMillis = null;\n\n // stereo panning\n this.panPosition = 0.0;\n this.panner = new Panner(this.output, p5sound.input, 2);\n\n // it is possible to instantiate a soundfile with no path\n if (this.url || this.file) {\n this.load(onload, onerror);\n }\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n\n if (typeof whileLoading === 'function') {\n this._whileLoading = whileLoading;\n } else {\n this._whileLoading = function () {};\n }\n\n this._clearOnEnd = _clearOnEnd.bind(this);\n\n // same as setVolume, to match Processing Sound\n this.amp = this.setVolume;\n\n // these are the same thing\n this.fade = this.setVolume;\n }\n\n /**\n * This is a helper function that the p5.SoundFile calls to load\n * itself. Accepts a callback (the name of another function)\n * as an optional parameter.\n *\n * @private\n * @for p5.SoundFile\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if there is an error\n */\n load(callback, errorCallback) {\n var self = this;\n var errorTrace = new Error().stack;\n\n if (this.url !== undefined && this.url !== '') {\n var request = new XMLHttpRequest();\n request.addEventListener(\n 'progress',\n function (evt) {\n self._updateProgress(evt);\n },\n false\n );\n request.open('GET', this.url, true);\n request.responseType = 'arraybuffer';\n\n request.onload = function () {\n if (request.status === 200) {\n // on sucess loading file:\n if (!self.panner) return;\n ac.decodeAudioData(\n request.response,\n // success decoding buffer:\n function (buff) {\n if (!self.panner) return;\n self.buffer = buff;\n self.panner.inputChannels(buff.numberOfChannels);\n if (callback) {\n callback(self);\n }\n },\n // error decoding buffer. \"e\" is undefined in Chrome 11/22/2015\n function () {\n if (!self.panner) return;\n var err = new CustomError(\n 'decodeAudioData',\n errorTrace,\n self.url\n );\n var msg = 'AudioContext error at decodeAudioData for ' + self.url;\n if (errorCallback) {\n err.msg = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n );\n }\n // if request status != 200, it failed\n else {\n if (!self.panner) return;\n var err = new CustomError('loadSound', errorTrace, self.url);\n var msg =\n 'Unable to load ' +\n self.url +\n '. The request status was: ' +\n request.status +\n ' (' +\n request.statusText +\n ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n };\n\n // if there is another error, aside from 404...\n request.onerror = function () {\n var err = new CustomError('loadSound', errorTrace, self.url);\n var msg =\n 'There was no response from the server at ' +\n self.url +\n '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n };\n\n request.send();\n } else if (this.file !== undefined) {\n var reader = new FileReader();\n reader.onload = function () {\n if (!self.panner) return;\n ac.decodeAudioData(reader.result, function (buff) {\n if (!self.panner) return;\n self.buffer = buff;\n self.panner.inputChannels(buff.numberOfChannels);\n if (callback) {\n callback(self);\n }\n });\n };\n reader.onerror = function (e) {\n if (!self.panner) return;\n if (onerror) {\n onerror(e);\n }\n };\n reader.readAsArrayBuffer(this.file);\n }\n }\n\n // TO DO: use this method to create a loading bar that shows progress during file upload/decode.\n _updateProgress(evt) {\n if (evt.lengthComputable) {\n var percentComplete = (evt.loaded / evt.total) * 0.99;\n this._whileLoading(percentComplete, evt);\n // ...\n } else {\n // Unable to compute progress information since the total size is unknown\n this._whileLoading('size unknown');\n }\n }\n\n /**\n * Returns true if the sound file finished loading successfully.\n *\n * @method isLoaded\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isLoaded() {\n if (this.buffer) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Play the p5.SoundFile\n *\n * @method play\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule playback to start (in seconds from now).\n * @param {Number} [rate] (optional) playback rate\n * @param {Number} [amp] (optional) amplitude (volume)\n * of playback\n * @param {Number} [cueStart] (optional) cue start time in seconds\n * @param {Number} [duration] (optional) duration of playback in seconds\n */\n play(startTime, rate, amp, _cueStart, duration) {\n if (!this.output) {\n console.warn('SoundFile.play() called after dispose');\n return;\n }\n\n var now = p5sound.audiocontext.currentTime;\n var cueStart, cueEnd;\n var time = startTime || 0;\n if (time < 0) {\n time = 0;\n }\n\n time = time + now;\n\n if (typeof rate !== 'undefined') {\n this.rate(rate);\n }\n\n if (typeof amp !== 'undefined') {\n this.setVolume(amp);\n }\n\n // TO DO: if already playing, create array of buffers for easy stop()\n if (this.buffer) {\n // reset the pause time (if it was paused)\n this._pauseTime = 0;\n\n // handle restart playmode\n if (this.mode === 'restart' && this.buffer && this.bufferSourceNode) {\n this.bufferSourceNode.stop(time);\n this._counterNode.stop(time);\n }\n\n //dont create another instance if already playing\n if (this.mode === 'untildone' && this.isPlaying()) {\n return;\n }\n // make a new source and counter. They are automatically assigned playbackRate and buffer\n this.bufferSourceNode = this._initSourceNode();\n\n // garbage collect counterNode and create a new one\n delete this._counterNode;\n this._counterNode = this._initCounterNode();\n\n if (_cueStart) {\n if (_cueStart >= 0 && _cueStart < this.buffer.duration) {\n // this.startTime = cueStart;\n cueStart = _cueStart;\n } else {\n throw 'start time out of range';\n }\n } else {\n cueStart = 0;\n }\n\n if (duration) {\n // if duration is greater than buffer.duration, just play entire file anyway rather than throw an error\n duration =\n duration <= this.buffer.duration - cueStart\n ? duration\n : this.buffer.duration;\n }\n\n // if it was paused, play at the pause position\n if (this._paused) {\n this.bufferSourceNode.start(time, this.pauseTime, duration);\n this._counterNode.start(time, this.pauseTime, duration);\n } else {\n this.bufferSourceNode.start(time, cueStart, duration);\n this._counterNode.start(time, cueStart, duration);\n }\n\n this._playing = true;\n this._paused = false;\n\n // add source to sources array, which is used in stopAll()\n this.bufferSourceNodes.push(this.bufferSourceNode);\n this.bufferSourceNode._arrayIndex = this.bufferSourceNodes.length - 1;\n\n this.bufferSourceNode.addEventListener('ended', this._clearOnEnd);\n }\n // If soundFile hasn't loaded the buffer yet, throw an error\n else {\n throw 'not ready to play file, buffer has yet to load. Try preload()';\n }\n\n // if looping, will restart at original time\n this.bufferSourceNode.loop = this._looping;\n this._counterNode.loop = this._looping;\n\n if (this._looping === true) {\n cueEnd = duration ? duration : cueStart - 0.000000000000001;\n this.bufferSourceNode.loopStart = cueStart;\n this.bufferSourceNode.loopEnd = cueEnd;\n this._counterNode.loopStart = cueStart;\n this._counterNode.loopEnd = cueEnd;\n }\n }\n\n /**\n * p5.SoundFile has two play modes: restart and\n * sustain. Play Mode determines what happens to a\n * p5.SoundFile if it is triggered while in the middle of playback.\n * In sustain mode, playback will continue simultaneous to the\n * new playback. In restart mode, play() will stop playback\n * and start over. With untilDone, a sound will play only if it's\n * not already playing. Sustain is the default mode.\n *\n * @method playMode\n * @for p5.SoundFile\n * @param {String} str 'restart' or 'sustain' or 'untilDone'\n * @example\n *
\n * let mySound;\n * function preload(){\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * noFill();\n * rect(0, height/2, width - 1, height/2 - 1);\n * rect(0, 0, width - 1, height/2);\n * textAlign(CENTER, CENTER);\n * fill(20);\n * text('restart', width/2, 1 * height/4);\n * text('sustain', width/2, 3 * height/4);\n * }\n * function canvasPressed() {\n * if (mouseX < height/2) {\n * mySound.playMode('restart');\n * } else {\n * mySound.playMode('sustain');\n * }\n * mySound.play();\n * }\n *\n *
\n */\n playMode(str) {\n var s = str.toLowerCase();\n\n // if restart, stop all other sounds from playing\n if (s === 'restart' && this.buffer && this.bufferSourceNode) {\n for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {\n var now = p5sound.audiocontext.currentTime;\n this.bufferSourceNodes[i].stop(now);\n }\n }\n\n // set play mode to effect future playback\n if (s === 'restart' || s === 'sustain' || s === 'untildone') {\n this.mode = s;\n } else {\n throw 'Invalid play mode. Must be either \"restart\" or \"sustain\"';\n }\n }\n\n /**\n * Pauses a file that is currently playing. If the file is not\n * playing, then nothing will happen.\n *\n * After pausing, .play() will resume from the paused\n * position.\n * If p5.SoundFile had been set to loop before it was paused,\n * it will continue to loop after it is unpaused with .play().\n *\n * @method pause\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * seconds from now\n * @example\n *
\n * let soundFile;\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play, release to pause', 10, 20, width - 20);\n * }\n * function canvasPressed() {\n * soundFile.loop();\n * background(0, 200, 50);\n * }\n * function mouseReleased() {\n * soundFile.pause();\n * background(220);\n * }\n * \n *
\n */\n pause(startTime) {\n var now = p5sound.audiocontext.currentTime;\n var time = startTime || 0;\n var pTime = time + now;\n\n if (this.isPlaying() && this.buffer && this.bufferSourceNode) {\n this._paused = true;\n this._playing = false;\n\n this.pauseTime = this.currentTime();\n this.bufferSourceNode.stop(pTime);\n this._counterNode.stop(pTime);\n\n this._pauseTime = this.currentTime();\n // TO DO: make sure play() still starts from orig start position\n } else {\n this._pauseTime = 0;\n }\n }\n\n /**\n * Loop the p5.SoundFile. Accepts optional parameters to set the\n * playback rate, playback volume, loopStart, loopEnd.\n *\n * @method loop\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * seconds from now\n * @param {Number} [rate] (optional) playback rate\n * @param {Number} [amp] (optional) playback volume\n * @param {Number} [cueLoopStart] (optional) startTime in seconds\n * @param {Number} [duration] (optional) loop duration in seconds\n * @example\n *
\n * let soundFile;\n * let loopStart = 0.5;\n * let loopDuration = 0.2;\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/Damscray_-_Dancing_Tiger_02.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play, release to pause', 10, 20, width - 20);\n * }\n * function canvasPressed() {\n * soundFile.loop();\n * background(0, 200, 50);\n * }\n * function mouseReleased() {\n * soundFile.pause();\n * background(220);\n * }\n * \n *
\n */\n loop(startTime, rate, amp, loopStart, duration) {\n this._looping = true;\n this.play(startTime, rate, amp, loopStart, duration);\n }\n\n /**\n * Set a p5.SoundFile's looping flag to true or false. If the sound\n * is currently playing, this change will take effect when it\n * reaches the end of the current playback.\n *\n * @method setLoop\n * @for p5.SoundFile\n * @param {Boolean} Boolean set looping to true or false\n */\n setLoop(bool) {\n if (bool === true) {\n this._looping = true;\n } else if (bool === false) {\n this._looping = false;\n } else {\n throw 'Error: setLoop accepts either true or false';\n }\n if (this.bufferSourceNode) {\n this.bufferSourceNode.loop = this._looping;\n this._counterNode.loop = this._looping;\n }\n }\n\n /**\n * Returns 'true' if a p5.SoundFile is currently looping and playing, 'false' if not.\n *\n * @method isLooping\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isLooping() {\n if (!this.bufferSourceNode) {\n return false;\n }\n if (this._looping === true && this.isPlaying() === true) {\n return true;\n }\n return false;\n }\n\n /**\n * Returns true if a p5.SoundFile is playing, false if not (i.e.\n * paused or stopped).\n *\n * @method isPlaying\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isPlaying() {\n return this._playing;\n }\n\n /**\n * Returns true if a p5.SoundFile is paused, false if not (i.e.\n * playing or stopped).\n *\n * @method isPaused\n * @for p5.SoundFile\n * @return {Boolean}\n */\n isPaused() {\n return this._paused;\n }\n\n /**\n * Stop soundfile playback.\n *\n * @method stop\n * @for p5.SoundFile\n * @param {Number} [startTime] (optional) schedule event to occur\n * in seconds from now\n */\n stop(timeFromNow) {\n var time = timeFromNow || 0;\n\n if (this.mode === 'sustain' || this.mode === 'untildone') {\n this.stopAll(time);\n this._playing = false;\n this.pauseTime = 0;\n this._paused = false;\n } else if (this.buffer && this.bufferSourceNode) {\n var now = p5sound.audiocontext.currentTime;\n var t = time || 0;\n this.pauseTime = 0;\n this.bufferSourceNode.stop(now + t);\n this._counterNode.stop(now + t);\n this._playing = false;\n this._paused = false;\n }\n }\n\n /**\n * Stop playback on all of this soundfile's sources.\n * @private\n */\n stopAll(_time) {\n var now = p5sound.audiocontext.currentTime;\n var time = _time || 0;\n if (this.buffer && this.bufferSourceNode) {\n for (var i in this.bufferSourceNodes) {\n const bufferSourceNode = this.bufferSourceNodes[i];\n if (bufferSourceNode) {\n try {\n bufferSourceNode.stop(now + time);\n } catch (e) {\n // this was throwing errors only on Safari\n }\n }\n }\n this._counterNode.stop(now + time);\n }\n }\n\n getVolume() {\n return this.output.gain.value;\n }\n\n /**\n * Set the stereo panning of a p5.sound object to\n * a floating point number between -1.0 (left) and 1.0 (right).\n * Default is 0.0 (center).\n *\n * @method pan\n * @for p5.SoundFile\n * @param {Number} [panValue] Set the stereo panner\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @example\n *
\n * let ballX = 0;\n * let soundFile;\n *\n * function preload() {\n * soundFormats('ogg', 'mp3');\n * soundFile = loadSound('assets/beatbox.mp3');\n * }\n *\n * function draw() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * ballX = constrain(mouseX, 0, width);\n * ellipse(ballX, height/2, 20, 20);\n * }\n *\n * function canvasPressed(){\n * // map the ball's x location to a panning degree\n * // between -1.0 (left) and 1.0 (right)\n * let panning = map(ballX, 0., width,-1.0, 1.0);\n * soundFile.pan(panning);\n * soundFile.play();\n * }\n *
\n */\n pan(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n }\n\n /**\n * Returns the current stereo pan position (-1.0 to 1.0)\n *\n * @method getPan\n * @for p5.SoundFile\n * @return {Number} Returns the stereo pan setting of the Oscillator\n * as a number between -1.0 (left) and 1.0 (right).\n * 0.0 is center and default.\n */\n getPan() {\n return this.panPosition;\n }\n\n /**\n * Set the playback rate of a sound file. Will change the speed and the pitch.\n * Values less than zero will reverse the audio buffer.\n *\n * @method rate\n * @for p5.SoundFile\n * @param {Number} [playbackRate] Set the playback rate. 1.0 is normal,\n * .5 is half-speed, 2.0 is twice as fast.\n * Values less than zero play backwards.\n * @example\n *
\n * let mySound;\n *\n * function preload() {\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * }\n * function canvasPressed() {\n * mySound.loop();\n * }\n * function mouseReleased() {\n * mySound.pause();\n * }\n * function draw() {\n * background(220);\n *\n * // Set the rate to a range between 0.1 and 4\n * // Changing the rate also alters the pitch\n * let playbackRate = map(mouseY, 0.1, height, 2, 0);\n * playbackRate = constrain(playbackRate, 0.01, 4);\n * mySound.rate(playbackRate);\n *\n * line(0, mouseY, width, mouseY);\n * text('rate: ' + round(playbackRate * 100) + '%', 10, 20);\n * }\n *\n * \n *
\n *\n */\n rate(playbackRate) {\n var reverse = false;\n if (typeof playbackRate === 'undefined') {\n return this.playbackRate;\n }\n\n this.playbackRate = playbackRate;\n\n if (playbackRate === 0) {\n playbackRate = 0.0000000000001;\n } else if (playbackRate < 0 && !this.reversed) {\n playbackRate = Math.abs(playbackRate);\n reverse = true;\n } else if (playbackRate > 0 && this.reversed) {\n reverse = true;\n }\n\n if (this.bufferSourceNode) {\n var now = p5sound.audiocontext.currentTime;\n this.bufferSourceNode.playbackRate.cancelScheduledValues(now);\n this.bufferSourceNode.playbackRate.linearRampToValueAtTime(\n Math.abs(playbackRate),\n now\n );\n this._counterNode.playbackRate.cancelScheduledValues(now);\n this._counterNode.playbackRate.linearRampToValueAtTime(\n Math.abs(playbackRate),\n now\n );\n }\n\n if (reverse) {\n this.reverseBuffer();\n }\n return this.playbackRate;\n }\n\n // TO DO: document this\n setPitch(num) {\n var newPlaybackRate = midiToFreq(num) / midiToFreq(60);\n this.rate(newPlaybackRate);\n }\n\n getPlaybackRate() {\n return this.playbackRate;\n }\n\n /**\n * Multiply the output volume (amplitude) of a sound file\n * between 0.0 (silence) and 1.0 (full volume).\n * 1.0 is the maximum amplitude of a digital sound, so multiplying\n * by greater than 1.0 may cause digital distortion. To\n * fade, provide a rampTime parameter. For more\n * complex fades, see the Envelope class.\n *\n * Alternately, you can pass in a signal source such as an\n * oscillator to modulate the amplitude with an audio signal.\n *\n * @method setVolume\n * @for p5.SoundFile\n * @param {Number|Object} volume Volume (amplitude) between 0.0\n * and 1.0 or modulating signal/oscillator\n * @param {Number} [rampTime] Fade for t seconds\n * @param {Number} [timeFromNow] Schedule this event to happen at\n * t seconds in the future\n */\n setVolume(vol, _rampTime, _tFromNow) {\n if (typeof vol === 'number') {\n var rampTime = _rampTime || 0;\n var tFromNow = _tFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now + tFromNow);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(this.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n }\n /**\n * Returns the duration of a sound file in seconds.\n *\n * @method duration\n * @for p5.SoundFile\n * @return {Number} The duration of the soundFile in seconds.\n */\n duration() {\n // Return Duration\n if (this.buffer) {\n return this.buffer.duration;\n } else {\n return 0;\n }\n }\n\n /**\n * Return the current position of the p5.SoundFile playhead, in seconds.\n * Time is relative to the normal buffer direction, so if `reverseBuffer`\n * has been called, currentTime will count backwards.\n *\n * @method currentTime\n * @for p5.SoundFile\n * @return {Number} currentTime of the soundFile in seconds.\n */\n currentTime() {\n return this.reversed\n ? Math.abs(this._lastPos - this.buffer.length) / ac.sampleRate\n : this._lastPos / ac.sampleRate;\n }\n\n /**\n * Move the playhead of a soundfile that is currently playing to a\n * new position and a new duration, in seconds.\n * If none are given, will reset the file to play entire duration\n * from start to finish. To set the position of a soundfile that is\n * not currently playing, use the `play` or `loop` methods.\n *\n * @method jump\n * @for p5.SoundFile\n * @param {Number} cueTime cueTime of the soundFile in seconds.\n * @param {Number} duration duration in seconds.\n */\n jump(cueTime, duration) {\n if (cueTime < 0 || cueTime > this.buffer.duration) {\n throw 'jump time out of range';\n }\n if (duration > this.buffer.duration - cueTime) {\n throw 'end time out of range';\n }\n\n var cTime = cueTime || 0;\n var dur = duration || undefined;\n if (this.isPlaying()) {\n this.stop(0);\n this.play(0, this.playbackRate, this.output.gain.value, cTime, dur);\n }\n }\n\n /**\n * Return the number of channels in a sound file.\n * For example, Mono = 1, Stereo = 2.\n *\n * @method channels\n * @for p5.SoundFile\n * @return {Number} [channels]\n */\n channels() {\n return this.buffer.numberOfChannels;\n }\n\n /**\n * Return the sample rate of the sound file.\n *\n * @method sampleRate\n * @for p5.SoundFile\n * @return {Number} [sampleRate]\n */\n sampleRate() {\n return this.buffer.sampleRate;\n }\n\n /**\n * Return the number of samples in a sound file.\n * Equal to sampleRate * duration.\n *\n * @method frames\n * @for p5.SoundFile\n * @return {Number} [sampleCount]\n */\n frames() {\n return this.buffer.length;\n }\n\n /**\n * Returns an array of amplitude peaks in a p5.SoundFile that can be\n * used to draw a static waveform. Scans through the p5.SoundFile's\n * audio buffer to find the greatest amplitudes. Accepts one\n * parameter, 'length', which determines size of the array.\n * Larger arrays result in more precise waveform visualizations.\n *\n * Inspired by Wavesurfer.js.\n *\n * @method getPeaks\n * @for p5.SoundFile\n * @params {Number} [length] length is the size of the returned array.\n * Larger length results in more precision.\n * Defaults to 5*width of the browser window.\n * @returns {Float32Array} Array of peaks.\n */\n getPeaks(length) {\n if (this.buffer) {\n // set length to window's width if no length is provided\n if (!length) {\n length = window.width * 5;\n }\n if (this.buffer) {\n var buffer = this.buffer;\n var sampleSize = buffer.length / length;\n var sampleStep = ~~(sampleSize / 10) || 1;\n var channels = buffer.numberOfChannels;\n var peaks = new Float32Array(Math.round(length));\n\n for (var c = 0; c < channels; c++) {\n var chan = buffer.getChannelData(c);\n for (var i = 0; i < length; i++) {\n var start = ~~(i * sampleSize);\n var end = ~~(start + sampleSize);\n var max = 0;\n for (var j = start; j < end; j += sampleStep) {\n var value = chan[j];\n if (value > max) {\n max = value;\n // faster than Math.abs\n } else if (-value > max) {\n max = value;\n }\n }\n if (c === 0 || Math.abs(max) > peaks[i]) {\n peaks[i] = max;\n }\n }\n }\n\n return peaks;\n }\n } else {\n throw 'Cannot load peaks yet, buffer is not loaded';\n }\n }\n\n /**\n * Reverses the p5.SoundFile's buffer source.\n * Playback must be handled separately (see example).\n *\n * @method reverseBuffer\n * @for p5.SoundFile\n * @example\n *
\n * let drum;\n * function preload() {\n * drum = loadSound('assets/drum.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function canvasPressed() {\n * drum.stop();\n * drum.reverseBuffer();\n * drum.play();\n * }\n * \n *
\n */\n reverseBuffer() {\n if (this.buffer) {\n var currentPos = this._lastPos / ac.sampleRate;\n var curVol = this.getVolume();\n this.setVolume(0, 0.001);\n\n const numChannels = this.buffer.numberOfChannels;\n for (var i = 0; i < numChannels; i++) {\n this.buffer.getChannelData(i).reverse();\n }\n // set reversed flag\n this.reversed = !this.reversed;\n\n if (this.isPlaying() && currentPos) {\n this.jump(this.duration() - currentPos);\n }\n this.setVolume(curVol, 0.001);\n } else {\n throw 'SoundFile is not done loading';\n }\n }\n\n /**\n * Schedule an event to be called when the soundfile\n * reaches the end of a buffer. If the soundfile is\n * playing through once, this will be called when it\n * ends. If it is looping, it will be called when\n * stop is called.\n *\n * @method onended\n * @for p5.SoundFile\n * @param {Function} callback function to call when the\n * soundfile has ended.\n */\n onended(callback) {\n this._onended = callback;\n return this;\n }\n\n add() {\n // TO DO\n }\n\n dispose() {\n var now = p5sound.audiocontext.currentTime;\n\n // remove reference to soundfile\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.stop(now);\n if (this.buffer && this.bufferSourceNode) {\n for (var i = 0; i < this.bufferSourceNodes.length - 1; i++) {\n if (this.bufferSourceNodes[i] !== null) {\n this.bufferSourceNodes[i].disconnect();\n try {\n this.bufferSourceNodes[i].stop(now);\n } catch (e) {\n console.warn('no buffer source node to dispose');\n }\n this.bufferSourceNodes[i] = null;\n }\n }\n if (this.isPlaying()) {\n try {\n this._counterNode.stop(now);\n } catch (e) {\n console.log(e);\n }\n this._counterNode = null;\n }\n }\n if (this.output) {\n this.output.disconnect();\n this.output = null;\n }\n if (this.panner) {\n this.panner.disconnect();\n this.panner = null;\n }\n }\n\n /**\n * Connects the output of a p5sound object to input of another\n * p5.sound object. For example, you may connect a p5.SoundFile to an\n * FFT or an Effect. If no parameter is given, it will connect to\n * the main output. Most p5sound objects connect to the master\n * output when they are created.\n *\n * @method connect\n * @for p5.SoundFile\n * @param {Object} [object] Audio object that accepts an input\n */\n connect(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n } else {\n if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n } else {\n this.panner.connect(unit);\n }\n }\n }\n\n /**\n * Disconnects the output of this p5sound object.\n *\n * @method disconnect\n * @for p5.SoundFile\n */\n disconnect() {\n if (this.panner) {\n this.panner.disconnect();\n }\n }\n\n /**\n */\n getLevel() {\n console.warn(\n 'p5.SoundFile.getLevel has been removed from the library. Use p5.Amplitude instead'\n );\n }\n\n /**\n * Reset the source for this SoundFile to a\n * new path (URL).\n *\n * @method setPath\n * @for p5.SoundFile\n * @param {String} path path to audio file\n * @param {Function} callback Callback\n */\n setPath(p, callback) {\n var path = p5.prototype._checkFileFormats(p);\n this.url = path;\n this.load(callback);\n }\n\n /**\n * Replace the current Audio Buffer with a new Buffer.\n *\n * @method setBuffer\n * @for p5.SoundFile\n * @param {Array} buf Array of Float32 Array(s). 2 Float32 Arrays\n * will create a stereo source. 1 will create\n * a mono source.\n */\n setBuffer(buf) {\n var numChannels = buf.length;\n var size = buf[0].length;\n var newBuffer = ac.createBuffer(numChannels, size, ac.sampleRate);\n\n if (!(buf[0] instanceof Float32Array)) {\n buf[0] = new Float32Array(buf[0]);\n }\n\n for (var channelNum = 0; channelNum < numChannels; channelNum++) {\n var channel = newBuffer.getChannelData(channelNum);\n channel.set(buf[channelNum]);\n }\n\n this.buffer = newBuffer;\n\n // set numbers of channels on input to the panner\n this.panner.inputChannels(numChannels);\n }\n\n // initialize counterNode, set its initial buffer and playbackRate\n _initCounterNode() {\n var self = this;\n var now = ac.currentTime;\n var cNode = ac.createBufferSource();\n\n const workletBufferSize = safeBufferSize(256);\n\n // dispose of worklet node if it already exists\n if (self._workletNode) {\n self._workletNode.disconnect();\n delete self._workletNode;\n }\n self._workletNode = new AudioWorkletNode(\n ac,\n processorNames.soundFileProcessor,\n {\n processorOptions: { bufferSize: workletBufferSize },\n }\n );\n self._workletNode.port.onmessage = (event) => {\n if (event.data.name === 'position') {\n // event.data.position should only be 0 when paused\n if (event.data.position === 0) {\n return;\n }\n this._lastPos = event.data.position;\n\n // do any callbacks that have been scheduled\n this._onTimeUpdate(self._lastPos);\n }\n };\n\n // create counter buffer of the same length as self.buffer\n cNode.buffer = _createCounterBuffer(self.buffer);\n\n cNode.playbackRate.setValueAtTime(self.playbackRate, now);\n\n cNode.connect(self._workletNode);\n self._workletNode.connect(p5.soundOut._silentNode);\n\n return cNode;\n }\n\n // initialize sourceNode, set its initial buffer and playbackRate\n _initSourceNode() {\n var bufferSourceNode = ac.createBufferSource();\n bufferSourceNode.buffer = this.buffer;\n bufferSourceNode.playbackRate.value = this.playbackRate;\n bufferSourceNode.connect(this.output);\n return bufferSourceNode;\n }\n\n processPeaks(callback, _initThreshold, _minThreshold, _minPeaks) {\n console.warn('processPeaks is deprecated');\n }\n\n /**\n * Schedule events to trigger every time a MediaElement\n * (audio/video) reaches a playback cue point.\n *\n * Accepts a callback function, a time (in seconds) at which to trigger\n * the callback, and an optional parameter for the callback.\n *\n * Time will be passed as the first parameter to the callback function,\n * and param will be the second parameter.\n *\n *\n * @method addCue\n * @for p5.SoundFile\n * @param {Number} time Time in seconds, relative to this media\n * element's playback. For example, to trigger\n * an event every time playback reaches two\n * seconds, pass in the number 2. This will be\n * passed as the first parameter to\n * the callback function.\n * @param {Function} callback Name of a function that will be\n * called at the given time. The callback will\n * receive time and (optionally) param as its\n * two parameters.\n * @param {Object} [value] An object to be passed as the\n * second parameter to the\n * callback function.\n * @return {Number} id ID of this cue,\n * useful for removeCue(id)\n * @example\n *
\n * let mySound;\n * function preload() {\n * mySound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to play', 10, 20);\n *\n * // schedule calls to changeText\n * mySound.addCue(0, changeText, \"hello\" );\n * mySound.addCue(0.5, changeText, \"hello,\" );\n * mySound.addCue(1, changeText, \"hello, p5!\");\n * mySound.addCue(1.5, changeText, \"hello, p5!!\");\n * mySound.addCue(2, changeText, \"hello, p5!!!!!\");\n * }\n *\n * function changeText(val) {\n * background(220);\n * text(val, 10, 20);\n * }\n *\n * function canvasPressed() {\n * mySound.play();\n * }\n *
\n */\n addCue(time, callback, val) {\n var id = this._cueIDCounter++;\n\n var cue = new Cue(callback, time, id, val);\n this._cues.push(cue);\n\n // if (!this.elt.ontimeupdate) {\n // this.elt.ontimeupdate = this._onTimeUpdate.bind(this);\n // }\n\n return id;\n }\n\n /**\n * Remove a callback based on its ID. The ID is returned by the\n * addCue method.\n *\n * @method removeCue\n * @for p5.SoundFile\n * @param {Number} id ID of the cue, as returned by addCue\n */\n removeCue(id) {\n var cueLength = this._cues.length;\n for (var i = 0; i < cueLength; i++) {\n var cue = this._cues[i];\n if (cue.id === id) {\n this._cues.splice(i, 1);\n break;\n }\n }\n\n if (this._cues.length === 0) {\n // TO DO: remove callback\n // this.elt.ontimeupdate = null\n }\n }\n\n /**\n * Remove all of the callbacks that had originally been scheduled\n * via the addCue method.\n *\n * @method clearCues\n */\n clearCues() {\n this._cues = [];\n // this.elt.ontimeupdate = null;\n }\n\n // private method that checks for cues to be fired if events\n // have been scheduled using addCue(callback, time).\n _onTimeUpdate(position) {\n var playbackTime = position / this.buffer.sampleRate;\n var cueLength = this._cues.length;\n\n for (var i = 0; i < cueLength; i++) {\n var cue = this._cues[i];\n var callbackTime = cue.time;\n var val = cue.val;\n var leftLimit = this._prevUpdateTime || 0;\n var rightLimit = playbackTime;\n if (leftLimit <= callbackTime && callbackTime <= rightLimit) {\n // pass the scheduled callbackTime as parameter to the callback\n cue.callback(val);\n }\n }\n\n this._prevUpdateTime = playbackTime;\n }\n\n /**\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\n * to download the file to their device. To upload a file to a server, see\n * getBlob\n *\n * @method save\n * @for p5.SoundFile\n * @param {String} [fileName] name of the resulting .wav file.\n * @example\n *
\n * let mySound;\n * function preload() {\n * mySound = loadSound('assets/doorbell.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap to download', 10, 20);\n * }\n *\n * function canvasPressed() {\n * mySound.save('my cool filename');\n * }\n *
\n */\n save(fileName) {\n p5.prototype.saveSound(this, fileName, 'wav');\n }\n\n /**\n * This method is useful for sending a SoundFile to a server. It returns the\n * .wav-encoded audio data as a \"Blob\".\n * A Blob is a file-like data object that can be uploaded to a server\n * with an http request. We'll\n * use the `httpDo` options object to send a POST request with some\n * specific options: we encode the request as `multipart/form-data`,\n * and attach the blob as one of the form values using `FormData`.\n *\n *\n * @method getBlob\n * @for p5.SoundFile\n * @returns {Blob} A file-like data object\n * @example\n *
\n * function preload() {\n * mySound = loadSound('assets/doorbell.mp3');\n * }\n *\n * function setup() {\n * noCanvas();\n * let soundBlob = mySound.getBlob();\n *\n * // Now we can send the blob to a server...\n * let serverUrl = 'https://jsonplaceholder.typicode.com/posts';\n * let httpRequestOptions = {\n * method: 'POST',\n * body: new FormData().append('soundBlob', soundBlob),\n * headers: new Headers({\n * 'Content-Type': 'multipart/form-data'\n * })\n * };\n * httpDo(serverUrl, httpRequestOptions);\n *\n * // We can also create an `ObjectURL` pointing to the Blob\n * let blobUrl = URL.createObjectURL(soundBlob);\n *\n * // The `
\n */\n getBlob() {\n const dataView = convertToWav(this.buffer);\n return new Blob([dataView], { type: 'audio/wav' });\n }\n}\n\n/**\n * loadSound() returns a new p5.SoundFile from a specified\n * path. If called during preload(), the p5.SoundFile will be ready\n * to play in time for setup() and draw(). If called outside of\n * preload, the p5.SoundFile will not be ready immediately, so\n * loadSound accepts a callback as the second parameter. Using a\n * \n * local server is recommended when loading external files.\n *\n * @method loadSound\n * @for p5\n * @param {String|Array} path Path to the sound file, or an array with\n * paths to soundfiles in multiple formats\n * i.e. ['sound.ogg', 'sound.mp3'].\n * Alternately, accepts an object: either\n * from the HTML5 File API, or a p5.File.\n * @param {Function} [successCallback] Name of a function to call once file loads\n * @param {Function} [errorCallback] Name of a function to call if there is\n * an error loading the file.\n * @param {Function} [whileLoading] Name of a function to call while file is loading.\n * This function will receive the percentage loaded\n * so far, from 0.0 to 1.0.\n * @return {SoundFile} Returns a p5.SoundFile\n * @example\n *
\n * let mySound;\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * mySound = loadSound('assets/doorbell');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * text('tap here to play', 10, 20);\n * }\n *\n * function canvasPressed() {\n * // playing a sound file on a user gesture\n * // is equivalent to `userStartAudio()`\n * mySound.play();\n * }\n *
\n */\nfunction loadSound(path, callback, onerror, whileLoading) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n window.alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n\n var self = this;\n var s = new SoundFile(\n path,\n function () {\n if (typeof callback === 'function') {\n callback.apply(self, arguments);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n },\n onerror,\n whileLoading\n );\n\n return s;\n}\n\nexport default SoundFile;\nexport { loadSound };\n","import p5sound from './main';\nimport { safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\n\n/**\n * Amplitude measures volume between 0.0 and 1.0.\n * Listens to all p5sound by default, or use setInput()\n * to listen to a specific sound source. Accepts an optional\n * smoothing value, which defaults to 0.\n *\n * @class p5.Amplitude\n * @constructor\n * @param {Number} [smoothing] between 0.0 and .999 to smooth\n * amplitude readings (defaults to 0)\n * @example\n *
\n * let sound, amplitude;\n *\n * function preload(){\n * sound = loadSound('assets/beat.mp3');\n * }\n * function setup() {\n * let cnv = createCanvas(100,100);\n * cnv.mouseClicked(togglePlay);\n * amplitude = new p5.Amplitude();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 20, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function togglePlay() {\n * if (sound.isPlaying() ){\n * sound.pause();\n * } else {\n * sound.loop();\n *\t\tamplitude = new p5.Amplitude();\n *\t\tamplitude.setInput(sound);\n * }\n * }\n *\n *
\n */\nclass Amplitude {\n constructor(smoothing) {\n // Set to 2048 for now. In future iterations, this should be inherited or parsed from p5sound's default\n this.bufferSize = safeBufferSize(2048);\n\n // set audio context\n this.audiocontext = p5sound.audiocontext;\n this._workletNode = new AudioWorkletNode(\n this.audiocontext,\n processorNames.amplitudeProcessor,\n {\n outputChannelCount: [1],\n\n parameterData: { smoothing: smoothing || 0 },\n processorOptions: {\n normalize: false,\n smoothing: smoothing || 0,\n numInputChannels: 2,\n bufferSize: this.bufferSize,\n },\n }\n );\n\n this._workletNode.port.onmessage = function (event) {\n if (event.data.name === 'amplitude') {\n this.volume = event.data.volume;\n this.volNorm = event.data.volNorm;\n this.stereoVol = event.data.stereoVol;\n this.stereoVolNorm = event.data.stereoVolNorm;\n }\n }.bind(this);\n\n // for connections\n this.input = this._workletNode;\n\n this.output = this.audiocontext.createGain();\n\n // the variables to return\n this.volume = 0;\n this.volNorm = 0;\n this.stereoVol = [0, 0];\n this.stereoVolNorm = [0, 0];\n\n this.normalize = false;\n\n this._workletNode.connect(this.output);\n this.output.gain.value = 0;\n\n // this may only be necessary because of a Chrome bug\n this.output.connect(this.audiocontext.destination);\n\n // connect to p5sound main output by default, unless set by input()\n p5sound.meter.connect(this._workletNode);\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connects to the p5sound instance (main output) by default.\n * Optionally, you can pass in a specific source (i.e. a soundfile).\n *\n * @method setInput\n * @for p5.Amplitude\n * @param {soundObject|undefined} [snd] set the sound source\n * (optional, defaults to\n * main output)\n * @param {Number|undefined} [smoothing] a range between 0.0 and 1.0\n * to smooth amplitude readings\n * @example\n *
\n * function preload(){\n * sound1 = loadSound('assets/beat.mp3');\n * sound2 = loadSound('assets/drum.mp3');\n * }\n * function setup(){\n * cnv = createCanvas(100, 100);\n * cnv.mouseClicked(toggleSound);\n *\n * amplitude = new p5.Amplitude();\n * amplitude.setInput(sound2);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap to play', 20, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function toggleSound(){\n * if (sound1.isPlaying() && sound2.isPlaying()) {\n * sound1.stop();\n * sound2.stop();\n * } else {\n * sound1.play();\n * sound2.play();\n * }\n * }\n *
\n */\n setInput(source, smoothing) {\n p5sound.meter.disconnect();\n\n if (smoothing) {\n this._workletNode.parameters.get('smoothing').value = smoothing;\n }\n\n // connect to the master out of p5s instance if no snd is provided\n if (source == null) {\n console.log(\n 'Amplitude input source is not ready! Connecting to main output instead'\n );\n p5sound.meter.connect(this._workletNode);\n }\n\n // connect to the sound if it is available\n else if (source) {\n source.connect(this._workletNode);\n this._workletNode.disconnect();\n this._workletNode.connect(this.output);\n }\n\n // otherwise, connect to the master out of p5s instance (default)\n else {\n p5sound.meter.connect(this._workletNode);\n }\n }\n\n connect(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n } else {\n this.output.connect(unit);\n }\n } else {\n this.output.connect(this.panner.connect(p5sound.input));\n }\n }\n\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Returns a single Amplitude reading at the moment it is called.\n * For continuous readings, run in the draw loop.\n *\n * @method getLevel\n * @for p5.Amplitude\n * @param {Number} [channel] Optionally return only channel 0 (left) or 1 (right)\n * @return {Number} Amplitude as a number between 0.0 and 1.0\n * @example\n *
\n * function preload(){\n * sound = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mouseClicked(toggleSound);\n * amplitude = new p5.Amplitude();\n * }\n *\n * function draw() {\n * background(220, 150);\n * textAlign(CENTER);\n * text('tap to play', width/2, 20);\n *\n * let level = amplitude.getLevel();\n * let size = map(level, 0, 1, 0, 200);\n * ellipse(width/2, height/2, size, size);\n * }\n *\n * function toggleSound(){\n * if (sound.isPlaying()) {\n * sound.stop();\n * } else {\n * sound.play();\n * }\n * }\n *
\n */\n getLevel(channel) {\n if (typeof channel !== 'undefined') {\n if (this.normalize) {\n return this.stereoVolNorm[channel];\n } else {\n return this.stereoVol[channel];\n }\n } else if (this.normalize) {\n return this.volNorm;\n } else {\n return this.volume;\n }\n }\n\n /**\n * Determines whether the results of Amplitude.process() will be\n * Normalized. To normalize, Amplitude finds the difference the\n * loudest reading it has processed and the maximum amplitude of\n * 1.0. Amplitude adds this difference to all values to produce\n * results that will reliably map between 0.0 and 1.0. However,\n * if a louder moment occurs, the amount that Normalize adds to\n * all the values will change. Accepts an optional boolean parameter\n * (true or false). Normalizing is off by default.\n *\n * @method toggleNormalize\n * @for p5.Amplitude\n * @param {boolean} [boolean] set normalize to true (1) or false (0)\n */\n toggleNormalize(bool) {\n if (typeof bool === 'boolean') {\n this.normalize = bool;\n } else {\n this.normalize = !this.normalize;\n }\n this._workletNode.port.postMessage({\n name: 'toggleNormalize',\n normalize: this.normalize,\n });\n }\n /**\n * Smooth Amplitude analysis by averaging with the last analysis\n * frame. Off by default.\n *\n * @method smooth\n * @for p5.Amplitude\n * @param {Number} set smoothing from 0.0 <= 1\n */\n smooth(s) {\n if (s >= 0 && s < 1) {\n this._workletNode.port.postMessage({ name: 'smoothing', smoothing: s });\n } else {\n console.log('Error: smoothing must be between 0 and 1');\n }\n }\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n\n this._workletNode.disconnect();\n delete this._workletNode;\n }\n}\n\nexport default Amplitude;\n","import p5sound from './main';\n\n/**\n *

FFT (Fast Fourier Transform) is an analysis algorithm that\n * isolates individual\n * \n * audio frequencies within a waveform.

\n *\n *

Once instantiated, a p5.FFT object can return an array based on\n * two types of analyses:
• FFT.waveform() computes\n * amplitude values along the time domain. The array indices correspond\n * to samples across a brief moment in time. Each value represents\n * amplitude of the waveform at that sample of time.
\n * • FFT.analyze() computes amplitude values along the\n * frequency domain. The array indices correspond to frequencies (i.e.\n * pitches), from the lowest to the highest that humans can hear. Each\n * value represents amplitude at that slice of the frequency spectrum.\n * Use with getEnergy() to measure amplitude at specific\n * frequencies, or within a range of frequencies.

\n *\n *

FFT analyzes a very short snapshot of sound called a sample\n * buffer. It returns an array of amplitude measurements, referred\n * to as bins. The array is 1024 bins long by default.\n * You can change the bin array length, but it must be a power of 2\n * between 16 and 1024 in order for the FFT algorithm to function\n * correctly. The actual size of the FFT buffer is twice the\n * number of bins, so given a standard sample rate, the buffer is\n * 2048/44100 seconds long.

\n *\n *\n * @class p5.FFT\n * @constructor\n * @param {Number} [smoothing] Smooth results of Freq Spectrum.\n * 0.0 < smoothing < 1.0.\n * Defaults to 0.8.\n * @param {Number} [bins] Length of resulting array.\n * Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @example\n *
\n * function preload(){\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup(){\n * let cnv = createCanvas(100,100);\n * cnv.mouseClicked(togglePlay);\n * fft = new p5.FFT();\n * sound.amp(0.2);\n * }\n *\n * function draw(){\n * background(220);\n *\n * let spectrum = fft.analyze();\n * noStroke();\n * fill(255, 0, 255);\n * for (let i = 0; i< spectrum.length; i++){\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width / spectrum.length, h )\n * }\n *\n * let waveform = fft.waveform();\n * noFill();\n * beginShape();\n * stroke(20);\n * for (let i = 0; i < waveform.length; i++){\n * let x = map(i, 0, waveform.length, 0, width);\n * let y = map( waveform[i], -1, 1, 0, height);\n * vertex(x,y);\n * }\n * endShape();\n *\n * text('tap to play', 20, 20);\n * }\n *\n * function togglePlay() {\n * if (sound.isPlaying()) {\n * sound.pause();\n * } else {\n * sound.loop();\n * }\n * }\n *
\n */\nclass FFT {\n constructor(smoothing, bins) {\n this.input = this.analyser = p5sound.audiocontext.createAnalyser();\n\n Object.defineProperties(this, {\n bins: {\n get: function () {\n return this.analyser.fftSize / 2;\n },\n set: function (b) {\n this.analyser.fftSize = b * 2;\n },\n configurable: true,\n enumerable: true,\n },\n smoothing: {\n get: function () {\n return this.analyser.smoothingTimeConstant;\n },\n set: function (s) {\n this.analyser.smoothingTimeConstant = s;\n },\n configurable: true,\n enumerable: true,\n },\n });\n\n // set default smoothing and bins\n this.smooth(smoothing);\n this.bins = bins || 1024;\n\n // default connections to p5sound fftMeter\n p5sound.fftMeter.connect(this.analyser);\n\n this.freqDomain = new Uint8Array(this.analyser.frequencyBinCount);\n this.timeDomain = new Uint8Array(this.analyser.frequencyBinCount);\n\n // predefined frequency ranges, these will be tweakable\n this.bass = [20, 140];\n this.lowMid = [140, 400];\n this.mid = [400, 2600];\n this.highMid = [2600, 5200];\n this.treble = [5200, 14000];\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Set the input source for the FFT analysis. If no source is\n * provided, FFT will analyze all sound in the sketch.\n *\n * @method setInput\n * @for p5.FFT\n * @param {Object} [source] p5.sound object (or web audio API source node)\n */\n setInput(source) {\n if (!source) {\n p5sound.fftMeter.connect(this.analyser);\n } else {\n if (source.output) {\n source.output.connect(this.analyser);\n } else if (source.connect) {\n source.connect(this.analyser);\n }\n p5sound.fftMeter.disconnect();\n }\n }\n\n /**\n * Returns an array of amplitude values (between -1.0 and +1.0) that represent\n * a snapshot of amplitude readings in a single buffer. Length will be\n * equal to bins (defaults to 1024). Can be used to draw the waveform\n * of a sound.\n *\n * @method waveform\n * @for p5.FFT\n * @param {Number} [bins] Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @param {String} [precision] If any value is provided, will return results\n * in a Float32 Array which is more precise\n * than a regular array.\n * @return {Array} Array Array of amplitude values (-1 to 1)\n * over time. Array length = bins.\n *\n */\n waveform() {\n var bins, mode;\n var normalArray = new Array();\n\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'number') {\n bins = arguments[i];\n this.analyser.fftSize = bins * 2;\n }\n if (typeof arguments[i] === 'string') {\n mode = arguments[i];\n }\n }\n\n // getFloatFrequencyData doesnt work in Safari as of 5/2015\n if (mode && !p5.prototype._isSafari()) {\n timeToFloat(this, this.timeDomain);\n this.analyser.getFloatTimeDomainData(this.timeDomain);\n return this.timeDomain;\n } else {\n timeToInt(this, this.timeDomain);\n this.analyser.getByteTimeDomainData(this.timeDomain);\n for (var j = 0; j < this.timeDomain.length; j++) {\n var scaled = p5.prototype.map(this.timeDomain[j], 0, 255, -1, 1);\n normalArray.push(scaled);\n }\n return normalArray;\n }\n }\n\n /**\n * Returns an array of amplitude values (between 0 and 255)\n * across the frequency spectrum. Length is equal to FFT bins\n * (1024 by default). The array indices correspond to frequencies\n * (i.e. pitches), from the lowest to the highest that humans can\n * hear. Each value represents amplitude at that slice of the\n * frequency spectrum. Must be called prior to using\n * getEnergy().\n *\n * @method analyze\n * @for p5.FFT\n * @param {Number} [bins] Must be a power of two between\n * 16 and 1024. Defaults to 1024.\n * @param {Number} [scale] If \"dB,\" returns decibel\n * float measurements between\n * -140 and 0 (max).\n * Otherwise returns integers from 0-255.\n * @return {Array} spectrum Array of energy (amplitude/volume)\n * values across the frequency spectrum.\n * Lowest energy (silence) = 0, highest\n * possible is 255.\n * @example\n *
\n * let osc, fft;\n *\n * function setup(){\n * let cnv = createCanvas(100,100);\n * cnv.mousePressed(startSound);\n * osc = new p5.Oscillator();\n * osc.amp(0);\n * fft = new p5.FFT();\n * }\n *\n * function draw(){\n * background(220);\n *\n * let freq = map(mouseX, 0, windowWidth, 20, 10000);\n * freq = constrain(freq, 1, 20000);\n * osc.freq(freq);\n *\n * let spectrum = fft.analyze();\n * noStroke();\n * fill(255, 0, 255);\n * for (let i = 0; i< spectrum.length; i++){\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width / spectrum.length, h );\n * }\n *\n * stroke(255);\n * if (!osc.started) {\n * text('tap here and drag to change frequency', 10, 20, width - 20);\n * } else {\n * text(round(freq)+'Hz', 10, 20);\n * }\n * }\n *\n * function startSound() {\n * osc.start();\n * osc.amp(0.5, 0.2);\n * }\n *\n * function mouseReleased() {\n * osc.amp(0, 0.2);\n * }\n *
\n *\n *\n */\n analyze() {\n var mode;\n\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'number') {\n this.bins = arguments[i];\n this.analyser.fftSize = this.bins * 2;\n }\n if (typeof arguments[i] === 'string') {\n mode = arguments[i];\n }\n }\n\n if (mode && mode.toLowerCase() === 'db') {\n freqToFloat(this);\n this.analyser.getFloatFrequencyData(this.freqDomain);\n return this.freqDomain;\n } else {\n freqToInt(this, this.freqDomain);\n this.analyser.getByteFrequencyData(this.freqDomain);\n var normalArray = Array.apply([], this.freqDomain);\n\n return normalArray;\n }\n }\n\n /**\n * Returns the amount of energy (volume) at a specific\n * \n * frequency, or the average amount of energy between two\n * frequencies. Accepts Number(s) corresponding\n * to frequency (in Hz), or a \"string\" corresponding to predefined\n * frequency ranges (\"bass\", \"lowMid\", \"mid\", \"highMid\", \"treble\").\n * Returns a range between 0 (no energy/volume at that frequency) and\n * 255 (maximum energy).\n * NOTE: analyze() must be called prior to getEnergy(). analyze()\n * tells the FFT to analyze frequency data, and getEnergy() uses\n * the results to determine the value at a specific frequency or\n * range of frequencies.

\n *\n * @method getEnergy\n * @for p5.FFT\n * @param {Number|String} frequency1 Will return a value representing\n * energy at this frequency. Alternately,\n * the strings \"bass\", \"lowMid\" \"mid\",\n * \"highMid\", and \"treble\" will return\n * predefined frequency ranges.\n * @param {Number} [frequency2] If a second frequency is given,\n * will return average amount of\n * energy that exists between the\n * two frequencies.\n * @return {Number} Energy Energy (volume/amplitude) from\n * 0 and 255.\n *\n */\n getEnergy(frequency1, frequency2) {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n\n if (frequency1 === 'bass') {\n frequency1 = this.bass[0];\n frequency2 = this.bass[1];\n } else if (frequency1 === 'lowMid') {\n frequency1 = this.lowMid[0];\n frequency2 = this.lowMid[1];\n } else if (frequency1 === 'mid') {\n frequency1 = this.mid[0];\n frequency2 = this.mid[1];\n } else if (frequency1 === 'highMid') {\n frequency1 = this.highMid[0];\n frequency2 = this.highMid[1];\n } else if (frequency1 === 'treble') {\n frequency1 = this.treble[0];\n frequency2 = this.treble[1];\n }\n\n if (typeof frequency1 !== 'number') {\n throw 'invalid input for getEnergy()';\n } else if (!frequency2) {\n // if only one parameter:\n var index = Math.round((frequency1 / nyquist) * this.freqDomain.length);\n return this.freqDomain[index];\n } else if (frequency1 && frequency2) {\n // if two parameters:\n // if second is higher than first\n if (frequency1 > frequency2) {\n var swap = frequency2;\n frequency2 = frequency1;\n frequency1 = swap;\n }\n var lowIndex = Math.round(\n (frequency1 / nyquist) * this.freqDomain.length\n );\n var highIndex = Math.round(\n (frequency2 / nyquist) * this.freqDomain.length\n );\n\n var total = 0;\n var numFrequencies = 0;\n // add up all of the values for the frequencies\n for (var i = lowIndex; i <= highIndex; i++) {\n total += this.freqDomain[i];\n numFrequencies += 1;\n }\n // divide by total number of frequencies\n var toReturn = total / numFrequencies;\n return toReturn;\n } else {\n throw 'invalid input for getEnergy()';\n }\n }\n\n // compatability with v.012, changed to getEnergy in v.0121. Will be deprecated...\n getFreq(freq1, freq2) {\n console.log('getFreq() is deprecated. Please use getEnergy() instead.');\n var x = this.getEnergy(freq1, freq2);\n return x;\n }\n\n /**\n * Returns the\n * \n * spectral centroid of the input signal.\n * NOTE: analyze() must be called prior to getCentroid(). Analyze()\n * tells the FFT to analyze frequency data, and getCentroid() uses\n * the results determine the spectral centroid.

\n *\n * @method getCentroid\n * @for p5.FFT\n * @return {Number} Spectral Centroid Frequency of the spectral centroid in Hz.\n *\n *\n * @example\n *
\n * function setup(){\n * cnv = createCanvas(100,100);\n * cnv.mousePressed(userStartAudio);\n * sound = new p5.AudioIn();\n * sound.start();\n * fft = new p5.FFT();\n * sound.connect(fft);\n *}\n *\n *function draw() {\n * if (getAudioContext().state !== 'running') {\n * background(220);\n * text('tap here and enable mic to begin', 10, 20, width - 20);\n * return;\n * }\n * let centroidplot = 0.0;\n * let spectralCentroid = 0;\n *\n * background(0);\n * stroke(0,255,0);\n * let spectrum = fft.analyze();\n * fill(0,255,0); // spectrum is green\n *\n * //draw the spectrum\n * for (let i = 0; i < spectrum.length; i++){\n * let x = map(log(i), 0, log(spectrum.length), 0, width);\n * let h = map(spectrum[i], 0, 255, 0, height);\n * let rectangle_width = (log(i+1)-log(i))*(width/log(spectrum.length));\n * rect(x, height, rectangle_width, -h )\n * }\n * let nyquist = 22050;\n *\n * // get the centroid\n * spectralCentroid = fft.getCentroid();\n *\n * // the mean_freq_index calculation is for the display.\n * let mean_freq_index = spectralCentroid/(nyquist/spectrum.length);\n *\n * centroidplot = map(log(mean_freq_index), 0, log(spectrum.length), 0, width);\n *\n * stroke(255,0,0); // the line showing where the centroid is will be red\n *\n * rect(centroidplot, 0, width / spectrum.length, height)\n * noStroke();\n * fill(255,255,255); // text is white\n * text('centroid: ', 10, 20);\n * text(round(spectralCentroid)+' Hz', 10, 40);\n *}\n *
\n */\n getCentroid() {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n var cumulative_sum = 0;\n var centroid_normalization = 0;\n\n for (var i = 0; i < this.freqDomain.length; i++) {\n cumulative_sum += i * this.freqDomain[i];\n centroid_normalization += this.freqDomain[i];\n }\n\n var mean_freq_index = 0;\n\n if (centroid_normalization !== 0) {\n mean_freq_index = cumulative_sum / centroid_normalization;\n }\n\n var spec_centroid_freq =\n mean_freq_index * (nyquist / this.freqDomain.length);\n return spec_centroid_freq;\n }\n\n /**\n * Smooth FFT analysis by averaging with the last analysis frame.\n *\n * @method smooth\n * @param {Number} smoothing 0.0 < smoothing < 1.0.\n * Defaults to 0.8.\n */\n smooth(s) {\n if (typeof s !== 'undefined') {\n this.smoothing = s;\n }\n return this.smoothing;\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.analyser) {\n this.analyser.disconnect();\n delete this.analyser;\n }\n }\n\n /**\n * Returns an array of average amplitude values for a given number\n * of frequency bands split equally. N defaults to 16.\n * NOTE: analyze() must be called prior to linAverages(). Analyze()\n * tells the FFT to analyze frequency data, and linAverages() uses\n * the results to group them into a smaller set of averages.

\n *\n * @method linAverages\n * @for p5.FFT\n * @param {Number} N Number of returned frequency groups\n * @return {Array} linearAverages Array of average amplitude values for each group\n */\n\n linAverages(_N) {\n var N = _N || 16; // This prevents undefined, null or 0 values of N\n\n var spectrum = this.freqDomain;\n var spectrumLength = spectrum.length;\n var spectrumStep = Math.floor(spectrumLength / N);\n\n var linearAverages = new Array(N);\n // Keep a second index for the current average group and place the values accordingly\n // with only one loop in the spectrum data\n var groupIndex = 0;\n\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\n linearAverages[groupIndex] =\n linearAverages[groupIndex] !== undefined\n ? (linearAverages[groupIndex] + spectrum[specIndex]) / 2\n : spectrum[specIndex];\n\n // Increase the group index when the last element of the group is processed\n if (specIndex % spectrumStep === spectrumStep - 1) {\n groupIndex++;\n }\n }\n\n return linearAverages;\n }\n\n /**\n * Returns an array of average amplitude values of the spectrum, for a given\n * set of \n * Octave Bands\n * NOTE: analyze() must be called prior to logAverages(). Analyze()\n * tells the FFT to analyze frequency data, and logAverages() uses\n * the results to group them into a smaller set of averages.

\n *\n * @method logAverages\n * @for p5.FFT\n * @param {Array} octaveBands Array of Octave Bands objects for grouping\n * @return {Array} logAverages Array of average amplitude values for each group\n */\n logAverages(octaveBands) {\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n var spectrum = this.freqDomain;\n var spectrumLength = spectrum.length;\n\n var logAverages = new Array(octaveBands.length);\n // Keep a second index for the current average group and place the values accordingly\n // With only one loop in the spectrum data\n var octaveIndex = 0;\n\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\n var specIndexFrequency = Math.round(\n (specIndex * nyquist) / this.freqDomain.length\n );\n\n // Increase the group index if the current frequency exceeds the limits of the band\n if (specIndexFrequency > octaveBands[octaveIndex].hi) {\n octaveIndex++;\n }\n\n logAverages[octaveIndex] =\n logAverages[octaveIndex] !== undefined\n ? (logAverages[octaveIndex] + spectrum[specIndex]) / 2\n : spectrum[specIndex];\n }\n\n return logAverages;\n }\n\n /**\n * Calculates and Returns the 1/N\n * Octave Bands\n * N defaults to 3 and minimum central frequency to 15.625Hz.\n * (1/3 Octave Bands ~= 31 Frequency Bands)\n * Setting fCtr0 to a central value of a higher octave will ignore the lower bands\n * and produce less frequency groups.\n *\n * @method getOctaveBands\n * @for p5.FFT\n * @param {Number} N Specifies the 1/N type of generated octave bands\n * @param {Number} fCtr0 Minimum central frequency for the lowest band\n * @return {Array} octaveBands Array of octave band objects with their bounds\n */\n getOctaveBands(_N, _fCtr0) {\n var N = _N || 3; // Default to 1/3 Octave Bands\n var fCtr0 = _fCtr0 || 15.625; // Minimum central frequency, defaults to 15.625Hz\n\n var octaveBands = [];\n var lastFrequencyBand = {\n lo: fCtr0 / Math.pow(2, 1 / (2 * N)),\n ctr: fCtr0,\n hi: fCtr0 * Math.pow(2, 1 / (2 * N)),\n };\n octaveBands.push(lastFrequencyBand);\n\n var nyquist = p5sound.audiocontext.sampleRate / 2;\n while (lastFrequencyBand.hi < nyquist) {\n var newFrequencyBand = {};\n newFrequencyBand.lo = lastFrequencyBand.hi;\n newFrequencyBand.ctr = lastFrequencyBand.ctr * Math.pow(2, 1 / N);\n newFrequencyBand.hi = newFrequencyBand.ctr * Math.pow(2, 1 / (2 * N));\n\n octaveBands.push(newFrequencyBand);\n lastFrequencyBand = newFrequencyBand;\n }\n\n return octaveBands;\n }\n}\n\n// helper methods to convert type from float (dB) to int (0-255)\nfunction freqToFloat(fft) {\n if (fft.freqDomain instanceof Float32Array === false) {\n fft.freqDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction freqToInt(fft) {\n if (fft.freqDomain instanceof Uint8Array === false) {\n fft.freqDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction timeToFloat(fft) {\n if (fft.timeDomain instanceof Float32Array === false) {\n fft.timeDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n}\nfunction timeToInt(fft) {\n if (fft.timeDomain instanceof Uint8Array === false) {\n fft.timeDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n}\n\nexport default FFT;\n","import p5sound from './main';\nimport Add from 'Tone/signal/Add';\nimport Mult from 'Tone/signal/Multiply';\nimport Scale from 'Tone/signal/Scale';\nimport Panner from './panner';\n// ========================== //\n// SIGNAL MATH FOR MODULATION //\n// ========================== //\n\n// return sigChain(this, scale, thisChain, nextChain, Scale);\nfunction sigChain(o, mathObj, thisChain, nextChain, type) {\n var chainSource = o.oscillator;\n // if this type of math already exists in the chain, replace it\n for (var i in o.mathOps) {\n if (o.mathOps[i] instanceof type) {\n chainSource.disconnect();\n o.mathOps[i].dispose();\n thisChain = i;\n // assume nextChain is output gain node unless...\n if (thisChain < o.mathOps.length - 2) {\n nextChain = o.mathOps[i + 1];\n }\n }\n }\n if (thisChain === o.mathOps.length - 1) {\n o.mathOps.push(nextChain);\n }\n // assume source is the oscillator unless i > 0\n if (i > 0) {\n chainSource = o.mathOps[i - 1];\n }\n chainSource.disconnect();\n chainSource.connect(mathObj);\n mathObj.connect(nextChain);\n o.mathOps[thisChain] = mathObj;\n return o;\n}\n\n/**\n *

Creates a signal that oscillates between -1.0 and 1.0.\n * By default, the oscillation takes the form of a sinusoidal\n * shape ('sine'). Additional types include 'triangle',\n * 'sawtooth' and 'square'. The frequency defaults to\n * 440 oscillations per second (440Hz, equal to the pitch of an\n * 'A' note).

\n *\n *

Set the type of oscillation with setType(), or by instantiating a\n * specific oscillator: p5.SinOsc, p5.TriOsc, p5.SqrOsc, or p5.SawOsc.\n *

\n *\n * @class p5.Oscillator\n * @constructor\n * @param {Number} [freq] frequency defaults to 440Hz\n * @param {String} [type] type of oscillator. Options:\n * 'sine' (default), 'triangle',\n * 'sawtooth', 'square'\n * @example\n *
\n * let osc, playing, freq, amp;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playOscillator);\n * osc = new p5.Oscillator('sine');\n * }\n *\n * function draw() {\n * background(220)\n * freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\n * amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\n *\n * text('tap to play', 20, 20);\n * text('freq: ' + freq, 20, 40);\n * text('amp: ' + amp, 20, 60);\n *\n * if (playing) {\n * // smooth the transitions by 0.1 seconds\n * osc.freq(freq, 0.1);\n * osc.amp(amp, 0.1);\n * }\n * }\n *\n * function playOscillator() {\n * // starting an oscillator on a user gesture will enable audio\n * // in browsers that have a strict autoplay policy.\n * // See also: userStartAudio();\n * osc.start();\n * playing = true;\n * }\n *\n * function mouseReleased() {\n * // ramp amplitude to 0 over 0.5 seconds\n * osc.amp(0, 0.5);\n * playing = false;\n * }\n *
\n */\nclass Oscillator {\n constructor(freq, type) {\n if (typeof freq === 'string') {\n let f = type;\n type = freq;\n freq = f;\n }\n if (typeof type === 'number') {\n let f = type;\n type = freq;\n freq = f;\n }\n this.started = false;\n\n // components\n this.phaseAmount = undefined;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.f = freq || 440.0; // frequency\n this.oscillator.type = type || 'sine';\n this.oscillator.frequency.setValueAtTime(\n this.f,\n p5sound.audiocontext.currentTime\n );\n\n // connections\n this.output = p5sound.audiocontext.createGain();\n\n this._freqMods = []; // modulators connected to this oscillator's frequency\n\n // set default output gain to 0.5\n this.output.gain.value = 0.5;\n this.output.gain.setValueAtTime(0.5, p5sound.audiocontext.currentTime);\n\n this.oscillator.connect(this.output);\n // stereo panning\n this.panPosition = 0.0;\n this.connection = p5sound.input; // connect to p5sound by default\n this.panner = new Panner(this.output, this.connection, 1);\n\n //array of math operation signal chaining\n this.mathOps = [this.output];\n\n // add to the soundArray so we can dispose of the osc later\n p5sound.soundArray.push(this);\n\n // these methods are now the same thing\n this.fade = this.amp;\n }\n\n /**\n * Start an oscillator.\n *\n * Starting an oscillator on a user gesture will enable audio in browsers\n * that have a strict autoplay policy, including Chrome and most mobile\n * devices. See also: `userStartAudio()`.\n *\n * @method start\n * @for p5.Oscillator\n * @param {Number} [time] startTime in seconds from now.\n * @param {Number} [frequency] frequency in Hz.\n */\n start(time, f) {\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n }\n if (!this.started) {\n var freq = f || this.f;\n var type = this.oscillator.type;\n\n // set old osc free to be garbage collected (memory)\n if (this.oscillator) {\n this.oscillator.disconnect();\n delete this.oscillator;\n }\n\n // var detune = this.oscillator.frequency.value;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.oscillator.frequency.value = Math.abs(freq);\n this.oscillator.type = type;\n // this.oscillator.detune.value = detune;\n this.oscillator.connect(this.output);\n time = time || 0;\n this.oscillator.start(time + p5sound.audiocontext.currentTime);\n this.freqNode = this.oscillator.frequency;\n\n // if other oscillators are already connected to this osc's freq\n for (var i in this._freqMods) {\n if (typeof this._freqMods[i].connect !== 'undefined') {\n this._freqMods[i].connect(this.oscillator.frequency);\n }\n }\n\n this.started = true;\n }\n }\n\n /**\n * Stop an oscillator. Accepts an optional parameter\n * to determine how long (in seconds from now) until the\n * oscillator stops.\n *\n * @method stop\n * @for p5.Oscillator\n * @param {Number} secondsFromNow Time, in seconds from now.\n */\n stop(time) {\n if (this.started) {\n var t = time || 0;\n var now = p5sound.audiocontext.currentTime;\n this.oscillator.stop(t + now);\n this.started = false;\n }\n }\n\n /**\n * Set the amplitude between 0 and 1.0. Or, pass in an object\n * such as an oscillator to modulate amplitude with an audio signal.\n *\n * @method amp\n * @for p5.Oscillator\n * @param {Number|Object} vol between 0 and 1.0\n * or a modulating signal/oscillator\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {AudioParam} gain If no value is provided,\n * returns the Web Audio API\n * AudioParam that controls\n * this oscillator's\n * gain/amplitude/volume)\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n if (typeof vol === 'number') {\n var now = p5sound.audiocontext.currentTime;\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n } else if (vol) {\n vol.connect(this.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n }\n\n /**\n * Returns the value of output gain\n *\n * @method getAmp\n * @for p5.Oscillator\n *\n * @returns {number} Amplitude value between 0.0 and 1.0\n */\n\n getAmp() {\n return this.output.gain.value;\n }\n\n /**\n * Set frequency of an oscillator to a value. Or, pass in an object\n * such as an oscillator to modulate the frequency with an audio signal.\n *\n * @method freq\n * @for p5.Oscillator\n * @param {Number|Object} Frequency Frequency in Hz\n * or modulating signal/oscillator\n * @param {Number} [rampTime] Ramp time (in seconds)\n * @param {Number} [timeFromNow] Schedule this event to happen\n * at x seconds from now\n * @return {AudioParam} Frequency If no value is provided,\n * returns the Web Audio API\n * AudioParam that controls\n * this oscillator's frequency\n * @example\n *
\n * let osc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playOscillator);\n * osc = new p5.Oscillator(300);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playOscillator() {\n * osc.start();\n * osc.amp(0.5);\n * // start at 700Hz\n * osc.freq(700);\n * // ramp to 60Hz over 0.7 seconds\n * osc.freq(60, 0.7);\n * osc.amp(0, 0.1, 0.7);\n * }\n *
\n */\n freq(val, rampTime = 0, tFromNow = 0) {\n if (typeof val === 'number' && !isNaN(val)) {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n\n if (rampTime === 0) {\n this.oscillator.frequency.setValueAtTime(val, tFromNow + now);\n } else {\n if (val > 0) {\n this.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n } else {\n this.oscillator.frequency.linearRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n }\n }\n\n // reset phase if oscillator has a phase\n if (this.phaseAmount) {\n this.phase(this.phaseAmount);\n }\n } else if (val) {\n if (val.output) {\n val = val.output;\n }\n val.connect(this.oscillator.frequency);\n\n // keep track of what is modulating this param\n // so it can be re-connected if\n this._freqMods.push(val);\n } else {\n // return the Frequency Node\n return this.oscillator.frequency;\n }\n }\n /**\n * Returns the value of frequency of oscillator\n *\n * @method getFreq\n * @for p5.Oscillator\n * @returns {number} Frequency of oscillator in Hertz\n */\n\n getFreq() {\n return this.oscillator.frequency.value;\n }\n\n /**\n * Set type to 'sine', 'triangle', 'sawtooth' or 'square'.\n *\n * @method setType\n * @for p5.Oscillator\n * @param {String} type 'sine', 'triangle', 'sawtooth' or 'square'.\n */\n setType(type) {\n this.oscillator.type = type;\n }\n /**\n * Returns current type of oscillator eg. 'sine', 'triangle', 'sawtooth' or 'square'.\n *\n * @method getType\n * @for p5.Oscillator\n * @returns {String} type of oscillator eg . 'sine', 'triangle', 'sawtooth' or 'square'.\n */\n\n getType() {\n return this.oscillator.type;\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.Oscillator\n * @param {Object} unit A p5.sound or Web Audio object\n */\n connect(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n } else if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n this.connection = unit.input;\n } else {\n this.panner.connect(unit);\n this.connection = unit;\n }\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.Oscillator\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n if (this.panner) {\n this.panner.disconnect();\n if (this.output) {\n this.output.connect(this.panner);\n }\n }\n this.oscMods = [];\n }\n\n /**\n * Pan between Left (-1) and Right (1)\n *\n * @method pan\n * @for p5.Oscillator\n * @param {Number} panning Number between -1 and 1\n * @param {Number} timeFromNow schedule this event to happen\n * seconds from now\n */\n pan(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n }\n\n /**\n * Returns the current value of panPosition , between Left (-1) and Right (1)\n *\n * @method getPan\n * @for p5.Oscillator\n *\n * @returns {number} panPosition of oscillator , between Left (-1) and Right (1)\n */\n\n getPan() {\n return this.panPosition;\n }\n\n // get rid of the oscillator\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.oscillator) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.disconnect();\n this.panner = null;\n this.oscillator = null;\n }\n // if it is a Pulse\n if (this.osc2) {\n this.osc2.dispose();\n }\n }\n\n /**\n * Set the phase of an oscillator between 0.0 and 1.0.\n * In this implementation, phase is a delay time\n * based on the oscillator's current frequency.\n *\n * @method phase\n * @for p5.Oscillator\n * @param {Number} phase float between 0.0 and 1.0\n */\n phase(p) {\n var delayAmt = p5.prototype.map(p, 0, 1.0, 0, 1 / this.f);\n var now = p5sound.audiocontext.currentTime;\n\n this.phaseAmount = p;\n\n if (!this.dNode) {\n // create a delay node\n this.dNode = p5sound.audiocontext.createDelay();\n // put the delay node in between output and panner\n this.oscillator.disconnect();\n this.oscillator.connect(this.dNode);\n this.dNode.connect(this.output);\n }\n\n // set delay time to match phase:\n this.dNode.delayTime.setValueAtTime(delayAmt, now);\n }\n\n /**\n * Add a value to the p5.Oscillator's output amplitude,\n * and return the oscillator. Calling this method again\n * will override the initial add() with a new value.\n *\n * @method add\n * @for p5.Oscillator\n * @param {Number} number Constant number to add\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with scaled output\n *\n */\n add(num) {\n var add = new Add(num);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, add, thisChain, nextChain, Add);\n }\n /**\n * Multiply the p5.Oscillator's output amplitude\n * by a fixed value (i.e. turn it up!). Calling this method\n * again will override the initial mult() with a new value.\n *\n * @method mult\n * @for p5.Oscillator\n * @param {Number} number Constant number to multiply\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with multiplied output\n */\n mult(num) {\n var mult = new Mult(num);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, mult, thisChain, nextChain, Mult);\n }\n\n /**\n * Scale this oscillator's amplitude values to a given\n * range, and return the oscillator. Calling this method\n * again will override the initial scale() with new values.\n *\n * @method scale\n * @for p5.Oscillator\n * @param {Number} inMin input range minumum\n * @param {Number} inMax input range maximum\n * @param {Number} outMin input range minumum\n * @param {Number} outMax input range maximum\n * @return {p5.Oscillator} Oscillator Returns this oscillator\n * with scaled output\n */\n scale(inMin, inMax, outMin, outMax) {\n var mapOutMin, mapOutMax;\n if (arguments.length === 4) {\n mapOutMin = p5.prototype.map(outMin, inMin, inMax, 0, 1) - 0.5; //find a way to get rid of p5.prototype ?\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5; //find a way to get rid of p5.prototype ?\n } else {\n mapOutMin = arguments[0];\n mapOutMax = arguments[1];\n }\n var scale = new Scale(mapOutMin, mapOutMax);\n var thisChain = this.mathOps.length - 1;\n var nextChain = this.output;\n return sigChain(this, scale, thisChain, nextChain, Scale);\n\n // this.output.disconnect();\n // this.output.connect(scale)\n }\n}\n\n// ============================== //\n// SinOsc, TriOsc, SqrOsc, SawOsc //\n// ============================== //\n\n/**\n * Constructor: new p5.SinOsc().\n * This creates a Sine Wave Oscillator and is\n * equivalent to new p5.Oscillator('sine')\n * or creating a p5.Oscillator and then calling\n * its method setType('sine').\n * See p5.Oscillator for methods.\n *\n * @class p5.SinOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SinOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'sine');\n }\n}\n\n/**\n * Constructor: new p5.TriOsc().\n * This creates a Triangle Wave Oscillator and is\n * equivalent to new p5.Oscillator('triangle')\n * or creating a p5.Oscillator and then calling\n * its method setType('triangle').\n * See p5.Oscillator for methods.\n *\n * @class p5.TriOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass TriOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'triangle');\n }\n}\n\n/**\n * Constructor: new p5.SawOsc().\n * This creates a SawTooth Wave Oscillator and is\n * equivalent to new p5.Oscillator('sawtooth')\n * or creating a p5.Oscillator and then calling\n * its method setType('sawtooth').\n * See p5.Oscillator for methods.\n *\n * @class p5.SawOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SawOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'sawtooth');\n }\n}\n\n/**\n * Constructor: new p5.SqrOsc().\n * This creates a Square Wave Oscillator and is\n * equivalent to new p5.Oscillator('square')\n * or creating a p5.Oscillator and then calling\n * its method setType('square').\n * See p5.Oscillator for methods.\n *\n * @class p5.SqrOsc\n * @constructor\n * @extends p5.Oscillator\n * @param {Number} [freq] Set the frequency\n */\nclass SqrOsc extends Oscillator {\n constructor(freq) {\n super(freq, 'square');\n }\n}\n\nexport default Oscillator;\nexport { SinOsc, TriOsc, SawOsc, SqrOsc };\n","import p5sound from './main';\nimport Add from 'Tone/signal/Add';\nimport Mult from 'Tone/signal/Multiply';\nimport Scale from 'Tone/signal/Scale';\nimport TimelineSignal from 'Tone/signal/TimelineSignal.js';\n\n/**\n *

Envelopes are pre-defined amplitude distribution over time.\n * Typically, envelopes are used to control the output volume\n * of an object, a series of fades referred to as Attack, Decay,\n * Sustain and Release (\n * ADSR\n * ). Envelopes can also control other Web Audio Parameters—for example, a p5.Envelope can\n * control an Oscillator's frequency like this: osc.freq(env).

\n *

Use setRange to change the attack/release level.\n * Use setADSR to change attackTime, decayTime, sustainPercent and releaseTime.

\n *

Use the play method to play the entire envelope,\n * the ramp method for a pingable trigger,\n * or triggerAttack/\n * triggerRelease to trigger noteOn/noteOff.

\n *\n * @class p5.Envelope\n * @constructor\n * @example\n *
\n * let t1 = 0.1; // attack time in seconds\n * let l1 = 0.7; // attack level 0.0 to 1.0\n * let t2 = 0.3; // decay time in seconds\n * let l2 = 0.1; // decay level 0.0 to 1.0\n *\n * let env;\n * let triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * text('tap to play', 20, 20);\n * cnv.mousePressed(playSound);\n *\n * env = new p5.Envelope(t1, l1, t2, l2);\n * triOsc = new p5.Oscillator('triangle');\n * }\n *\n * function playSound() {\n * // starting the oscillator ensures that audio is enabled.\n * triOsc.start();\n * env.play(triOsc);\n * }\n *
\n */\np5.Envelope = function (t1, l1, t2, l2, t3, l3) {\n /**\n * Time until envelope reaches attackLevel\n * @property attackTime\n */\n this.aTime = t1 || 0.1;\n /**\n * Level once attack is complete.\n * @property attackLevel\n */\n this.aLevel = l1 || 1;\n /**\n * Time until envelope reaches decayLevel.\n * @property decayTime\n */\n this.dTime = t2 || 0.5;\n /**\n * Level after decay. The envelope will sustain here until it is released.\n * @property decayLevel\n */\n this.dLevel = l2 || 0;\n /**\n * Duration of the release portion of the envelope.\n * @property releaseTime\n */\n this.rTime = t3 || 0;\n /**\n * Level at the end of the release.\n * @property releaseLevel\n */\n this.rLevel = l3 || 0;\n\n this._rampHighPercentage = 0.98;\n\n this._rampLowPercentage = 0.02;\n\n this.output = p5sound.audiocontext.createGain();\n\n this.control = new TimelineSignal();\n\n this._init(); // this makes sure the envelope starts at zero\n\n this.control.connect(this.output); // connect to the output\n\n this.connection = null; // store connection\n\n //array of math operation signal chaining\n this.mathOps = [this.control];\n\n //whether envelope should be linear or exponential curve\n this.isExponential = false;\n\n // oscillator or buffer source to clear on env complete\n // to save resources if/when it is retriggered\n this.sourceToClear = null;\n\n // set to true if attack is set, then false on release\n this.wasTriggered = false;\n\n // add to the soundArray so we can dispose of the env later\n p5sound.soundArray.push(this);\n};\n\n// this init function just smooths the starting value to zero and gives a start point for the timeline\n// - it was necessary to remove glitches at the beginning.\np5.Envelope.prototype._init = function () {\n var now = p5sound.audiocontext.currentTime;\n var t = now;\n this.control.setTargetAtTime(0.00001, t, 0.001);\n //also, compute the correct time constants\n this._setRampAD(this.aTime, this.dTime);\n};\n\n/**\n * Reset the envelope with a series of time/value pairs.\n *\n * @method set\n * @for p5.Envelope\n * @param {Number} attackTime Time (in seconds) before level\n * reaches attackLevel\n * @param {Number} attackLevel Typically an amplitude between\n * 0.0 and 1.0\n * @param {Number} decayTime Time\n * @param {Number} decayLevel Amplitude (In a standard ADSR envelope,\n * decayLevel = sustainLevel)\n * @param {Number} releaseTime Release Time (in seconds)\n * @param {Number} releaseLevel Amplitude\n * @example\n *
\n * let attackTime;\n * let l1 = 0.7; // attack level 0.0 to 1.0\n * let t2 = 0.3; // decay time in seconds\n * let l2 = 0.1; // decay level 0.0 to 1.0\n * let l3 = 0.2; // release time in seconds\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n *\n * attackTime = map(mouseX, 0, width, 0.0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 20);\n * }\n *\n * // mouseClick triggers envelope if over canvas\n * function playSound() {\n * env.set(attackTime, l1, t2, l2, l3);\n *\n * triOsc.start();\n * env.play(triOsc);\n * }\n *
\n *\n */\np5.Envelope.prototype.set = function (t1, l1, t2, l2, t3, l3) {\n this.aTime = t1;\n this.aLevel = l1;\n this.dTime = t2 || 0;\n this.dLevel = l2 || 0;\n this.rTime = t3 || 0;\n this.rLevel = l3 || 0;\n\n // set time constants for ramp\n this._setRampAD(t1, t2);\n};\n\n/**\n * Set values like a traditional\n * \n * ADSR envelope\n * .\n *\n * @method setADSR\n * @for p5.Envelope\n * @param {Number} attackTime Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackTime = map(mouseX, 0, width, 0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 40);\n * }\n *\n * function playEnv() {\n * triOsc.start();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.setADSR = function (aTime, dTime, sPercent, rTime) {\n this.aTime = aTime;\n this.dTime = dTime || 0;\n\n // lerp\n this.sPercent = sPercent || 0;\n this.dLevel =\n typeof sPercent !== 'undefined'\n ? sPercent * (this.aLevel - this.rLevel) + this.rLevel\n : 0;\n\n this.rTime = rTime || 0;\n\n // also set time constants for ramp\n this._setRampAD(aTime, dTime);\n};\n\n/**\n * Set max (attackLevel) and min (releaseLevel) of envelope.\n *\n * @method setRange\n * @for p5.Envelope\n * @param {Number} aLevel attack level (defaults to 1)\n * @param {Number} rLevel release level (defaults to 0)\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackLevel = map(mouseY, height, 0, 0, 1.0);\n * text('attack level: ' + attackLevel, 5, height - 20);\n * }\n *\n * function playEnv() {\n * triOsc.start();\n * env.setRange(attackLevel, releaseLevel);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.setRange = function (aLevel, rLevel) {\n this.aLevel = aLevel || 1;\n this.rLevel = rLevel || 0;\n\n // not sure if this belongs here:\n\n // {Number} [dLevel] decay/sustain level (optional)\n // if (typeof(dLevel) !== 'undefined') {\n // this.dLevel = dLevel\n // } else if (this.sPercent) {\n // this.dLevel = this.sPercent ? this.sPercent * (this.aLevel - this.rLevel) + this.rLevel : 0;\n // }\n};\n\n// private (undocumented) method called when ADSR is set to set time constants for ramp\n//\n// Set the \n// time constants for simple exponential ramps.\n// The larger the time constant value, the slower the\n// transition will be.\n//\n// method _setRampAD\n// param {Number} attackTimeConstant attack time constant\n// param {Number} decayTimeConstant decay time constant\n//\np5.Envelope.prototype._setRampAD = function (t1, t2) {\n this._rampAttackTime = this.checkExpInput(t1);\n this._rampDecayTime = this.checkExpInput(t2);\n\n var TCDenominator = 1.0;\n /// Aatish Bhatia's calculation for time constant for rise(to adjust 1/1-e calculation to any percentage)\n TCDenominator = Math.log(\n 1.0 / this.checkExpInput(1.0 - this._rampHighPercentage)\n );\n this._rampAttackTC = t1 / this.checkExpInput(TCDenominator);\n TCDenominator = Math.log(1.0 / this._rampLowPercentage);\n this._rampDecayTC = t2 / this.checkExpInput(TCDenominator);\n};\n\n// private method\np5.Envelope.prototype.setRampPercentages = function (p1, p2) {\n //set the percentages that the simple exponential ramps go to\n this._rampHighPercentage = this.checkExpInput(p1);\n this._rampLowPercentage = this.checkExpInput(p2);\n var TCDenominator = 1.0;\n //now re-compute the time constants based on those percentages\n /// Aatish Bhatia's calculation for time constant for rise(to adjust 1/1-e calculation to any percentage)\n TCDenominator = Math.log(\n 1.0 / this.checkExpInput(1.0 - this._rampHighPercentage)\n );\n this._rampAttackTC = this._rampAttackTime / this.checkExpInput(TCDenominator);\n TCDenominator = Math.log(1.0 / this._rampLowPercentage);\n this._rampDecayTC = this._rampDecayTime / this.checkExpInput(TCDenominator);\n};\n\n/**\n * Assign a parameter to be controlled by this envelope.\n * If a p5.Sound object is given, then the p5.Envelope will control its\n * output gain. If multiple inputs are provided, the env will\n * control all of them.\n *\n * @method setInput\n * @for p5.Envelope\n * @param {Object} [...inputs] A p5.sound object or\n * Web Audio Param.\n */\np5.Envelope.prototype.setInput = function () {\n for (var i = 0; i < arguments.length; i++) {\n this.connect(arguments[i]);\n }\n};\n\n/**\n * Set whether the envelope ramp is linear (default) or exponential.\n * Exponential ramps can be useful because we perceive amplitude\n * and frequency logarithmically.\n *\n * @method setExp\n * @for p5.Envelope\n * @param {Boolean} isExp true is exponential, false is linear\n */\np5.Envelope.prototype.setExp = function (isExp) {\n this.isExponential = isExp;\n};\n\n//helper method to protect against zero values being sent to exponential functions\np5.Envelope.prototype.checkExpInput = function (value) {\n if (value <= 0) {\n value = 0.00000001;\n }\n return value;\n};\n\n/**\n *

Play tells the envelope to start acting on a given input.\n * If the input is a p5.sound object (i.e. AudioIn, Oscillator,\n * SoundFile), then Envelope will control its output volume.\n * Envelopes can also be used to control any \n * Web Audio Audio Param.

\n *\n * @method play\n * @for p5.Envelope\n * @param {Object} unit A p5.sound object or\n * Web Audio Param.\n * @param {Number} [startTime] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\n * @example\n *
\n * let attackLevel = 1.0;\n * let releaseLevel = 0;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.2;\n * let releaseTime = 0.5;\n *\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playEnv);\n *\n * env = new p5.Envelope();\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.amp(env);\n * triOsc.freq(220);\n * triOsc.start();\n * }\n *\n * function draw() {\n * background(220);\n * text('tap here to play', 5, 20);\n * attackTime = map(mouseX, 0, width, 0, 1.0);\n * attackLevel = map(mouseY, height, 0, 0, 1.0);\n * text('attack time: ' + attackTime, 5, height - 40);\n * text('attack level: ' + attackLevel, 5, height - 20);\n * }\n *\n * function playEnv() {\n * // ensure that audio is enabled\n * userStartAudio();\n *\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(attackLevel, releaseLevel);\n * env.play();\n * }\n *
\n */\np5.Envelope.prototype.play = function (unit, secondsFromNow, susTime) {\n var tFromNow = secondsFromNow || 0;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n this.triggerAttack(unit, tFromNow);\n\n this.triggerRelease(unit, tFromNow + this.aTime + this.dTime + ~~susTime);\n};\n\n/**\n * Trigger the Attack, and Decay portion of the Envelope.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go. Input can be\n * any p5.sound object, or a \n * Web Audio Param.\n *\n * @method triggerAttack\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow time from now (in seconds)\n * @example\n *
\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.3;\n * let releaseTime = 0.4;\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * textSize(10);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(1.0, 0.0);\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.freq(220);\n *\n * cnv.mousePressed(envAttack);\n * }\n *\n * function envAttack() {\n * background(0, 255, 255);\n * text('release to release', width/2, height/2);\n *\n * // ensures audio is enabled. See also: `userStartAudio`\n * triOsc.start();\n *\n * env.triggerAttack(triOsc);\n * }\n *\n * function mouseReleased() {\n * background(220);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env.triggerRelease(triOsc);\n * }\n *
\n */\np5.Envelope.prototype.triggerAttack = function (unit, secondsFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n this.lastAttack = t;\n this.wasTriggered = true;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n // get and set value (with linear ramp) to anchor automation\n var valToSet = this.control.getValueAtTime(t);\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n } else {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // after each ramp completes, cancel scheduled values\n // (so they can be overridden in case env has been re-triggered)\n // then, set current value (with linearRamp to avoid click)\n // then, schedule the next automation...\n\n // attack\n t += this.aTime;\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.aLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.aLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // decay to decay level (if using ADSR, then decay level == sustain level)\n t += this.dTime;\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.dLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.dLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n};\n\n/**\n * Trigger the Release of the Envelope. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @method triggerRelease\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow time to trigger the release\n * @example\n *
\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let susPercent = 0.3;\n * let releaseTime = 0.4;\n * let env, triOsc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * textSize(10);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime, susPercent, releaseTime);\n * env.setRange(1.0, 0.0);\n * triOsc = new p5.Oscillator('triangle');\n * triOsc.freq(220);\n *\n * cnv.mousePressed(envAttack);\n * }\n *\n * function envAttack() {\n * background(0, 255, 255);\n * text('release to release', width/2, height/2);\n *\n * // ensures audio is enabled. See also: `userStartAudio`\n * triOsc.start();\n *\n * env.triggerAttack(triOsc);\n * }\n *\n * function mouseReleased() {\n * background(220);\n * text('tap to triggerAttack', width/2, height/2);\n *\n * env.triggerRelease(triOsc);\n * }\n *
\n */\np5.Envelope.prototype.triggerRelease = function (unit, secondsFromNow) {\n // only trigger a release if an attack was triggered\n if (!this.wasTriggered) {\n // this currently causes a bit of trouble:\n // if a later release has been scheduled (via the play function)\n // a new earlier release won't interrupt it, because\n // this.wasTriggered has already been set to false.\n // If we want new earlier releases to override, then we need to\n // keep track of the last release time, and if the new release time is\n // earlier, then use it.\n return;\n }\n\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n // get and set value (with linear or exponential ramp) to anchor automation\n var valToSet = this.control.getValueAtTime(t);\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n } else {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // release\n t += this.rTime;\n\n if (this.isExponential === true) {\n this.control.exponentialRampToValueAtTime(\n this.checkExpInput(this.rLevel),\n t\n );\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n } else {\n this.control.linearRampToValueAtTime(this.rLevel, t);\n valToSet = this.control.getValueAtTime(t);\n this.control.cancelScheduledValues(t);\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n this.wasTriggered = false;\n};\n\n/**\n * Exponentially ramp to a value using the first two\n * values from setADSR(attackTime, decayTime)\n * as \n * time constants for simple exponential ramps.\n * If the value is higher than current value, it uses attackTime,\n * while a decrease uses decayTime.\n *\n * @method ramp\n * @for p5.Envelope\n * @param {Object} unit p5.sound Object or Web Audio Param\n * @param {Number} secondsFromNow When to trigger the ramp\n * @param {Number} v Target value\n * @param {Number} [v2] Second target value\n * @example\n *
\n * let env, osc, amp;\n *\n * let attackTime = 0.001;\n * let decayTime = 0.2;\n * let attackLevel = 1;\n * let decayLevel = 0;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * fill(0,255,0);\n * noStroke();\n *\n * env = new p5.Envelope();\n * env.setADSR(attackTime, decayTime);\n * osc = new p5.Oscillator();\n * osc.amp(env);\n * amp = new p5.Amplitude();\n *\n * cnv.mousePressed(triggerRamp);\n * }\n *\n * function triggerRamp() {\n * // ensures audio is enabled. See also: `userStartAudio`\n * osc.start();\n *\n * env.ramp(osc, 0, attackLevel, decayLevel);\n * }\n *\n * function draw() {\n * background(20);\n * text('tap to play', 10, 20);\n * let h = map(amp.getLevel(), 0, 0.4, 0, height);;\n * rect(0, height, width, -h);\n * }\n *
\n */\np5.Envelope.prototype.ramp = function (unit, secondsFromNow, v1, v2) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n var destination1 = this.checkExpInput(v1);\n var destination2 =\n typeof v2 !== 'undefined' ? this.checkExpInput(v2) : undefined;\n\n // connect env to unit if not already connected\n if (unit) {\n if (this.connection !== unit) {\n this.connect(unit);\n }\n }\n\n //get current value\n var currentVal = this.checkExpInput(this.control.getValueAtTime(t));\n // this.control.cancelScheduledValues(t);\n\n //if it's going up\n if (destination1 > currentVal) {\n this.control.setTargetAtTime(destination1, t, this._rampAttackTC);\n t += this._rampAttackTime;\n }\n\n //if it's going down\n else if (destination1 < currentVal) {\n this.control.setTargetAtTime(destination1, t, this._rampDecayTC);\n t += this._rampDecayTime;\n }\n\n // Now the second part of envelope begins\n if (destination2 === undefined) return;\n\n //if it's going up\n if (destination2 > destination1) {\n this.control.setTargetAtTime(destination2, t, this._rampAttackTC);\n }\n\n //if it's going down\n else if (destination2 < destination1) {\n this.control.setTargetAtTime(destination2, t, this._rampDecayTC);\n }\n};\n\np5.Envelope.prototype.connect = function (unit) {\n this.connection = unit;\n\n // assume we're talking about output gain\n // unless given a different audio param\n if (\n unit instanceof p5.Oscillator ||\n unit instanceof p5.SoundFile ||\n unit instanceof p5.AudioIn ||\n unit instanceof p5.Reverb ||\n unit instanceof p5.Noise ||\n unit instanceof p5.Filter ||\n unit instanceof p5.Delay\n ) {\n unit = unit.output.gain;\n }\n if (unit instanceof AudioParam) {\n //set the initial value\n unit.setValueAtTime(0, p5sound.audiocontext.currentTime);\n }\n\n this.output.connect(unit);\n};\n\np5.Envelope.prototype.disconnect = function () {\n if (this.output) {\n this.output.disconnect();\n }\n};\n\n// Signal Math\n\n/**\n * Add a value to the p5.Oscillator's output amplitude,\n * and return the oscillator. Calling this method\n * again will override the initial add() with new values.\n *\n * @method add\n * @for p5.Envelope\n * @param {Number} number Constant number to add\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.add = function (num) {\n var add = new Add(num);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, add, thisChain, nextChain, Add);\n};\n\n/**\n * Multiply the p5.Envelope's output amplitude\n * by a fixed value. Calling this method\n * again will override the initial mult() with new values.\n *\n * @method mult\n * @for p5.Envelope\n * @param {Number} number Constant number to multiply\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.mult = function (num) {\n var mult = new Mult(num);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, mult, thisChain, nextChain, Mult);\n};\n\n/**\n * Scale this envelope's amplitude values to a given\n * range, and return the envelope. Calling this method\n * again will override the initial scale() with new values.\n *\n * @method scale\n * @for p5.Envelope\n * @param {Number} inMin input range minumum\n * @param {Number} inMax input range maximum\n * @param {Number} outMin input range minumum\n * @param {Number} outMax input range maximum\n * @return {p5.Envelope} Envelope Returns this envelope\n * with scaled output\n */\np5.Envelope.prototype.scale = function (inMin, inMax, outMin, outMax) {\n var scale = new Scale(inMin, inMax, outMin, outMax);\n var thisChain = this.mathOps.length;\n var nextChain = this.output;\n return p5.prototype._mathChain(this, scale, thisChain, nextChain, Scale);\n};\n\n// get rid of the oscillator\np5.Envelope.prototype.dispose = function () {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.disconnect();\n if (this.control) {\n this.control.dispose();\n this.control = null;\n }\n for (var i = 1; i < this.mathOps.length; i++) {\n this.mathOps[i].dispose();\n }\n};\n\n// Different name for backwards compatibility, replicates p5.Envelope class\np5.Env = function (t1, l1, t2, l2, t3, l3) {\n console.warn(\n 'WARNING: p5.Env is now deprecated and may be removed in future versions. ' +\n 'Please use the new p5.Envelope instead.'\n );\n p5.Envelope.call(this, t1, l1, t2, l2, t3, l3);\n};\np5.Env.prototype = Object.create(p5.Envelope.prototype);\n\nconst Envelope = p5.Envelope;\nexport default Envelope;\n","import p5sound from './main';\nimport Oscillator from './oscillator';\n\n// generate noise buffers\nconst _whiteNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var whiteBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = whiteBuffer.getChannelData(0);\n for (var i = 0; i < bufferSize; i++) {\n noiseData[i] = Math.random() * 2 - 1;\n }\n whiteBuffer.type = 'white';\n return whiteBuffer;\n})();\n\nconst _pinkNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var pinkBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = pinkBuffer.getChannelData(0);\n var b0, b1, b2, b3, b4, b5, b6;\n b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0.0;\n for (var i = 0; i < bufferSize; i++) {\n var white = Math.random() * 2 - 1;\n b0 = 0.99886 * b0 + white * 0.0555179;\n b1 = 0.99332 * b1 + white * 0.0750759;\n b2 = 0.969 * b2 + white * 0.153852;\n b3 = 0.8665 * b3 + white * 0.3104856;\n b4 = 0.55 * b4 + white * 0.5329522;\n b5 = -0.7616 * b5 - white * 0.016898;\n noiseData[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362;\n noiseData[i] *= 0.11; // (roughly) compensate for gain\n b6 = white * 0.115926;\n }\n pinkBuffer.type = 'pink';\n return pinkBuffer;\n})();\n\nconst _brownNoiseBuffer = (function () {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var brownBuffer = p5sound.audiocontext.createBuffer(\n 1,\n bufferSize,\n p5sound.audiocontext.sampleRate\n );\n var noiseData = brownBuffer.getChannelData(0);\n var lastOut = 0.0;\n for (var i = 0; i < bufferSize; i++) {\n var white = Math.random() * 2 - 1;\n noiseData[i] = (lastOut + 0.02 * white) / 1.02;\n lastOut = noiseData[i];\n noiseData[i] *= 3.5;\n }\n brownBuffer.type = 'brown';\n return brownBuffer;\n})();\n\n/**\n * Noise is a type of oscillator that generates a buffer with random values.\n *\n * @class p5.Noise\n * @extends p5.Oscillator\n * @constructor\n * @param {String} type Type of noise can be 'white' (default),\n * 'brown' or 'pink'.\n */\nclass Noise extends Oscillator {\n constructor(type) {\n super();\n var assignType;\n delete this.f;\n delete this.freq;\n delete this.oscillator;\n\n if (type === 'brown') {\n assignType = _brownNoiseBuffer;\n } else if (type === 'pink') {\n assignType = _pinkNoiseBuffer;\n } else {\n assignType = _whiteNoiseBuffer;\n }\n this.buffer = assignType;\n }\n\n /**\n * Set type of noise to 'white', 'pink' or 'brown'.\n * White is the default.\n *\n * @method setType\n * @param {String} [type] 'white', 'pink' or 'brown'\n */\n setType(type) {\n switch (type) {\n case 'white':\n this.buffer = _whiteNoiseBuffer;\n break;\n case 'pink':\n this.buffer = _pinkNoiseBuffer;\n break;\n case 'brown':\n this.buffer = _brownNoiseBuffer;\n break;\n default:\n this.buffer = _whiteNoiseBuffer;\n }\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.start(now + 0.01);\n }\n }\n\n getType() {\n return this.buffer.type;\n }\n start() {\n if (this.started) {\n this.stop();\n }\n this.noise = p5sound.audiocontext.createBufferSource();\n this.noise.buffer = this.buffer;\n this.noise.loop = true;\n this.noise.connect(this.output);\n var now = p5sound.audiocontext.currentTime;\n this.noise.start(now);\n this.started = true;\n }\n\n stop() {\n var now = p5sound.audiocontext.currentTime;\n if (this.noise) {\n this.noise.stop(now);\n this.started = false;\n }\n }\n\n dispose() {\n var now = p5sound.audiocontext.currentTime;\n\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.noise) {\n this.noise.disconnect();\n this.stop(now);\n }\n if (this.output) {\n this.output.disconnect();\n }\n if (this.panner) {\n this.panner.disconnect();\n }\n this.output = null;\n this.panner = null;\n this.buffer = null;\n this.noise = null;\n }\n}\n\nexport default Noise;\n","import Signal from 'Tone/signal/Signal';\nimport Multiply from 'Tone/signal/Multiply';\n\nimport p5sound from './main';\nimport Oscillator, { SawOsc } from './oscillator';\n\n/**\n * Creates a Pulse object, an oscillator that implements\n * Pulse Width Modulation.\n * The pulse is created with two oscillators.\n * Accepts a parameter for frequency, and to set the\n * width between the pulses. See \n * p5.Oscillator for a full list of methods.\n *\n * @class p5.Pulse\n * @extends p5.Oscillator\n * @constructor\n * @param {Number} [freq] Frequency in oscillations per second (Hz)\n * @param {Number} [w] Width between the pulses (0 to 1.0,\n * defaults to 0)\n * @example\n *
\n * let pulse;\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startPulse);\n * background(220);\n *\n * pulse = new p5.Pulse();\n * pulse.amp(0.5);\n * pulse.freq(220);\n * }\n * function startPulse() {\n * pulse.start();\n * pulse.amp(0.5, 0.02);\n * }\n * function mouseReleased() {\n * pulse.amp(0, 0.2);\n * }\n * function draw() {\n * background(220);\n * text('tap to play', 5, 20, width - 20);\n * let w = map(mouseX, 0, width, 0, 1);\n * w = constrain(w, 0, 1);\n * pulse.width(w);\n * text('pulse width: ' + w, 5, height - 20);\n * }\n *
\n */\nclass Pulse extends Oscillator {\n constructor(freq, w) {\n super(freq, 'sawtooth');\n\n // width of PWM, should be betw 0 to 1.0\n this.w = w || 0;\n\n // create a second oscillator with inverse frequency\n this.osc2 = new SawOsc(freq);\n\n // create a delay node\n this.dNode = p5sound.audiocontext.createDelay();\n\n // dc offset\n this.dcOffset = createDCOffset();\n this.dcGain = p5sound.audiocontext.createGain();\n this.dcOffset.connect(this.dcGain);\n this.dcGain.connect(this.output);\n // set delay time based on PWM width\n this.f = freq || 440;\n var mW = this.w / this.oscillator.frequency.value;\n this.dNode.delayTime.value = mW;\n this.dcGain.gain.value = 1.7 * (0.5 - this.w);\n\n // disconnect osc2 and connect it to delay, which is connected to output\n this.osc2.disconnect();\n this.osc2.panner.disconnect();\n this.osc2.amp(-1); // inverted amplitude\n this.osc2.output.connect(this.dNode);\n this.dNode.connect(this.output);\n\n this.output.gain.value = 1;\n this.output.connect(this.panner);\n }\n\n /**\n * Set the width of a Pulse object (an oscillator that implements\n * Pulse Width Modulation).\n *\n * @method width\n * @param {Number} [width] Width between the pulses (0 to 1.0,\n * defaults to 0)\n */\n width(w) {\n if (typeof w === 'number') {\n if (w <= 1.0 && w >= 0.0) {\n this.w = w;\n // set delay time based on PWM width\n\n // var mW = map(this.w, 0, 1.0, 0, 1/this.f);\n var mW = this.w / this.oscillator.frequency.value;\n this.dNode.delayTime.value = mW;\n }\n\n this.dcGain.gain.value = 1.7 * (0.5 - this.w);\n } else {\n w.connect(this.dNode.delayTime);\n let sig = new Signal(-0.5); //repalce it with tones Signals Method\n w.connect(sig);\n let mult1 = new Multiply(-1);\n let mult2 = new Multiply(1.7);\n sig = sig.connect(mult1).connect(mult2);\n sig.connect(this.dcGain.gain);\n }\n }\n\n start(f, time) {\n var now = p5sound.audiocontext.currentTime;\n var t = time || 0;\n if (!this.started) {\n var freq = f || this.f;\n var type = this.oscillator.type;\n this.oscillator = p5sound.audiocontext.createOscillator();\n this.oscillator.frequency.setValueAtTime(freq, now);\n this.oscillator.type = type;\n this.oscillator.connect(this.output);\n this.oscillator.start(t + now);\n\n // set up osc2\n this.osc2.oscillator = p5sound.audiocontext.createOscillator();\n this.osc2.oscillator.frequency.setValueAtTime(freq, t + now);\n this.osc2.oscillator.type = type;\n this.osc2.oscillator.connect(this.osc2.output);\n this.osc2.start(t + now);\n this.freqNode = [\n this.oscillator.frequency,\n this.osc2.oscillator.frequency,\n ];\n\n // start dcOffset, too\n this.dcOffset = createDCOffset();\n this.dcOffset.connect(this.dcGain);\n this.dcOffset.start(t + now);\n\n // if LFO connections depend on these oscillators\n if (this.mods !== undefined && this.mods.frequency !== undefined) {\n this.mods.frequency.connect(this.freqNode[0]);\n this.mods.frequency.connect(this.freqNode[1]);\n }\n this.started = true;\n this.osc2.started = true;\n }\n }\n\n stop(time) {\n if (this.started) {\n var t = time || 0;\n var now = p5sound.audiocontext.currentTime;\n this.oscillator.stop(t + now);\n if (this.osc2.oscillator) {\n this.osc2.oscillator.stop(t + now);\n }\n this.dcOffset.stop(t + now);\n this.started = false;\n this.osc2.started = false;\n }\n }\n\n freq(val, rampTime = 0, tFromNow = 0) {\n if (typeof val === 'number') {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n var currentFreq = this.oscillator.frequency.value;\n this.oscillator.frequency.cancelScheduledValues(now);\n this.oscillator.frequency.setValueAtTime(currentFreq, now + tFromNow);\n this.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n this.osc2.oscillator.frequency.cancelScheduledValues(now);\n this.osc2.oscillator.frequency.setValueAtTime(\n currentFreq,\n now + tFromNow\n );\n this.osc2.oscillator.frequency.exponentialRampToValueAtTime(\n val,\n tFromNow + rampTime + now\n );\n\n if (this.freqMod) {\n this.freqMod.output.disconnect();\n this.freqMod = null;\n }\n } else if (val.output) {\n val.output.disconnect();\n val.output.connect(this.oscillator.frequency);\n val.output.connect(this.osc2.oscillator.frequency);\n this.freqMod = val;\n }\n }\n}\n\n// inspiration: http://webaudiodemos.appspot.com/oscilloscope/\nfunction createDCOffset() {\n var ac = p5sound.audiocontext;\n var buffer = ac.createBuffer(1, 2048, ac.sampleRate);\n var data = buffer.getChannelData(0);\n for (var i = 0; i < 2048; i++) data[i] = 1.0;\n var bufferSource = ac.createBufferSource();\n bufferSource.buffer = buffer;\n bufferSource.loop = true;\n return bufferSource;\n}\n\nexport default Pulse;\n","import p5sound from './main';\nimport Amplitude from './amplitude';\n\n// an array of input sources\np5sound.inputSources = [];\n\n/**\n *

Get audio from an input, i.e. your computer's microphone.

\n *\n *

Turn the mic on/off with the start() and stop() methods. When the mic\n * is on, its volume can be measured with getLevel or by connecting an\n * FFT object.

\n *\n *

If you want to hear the AudioIn, use the .connect() method.\n * AudioIn does not connect to p5.sound output by default to prevent\n * feedback.

\n *\n *

Note: This uses the getUserMedia/\n * Stream API, which is not supported by certain browsers. Access in Chrome browser\n * is limited to localhost and https, but access over http may be limited.

\n *\n * @class p5.AudioIn\n * @constructor\n * @param {Function} [errorCallback] A function to call if there is an error\n * accessing the AudioIn. For example,\n * Safari and iOS devices do not\n * currently allow microphone access.\n * @example\n *
\n * let mic;\n *\n * function setup(){\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(userStartAudio);\n * textAlign(CENTER);\n * mic = new p5.AudioIn();\n * mic.start();\n * }\n *\n * function draw(){\n * background(0);\n * fill(255);\n * text('tap to start', width/2, 20);\n *\n * micLevel = mic.getLevel();\n * let y = height - micLevel * height;\n * ellipse(width/2, y, 10, 10);\n * }\n *
\n */\nclass AudioIn {\n constructor(errorCallback) {\n // set up audio input\n /**\n * @property {GainNode} input\n */\n this.input = p5sound.audiocontext.createGain();\n /**\n * @property {GainNode} output\n */\n this.output = p5sound.audiocontext.createGain();\n\n /**\n * @property {MediaStream|null} stream\n */\n this.stream = null;\n /**\n * @property {MediaStreamAudioSourceNode|null} mediaStream\n */\n this.mediaStream = null;\n /**\n * @property {Number|null} currentSource\n */\n this.currentSource = null;\n\n /**\n * Client must allow browser to access their microphone / audioin source.\n * Default: false. Will become true when the client enables access.\n *\n * @property {Boolean} enabled\n */\n this.enabled = false;\n\n /**\n * Input amplitude, connect to it by default but not to master out\n *\n * @property {p5.Amplitude} amplitude\n */\n this.amplitude = new Amplitude();\n this.output.connect(this.amplitude.input);\n\n if (\n !window.MediaStreamTrack ||\n !window.navigator.mediaDevices ||\n !window.navigator.mediaDevices.getUserMedia\n ) {\n errorCallback\n ? errorCallback()\n : window.alert(\n 'This browser does not support MediaStreamTrack and mediaDevices'\n );\n }\n\n // add to soundArray so we can dispose on close\n p5sound.soundArray.push(this);\n }\n /**\n * Start processing audio input. This enables the use of other\n * AudioIn methods like getLevel(). Note that by default, AudioIn\n * is not connected to p5.sound's output. So you won't hear\n * anything unless you use the connect() method.
\n *\n * Certain browsers limit access to the user's microphone. For example,\n * Chrome only allows access from localhost and over https. For this reason,\n * you may want to include an errorCallback—a function that is called in case\n * the browser won't provide mic access.\n *\n * @method start\n * @for p5.AudioIn\n * @param {Function} [successCallback] Name of a function to call on\n * success.\n * @param {Function} [errorCallback] Name of a function to call if\n * there was an error. For example,\n * some browsers do not support\n * getUserMedia.\n */\n start(successCallback, errorCallback) {\n var self = this;\n\n if (this.stream) {\n this.stop();\n }\n\n // set the audio source\n var audioSource = p5sound.inputSources[self.currentSource];\n var constraints = {\n audio: {\n sampleRate: p5sound.audiocontext.sampleRate,\n echoCancellation: false,\n },\n };\n\n // if developers determine which source to use\n if (p5sound.inputSources[this.currentSource]) {\n constraints.audio.deviceId = audioSource.deviceId;\n }\n\n window.navigator.mediaDevices\n .getUserMedia(constraints)\n .then(function (stream) {\n self.stream = stream;\n self.enabled = true;\n // Wrap a MediaStreamSourceNode around the live input\n self.mediaStream = p5sound.audiocontext.createMediaStreamSource(stream);\n self.mediaStream.connect(self.output);\n // only send to the Amplitude reader, so we can see it but not hear it.\n self.amplitude.setInput(self.output);\n if (successCallback) successCallback();\n })\n .catch(function (err) {\n if (errorCallback) errorCallback(err);\n else console.error(err);\n });\n }\n\n /**\n * Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().\n * If re-starting, the user may be prompted for permission access.\n *\n * @method stop\n * @for p5.AudioIn\n */\n stop() {\n if (this.stream) {\n this.stream.getTracks().forEach(function (track) {\n track.stop();\n });\n\n this.mediaStream.disconnect();\n\n delete this.mediaStream;\n delete this.stream;\n }\n }\n\n /**\n * Connect to an audio unit. If no parameter is provided, will\n * connect to the main output (i.e. your speakers).
\n *\n * @method connect\n * @for p5.AudioIn\n * @param {Object} [unit] An object that accepts audio input,\n * such as an FFT\n */\n connect(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n } else if (unit.hasOwnProperty('analyser')) {\n this.output.connect(unit.analyser);\n } else {\n this.output.connect(unit);\n }\n } else {\n this.output.connect(p5sound.input);\n }\n }\n\n /**\n * Disconnect the AudioIn from all audio units. For example, if\n * connect() had been called, disconnect() will stop sending\n * signal to your speakers.
\n *\n * @method disconnect\n * @for p5.AudioIn\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n // stay connected to amplitude even if not outputting to p5\n this.output.connect(this.amplitude.input);\n }\n }\n\n /**\n * Read the Amplitude (volume level) of an AudioIn. The AudioIn\n * class contains its own instance of the Amplitude class to help\n * make it easy to get a microphone's volume level. Accepts an\n * optional smoothing value (0.0 < 1.0). NOTE: AudioIn must\n * .start() before using .getLevel().
\n *\n * @method getLevel\n * @for p5.AudioIn\n * @param {Number} [smoothing] Smoothing is 0.0 by default.\n * Smooths values based on previous values.\n * @return {Number} Volume level (between 0.0 and 1.0)\n */\n getLevel(smoothing) {\n if (smoothing) {\n this.amplitude.smoothing = smoothing;\n }\n return this.amplitude.getLevel();\n }\n\n /**\n * Set amplitude (volume) of a mic input between 0 and 1.0.
\n *\n * @method amp\n * @for p5.AudioIn\n * @param {Number} vol between 0 and 1.0\n * @param {Number} [time] ramp time (optional)\n */\n amp(vol, t) {\n if (t) {\n var rampTime = t || 0;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\n this.output.gain.setValueAtTime(\n currentVol,\n p5sound.audiocontext.currentTime\n );\n this.output.gain.linearRampToValueAtTime(\n vol,\n rampTime + p5sound.audiocontext.currentTime\n );\n } else {\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\n this.output.gain.setValueAtTime(vol, p5sound.audiocontext.currentTime);\n }\n }\n\n /**\n * Returns a list of available input sources. This is a wrapper\n * for \n * MediaDevices.enumerateDevices() - Web APIs | MDN\n * and it returns a Promise.\n * @method getSources\n * @for p5.AudioIn\n * @param {Function} [successCallback] This callback function handles the sources when they\n * have been enumerated. The callback function\n * receives the deviceList array as its only argument\n * @param {Function} [errorCallback] This optional callback receives the error\n * message as its argument.\n * @returns {Promise} Returns a Promise that can be used in place of the callbacks, similar\n * to the enumerateDevices() method\n * @example\n *
\n * let audioIn;\n *\n * function setup(){\n * text('getting sources...', 0, 20);\n * audioIn = new p5.AudioIn();\n * audioIn.getSources(gotSources);\n * }\n *\n * function gotSources(deviceList) {\n * if (deviceList.length > 0) {\n * //set the source to the first item in the deviceList array\n * audioIn.setSource(0);\n * let currentSource = deviceList[audioIn.currentSource];\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\n * }\n * }\n *
\n */\n getSources(onSuccess, onError) {\n return new Promise(function (resolve, reject) {\n window.navigator.mediaDevices\n .enumerateDevices()\n .then(function (devices) {\n p5sound.inputSources = devices.filter(function (device) {\n return device.kind === 'audioinput';\n });\n resolve(p5sound.inputSources);\n if (onSuccess) {\n onSuccess(p5sound.inputSources);\n }\n })\n .catch(function (error) {\n reject(error);\n if (onError) {\n onError(error);\n } else {\n console.error(\n 'This browser does not support MediaStreamTrack.getSources()'\n );\n }\n });\n });\n }\n\n /**\n * Set the input source. Accepts a number representing a\n * position in the array returned by getSources().\n * This is only available in browsers that support\n * \n * navigator.mediaDevices.enumerateDevices()\n *\n * @method setSource\n * @for p5.AudioIn\n * @param {number} num position of input source in the array\n * @example\n *
\n * let audioIn;\n *\n * function setup(){\n * text('getting sources...', 0, 20);\n * audioIn = new p5.AudioIn();\n * audioIn.getSources(gotSources);\n * }\n *\n * function gotSources(deviceList) {\n * if (deviceList.length > 0) {\n * //set the source to the first item in the deviceList array\n * audioIn.setSource(0);\n * let currentSource = deviceList[audioIn.currentSource];\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\n * }\n * }\n *
\n */\n setSource(num) {\n if (p5sound.inputSources.length > 0 && num < p5sound.inputSources.length) {\n // set the current source\n this.currentSource = num;\n console.log('set source to ', p5sound.inputSources[this.currentSource]);\n } else {\n console.log('unable to set input source');\n }\n\n // restart stream if currently active\n if (this.stream && this.stream.active) {\n this.start();\n }\n }\n\n // private method\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this.stop();\n\n if (this.output) {\n this.output.disconnect();\n }\n if (this.amplitude) {\n this.amplitude.disconnect();\n }\n delete this.amplitude;\n delete this.output;\n }\n}\n\nexport default AudioIn;\n","import p5sound from './main';\nimport CrossFade from 'Tone/component/CrossFade.js';\n\n/**\n * Effect is a base class for audio effects in p5.
\n * This module handles the nodes and methods that are\n * common and useful for current and future effects.\n *\n *\n * This class is extended by p5.Distortion,\n * p5.Compressor,\n * p5.Delay,\n * p5.Filter,\n * p5.Reverb.\n *\n * @class p5.Effect\n * @constructor\n *\n * @param {Object} [ac] Reference to the audio context of the p5 object\n * @param {AudioNode} [input] Gain Node effect wrapper\n * @param {AudioNode} [output] Gain Node effect wrapper\n * @param {Object} [_drywet] Tone.JS CrossFade node (defaults to value: 1)\n * @param {AudioNode} [wet] Effects that extend this class should connect\n * to the wet signal to this gain node, so that dry and wet\n * signals are mixed properly.\n */\nclass Effect {\n constructor() {\n this.ac = p5sound.audiocontext;\n\n this.input = this.ac.createGain();\n this.output = this.ac.createGain();\n\n /**\n *\tThe p5.Effect class is built\n * \tusing Tone.js CrossFade\n * \t@private\n */\n\n this._drywet = new CrossFade(1);\n\n /**\n *\tIn classes that extend\n *\tp5.Effect, connect effect nodes\n *\tto the wet parameter\n */\n this.wet = this.ac.createGain();\n\n this.input.connect(this._drywet.a);\n this.wet.connect(this._drywet.b);\n this._drywet.connect(this.output);\n\n this.connect();\n\n //Add to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Set the output volume of the filter.\n *\n * @method amp\n * @for p5.Effect\n * @param {Number} [vol] amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts until rampTime\n * @param {Number} [tFromNow] schedule this event to happen in tFromNow seconds\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n const now = p5sound.audiocontext.currentTime;\n const startTime = now + tFromNow;\n const endTime = startTime + rampTime + 0.001;\n const currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now);\n this.output.gain.linearRampToValueAtTime(currentVol, startTime + 0.001);\n this.output.gain.linearRampToValueAtTime(vol, endTime);\n }\n\n /**\n * Link effects together in a chain\n * Example usage: filter.chain(reverb, delay, panner);\n * May be used with an open-ended number of arguments\n *\n * @method chain\n * @for p5.Effect\n * @param {Object} [arguments] Chain together multiple sound objects\n */\n chain() {\n if (arguments.length > 0) {\n this.connect(arguments[0]);\n for (var i = 1; i < arguments.length; i += 1) {\n arguments[i - 1].connect(arguments[i]);\n }\n }\n return this;\n }\n\n /**\n * Adjust the dry/wet value.\n *\n * @method drywet\n * @for p5.Effect\n * @param {Number} [fade] The desired drywet value (0 - 1.0)\n */\n drywet(fade) {\n if (typeof fade !== 'undefined') {\n this._drywet.fade.value = fade;\n }\n return this._drywet.fade.value;\n }\n\n /**\n * Send output to a p5.js-sound, Web Audio Node, or use signal to\n * control an AudioParam\n *\n * @method connect\n * @for p5.Effect\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5.soundOut.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all output.\n * @method disconnect\n * @for p5.Effect\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n dispose() {\n // remove refernce form soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n\n if (this._drywet) {\n this._drywet.disconnect();\n delete this._drywet;\n }\n\n if (this.wet) {\n this.wet.disconnect();\n delete this.wet;\n }\n\n this.ac = undefined;\n }\n}\n\nexport default Effect;\n","import Effect from './effect';\n\n/**\n *

A p5.Filter uses a Web Audio Biquad Filter to filter\n * the frequency response of an input source. Subclasses\n * include:

\n * p5.LowPass:\n * Allows frequencies below the cutoff frequency to pass through,\n * and attenuates frequencies above the cutoff.
\n * p5.HighPass:\n * The opposite of a lowpass filter.
\n * p5.BandPass:\n * Allows a range of frequencies to pass through and attenuates\n * the frequencies below and above this frequency range.
\n *\n * The .res() method controls either width of the\n * bandpass, or resonance of the low/highpass cutoff frequency.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Filter\n * @extends p5.Effect\n * @constructor\n * @param {String} [type] 'lowpass' (default), 'highpass', 'bandpass'\n * @example\n *
\n * let fft, noise, filter;\n *\n * function setup() {\n * let cnv = createCanvas(100,100);\n * cnv.mousePressed(makeNoise);\n * fill(255, 0, 255);\n *\n * filter = new p5.BandPass();\n * noise = new p5.Noise();\n * noise.disconnect();\n * noise.connect(filter);\n *\n * fft = new p5.FFT();\n * }\n *\n * function draw() {\n * background(220);\n *\n * // set the BandPass frequency based on mouseX\n * let freq = map(mouseX, 0, width, 20, 10000);\n * freq = constrain(freq, 0, 22050);\n * filter.freq(freq);\n * // give the filter a narrow band (lower res = wider bandpass)\n * filter.res(50);\n *\n * // draw filtered spectrum\n * let spectrum = fft.analyze();\n * noStroke();\n * for (let i = 0; i < spectrum.length; i++) {\n * let x = map(i, 0, spectrum.length, 0, width);\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\n * rect(x, height, width/spectrum.length, h);\n * }\n * if (!noise.started) {\n * text('tap here and drag to change frequency', 10, 20, width - 20);\n * } else {\n * text('Frequency: ' + round(freq)+'Hz', 20, 20, width - 20);\n * }\n * }\n *\n * function makeNoise() {\n * // see also: `userStartAudio()`\n * noise.start();\n * noise.amp(0.5, 0.2);\n * }\n *\n * function mouseReleased() {\n * noise.amp(0, 0.2);\n * }\n *\n *
\n */\nclass Filter extends Effect {\n constructor(type) {\n super();\n //add extend Effect by adding a Biquad Filter\n\n /**\n * The p5.Filter is built with a\n * \n * Web Audio BiquadFilter Node.\n *\n * @property {DelayNode} biquadFilter\n */\n\n this.biquad = this.ac.createBiquadFilter();\n\n this.input.connect(this.biquad);\n\n this.biquad.connect(this.wet);\n\n if (type) {\n this.setType(type);\n }\n\n //Properties useful for the toggle method.\n this._on = true;\n this._untoggledType = this.biquad.type;\n }\n\n /**\n * Filter an audio signal according to a set\n * of filter parameters.\n *\n * @method process\n * @param {Object} Signal An object that outputs audio\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\n * @param {Number} [res] Resonance/Width of the filter frequency\n * from 0.001 to 1000\n */\n process(src, freq, res, time) {\n src.connect(this.input);\n this.set(freq, res, time);\n }\n\n /**\n * Set the frequency and the resonance of the filter.\n *\n * @method set\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\n * @param {Number} [res] Resonance (Q) from 0.001 to 1000\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n set(freq, res, time) {\n if (freq) {\n this.freq(freq, time);\n }\n if (res) {\n this.res(res, time);\n }\n }\n\n /**\n * Set the filter frequency, in Hz, from 10 to 22050 (the range of\n * human hearing, although in reality most people hear in a narrower\n * range).\n *\n * @method freq\n * @param {Number} freq Filter Frequency\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {Number} value Returns the current frequency value\n */\n freq(freq, time) {\n var t = time || 0;\n if (freq <= 0) {\n freq = 1;\n }\n if (typeof freq === 'number') {\n this.biquad.frequency.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.biquad.frequency.exponentialRampToValueAtTime(\n freq,\n this.ac.currentTime + 0.02 + t\n );\n } else if (freq) {\n freq.connect(this.biquad.frequency);\n }\n return this.biquad.frequency.value;\n }\n\n /**\n * Controls either width of a bandpass frequency,\n * or the resonance of a low/highpass cutoff frequency.\n *\n * @method res\n * @param {Number} res Resonance/Width of filter freq\n * from 0.001 to 1000\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n * @return {Number} value Returns the current res value\n */\n res(res, time) {\n var t = time || 0;\n if (typeof res === 'number') {\n this.biquad.Q.value = res;\n this.biquad.Q.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.biquad.Q.linearRampToValueAtTime(\n res,\n this.ac.currentTime + 0.02 + t\n );\n } else if (res) {\n res.connect(this.biquad.Q);\n }\n return this.biquad.Q.value;\n }\n\n /**\n * Controls the gain attribute of a Biquad Filter.\n * This is distinctly different from .amp() which is inherited from p5.Effect\n * .amp() controls the volume via the output gain node\n * p5.Filter.gain() controls the gain parameter of a Biquad Filter node.\n *\n * @method gain\n * @param {Number} gain\n * @return {Number} Returns the current or updated gain value\n */\n gain(gain, time) {\n var t = time || 0;\n if (typeof gain === 'number') {\n this.biquad.gain.value = gain;\n this.biquad.gain.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.biquad.gain.linearRampToValueAtTime(\n gain,\n this.ac.currentTime + 0.02 + t\n );\n } else if (gain) {\n gain.connect(this.biquad.gain);\n }\n return this.biquad.gain.value;\n }\n\n /**\n * Toggle function. Switches between the specified type and allpass\n *\n * @method toggle\n * @return {boolean} [Toggle value]\n */\n toggle() {\n this._on = !this._on;\n\n if (this._on === true) {\n this.biquad.type = this._untoggledType;\n } else if (this._on === false) {\n this.biquad.type = 'allpass';\n }\n\n return this._on;\n }\n\n /**\n * Set the type of a p5.Filter. Possible types include:\n * \"lowpass\" (default), \"highpass\", \"bandpass\",\n * \"lowshelf\", \"highshelf\", \"peaking\", \"notch\",\n * \"allpass\".\n *\n * @method setType\n * @param {String} t\n */\n setType(t) {\n this.biquad.type = t;\n this._untoggledType = this.biquad.type;\n }\n\n dispose() {\n // remove reference from soundArray\n super.dispose();\n if (this.biquad) {\n this.biquad.disconnect();\n delete this.biquad;\n }\n }\n}\n\n/**\n * Constructor: new p5.LowPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('lowpass').\n * See p5.Filter for methods.\n *\n * @class p5.LowPass\n * @constructor\n * @extends p5.Filter\n */\nclass LowPass extends Filter {\n constructor() {\n super('lowpass');\n }\n}\n\n/**\n * Constructor: new p5.HighPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('highpass').\n * See p5.Filter for methods.\n *\n * @class p5.HighPass\n * @constructor\n * @extends p5.Filter\n */\nclass HighPass extends Filter {\n constructor() {\n super('highpass');\n }\n}\n\n/**\n * Constructor: new p5.BandPass() Filter.\n * This is the same as creating a p5.Filter and then calling\n * its method setType('bandpass').\n * See p5.Filter for methods.\n *\n * @class p5.BandPass\n * @constructor\n * @extends p5.Filter\n */\nclass BandPass extends Filter {\n constructor() {\n super('bandpass');\n }\n}\nexport default Filter;\nexport { LowPass, HighPass, BandPass };\n","import Filter from './filter';\nimport p5sound from './main';\n\n/**\n * EQFilter extends p5.Filter with constraints\n * necessary for the p5.EQ\n *\n * @private\n */\nclass EQFilter extends Filter {\n constructor(freq, res) {\n super('peaking');\n\n this.disconnect();\n this.set(freq, res);\n this.biquad.gain.value = 0;\n delete this.input;\n delete this.output;\n delete this._drywet;\n delete this.wet;\n }\n\n amp() {\n console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');\n }\n\n drywet() {\n console.warn('`drywet()` is not available for p5.EQ bands.');\n }\n\n connect(unit) {\n var u = unit || p5.soundOut.input;\n if (this.biquad) {\n this.biquad.connect(u.input ? u.input : u);\n } else {\n this.output.connect(u.input ? u.input : u);\n }\n }\n disconnect() {\n if (this.biquad) {\n this.biquad.disconnect();\n }\n }\n\n dispose() {\n // remove reference form soundArray\n const index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n this.disconnect();\n delete this.biquad;\n }\n}\n\nexport default EQFilter;\n","import Effect from './effect';\nimport EQFilter from './eqFilter';\n\n/**\n * p5.EQ is an audio effect that performs the function of a multiband\n * audio equalizer. Equalization is used to adjust the balance of\n * frequency compoenents of an audio signal. This process is commonly used\n * in sound production and recording to change the waveform before it reaches\n * a sound output device. EQ can also be used as an audio effect to create\n * interesting distortions by filtering out parts of the spectrum. p5.EQ is\n * built using a chain of Web Audio Biquad Filter Nodes and can be\n * instantiated with 3 or 8 bands. Bands can be added or removed from\n * the EQ by directly modifying p5.EQ.bands (the array that stores filters).\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.EQ\n * @constructor\n * @extends p5.Effect\n * @param {Number} [_eqsize] Constructor will accept 3 or 8, defaults to 3\n * @return {Object} p5.EQ object\n *\n * @example\n *
\n * let eq, soundFile\n * let eqBandIndex = 0;\n * let eqBandNames = ['lows', 'mids', 'highs'];\n *\n * function preload() {\n * soundFormats('mp3', 'ogg');\n * soundFile = loadSound('assets/beat');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(toggleSound);\n *\n * eq = new p5.EQ(eqBandNames.length);\n * soundFile.disconnect();\n * eq.process(soundFile);\n * }\n *\n * function draw() {\n * background(30);\n * noStroke();\n * fill(255);\n * textAlign(CENTER);\n * text('filtering ', 50, 25);\n *\n * fill(255, 40, 255);\n * textSize(26);\n * text(eqBandNames[eqBandIndex], 50, 55);\n *\n * fill(255);\n * textSize(9);\n *\n * if (!soundFile.isPlaying()) {\n * text('tap to play', 50, 80);\n * } else {\n * text('tap to filter next band', 50, 80)\n * }\n * }\n *\n * function toggleSound() {\n * if (!soundFile.isPlaying()) {\n * soundFile.play();\n * } else {\n * eqBandIndex = (eqBandIndex + 1) % eq.bands.length;\n * }\n *\n * for (let i = 0; i < eq.bands.length; i++) {\n * eq.bands[i].gain(0);\n * }\n * // filter the band we want to filter\n * eq.bands[eqBandIndex].gain(-40);\n * }\n *
\n */\nclass EQ extends Effect {\n constructor(_eqsize) {\n super();\n\n //p5.EQ can be of size (3) or (8), defaults to 3\n _eqsize = _eqsize === 3 || _eqsize === 8 ? _eqsize : 3;\n\n var factor;\n _eqsize === 3 ? (factor = Math.pow(2, 3)) : (factor = 2);\n\n /**\n * The p5.EQ is built with abstracted p5.Filter objects.\n * To modify any bands, use methods of the \n * p5.Filter API, especially `gain` and `freq`.\n * Bands are stored in an array, with indices 0 - 3, or 0 - 7\n * @property {Array} bands\n *\n */\n this.bands = [];\n\n var freq, res;\n for (var i = 0; i < _eqsize; i++) {\n if (i === _eqsize - 1) {\n freq = 21000;\n res = 0.01;\n } else if (i === 0) {\n freq = 100;\n res = 0.1;\n } else if (i === 1) {\n freq = _eqsize === 3 ? 360 * factor : 360;\n res = 1;\n } else {\n freq = this.bands[i - 1].freq() * factor;\n res = 1;\n }\n this.bands[i] = this._newBand(freq, res);\n\n if (i > 0) {\n this.bands[i - 1].connect(this.bands[i].biquad);\n } else {\n this.input.connect(this.bands[i].biquad);\n }\n }\n this.bands[_eqsize - 1].connect(this.output);\n }\n\n /**\n * Process an input by connecting it to the EQ\n * @method process\n * @param {Object} src Audio source\n */\n process(src) {\n src.connect(this.input);\n }\n\n // /**\n // * Set the frequency and gain of each band in the EQ. This method should be\n // * called with 3 or 8 frequency and gain pairs, depending on the size of the EQ.\n // * ex. eq.set(freq0, gain0, freq1, gain1, freq2, gain2);\n // *\n // * @method set\n // * @for p5.EQ\n // * @param {Number} [freq0] Frequency value for band with index 0\n // * @param {Number} [gain0] Gain value for band with index 0\n // * @param {Number} [freq1] Frequency value for band with index 1\n // * @param {Number} [gain1] Gain value for band with index 1\n // * @param {Number} [freq2] Frequency value for band with index 2\n // * @param {Number} [gain2] Gain value for band with index 2\n // * @param {Number} [freq3] Frequency value for band with index 3\n // * @param {Number} [gain3] Gain value for band with index 3\n // * @param {Number} [freq4] Frequency value for band with index 4\n // * @param {Number} [gain4] Gain value for band with index 4\n // * @param {Number} [freq5] Frequency value for band with index 5\n // * @param {Number} [gain5] Gain value for band with index 5\n // * @param {Number} [freq6] Frequency value for band with index 6\n // * @param {Number} [gain6] Gain value for band with index 6\n // * @param {Number} [freq7] Frequency value for band with index 7\n // * @param {Number} [gain7] Gain value for band with index 7\n // */\n set() {\n if (arguments.length === this.bands.length * 2) {\n for (var i = 0; i < arguments.length; i += 2) {\n this.bands[i / 2].freq(arguments[i]);\n this.bands[i / 2].gain(arguments[i + 1]);\n }\n } else {\n console.error(\n 'Argument mismatch. .set() should be called with ' +\n this.bands.length * 2 +\n ' arguments. (one frequency and gain value pair for each band of the eq)'\n );\n }\n }\n\n /**\n * Add a new band. Creates a p5.Filter and strips away everything but\n * the raw biquad filter. This method returns an abstracted p5.Filter,\n * which can be added to p5.EQ.bands, in order to create new EQ bands.\n * @private\n * @for p5.EQ\n * @method _newBand\n * @param {Number} freq\n * @param {Number} res\n * @return {Object} Abstracted Filter\n */\n _newBand(freq, res) {\n return new EQFilter(freq, res);\n }\n\n dispose() {\n super.dispose();\n\n if (this.bands) {\n while (this.bands.length > 0) {\n delete this.bands.pop().dispose();\n }\n delete this.bands;\n }\n }\n}\nexport default EQ;\n","import p5sound from './main';\n\n// /**\n// * listener is a class that can construct both a Spatial Panner\n// * and a Spatial Listener. The panner is based on the\n// * Web Audio Spatial Panner Node\n// * https://www.w3.org/TR/webaudio/#the-listenernode-interface\n// * This panner is a spatial processing node that allows audio to be positioned\n// * and oriented in 3D space.\n// *\n// * The Listener modifies the properties of the Audio Context Listener.\n// * Both objects types use the same methods. The default is a spatial panner.\n// *\n// * p5.Panner3D - Constructs a Spatial Panner
\n// * p5.Listener3D - Constructs a Spatial Listener
\n// *\n// * @class listener\n// * @constructor\n// * @return {Object} p5.Listener3D Object\n// *\n// * @param {Web Audio Node} listener Web Audio Spatial Panning Node\n// * @param {AudioParam} listener.panningModel \"equal power\" or \"HRTF\"\n// * @param {AudioParam} listener.distanceModel \"linear\", \"inverse\", or \"exponential\"\n// * @param {String} [type] [Specify construction of a spatial panner or listener]\n// */\n\nclass Listener3D {\n constructor(type) {\n this.ac = p5sound.audiocontext;\n this.listener = this.ac.listener;\n }\n\n // /**\n // * Connect an audio sorce\n // * @param {Object} src Input source\n // */\n process(src) {\n src.connect(this.input);\n }\n // /**\n // * Set the X,Y,Z position of the Panner\n // * @param {[Number]} xVal\n // * @param {[Number]} yVal\n // * @param {[Number]} zVal\n // * @param {[Number]} time\n // * @return {[Array]} [Updated x, y, z values as an array]\n // */\n position(xVal, yVal, zVal, time) {\n this.positionX(xVal, time);\n this.positionY(yVal, time);\n this.positionZ(zVal, time);\n return [\n this.listener.positionX.value,\n this.listener.positionY.value,\n this.listener.positionZ.value,\n ];\n }\n\n // /**\n // * Getter and setter methods for position coordinates\n // * @return {Number} [updated coordinate value]\n // */\n positionX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.positionX.value = xVal;\n this.listener.positionX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.positionX);\n }\n return this.listener.positionX.value;\n }\n positionY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.positionY.value = yVal;\n this.listener.positionY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.positionY);\n }\n return this.listener.positionY.value;\n }\n positionZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.positionZ.value = zVal;\n this.listener.positionZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.positionZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.positionZ);\n }\n return this.listener.positionZ.value;\n }\n\n // cannot define method when class definition is commented\n // /**\n // * Overrides the listener orient() method because Listener has slightly\n // * different params. In human terms, Forward vectors are the direction the\n // * nose is pointing. Up vectors are the direction of the top of the head.\n // *\n // * @method orient\n // * @param {Number} xValF Forward vector X direction\n // * @param {Number} yValF Forward vector Y direction\n // * @param {Number} zValF Forward vector Z direction\n // * @param {Number} xValU Up vector X direction\n // * @param {Number} yValU Up vector Y direction\n // * @param {Number} zValU Up vector Z direction\n // * @param {Number} time\n // * @return {Array} All orienation params\n // */\n orient(xValF, yValF, zValF, xValU, yValU, zValU, time) {\n if (arguments.length === 3 || arguments.length === 4) {\n time = arguments[3];\n this.orientForward(xValF, yValF, zValF, time);\n } else if (arguments.length === 6 || arguments === 7) {\n this.orientForward(xValF, yValF, zValF);\n this.orientUp(xValU, yValU, zValU, time);\n }\n\n return [\n this.listener.forwardX.value,\n this.listener.forwardY.value,\n this.listener.forwardZ.value,\n this.listener.upX.value,\n this.listener.upY.value,\n this.listener.upZ.value,\n ];\n }\n\n orientForward(xValF, yValF, zValF, time) {\n this.forwardX(xValF, time);\n this.forwardY(yValF, time);\n this.forwardZ(zValF, time);\n\n return [\n this.listener.forwardX,\n this.listener.forwardY,\n this.listener.forwardZ,\n ];\n }\n\n orientUp(xValU, yValU, zValU, time) {\n this.upX(xValU, time);\n this.upY(yValU, time);\n this.upZ(zValU, time);\n\n return [this.listener.upX, this.listener.upY, this.listener.upZ];\n }\n // /**\n // * Getter and setter methods for orient coordinates\n // * @return {Number} [updated coordinate value]\n // */\n forwardX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.forwardX.value = xVal;\n this.listener.forwardX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.forwardX);\n }\n return this.listener.forwardX.value;\n }\n forwardY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.forwardY.value = yVal;\n this.listener.forwardY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.forwardY);\n }\n return this.listener.forwardY.value;\n }\n forwardZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.forwardZ.value = zVal;\n this.listener.forwardZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.listener.forwardZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.forwardZ);\n }\n return this.listener.forwardZ.value;\n }\n upX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.upX.value = xVal;\n this.listener.upX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.listener.upX);\n }\n return this.listener.upX.value;\n }\n upY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.upY.value = yVal;\n this.listener.upY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.listener.upY);\n }\n return this.listener.upY.value;\n }\n upZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.upZ.value = zVal;\n this.listener.upZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.upZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.listener.upZ);\n }\n return this.listener.upZ.value;\n }\n}\n\nexport default Listener3D;\n","import Effect from './effect';\n\n/**\n * Panner3D is based on the \n * Web Audio Spatial Panner Node.\n * This panner is a spatial processing node that allows audio to be positioned\n * and oriented in 3D space.\n *\n * The position is relative to an \n * Audio Context Listener, which can be accessed\n * by p5.soundOut.audiocontext.listener\n *\n *\n * @class p5.Panner3D\n * @constructor\n */\n\nclass Panner3D extends Effect {\n constructor() {\n super();\n /**\n * \n * Web Audio Spatial Panner Node\n *\n * Properties include
\n * [Panning Model](https://www.w3.org/TR/webaudio/#idl-def-PanningModelType)\n * : \"equal power\" or \"HRTF\"
\n * [DistanceModel](https://www.w3.org/TR/webaudio/#idl-def-DistanceModelType)\n * : \"linear\", \"inverse\", or \"exponential\"\n *\n * @property {AudioNode} panner\n *\n */\n this.panner = this.ac.createPanner();\n this.panner.panningModel = 'HRTF';\n this.panner.distanceModel = 'linear';\n this.panner.connect(this.output);\n this.input.connect(this.panner);\n }\n\n /**\n * Connect an audio sorce\n *\n * @method process\n * @for p5.Panner3D\n * @param {Object} src Input source\n */\n process(src) {\n src.connect(this.input);\n }\n /**\n * Set the X,Y,Z position of the Panner\n * @method set\n * @for p5.Panner3D\n * @param {Number} xVal\n * @param {Number} yVal\n * @param {Number} zVal\n * @param {Number} time\n * @return {Array} Updated x, y, z values as an array\n */\n set(xVal, yVal, zVal, time) {\n this.positionX(xVal, time);\n this.positionY(yVal, time);\n this.positionZ(zVal, time);\n return [\n this.panner.positionX.value,\n this.panner.positionY.value,\n this.panner.positionZ.value,\n ];\n }\n\n /**\n * Getter and setter methods for position coordinates\n * @method positionX\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for position coordinates\n * @method positionY\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for position coordinates\n * @method positionZ\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n positionX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.positionX.value = xVal;\n this.panner.positionX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.panner.positionX);\n }\n return this.panner.positionX.value;\n }\n positionY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.positionY.value = yVal;\n this.panner.positionY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.panner.positionY);\n }\n return this.panner.positionY.value;\n }\n positionZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.positionZ.value = zVal;\n this.panner.positionZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.positionZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.panner.positionZ);\n }\n return this.panner.positionZ.value;\n }\n\n /**\n * Set the X,Y,Z position of the Panner\n * @method orient\n * @for p5.Panner3D\n * @param {Number} xVal\n * @param {Number} yVal\n * @param {Number} zVal\n * @param {Number} time\n * @return {Array} Updated x, y, z values as an array\n */\n orient(xVal, yVal, zVal, time) {\n this.orientX(xVal, time);\n this.orientY(yVal, time);\n this.orientZ(zVal, time);\n return [\n this.panner.orientationX.value,\n this.panner.orientationY.value,\n this.panner.orientationZ.value,\n ];\n }\n\n /**\n * Getter and setter methods for orient coordinates\n * @method orientX\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for orient coordinates\n * @method orientY\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n /**\n * Getter and setter methods for orient coordinates\n * @method orientZ\n * @for p5.Panner3D\n * @return {Number} updated coordinate value\n */\n orientX(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.orientationX.value = xVal;\n this.panner.orientationX.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationX.linearRampToValueAtTime(\n xVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (xVal) {\n xVal.connect(this.panner.orientationX);\n }\n return this.panner.orientationX.value;\n }\n orientY(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.orientationY.value = yVal;\n this.panner.orientationY.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationY.linearRampToValueAtTime(\n yVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (yVal) {\n yVal.connect(this.panner.orientationY);\n }\n return this.panner.orientationY.value;\n }\n orientZ(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.orientationZ.value = zVal;\n this.panner.orientationZ.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.panner.orientationZ.linearRampToValueAtTime(\n zVal,\n this.ac.currentTime + 0.02 + t\n );\n } else if (zVal) {\n zVal.connect(this.panner.orientationZ);\n }\n return this.panner.orientationZ.value;\n }\n\n /**\n * Set the rolloff factor and max distance\n * @method setFalloff\n * @for p5.Panner3D\n * @param {Number} [maxDistance]\n * @param {Number} [rolloffFactor]\n */\n setFalloff(maxDistance, rolloffFactor) {\n this.maxDist(maxDistance);\n this.rolloff(rolloffFactor);\n }\n /**\n * Maxium distance between the source and the listener\n * @method maxDist\n * @for p5.Panner3D\n * @param {Number} maxDistance\n * @return {Number} updated value\n */\n maxDist(maxDistance) {\n if (typeof maxDistance === 'number') {\n this.panner.maxDistance = maxDistance;\n }\n return this.panner.maxDistance;\n }\n\n /**\n * How quickly the volume is reduced as the source moves away from the listener\n * @method rollof\n * @for p5.Panner3D\n * @param {Number} rolloffFactor\n * @return {Number} updated value\n */\n rolloff(rolloffFactor) {\n if (typeof rolloffFactor === 'number') {\n this.panner.rolloffFactor = rolloffFactor;\n }\n return this.panner.rolloffFactor;\n }\n\n dispose() {\n super.dispose();\n if (this.panner) {\n this.panner.disconnect();\n delete this.panner;\n }\n }\n}\n\nexport default Panner3D;\n","import Filter from './filter';\nimport Effect from './effect';\n\n/**\n * Delay is an echo effect. It processes an existing sound source,\n * and outputs a delayed version of that sound. The p5.Delay can\n * produce different effects depending on the delayTime, feedback,\n * filter, and type. In the example below, a feedback of 0.5 (the\n * default value) will produce a looping delay that decreases in\n * volume by 50% each repeat. A filter will cut out the high\n * frequencies so that the delay does not sound as piercing as the\n * original source.\n *\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n * @class p5.Delay\n * @extends p5.Effect\n * @constructor\n * @example\n *
\n * let osc;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * osc = new p5.Oscillator('square');\n * osc.amp(0.5);\n * delay = new p5.Delay();\n *\n * // delay.process() accepts 4 parameters:\n * // source, delayTime (in seconds), feedback, filter frequency\n * delay.process(osc, 0.12, .7, 2300);\n *\n * cnv.mousePressed(oscStart);\n * }\n *\n * function oscStart() {\n * osc.start();\n * }\n *\n * function mouseReleased() {\n * osc.stop();\n * }\n *
\n */\nclass Delay extends Effect {\n constructor() {\n super();\n\n this._split = this.ac.createChannelSplitter(2);\n this._merge = this.ac.createChannelMerger(2);\n\n this._leftGain = this.ac.createGain();\n this._rightGain = this.ac.createGain();\n /**\n * The p5.Delay is built with two\n * \n * Web Audio Delay Nodes, one for each stereo channel.\n *\n * @for p5.Delay\n * @property {DelayNode} leftDelay\n */\n this.leftDelay = this.ac.createDelay();\n /**\n * The p5.Delay is built with two\n * \n * Web Audio Delay Nodes, one for each stereo channel.\n * @for p5.Delay\n * @property {DelayNode} rightDelay\n */\n this.rightDelay = this.ac.createDelay();\n\n this._leftFilter = new Filter();\n this._rightFilter = new Filter();\n this._leftFilter.disconnect();\n this._rightFilter.disconnect();\n\n this._leftFilter.biquad.frequency.setValueAtTime(1200, this.ac.currentTime);\n this._rightFilter.biquad.frequency.setValueAtTime(\n 1200,\n this.ac.currentTime\n );\n this._leftFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\n this._rightFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\n\n // graph routing\n this.input.connect(this._split);\n this.leftDelay.connect(this._leftGain);\n this.rightDelay.connect(this._rightGain);\n this._leftGain.connect(this._leftFilter.input);\n this._rightGain.connect(this._rightFilter.input);\n this._merge.connect(this.wet);\n\n this._leftFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\n this._rightFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\n\n // default routing\n this.setType(0);\n\n this._maxDelay = this.leftDelay.delayTime.maxValue;\n\n // set initial feedback to 0.5\n this.feedback(0.5);\n }\n /**\n * Add delay to an audio signal according to a set\n * of delay parameters.\n *\n * @method process\n * @for p5.Delay\n * @param {Object} Signal An object that outputs audio\n * @param {Number} [delayTime] Time (in seconds) of the delay/echo.\n * Some browsers limit delayTime to\n * 1 second.\n * @param {Number} [feedback] sends the delay back through itself\n * in a loop that decreases in volume\n * each time.\n * @param {Number} [lowPass] Cutoff frequency. Only frequencies\n * below the lowPass will be part of the\n * delay.\n */\n process(src, _delayTime, _feedback, _filter) {\n var feedback = _feedback || 0;\n var delayTime = _delayTime || 0;\n if (feedback >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n }\n if (delayTime >= this._maxDelay) {\n throw new Error(\n 'Delay Time exceeds maximum delay time of ' +\n this._maxDelay +\n ' second.'\n );\n }\n\n src.connect(this.input);\n this.leftDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\n this.rightDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\n this._leftGain.gain.value = feedback;\n this._rightGain.gain.value = feedback;\n\n if (_filter) {\n this._leftFilter.freq(_filter);\n this._rightFilter.freq(_filter);\n }\n }\n\n /**\n * Set the delay (echo) time, in seconds. Usually this value will be\n * a floating point number between 0.0 and 1.0.\n *\n * @method delayTime\n * @for p5.Delay\n * @param {Number} delayTime Time (in seconds) of the delay\n */\n delayTime(t) {\n // if t is an audio node...\n if (typeof t !== 'number') {\n t.connect(this.leftDelay.delayTime);\n t.connect(this.rightDelay.delayTime);\n } else {\n this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\n this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\n this.leftDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\n this.rightDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\n }\n }\n\n /**\n * Feedback occurs when Delay sends its signal back through its input\n * in a loop. The feedback amount determines how much signal to send each\n * time through the loop. A feedback greater than 1.0 is not desirable because\n * it will increase the overall output each time through the loop,\n * creating an infinite feedback loop. The default value is 0.5\n *\n * @method feedback\n * @for p5.Delay\n * @param {Number|Object} feedback 0.0 to 1.0, or an object such as an\n * Oscillator that can be used to\n * modulate this param\n * @returns {Number} Feedback value\n *\n */\n feedback(f) {\n // if f is an audio node...\n if (f && typeof f !== 'number') {\n f.connect(this._leftGain.gain);\n f.connect(this._rightGain.gain);\n } else if (f >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n } else if (typeof f === 'number') {\n this._leftGain.gain.value = f;\n this._rightGain.gain.value = f;\n }\n\n // return value of feedback\n return this._leftGain.gain.value;\n }\n\n /**\n * Set a lowpass filter frequency for the delay. A lowpass filter\n * will cut off any frequencies higher than the filter frequency.\n *\n * @method filter\n * @for p5.Delay\n * @param {Number|Object} cutoffFreq A lowpass filter will cut off any\n * frequencies higher than the filter frequency.\n * @param {Number|Object} res Resonance of the filter frequency\n * cutoff, or an object (i.e. a p5.Oscillator)\n * that can be used to modulate this parameter.\n * High numbers (i.e. 15) will produce a resonance,\n * low numbers (i.e. .2) will produce a slope.\n */\n filter(freq, q) {\n this._leftFilter.set(freq, q);\n this._rightFilter.set(freq, q);\n }\n\n /**\n * Choose a preset type of delay. 'pingPong' bounces the signal\n * from the left to the right channel to produce a stereo effect.\n * Any other parameter will revert to the default delay setting.\n *\n * @method setType\n * @for p5.Delay\n * @param {String|Number} type 'pingPong' (1) or 'default' (0)\n */\n setType(t) {\n if (t === 1) {\n t = 'pingPong';\n }\n this._split.disconnect();\n this._leftFilter.disconnect();\n this._rightFilter.disconnect();\n this._split.connect(this.leftDelay, 0);\n this._split.connect(this.rightDelay, 1);\n switch (t) {\n case 'pingPong':\n this._rightFilter.setType(this._leftFilter.biquad.type);\n this._leftFilter.output.connect(this._merge, 0, 0);\n this._rightFilter.output.connect(this._merge, 0, 1);\n this._leftFilter.output.connect(this.rightDelay);\n this._rightFilter.output.connect(this.leftDelay);\n break;\n default:\n this._leftFilter.output.connect(this._merge, 0, 0);\n this._rightFilter.output.connect(this._merge, 0, 1);\n this._leftFilter.output.connect(this.leftDelay);\n this._rightFilter.output.connect(this.rightDelay);\n }\n }\n\n // DocBlocks for methods inherited from p5.Effect\n /**\n * Set the output level of the delay effect.\n *\n * @method amp\n * @for p5.Delay\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Delay\n * @param {Object} unit\n */\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Delay\n */\n\n dispose() {\n super.dispose();\n\n this._split.disconnect();\n this._leftFilter.dispose();\n this._rightFilter.dispose();\n this._merge.disconnect();\n this._leftGain.disconnect();\n this._rightGain.disconnect();\n this.leftDelay.disconnect();\n this.rightDelay.disconnect();\n\n this._split = undefined;\n this._leftFilter = undefined;\n this._rightFilter = undefined;\n this._merge = undefined;\n this._leftGain = undefined;\n this._rightGain = undefined;\n this.leftDelay = undefined;\n this.rightDelay = undefined;\n }\n}\n\nexport default Delay;\n","import { getAudioContext } from './audiocontext';\nimport CustomError from './errorHandler';\nimport Effect from './effect';\n\n/**\n * Reverb adds depth to a sound through a large number of decaying\n * echoes. It creates the perception that sound is occurring in a\n * physical space. The p5.Reverb has paramters for Time (how long does the\n * reverb last) and decayRate (how much the sound decays with each echo)\n * that can be set with the .set() or .process() methods. The p5.Convolver\n * extends p5.Reverb allowing you to recreate the sound of actual physical\n * spaces through convolution.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Reverb\n * @extends p5.Effect\n * @constructor\n * @example\n *
\n * let soundFile, reverb;\n * function preload() {\n * soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n *\n * reverb = new p5.Reverb();\n * soundFile.disconnect(); // so we'll only hear reverb...\n *\n * // connect soundFile to reverb, process w/\n * // 3 second reverbTime, decayRate of 2%\n * reverb.process(soundFile, 3, 2);\n * }\n *\n * function draw() {\n * let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);\n * // 1 = all reverb, 0 = no reverb\n * reverb.drywet(dryWet);\n *\n * background(220);\n * text('tap to play', 10, 20);\n * text('dry/wet: ' + round(dryWet * 100) + '%', 10, height - 20);\n * }\n *\n * function playSound() {\n * soundFile.play();\n * }\n *
\n */\n\nclass Reverb extends Effect {\n constructor() {\n super();\n this._initConvolverNode();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n\n // default params\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n _initConvolverNode() {\n this.convolverNode = this.ac.createConvolver();\n this.input.connect(this.convolverNode);\n this.convolverNode.connect(this.wet);\n }\n\n _teardownConvolverNode() {\n if (this.convolverNode) {\n this.convolverNode.disconnect();\n delete this.convolverNode;\n }\n }\n\n _setBuffer(audioBuffer) {\n this._teardownConvolverNode();\n this._initConvolverNode();\n this.convolverNode.buffer = audioBuffer;\n }\n /**\n * Connect a source to the reverb, and assign reverb parameters.\n *\n * @method process\n * @for p5.Reverb\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n * @param {Number} [seconds] Duration of the reverb, in seconds.\n * Min: 0, Max: 10. Defaults to 3.\n * @param {Number} [decayRate] Percentage of decay with each echo.\n * Min: 0, Max: 100. Defaults to 2.\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\n */\n process(src, seconds, decayRate, reverse) {\n src.connect(this.input);\n var rebuild = false;\n if (seconds) {\n this._seconds = seconds;\n rebuild = true;\n }\n if (decayRate) {\n this._decay = decayRate;\n }\n if (reverse) {\n this._reverse = reverse;\n }\n if (rebuild) {\n this._buildImpulse();\n }\n }\n\n /**\n * Set the reverb settings. Similar to .process(), but without\n * assigning a new input.\n *\n * @method set\n * @for p5.Reverb\n * @param {Number} [seconds] Duration of the reverb, in seconds.\n * Min: 0, Max: 10. Defaults to 3.\n * @param {Number} [decayRate] Percentage of decay with each echo.\n * Min: 0, Max: 100. Defaults to 2.\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\n */\n set(seconds, decayRate, reverse) {\n var rebuild = false;\n if (seconds) {\n this._seconds = seconds;\n rebuild = true;\n }\n if (decayRate) {\n this._decay = decayRate;\n }\n if (reverse) {\n this._reverse = reverse;\n }\n if (rebuild) {\n this._buildImpulse();\n }\n }\n\n // DocBlocks for methods inherited from p5.Effect\n /**\n * Set the output level of the reverb effect.\n *\n * @method amp\n * @for p5.Reverb\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Reverb\n * @param {Object} unit\n */\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Reverb\n */\n\n /**\n * Inspired by Simple Reverb by Jordan Santell\n * https://github.com/web-audio-components/simple-reverb/blob/master/index.js\n *\n * Utility function for building an impulse response\n * based on the module parameters.\n *\n * @private\n */\n _buildImpulse() {\n var rate = this.ac.sampleRate;\n var length = rate * this._seconds;\n var decay = this._decay;\n var impulse = this.ac.createBuffer(2, length, rate);\n var impulseL = impulse.getChannelData(0);\n var impulseR = impulse.getChannelData(1);\n var n, i;\n for (i = 0; i < length; i++) {\n n = this._reverse ? length - i : i;\n impulseL[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\n impulseR[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\n }\n this._setBuffer(impulse);\n }\n\n dispose() {\n super.dispose();\n this._teardownConvolverNode();\n }\n}\n\n// =======================================================================\n// *** p5.Convolver ***\n// =======================================================================\n\n/**\n *

p5.Convolver extends p5.Reverb. It can emulate the sound of real\n * physical spaces through a process called \n * convolution.

\n *\n *

Convolution multiplies any audio input by an \"impulse response\"\n * to simulate the dispersion of sound over time. The impulse response is\n * generated from an audio file that you provide. One way to\n * generate an impulse response is to pop a balloon in a reverberant space\n * and record the echo. Convolution can also be used to experiment with\n * sound.

\n *\n *

Use the method createConvolution(path) to instantiate a\n * p5.Convolver with a path to your impulse response audio file.

\n *\n * @class p5.Convolver\n * @extends p5.Effect\n * @constructor\n * @param {String} path path to a sound file\n * @param {Function} [callback] function to call when loading succeeds\n * @param {Function} [errorCallback] function to call if loading fails.\n * This function will receive an error or\n * XMLHttpRequest object with information\n * about what went wrong.\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from main output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *
\n */\nclass Convolver extends Reverb {\n constructor(path, callback, errorCallback) {\n super();\n /**\n * Internally, the p5.Convolver uses the a\n * \n * Web Audio Convolver Node.\n *\n * @property {ConvolverNode} convolverNode\n */\n this._initConvolverNode();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n\n if (path) {\n this.impulses = [];\n this._loadBuffer(path, callback, errorCallback);\n } else {\n // parameters\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n /**\n * If you load multiple impulse files using the .addImpulse method,\n * they will be stored as Objects in this Array. Toggle between them\n * with the toggleImpulse(id) method.\n *\n * @property {Array} impulses\n * @for p5.Convolver\n */\n this.impulses = [];\n this.set = null;\n }\n\n /**\n * Private method to load a buffer as an Impulse Response,\n * assign it to the convolverNode, and add to the Array of .impulses.\n *\n * @param {String} path\n * @param {Function} callback\n * @param {Function} errorCallback\n * @private\n */\n _loadBuffer(_path, callback, errorCallback) {\n var path = p5.prototype._checkFileFormats(_path);\n var self = this;\n var errorTrace = new Error().stack;\n var ac = getAudioContext();\n\n var request = new XMLHttpRequest();\n request.open('GET', path, true);\n request.responseType = 'arraybuffer';\n\n request.onload = function () {\n if (request.status === 200) {\n // on success loading file:\n ac.decodeAudioData(\n request.response,\n function (buff) {\n var buffer = {};\n var chunks = path.split('/');\n buffer.name = chunks[chunks.length - 1];\n buffer.audioBuffer = buff;\n self.impulses.push(buffer);\n self._setBuffer(buffer.audioBuffer);\n if (callback) {\n callback(buffer);\n }\n },\n // error decoding buffer. \"e\" is undefined in Chrome 11/22/2015\n function () {\n var err = new CustomError('decodeAudioData', errorTrace, self.url);\n var msg = 'AudioContext error at decodeAudioData for ' + self.url;\n if (errorCallback) {\n err.msg = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n );\n }\n // if request status != 200, it failed\n else {\n var err = new CustomError('loadConvolver', errorTrace, self.url);\n var msg =\n 'Unable to load ' +\n self.url +\n '. The request status was: ' +\n request.status +\n ' (' +\n request.statusText +\n ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n }\n };\n\n // if there is another error, aside from 404...\n request.onerror = function () {\n var err = new CustomError('loadConvolver', errorTrace, self.url);\n var msg =\n 'There was no response from the server at ' +\n self.url +\n '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(\n msg + '\\n The error stack trace includes: \\n' + err.stack\n );\n }\n };\n request.send();\n }\n\n /**\n * Connect a source to the convolver.\n *\n * @method process\n * @for p5.Convolver\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from main output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *\n *
\n */\n process(src) {\n src.connect(this.input);\n }\n\n /**\n * Load and assign a new Impulse Response to the p5.Convolver.\n * The impulse is added to the .impulses array. Previous\n * impulses can be accessed with the .toggleImpulse(id)\n * method.\n *\n * @method addImpulse\n * @for p5.Convolver\n * @param {String} path path to a sound file\n * @param {Function} callback function (optional)\n * @param {Function} errorCallback function (optional)\n */\n addImpulse(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n this._loadBuffer(path, callback, errorCallback);\n }\n\n /**\n * Similar to .addImpulse, except that the .impulses\n * Array is reset to save memory. A new .impulses\n * array is created with this impulse as the only item.\n *\n * @method resetImpulse\n * @for p5.Convolver\n * @param {String} path path to a sound file\n * @param {Function} callback function (optional)\n * @param {Function} errorCallback function (optional)\n */\n resetImpulse(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n this.impulses = [];\n this._loadBuffer(path, callback, errorCallback);\n }\n\n /**\n * If you have used .addImpulse() to add multiple impulses\n * to a p5.Convolver, then you can use this method to toggle between\n * the items in the .impulses Array. Accepts a parameter\n * to identify which impulse you wish to use, identified either by its\n * original filename (String) or by its position in the .impulses\n * Array (Number).
\n * You can access the objects in the .impulses Array directly. Each\n * Object has two attributes: an .audioBuffer (type:\n * Web Audio \n * AudioBuffer) and a .name, a String that corresponds\n * with the original filename.\n *\n * @method toggleImpulse\n * @for p5.Convolver\n * @param {String|Number} id Identify the impulse by its original filename\n * (String), or by its position in the\n * .impulses Array (Number).\n */\n toggleImpulse(id) {\n if (typeof id === 'number' && id < this.impulses.length) {\n this._setBuffer(this.impulses[id].audioBuffer);\n }\n if (typeof id === 'string') {\n for (var i = 0; i < this.impulses.length; i++) {\n if (this.impulses[i].name === id) {\n this._setBuffer(this.impulses[i].audioBuffer);\n break;\n }\n }\n }\n }\n\n dispose() {\n super.dispose();\n\n // remove all the Impulse Response buffers\n for (var i in this.impulses) {\n if (this.impulses[i]) {\n this.impulses[i] = null;\n }\n }\n }\n}\n\n/**\n * Create a p5.Convolver. Accepts a path to a soundfile\n * that will be used to generate an impulse response.\n *\n * @method createConvolver\n * @for p5\n * @param {String} path path to a sound file\n * @param {Function} [callback] function to call if loading is successful.\n * The object will be passed in as the argument\n * to the callback function.\n * @param {Function} [errorCallback] function to call if loading is not successful.\n * A custom error will be passed in as the argument\n * to the callback function.\n * @return {p5.Convolver}\n * @example\n *
\n * let cVerb, sound;\n * function preload() {\n * // We have both MP3 and OGG versions of all sound assets\n * soundFormats('ogg', 'mp3');\n *\n * // Try replacing 'bx-spring' with other soundfiles like\n * // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox'\n * cVerb = createConvolver('assets/bx-spring.mp3');\n *\n * // Try replacing 'Damscray_DancingTiger' with\n * // 'beat', 'doorbell', lucky_dragons_-_power_melody'\n * sound = loadSound('assets/Damscray_DancingTiger.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSound);\n * background(220);\n * text('tap to play', 20, 20);\n *\n * // disconnect from main output...\n * sound.disconnect();\n *\n * // ...and process with cVerb\n * // so that we only hear the convolution\n * cVerb.process(sound);\n * }\n *\n * function playSound() {\n * sound.play();\n * }\n *
\n */\nfunction createConvolver(path, callback, errorCallback) {\n // if loading locally without a server\n if (\n window.location.origin.indexOf('file://') > -1 &&\n window.cordova === 'undefined'\n ) {\n alert(\n 'This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'\n );\n }\n var self = this;\n var cReverb = new Convolver(\n path,\n function (buffer) {\n if (typeof callback === 'function') {\n callback(buffer);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n },\n errorCallback\n );\n cReverb.impulses = [];\n return cReverb;\n}\n\nexport { Reverb, Convolver, createConvolver };\n","import p5sound from './main';\n// requires the Tone.js library's Clock (MIT license, Yotam Mann)\n// https://github.com/TONEnoTONE/Tone.js/\nimport Clock from 'Tone/core/Clock';\n\nclass Metro {\n constructor() {\n this.clock = new Clock({\n callback: this.ontick.bind(this),\n });\n this.syncedParts = [];\n this.bpm = 120; // gets overridden by p5.Part\n this._init();\n\n this.prevTick = 0;\n this.tatumTime = 0;\n\n this.tickCallback = function () {};\n }\n\n ontick(tickTime) {\n var elapsedTime = tickTime - this.prevTick;\n var secondsFromNow = tickTime - p5sound.audiocontext.currentTime;\n if (elapsedTime - this.tatumTime <= -0.02) {\n return;\n } else {\n // console.log('ok', this.syncedParts[0].phrases[0].name);\n this.prevTick = tickTime;\n\n // for all of the active things on the metro:\n var self = this;\n this.syncedParts.forEach(function (thisPart) {\n if (!thisPart.isPlaying) return;\n thisPart.incrementStep(secondsFromNow);\n // each synced source keeps track of its own beat number\n thisPart.phrases.forEach(function (thisPhrase) {\n var phraseArray = thisPhrase.sequence;\n var bNum = self.metroTicks % phraseArray.length;\n if (\n phraseArray[bNum] !== 0 &&\n (self.metroTicks < phraseArray.length || !thisPhrase.looping)\n ) {\n thisPhrase.callback(secondsFromNow, phraseArray[bNum]);\n }\n });\n });\n this.metroTicks += 1;\n this.tickCallback(secondsFromNow);\n }\n }\n\n setBPM(bpm, rampTime = 0) {\n var beatTime = 60 / (bpm * this.tatums);\n var now = p5sound.audiocontext.currentTime;\n this.tatumTime = beatTime;\n\n this.clock.frequency.setValueAtTime(this.clock.frequency.value, now);\n this.clock.frequency.linearRampToValueAtTime(bpm, now + rampTime);\n this.bpm = bpm;\n }\n\n getBPM() {\n return (this.clock.getRate() / this.tatums) * 60;\n }\n\n _init() {\n this.metroTicks = 0;\n // this.setBPM(120);\n }\n\n // clear existing synced parts, add only this one\n resetSync(part) {\n this.syncedParts = [part];\n }\n\n // push a new synced part to the array\n pushSync(part) {\n this.syncedParts.push(part);\n }\n\n start(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.start(now + t);\n this.setBPM(this.bpm);\n }\n\n stop(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.stop(now + t);\n }\n\n beatLength(tatums) {\n this.tatums = 1 / tatums / 4; // lowest possible division of a beat\n }\n}\nexport default Metro;\n","import p5sound from './main';\nimport Metro from './metro';\n\nvar BPM = 120;\n\n/**\n * Set the global tempo, in beats per minute, for all\n * p5.Parts. This method will impact all active p5.Parts.\n *\n * @method setBPM\n * @for p5\n * @param {Number} BPM Beats Per Minute\n * @param {Number} rampTime Seconds from now\n */\np5.prototype.setBPM = function (bpm, rampTime) {\n BPM = bpm;\n for (var i in p5sound.parts) {\n if (p5sound.parts[i]) {\n p5sound.parts[i].setBPM(bpm, rampTime);\n }\n }\n};\n\n/**\n *

A phrase is a pattern of musical events over time, i.e.\n * a series of notes and rests.

\n *\n *

Phrases must be added to a p5.Part for playback, and\n * each part can play multiple phrases at the same time.\n * For example, one Phrase might be a kick drum, another\n * could be a snare, and another could be the bassline.

\n *\n *

The first parameter is a name so that the phrase can be\n * modified or deleted later. The callback is a a function that\n * this phrase will call at every step—for example it might be\n * called playNote(value){}. The array determines\n * which value is passed into the callback at each step of the\n * phrase. It can be numbers, an object with multiple numbers,\n * or a zero (0) indicates a rest so the callback won't be called).

\n *\n * @class p5.Phrase\n * @constructor\n * @param {String} name Name so that you can access the Phrase.\n * @param {Function} callback The name of a function that this phrase\n * will call. Typically it will play a sound,\n * and accept two parameters: a time at which\n * to play the sound (in seconds from now),\n * and a value from the sequence array. The\n * time should be passed into the play() or\n * start() method to ensure precision.\n * @param {Array} sequence Array of values to pass into the callback\n * at each step of the phrase.\n * @example\n *
\n * let mySound, myPhrase, myPart;\n * let pattern = [1,0,0,2,0,2,0,0];\n *\n * function preload() {\n * mySound = loadSound('assets/beatbox.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playMyPart);\n * background(220);\n * text('tap to play', width/2, height/2);\n * textAlign(CENTER, CENTER);\n *\n * myPhrase = new p5.Phrase('bbox', onEachStep, pattern);\n * myPart = new p5.Part();\n * myPart.addPhrase(myPhrase);\n * myPart.setBPM(60);\n * }\n *\n * function onEachStep(time, playbackRate) {\n * mySound.rate(playbackRate);\n * mySound.play(time);\n * }\n *\n * function playMyPart() {\n * userStartAudio();\n * myPart.start();\n * }\n *
\n */\nclass Phrase {\n constructor(name, callback, sequence) {\n this.phraseStep = 0;\n this.name = name;\n this.callback = callback;\n /**\n * Array of values to pass into the callback\n * at each step of the phrase. Depending on the callback\n * function's requirements, these values may be numbers,\n * strings, or an object with multiple parameters.\n * Zero (0) indicates a rest.\n *\n * @property {Array} sequence\n */\n this.sequence = sequence;\n }\n}\n\n/**\n *

A p5.Part plays back one or more p5.Phrases. Instantiate a part\n * with steps and tatums. By default, each step represents a 1/16th note.

\n *\n *

See p5.Phrase for more about musical timing.

\n *\n * @class p5.Part\n * @constructor\n * @param {Number} [steps] Steps in the part\n * @param {Number} [tatums] Divisions of a beat, e.g. use 1/4, or 0.25 for a quater note (default is 1/16, a sixteenth note)\n * @example\n *
\n * let box, drum, myPart;\n * let boxPat = [1,0,0,2,0,2,0,0];\n * let drumPat = [0,1,1,0,2,0,1,0];\n *\n * function preload() {\n * box = loadSound('assets/beatbox.mp3');\n * drum = loadSound('assets/drum.mp3');\n * }\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playMyPart);\n * background(220);\n * textAlign(CENTER, CENTER);\n * text('tap to play', width/2, height/2);\n *\n * let boxPhrase = new p5.Phrase('box', playBox, boxPat);\n * let drumPhrase = new p5.Phrase('drum', playDrum, drumPat);\n * myPart = new p5.Part();\n * myPart.addPhrase(boxPhrase);\n * myPart.addPhrase(drumPhrase);\n * myPart.setBPM(60);\n * }\n *\n * function playBox(time, playbackRate) {\n * box.rate(playbackRate);\n * box.play(time);\n * }\n *\n * function playDrum(time, playbackRate) {\n * drum.rate(playbackRate);\n * drum.play(time);\n * }\n *\n * function playMyPart() {\n * userStartAudio();\n *\n * myPart.start();\n * }\n *
\n */\nclass Part {\n constructor(steps, bLength) {\n this.length = steps || 0; // how many beats\n this.partStep = 0;\n this.phrases = [];\n this.isPlaying = false;\n this.noLoop();\n this.tatums = bLength || 0.0625; // defaults to quarter note\n\n this.metro = new Metro();\n this.metro._init();\n this.metro.beatLength(this.tatums);\n this.metro.setBPM(BPM);\n p5sound.parts.push(this);\n this.callback = function () {};\n }\n\n /**\n * Set the tempo of this part, in Beats Per Minute.\n *\n * @method setBPM\n * @for p5.Part\n * @param {Number} BPM Beats Per Minute\n * @param {Number} [rampTime] Seconds from now\n */\n setBPM(tempo, rampTime) {\n this.metro.setBPM(tempo, rampTime);\n }\n\n /**\n * Returns the tempo, in Beats Per Minute, of this part.\n *\n * @method getBPM\n * @for p5.Part\n * @return {Number}\n */\n getBPM() {\n return this.metro.getBPM();\n }\n\n /**\n * Start playback of this part. It will play\n * through all of its phrases at a speed\n * determined by setBPM.\n *\n * @method start\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n start(time) {\n if (!this.isPlaying) {\n this.isPlaying = true;\n this.metro.resetSync(this);\n var t = time || 0;\n this.metro.start(t);\n }\n }\n\n /**\n * Loop playback of this part. It will begin\n * looping through all of its phrases at a speed\n * determined by setBPM.\n *\n * @method loop\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n loop(time) {\n this.looping = true;\n // rest onended function\n this.onended = function () {\n this.partStep = 0;\n };\n var t = time || 0;\n this.start(t);\n }\n\n /**\n * Tell the part to stop looping.\n *\n * @method noLoop\n * @for p5.Part\n */\n noLoop() {\n this.looping = false;\n // rest onended function\n this.onended = function () {\n this.stop();\n };\n }\n\n /**\n * Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.\n *\n * @method stop\n * @for p5.Part\n * @param {Number} [time] seconds from now\n */\n stop(time) {\n this.partStep = 0;\n this.pause(time);\n }\n\n /**\n * Pause the part. Playback will resume\n * from the current step.\n *\n * @method pause\n * @for p5.Part\n * @param {Number} time seconds from now\n */\n pause(time) {\n this.isPlaying = false;\n var t = time || 0;\n this.metro.stop(t);\n }\n\n /**\n * Add a p5.Phrase to this Part.\n *\n * @method addPhrase\n * @for p5.Part\n * @param {p5.Phrase} phrase reference to a p5.Phrase\n */\n addPhrase(name, callback, array) {\n var p;\n if (arguments.length === 3) {\n p = new Phrase(name, callback, array);\n } else if (arguments[0] instanceof Phrase) {\n p = arguments[0];\n } else {\n throw 'invalid input. addPhrase accepts name, callback, array or a p5.Phrase';\n }\n this.phrases.push(p);\n // reset the length if phrase is longer than part's existing length\n if (p.sequence.length > this.length) {\n this.length = p.sequence.length;\n }\n }\n\n /**\n * Remove a phrase from this part, based on the name it was\n * given when it was created.\n *\n * @method removePhrase\n * @for p5.Part\n * @param {String} phraseName\n */\n removePhrase(name) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n this.phrases.splice(i, 1);\n }\n }\n }\n\n /**\n * Get a phrase from this part, based on the name it was\n * given when it was created. Now you can modify its array.\n *\n * @method getPhrase\n * @for p5.Part\n * @param {String} phraseName\n */\n getPhrase(name) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n return this.phrases[i];\n }\n }\n }\n\n /**\n * Find all sequences with the specified name, and replace their patterns with the specified array.\n *\n * @method replaceSequence\n * @for p5.Part\n * @param {String} phraseName\n * @param {Array} sequence Array of values to pass into the callback\n * at each step of the phrase.\n */\n replaceSequence(name, array) {\n for (var i in this.phrases) {\n if (this.phrases[i].name === name) {\n this.phrases[i].sequence = array;\n }\n }\n }\n\n incrementStep(time) {\n if (this.partStep < this.length - 1) {\n this.callback(time);\n this.partStep += 1;\n } else {\n if (!this.looping && this.partStep === this.length - 1) {\n // this.callback(time);\n this.onended();\n }\n }\n }\n\n /**\n * Set the function that will be called at every step. This will clear the previous function.\n *\n * @method onStep\n * @for p5.Part\n * @param {Function} callback The name of the callback\n * you want to fire\n * on every beat/tatum.\n */\n onStep(callback) {\n this.callback = callback;\n }\n}\n\n// ===============\n// p5.Score\n// ===============\n\n/**\n * A Score consists of a series of Parts. The parts will\n * be played back in order. For example, you could have an\n * A part, a B part, and a C part, and play them back in this order\n * new p5.Score(a, a, b, a, c)\n *\n * @class p5.Score\n * @constructor\n * @param {p5.Part} [...parts] One or multiple parts, to be played in sequence.\n */\nclass Score {\n constructor() {\n // for all of the arguments\n this.parts = [];\n this.currentPart = new Array(arguments.length);;\n\n var thisScore = this;\n for (var i in arguments) {\n this.parts[i] = arguments[i];\n this.parts[i].nextPart = this.parts[i + 1];\n this.parts[i].onended = function () {\n thisScore.resetPart(i);\n playNextPart(thisScore);\n }; \n }\n this.looping = false;\n }\n\n onended() {\n if (this.looping) {\n // this.resetParts();\n this.parts[0].start();\n } else {\n this.parts[this.parts.length - 1].onended = function () {\n this.stop();\n this.resetParts();\n };\n }\n this.currentPart = 0;\n }\n\n /**\n * Start playback of the score.\n *\n * @method start\n * @for p5.Score\n */\n start() {\n this.parts[this.currentPart].start();\n this.scoreStep = 0;\n }\n\n /**\n * Stop playback of the score.\n *\n * @method stop\n * @for p5.Score\n */\n stop() {\n this.parts[this.currentPart].stop();\n this.currentPart = 0;\n this.scoreStep = 0;\n }\n\n /**\n * Pause playback of the score.\n *\n * @method pause\n * @for p5.Score\n */\n pause() {\n this.parts[this.currentPart].stop();\n }\n\n /**\n * Loop playback of the score.\n *\n * @method loop\n * @for p5.Score\n */\n loop() {\n this.looping = true;\n this.start();\n }\n\n /**\n * Stop looping playback of the score. If it\n * is currently playing, this will go into effect\n * after the current round of playback completes.\n *\n * @method noLoop\n * @for p5.Score\n */\n noLoop() {\n this.looping = false;\n }\n\n resetParts() {\n var self = this;\n this.parts.forEach(function (part) {\n self.resetParts[part];\n });\n }\n\n resetPart(i) {\n this.parts[i].stop();\n this.parts[i].partStep = 0;\n for (var p in this.parts[i].phrases) {\n if (this.parts[i]) {\n this.parts[i].phrases[p].phraseStep = 0;\n }\n }\n }\n\n /**\n * Set the tempo for all parts in the score\n *\n * @method setBPM\n * @for p5.Score\n * @param {Number} BPM Beats Per Minute\n * @param {Number} rampTime Seconds from now\n */\n setBPM(bpm, rampTime) {\n for (var i in this.parts) {\n if (this.parts[i]) {\n this.parts[i].setBPM(bpm, rampTime);\n }\n }\n }\n}\n\nfunction playNextPart(aScore) {\n aScore.currentPart++;\n if (aScore.currentPart >= aScore.parts.length) {\n aScore.scoreStep = 0;\n aScore.onended();\n } else {\n aScore.scoreStep = 0;\n aScore.parts[aScore.currentPart - 1].stop();\n aScore.parts[aScore.currentPart].start();\n }\n}\n\nexport { Phrase, Part, Score };\n","import p5sound from './main';\nimport Clock from 'Tone/core/Clock';\n\n/**\n * SoundLoop\n *\n * @class p5.SoundLoop\n * @constructor\n *\n * @param {Function} callback this function will be called on each iteration of theloop\n * @param {Number|String} [interval] amount of time (if a number) or beats (if a string, following Tone.Time convention) for each iteration of the loop. Defaults to 1 second.\n *\n * @example\n *
\n * let synth, soundLoop;\n * let notePattern = [60, 62, 64, 67, 69, 72];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * colorMode(HSB);\n * background(0, 0, 86);\n * text('tap to start/stop', 10, 20);\n *\n * //the looper's callback is passed the timeFromNow\n * //this value should be used as a reference point from\n * //which to schedule sounds\n * let intervalInSeconds = 0.2;\n * soundLoop = new p5.SoundLoop(onSoundLoop, intervalInSeconds);\n *\n * synth = new p5.MonoSynth();\n * }\n *\n * function canvasPressed() {\n * // ensure audio is enabled\n * userStartAudio();\n *\n * if (soundLoop.isPlaying) {\n * soundLoop.stop();\n * } else {\n * // start the loop\n * soundLoop.start();\n * }\n * }\n *\n * function onSoundLoop(timeFromNow) {\n * let noteIndex = (soundLoop.iterations - 1) % notePattern.length;\n * let note = midiToFreq(notePattern[noteIndex]);\n * synth.play(note, 0.5, timeFromNow);\n * background(noteIndex * 360 / notePattern.length, 50, 100);\n * }\n *
\n */\nclass SoundLoop {\n constructor(callback, interval) {\n /**\n * Getters and Setters, setting any paramter will result in a change in the clock's\n * frequency, that will be reflected after the next callback\n * beats per minute (defaults to 60)\n * @property {Number} bpm\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'bpm', {\n get: function () {\n return this._bpm;\n },\n set: function (bpm) {\n if (!this.musicalTimeMode) {\n console.warn(\n 'Changing the BPM in \"seconds\" mode has no effect. ' +\n 'BPM is only relevant in musicalTimeMode ' +\n 'when the interval is specified as a string ' +\n '(\"2n\", \"4n\", \"1m\"...etc)'\n );\n }\n this._bpm = bpm;\n this._update();\n },\n });\n\n /**\n * number of quarter notes in a measure (defaults to 4)\n * @property {Number} timeSignature\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'timeSignature', {\n get: function () {\n return this._timeSignature;\n },\n set: function (timeSig) {\n if (!this.musicalTimeMode) {\n console.warn(\n 'Changing the timeSignature in \"seconds\" mode has no effect. ' +\n 'BPM is only relevant in musicalTimeMode ' +\n 'when the interval is specified as a string ' +\n '(\"2n\", \"4n\", \"1m\"...etc)'\n );\n }\n this._timeSignature = timeSig;\n this._update();\n },\n });\n\n /**\n * length of the loops interval\n * @property {Number|String} interval\n * @for p5.SoundLoop\n */\n Object.defineProperty(this, 'interval', {\n get: function () {\n return this._interval;\n },\n set: function (interval) {\n this.musicalTimeMode = typeof interval === 'number' ? false : true;\n this._interval = interval;\n this._update();\n },\n });\n\n /**\n * how many times the callback has been called so far\n * @property {Number} iterations\n * @for p5.SoundLoop\n * @readonly\n */\n Object.defineProperty(this, 'iterations', {\n get: function () {\n return this.clock.ticks;\n },\n });\n\n this.callback = callback;\n /**\n * musicalTimeMode uses Tone.Time convention\n * true if string, false if number\n * @property {Boolean} musicalTimeMode\n */\n this.musicalTimeMode = typeof this._interval === 'number' ? false : true;\n\n this._interval = interval || 1;\n\n /**\n * musicalTimeMode variables\n * modify these only when the interval is specified in musicalTime format as a string\n */\n this._timeSignature = 4;\n this._bpm = 60;\n\n this.isPlaying = false;\n\n /**\n * Set a limit to the number of loops to play. defaults to Infinity\n * @property {Number} maxIterations\n */\n this.maxIterations = Infinity;\n var self = this;\n\n this.clock = new Clock({\n callback: function (time) {\n var timeFromNow = time - p5sound.audiocontext.currentTime;\n /**\n * Do not initiate the callback if timeFromNow is < 0\n * This ususually occurs for a few milliseconds when the page\n * is not fully loaded\n *\n * The callback should only be called until maxIterations is reached\n */\n if (timeFromNow > 0 && self.iterations <= self.maxIterations) {\n self.callback(timeFromNow);\n }\n },\n frequency: this._calcFreq(),\n });\n }\n\n /**\n * Start the loop\n * @method start\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a starting time\n */\n start(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (!this.isPlaying) {\n this.clock.start(now + t);\n this.isPlaying = true;\n }\n }\n\n /**\n * Stop the loop\n * @method stop\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a stopping time\n */\n stop(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (this.isPlaying) {\n this.clock.stop(now + t);\n this.isPlaying = false;\n }\n }\n\n /**\n * Pause the loop\n * @method pause\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a pausing time\n */\n pause(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n if (this.isPlaying) {\n this.clock.pause(now + t);\n this.isPlaying = false;\n }\n }\n\n /**\n * Synchronize loops. Use this method to start two or more loops in synchronization\n * or to start a loop in synchronization with a loop that is already playing\n * This method will schedule the implicit loop in sync with the explicit master loop\n * i.e. loopToStart.syncedStart(loopToSyncWith)\n *\n * @method syncedStart\n * @for p5.SoundLoop\n * @param {Object} otherLoop a p5.SoundLoop to sync with\n * @param {Number} [timeFromNow] Start the loops in sync after timeFromNow seconds\n */\n syncedStart(otherLoop, timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n\n if (!otherLoop.isPlaying) {\n otherLoop.clock.start(now + t);\n otherLoop.isPlaying = true;\n this.clock.start(now + t);\n this.isPlaying = true;\n } else if (otherLoop.isPlaying) {\n var time = otherLoop.clock._nextTick - p5sound.audiocontext.currentTime;\n this.clock.start(now + time);\n this.isPlaying = true;\n }\n }\n /**\n * Updates frequency value, reflected in next callback\n * @private\n * @for p5.SoundLoop\n * @method _update\n */\n _update() {\n this.clock.frequency.value = this._calcFreq();\n }\n\n /**\n * Calculate the frequency of the clock's callback based on bpm, interval, and timesignature\n * @private\n * @for p5.SoundLoop\n * @method _calcFreq\n * @return {Number} new clock frequency value\n */\n _calcFreq() {\n //Seconds mode, bpm / timesignature has no effect\n if (typeof this._interval === 'number') {\n this.musicalTimeMode = false;\n return 1 / this._interval;\n }\n //Musical timing mode, calculate interval based bpm, interval,and time signature\n else if (typeof this._interval === 'string') {\n this.musicalTimeMode = true;\n return (\n (this._bpm / 60 / this._convertNotation(this._interval)) *\n (this._timeSignature / 4)\n );\n }\n }\n\n /**\n * Convert notation from musical time format to seconds\n * Uses Tone.Time convention\n * @private\n * @for p5.SoundLoop\n * @method _convertNotation\n * @param {String} value value to be converted\n * @return {Number} converted value in seconds\n */\n _convertNotation(value) {\n var type = value.slice(-1);\n value = Number(value.slice(0, -1));\n switch (type) {\n case 'm':\n return this._measure(value);\n case 'n':\n return this._note(value);\n default:\n console.warn(\n 'Specified interval is not formatted correctly. See Tone.js ' +\n 'timing reference for more info: https://github.com/Tonejs/Tone.js/wiki/Time'\n );\n }\n }\n\n /**\n * Helper conversion methods of measure and note\n * @private\n * @for p5.SoundLoop\n * @method _measure\n */\n _measure(value) {\n return value * this._timeSignature;\n }\n\n /**\n * @private\n * @method _note\n * @for p5.SoundLoop\n */\n _note(value) {\n return this._timeSignature / value;\n }\n}\n\nexport default SoundLoop;\n","import Effect from './effect';\n\n/**\n * Compressor is an audio effect class that performs dynamics compression\n * on an audio input source. This is a very commonly used technique in music\n * and sound production. Compression creates an overall louder, richer,\n * and fuller sound by lowering the volume of louds and raising that of softs.\n * Compression can be used to avoid clipping (sound distortion due to\n * peaks in volume) and is especially useful when many sounds are played\n * at once. Compression can be used on indivudal sound sources in addition\n * to the main output.\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Compressor\n * @constructor\n * @extends p5.Effect\n *\n *\n */\nclass Compressor extends Effect {\n constructor() {\n super();\n /**\n *\n * The p5.Compressor is built with a Web Audio Dynamics Compressor Node\n * \n * @property {AudioNode} compressor\n */\n\n this.compressor = this.ac.createDynamicsCompressor();\n\n this.input.connect(this.compressor);\n this.compressor.connect(this.wet);\n }\n\n /**\n * Performs the same function as .connect, but also accepts\n * optional parameters to set compressor's audioParams\n * @method process\n * @for p5.Compressor\n *\n * @param {Object} src Sound source to be connected\n *\n * @param {Number} [attack] The amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} [knee] A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} [threshold] The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} [release] The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n */\n process(src, attack, knee, ratio, threshold, release) {\n src.connect(this.input);\n this.set(attack, knee, ratio, threshold, release);\n }\n\n /**\n * Set the paramters of a compressor.\n * @method set\n * @for p5.Compressor\n * @param {Number} attack The amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} knee A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} ratio The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} threshold The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n */\n set(attack, knee, ratio, threshold, release) {\n if (typeof attack !== 'undefined') {\n this.attack(attack);\n }\n if (typeof knee !== 'undefined') {\n this.knee(knee);\n }\n if (typeof ratio !== 'undefined') {\n this.ratio(ratio);\n }\n if (typeof threshold !== 'undefined') {\n this.threshold(threshold);\n }\n if (typeof release !== 'undefined') {\n this.release(release);\n }\n }\n\n /**\n * Get current attack or set value w/ time ramp\n *\n *\n * @method attack\n * @for p5.Compressor\n * @param {Number} [attack] Attack is the amount of time (in seconds) to reduce the gain by 10dB,\n * default = .003, range 0 - 1\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n attack(attack, time) {\n var t = time || 0;\n if (typeof attack === 'number') {\n this.compressor.attack.value = attack;\n this.compressor.attack.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.attack.linearRampToValueAtTime(\n attack,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof attack !== 'undefined') {\n attack.connect(this.compressor.attack);\n }\n return this.compressor.attack.value;\n }\n\n /**\n * Get current knee or set value w/ time ramp\n *\n * @method knee\n * @for p5.Compressor\n * @param {Number} [knee] A decibel value representing the range above the\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\n * default = 30, range 0 - 40\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n knee(knee, time) {\n var t = time || 0;\n if (typeof knee === 'number') {\n this.compressor.knee.value = knee;\n this.compressor.knee.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.knee.linearRampToValueAtTime(\n knee,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof knee !== 'undefined') {\n knee.connect(this.compressor.knee);\n }\n return this.compressor.knee.value;\n }\n\n /**\n * Get current ratio or set value w/ time ramp\n * @method ratio\n * @for p5.Compressor\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\n * default = 12, range 1 - 20\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n ratio(ratio, time) {\n var t = time || 0;\n if (typeof ratio === 'number') {\n this.compressor.ratio.value = ratio;\n this.compressor.ratio.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.ratio.linearRampToValueAtTime(\n ratio,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof ratio !== 'undefined') {\n ratio.connect(this.compressor.ratio);\n }\n return this.compressor.ratio.value;\n }\n\n /**\n * Get current threshold or set value w/ time ramp\n * @method threshold\n * @for p5.Compressor\n * @param {Number} threshold The decibel value above which the compression will start taking effect\n * default = -24, range -100 - 0\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n threshold(threshold, time) {\n var t = time || 0;\n if (typeof threshold === 'number') {\n this.compressor.threshold.value = threshold;\n this.compressor.threshold.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.threshold.linearRampToValueAtTime(\n threshold,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof threshold !== 'undefined') {\n threshold.connect(this.compressor.threshold);\n }\n return this.compressor.threshold.value;\n }\n\n /**\n * Get current release or set value w/ time ramp\n * @method release\n * @for p5.Compressor\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\n * default = .25, range 0 - 1\n *\n * @param {Number} [time] Assign time value to schedule the change in value\n */\n release(release, time) {\n var t = time || 0;\n if (typeof release === 'number') {\n this.compressor.release.value = release;\n this.compressor.release.cancelScheduledValues(\n this.ac.currentTime + 0.01 + t\n );\n this.compressor.release.linearRampToValueAtTime(\n release,\n this.ac.currentTime + 0.02 + t\n );\n } else if (typeof number !== 'undefined') {\n release.connect(this.compressor.release);\n }\n return this.compressor.release.value;\n }\n\n /**\n * Return the current reduction value\n *\n * @method reduction\n * @for p5.Compressor\n * @return {Number} Value of the amount of gain reduction that is applied to the signal\n */\n reduction() {\n return this.compressor.reduction.value;\n }\n\n dispose() {\n super.dispose();\n if (this.compressor) {\n this.compressor.disconnect();\n delete this.compressor;\n }\n }\n}\n\nexport default Compressor;\n","/**\n *

PeakDetect works in conjunction with p5.FFT to\n * look for onsets in some or all of the frequency spectrum.\n *

\n *

\n * To use p5.PeakDetect, call update in the draw loop\n * and pass in a p5.FFT object.\n *

\n *

\n * You can listen for a specific part of the frequency spectrum by\n * setting the range between freq1 and freq2.\n *

\n *\n *

threshold is the threshold for detecting a peak,\n * scaled between 0 and 1. It is logarithmic, so 0.1 is half as loud\n * as 1.0.

\n *\n *

\n * The update method is meant to be run in the draw loop, and\n * frames determines how many loops must pass before\n * another peak can be detected.\n * For example, if the frameRate() = 60, you could detect the beat of a\n * 120 beat-per-minute song with this equation:\n * framesPerPeak = 60 / (estimatedBPM / 60 );\n *

\n *\n *

\n * Based on example contribtued by @b2renger, and a simple beat detection\n * explanation by Felix Turner.\n *

\n *\n * @class p5.PeakDetect\n * @constructor\n * @param {Number} [freq1] lowFrequency - defaults to 20Hz\n * @param {Number} [freq2] highFrequency - defaults to 20000 Hz\n * @param {Number} [threshold] Threshold for detecting a beat between 0 and 1\n * scaled logarithmically where 0.1 is 1/2 the loudness\n * of 1.0. Defaults to 0.35.\n * @param {Number} [framesPerPeak] Defaults to 20.\n * @example\n *
\n *\n * var cnv, soundFile, fft, peakDetect;\n * var ellipseWidth = 10;\n *\n * function preload() {\n * soundFile = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * background(0);\n * noStroke();\n * fill(255);\n * textAlign(CENTER);\n *\n * // p5.PeakDetect requires a p5.FFT\n * fft = new p5.FFT();\n * peakDetect = new p5.PeakDetect();\n * }\n *\n * function draw() {\n * background(0);\n * text('click to play/pause', width/2, height/2);\n *\n * // peakDetect accepts an fft post-analysis\n * fft.analyze();\n * peakDetect.update(fft);\n *\n * if ( peakDetect.isDetected ) {\n * ellipseWidth = 50;\n * } else {\n * ellipseWidth *= 0.95;\n * }\n *\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n * }\n *\n * // toggle play/stop when canvas is clicked\n * function mouseClicked() {\n * if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\n * if (soundFile.isPlaying() ) {\n * soundFile.stop();\n * } else {\n * soundFile.play();\n * }\n * }\n * }\n *
\n */\nclass PeakDetect {\n // framesPerPeak determines how often to look for a beat.\n // If a beat is provided, try to look for a beat based on bpm\n constructor(freq1, freq2, threshold, _framesPerPeak) {\n this.framesPerPeak = _framesPerPeak || 20;\n this.framesSinceLastPeak = 0;\n this.decayRate = 0.95;\n\n this.threshold = threshold || 0.35;\n this.cutoff = 0;\n\n // how much to increase the cutoff\n // TO DO: document this / figure out how to make it accessible\n this.cutoffMult = 1.5;\n\n this.energy = 0;\n this.penergy = 0;\n\n // TO DO: document this property / figure out how to make it accessible\n this.currentValue = 0;\n\n /**\n * isDetected is set to true when a peak is detected.\n *\n * @attribute isDetected {Boolean}\n * @default false\n */\n this.isDetected = false;\n\n this.f1 = freq1 || 40;\n this.f2 = freq2 || 20000;\n\n // function to call when a peak is detected\n this._onPeak = function () {};\n }\n\n /**\n * The update method is run in the draw loop.\n *\n * Accepts an FFT object. You must call .analyze()\n * on the FFT object prior to updating the peakDetect\n * because it relies on a completed FFT analysis.\n *\n * @method update\n * @param {p5.FFT} fftObject A p5.FFT object\n */\n update(fftObject) {\n var nrg = (this.energy = fftObject.getEnergy(this.f1, this.f2) / 255);\n if (nrg > this.cutoff && nrg > this.threshold && nrg - this.penergy > 0) {\n // trigger callback\n this._onPeak();\n this.isDetected = true;\n\n // debounce\n this.cutoff = nrg * this.cutoffMult;\n this.framesSinceLastPeak = 0;\n } else {\n this.isDetected = false;\n if (this.framesSinceLastPeak <= this.framesPerPeak) {\n this.framesSinceLastPeak++;\n } else {\n this.cutoff *= this.decayRate;\n this.cutoff = Math.max(this.cutoff, this.threshold);\n }\n }\n\n this.currentValue = nrg;\n this.penergy = nrg;\n }\n\n /**\n * onPeak accepts two arguments: a function to call when\n * a peak is detected. The value of the peak,\n * between 0.0 and 1.0, is passed to the callback.\n *\n * @method onPeak\n * @param {Function} callback Name of a function that will\n * be called when a peak is\n * detected.\n * @param {Object} [val] Optional value to pass\n * into the function when\n * a peak is detected.\n * @example\n *
\n * var cnv, soundFile, fft, peakDetect;\n * var ellipseWidth = 0;\n *\n * function preload() {\n * soundFile = loadSound('assets/beat.mp3');\n * }\n *\n * function setup() {\n * cnv = createCanvas(100,100);\n * textAlign(CENTER);\n *\n * fft = new p5.FFT();\n * peakDetect = new p5.PeakDetect();\n *\n * setupSound();\n *\n * // when a beat is detected, call triggerBeat()\n * peakDetect.onPeak(triggerBeat);\n * }\n *\n * function draw() {\n * background(0);\n * fill(255);\n * text('click to play', width/2, height/2);\n *\n * fft.analyze();\n * peakDetect.update(fft);\n *\n * ellipseWidth *= 0.95;\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\n * }\n *\n * // this function is called by peakDetect.onPeak\n * function triggerBeat() {\n * ellipseWidth = 50;\n * }\n *\n * // mouseclick starts/stops sound\n * function setupSound() {\n * cnv.mouseClicked( function() {\n * if (soundFile.isPlaying() ) {\n * soundFile.stop();\n * } else {\n * soundFile.play();\n * }\n * });\n * }\n *
\n */\n onPeak(callback, val) {\n var self = this;\n\n self._onPeak = function () {\n callback(self.energy, val);\n };\n }\n}\n\nexport default PeakDetect;\n","// inspiration: recorder.js, Tone.js & typedarray.org\n\nimport p5sound from './main';\nimport { safeBufferSize } from './helpers';\nimport processorNames from './audioWorklet/processorNames';\n\nconst ac = p5sound.audiocontext;\n\n/**\n *

Record sounds for playback and/or to save as a .wav file.\n * The p5.SoundRecorder records all sound output from your sketch,\n * or can be assigned a specific source with setInput().

\n *

The record() method accepts a p5.SoundFile as a parameter.\n * When playback is stopped (either after the given amount of time,\n * or with the stop() method), the p5.SoundRecorder will send its\n * recording to that p5.SoundFile for playback.

\n *\n * @class p5.SoundRecorder\n * @constructor\n * @example\n *
\n * let mic, recorder, soundFile;\n * let state = 0;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(canvasPressed);\n * background(220);\n * textAlign(CENTER, CENTER);\n *\n * // create an audio in\n * mic = new p5.AudioIn();\n *\n * // prompts user to enable their browser mic\n * mic.start();\n *\n * // create a sound recorder\n * recorder = new p5.SoundRecorder();\n *\n * // connect the mic to the recorder\n * recorder.setInput(mic);\n *\n * // this sound file will be used to\n * // playback & save the recording\n * soundFile = new p5.SoundFile();\n *\n * text('tap to record', width/2, height/2);\n * }\n *\n * function canvasPressed() {\n * // ensure audio is enabled\n * userStartAudio();\n *\n * // make sure user enabled the mic\n * if (state === 0 && mic.enabled) {\n *\n * // record to our p5.SoundFile\n * recorder.record(soundFile);\n *\n * background(255,0,0);\n * text('Recording!', width/2, height/2);\n * state++;\n * }\n * else if (state === 1) {\n * background(0,255,0);\n *\n * // stop recorder and\n * // send result to soundFile\n * recorder.stop();\n *\n * text('Done! Tap to play and download', width/2, height/2, width - 20);\n * state++;\n * }\n *\n * else if (state === 2) {\n * soundFile.play(); // play the result!\n * save(soundFile, 'mySound.wav');\n * state++;\n * }\n * }\n *
\n */\nclass SoundRecorder {\n constructor() {\n this.input = ac.createGain();\n this.output = ac.createGain();\n\n this._inputChannels = 2;\n this._outputChannels = 2; // stereo output, even if input is mono\n\n const workletBufferSize = safeBufferSize(1024);\n\n this._workletNode = new AudioWorkletNode(\n ac,\n processorNames.recorderProcessor,\n {\n outputChannelCount: [this._outputChannels],\n processorOptions: {\n numInputChannels: this._inputChannels,\n bufferSize: workletBufferSize,\n },\n }\n );\n\n this._workletNode.port.onmessage = function (event) {\n if (event.data.name === 'buffers') {\n const buffers = [\n new Float32Array(event.data.leftBuffer),\n new Float32Array(event.data.rightBuffer),\n ];\n this._callback(buffers);\n }\n }.bind(this);\n\n /**\n * callback invoked when the recording is over\n * @private\n * @type Function(Float32Array)\n */\n this._callback = function () {};\n\n // connections\n this._workletNode.connect(p5.soundOut._silentNode);\n this.setInput();\n\n // add this p5.SoundFile to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connect a specific device to the p5.SoundRecorder.\n * If no parameter is given, p5.SoundRecorer will record\n * all audible p5.sound from your sketch.\n *\n * @method setInput\n * @for p5.SoundRecorder\n * @param {Object} [unit] p5.sound object or a web audio unit\n * that outputs sound\n */\n setInput(unit) {\n this.input.disconnect();\n this.input = null;\n this.input = ac.createGain();\n this.input.connect(this._workletNode);\n this.input.connect(this.output);\n if (unit) {\n unit.connect(this.input);\n } else {\n p5.soundOut.output.connect(this.input);\n }\n }\n\n /**\n * Start recording. To access the recording, provide\n * a p5.SoundFile as the first parameter. The p5.SoundRecorder\n * will send its recording to that p5.SoundFile for playback once\n * recording is complete. Optional parameters include duration\n * (in seconds) of the recording, and a callback function that\n * will be called once the complete recording has been\n * transfered to the p5.SoundFile.\n *\n * @method record\n * @for p5.SoundRecorder\n * @param {p5.SoundFile} soundFile p5.SoundFile\n * @param {Number} [duration] Time (in seconds)\n * @param {Function} [callback] The name of a function that will be\n * called once the recording completes\n */\n record(sFile, duration, callback) {\n this._workletNode.port.postMessage({ name: 'start', duration: duration });\n\n if (sFile && callback) {\n this._callback = function (buffer) {\n sFile.setBuffer(buffer);\n callback();\n };\n } else if (sFile) {\n this._callback = function (buffer) {\n sFile.setBuffer(buffer);\n };\n }\n }\n\n /**\n * Stop the recording. Once the recording is stopped,\n * the results will be sent to the p5.SoundFile that\n * was given on .record(), and if a callback function\n * was provided on record, that function will be called.\n *\n * @method stop\n * @for p5.SoundRecorder\n */\n stop() {\n this._workletNode.port.postMessage({ name: 'stop' });\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n\n this._callback = function () {};\n if (this.input) {\n this.input.disconnect();\n }\n this.input = null;\n this._workletNode = null;\n }\n}\n\nexport default SoundRecorder;\n","import Effect from './effect.js';\n\n/*\n * Adapted from [Kevin Ennis on StackOverflow](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n */\nfunction makeDistortionCurve(amount) {\n var k = typeof amount === 'number' ? amount : 50;\n var numSamples = 44100;\n var curve = new Float32Array(numSamples);\n var deg = Math.PI / 180;\n var i = 0;\n var x;\n for (; i < numSamples; ++i) {\n x = (i * 2) / numSamples - 1;\n curve[i] = ((3 + k) * x * 20 * deg) / (Math.PI + k * Math.abs(x));\n }\n return curve;\n}\n\n/**\n * A Distortion effect created with a Waveshaper Node,\n * with an approach adapted from\n * [Kevin Ennis](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n *\n * This class extends p5.Effect.\n * Methods amp(), chain(),\n * drywet(), connect(), and\n * disconnect() are available.\n *\n * @class p5.Distortion\n * @extends p5.Effect\n * @constructor\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n *\n */\nclass Distortion extends Effect {\n constructor(amount, oversample) {\n super();\n if (typeof amount === 'undefined') {\n amount = 0.25;\n }\n if (typeof amount !== 'number') {\n throw new Error('amount must be a number');\n }\n if (typeof oversample === 'undefined') {\n oversample = '2x';\n }\n if (typeof oversample !== 'string') {\n throw new Error('oversample must be a String');\n }\n\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\n\n /**\n * The p5.Distortion is built with a\n * \n * Web Audio WaveShaper Node.\n *\n * @property {AudioNode} WaveShaperNode\n */\n this.waveShaperNode = this.ac.createWaveShaper();\n\n this.amount = curveAmount;\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\n this.waveShaperNode.oversample = oversample;\n\n this.input.connect(this.waveShaperNode);\n\n this.waveShaperNode.connect(this.wet);\n }\n\n /**\n * Process a sound source, optionally specify amount and oversample values.\n *\n * @method process\n * @for p5.Distortion\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n */\n process(src, amount, oversample) {\n src.connect(this.input);\n this.set(amount, oversample);\n }\n\n /**\n * Set the amount and oversample of the waveshaper distortion.\n *\n * @method set\n * @for p5.Distortion\n * @param {Number} [amount=0.25] Unbounded distortion amount.\n * Normal values range from 0-1.\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\n */\n set(amount, oversample) {\n if (amount) {\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\n this.amount = curveAmount;\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\n }\n if (oversample) {\n this.waveShaperNode.oversample = oversample;\n }\n }\n\n /**\n * Return the distortion amount, typically between 0-1.\n *\n * @method getAmount\n * @for p5.Distortion\n * @return {Number} Unbounded distortion amount.\n * Normal values range from 0-1.\n */\n getAmount() {\n return this.amount;\n }\n\n /**\n * Return the oversampling.\n *\n * @method getOversample\n * @for p5.Distortion\n * @return {String} Oversample can either be 'none', '2x', or '4x'.\n */\n getOversample() {\n return this.waveShaperNode.oversample;\n }\n\n dispose() {\n super.dispose();\n if (this.waveShaperNode) {\n this.waveShaperNode.disconnect();\n this.waveShaperNode = null;\n }\n }\n}\n\nexport default Distortion;\n","import p5sound from './main';\n\n/**\n * A gain node is usefull to set the relative volume of sound.\n * It's typically used to build mixers.\n *\n * @class p5.Gain\n * @constructor\n * @example\n *
\n *\n * // load two soundfile and crossfade beetween them\n * let sound1,sound2;\n * let sound1Gain, sound2Gain, mixGain;\n * function preload(){\n * soundFormats('ogg', 'mp3');\n * sound1 = loadSound('assets/Damscray_-_Dancing_Tiger_01');\n * sound2 = loadSound('assets/beat');\n * }\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(startSound);\n * // create a 'mix' gain bus to which we will connect both soundfiles\n * mixGain = new p5.Gain();\n * mixGain.connect();\n * sound1.disconnect(); // diconnect from p5 output\n * sound1Gain = new p5.Gain(); // setup a gain node\n * sound1Gain.setInput(sound1); // connect the first sound to its input\n * sound1Gain.connect(mixGain); // connect its output to the final mix bus\n * sound2.disconnect();\n * sound2Gain = new p5.Gain();\n * sound2Gain.setInput(sound2);\n * sound2Gain.connect(mixGain);\n * }\n * function startSound() {\n * sound1.loop();\n * sound2.loop();\n * loop();\n * }\n * function mouseReleased() {\n * sound1.stop();\n * sound2.stop();\n * }\n * function draw(){\n * background(220);\n * textAlign(CENTER);\n * textSize(11);\n * fill(0);\n * if (!sound1.isPlaying()) {\n * text('tap and drag to play', width/2, height/2);\n * return;\n * }\n * // map the horizontal position of the mouse to values useable for volume * control of sound1\n * var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);\n * var sound2Volume = 1-sound1Volume;\n * sound1Gain.amp(sound1Volume);\n * sound2Gain.amp(sound2Volume);\n * // map the vertical position of the mouse to values useable for 'output * volume control'\n * var outputVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\n * mixGain.amp(outputVolume);\n * text('output', width/2, height - outputVolume * height * 0.9)\n * fill(255, 0, 255);\n * textAlign(LEFT);\n * text('sound1', 5, height - sound1Volume * height * 0.9);\n * textAlign(RIGHT);\n * text('sound2', width - 5, height - sound2Volume * height * 0.9);\n * }\n *
\n */\n\nclass Gain {\n constructor() {\n this.ac = p5sound.audiocontext;\n\n this.input = this.ac.createGain();\n this.output = this.ac.createGain();\n\n // otherwise, Safari distorts\n this.input.gain.value = 0.5;\n this.input.connect(this.output);\n\n // add to the soundArray\n p5sound.soundArray.push(this);\n }\n\n /**\n * Connect a source to the gain node.\n *\n * @method setInput\n * @for p5.Gain\n * @param {Object} src p5.sound / Web Audio object with a sound\n * output.\n */\n\n setInput(src) {\n src.connect(this.input);\n }\n\n /**\n * Send output to a p5.sound or web audio object\n *\n * @method connect\n * @for p5.Gain\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5.soundOut.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all output.\n *\n * @method disconnect\n * @for p5.Gain\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Set the output level of the gain node.\n *\n * @method amp\n * @for p5.Gain\n * @param {Number} volume amplitude between 0 and 1.0\n * @param {Number} [rampTime] create a fade that lasts rampTime\n * @param {Number} [timeFromNow] schedule this event to happen\n * seconds from now\n */\n amp(vol, rampTime = 0, tFromNow = 0) {\n var now = p5sound.audiocontext.currentTime;\n var currentVol = this.output.gain.value;\n this.output.gain.cancelScheduledValues(now);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n }\n\n dispose() {\n // remove reference from soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n if (this.input) {\n this.input.disconnect();\n delete this.input;\n }\n }\n}\n\nexport default Gain;\n","import p5sound from './main';\n\n/**\n * Base class for monophonic synthesizers. Any extensions of this class\n * should follow the API and implement the methods below in order to\n * remain compatible with p5.PolySynth();\n *\n * @class p5.AudioVoice\n * @constructor\n */\nclass AudioVoice {\n constructor() {\n this.ac = p5sound.audiocontext;\n this.output = this.ac.createGain();\n this.connect();\n p5sound.soundArray.push(this);\n }\n play(note, velocity, secondsFromNow, sustime) {}\n\n triggerAttack(note, velocity, secondsFromNow) {}\n\n triggerRelease(secondsFromNow) {}\n\n amp(vol, rampTime) {}\n\n /**\n * Connect to p5 objects or Web Audio Nodes\n * @method connect\n * @for p5.AudioVoice\n * @param {Object} unit\n */\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect from soundOut\n * @method disconnect\n * @for p5.AudioVoice\n */\n disconnect() {\n this.output.disconnect();\n }\n\n dispose() {\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n }\n}\n\nexport default AudioVoice;\n","import AudioVoice from './audioVoice';\nimport Envelope from './envelope';\nimport p5sound from './main';\nimport Oscillator from './oscillator';\nimport { noteToFreq } from './helpers';\n\nvar DEFAULT_SUSTAIN = 0.15;\n\n/**\n * A MonoSynth is used as a single voice for sound synthesis.\n * This is a class to be used in conjunction with the PolySynth\n * class. Custom synthetisers should be built inheriting from\n * this class.\n *\n * @class p5.MonoSynth\n * @constructor\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * let note = random(['Fb4', 'G4']);\n * // note velocity (volume, from 0 to 1)\n * let velocity = random();\n * // time from now (in seconds)\n * let time = 0;\n * // note duration (in seconds)\n * let dur = 1/6;\n *\n * monoSynth.play(note, velocity, time, dur);\n * }\n *
\n **/\n\nclass MonoSynth extends AudioVoice {\n constructor() {\n super();\n this.oscillator = new Oscillator();\n\n this.env = new Envelope(); //to be changed\n this.env.setRange(1, 0);\n this.env.setExp(true);\n\n //set params\n this.setADSR(0.02, 0.25, 0.05, 0.35);\n\n // oscillator --> env --> this.output (gain) --> p5.soundOut\n this.oscillator.disconnect();\n this.oscillator.connect(this.output);\n\n this.env.disconnect();\n this.env.setInput(this.output.gain);\n\n // reset oscillator gain to 1.0\n this.oscillator.output.gain.value = 1.0;\n\n this.oscillator.start();\n this.connect();\n\n p5sound.soundArray.push(this);\n\n /**\n * Getters and Setters\n * @property {Number} attack\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} decay\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} sustain\n * @for p5.MonoSynth\n */\n /**\n * @property {Number} release\n * @for p5.MonoSynth\n */\n Object.defineProperties(this, {\n attack: {\n get: function () {\n return this.env.aTime;\n },\n set: function (attack) {\n this.env.setADSR(\n attack,\n this.env.dTime,\n this.env.sPercent,\n this.env.rTime\n );\n },\n },\n decay: {\n get: function () {\n return this.env.dTime;\n },\n set: function (decay) {\n this.env.setADSR(\n this.env.aTime,\n decay,\n this.env.sPercent,\n this.env.rTime\n );\n },\n },\n sustain: {\n get: function () {\n return this.env.sPercent;\n },\n set: function (sustain) {\n this.env.setADSR(\n this.env.aTime,\n this.env.dTime,\n sustain,\n this.env.rTime\n );\n },\n },\n release: {\n get: function () {\n return this.env.rTime;\n },\n set: function (release) {\n this.env.setADSR(\n this.env.aTime,\n this.env.dTime,\n this.env.sPercent,\n release\n );\n },\n },\n });\n }\n\n /**\n * Play tells the MonoSynth to start playing a note. This method schedules\n * the calling of .triggerAttack and .triggerRelease.\n *\n * @method play\n * @for p5.MonoSynth\n * @param {String | Number} note the note you want to play, specified as a\n * frequency in Hertz (Number) or as a midi\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n * See \n * Tone. Defaults to 440 hz.\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope. Defaults to 0.15 seconds.\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * textAlign(CENTER);\n * text('tap to play', width/2, height/2);\n *\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * let note = random(['Fb4', 'G4']);\n * // note velocity (volume, from 0 to 1)\n * let velocity = random();\n * // time from now (in seconds)\n * let time = 0;\n * // note duration (in seconds)\n * let dur = 1/6;\n *\n * monoSynth.play(note, velocity, time, dur);\n * }\n *
\n *\n */\n play(note, velocity, secondsFromNow, susTime) {\n this.triggerAttack(note, velocity, ~~secondsFromNow);\n this.triggerRelease(~~secondsFromNow + (susTime || DEFAULT_SUSTAIN));\n }\n\n /**\n * Trigger the Attack, and Decay portion of the Envelope.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go.\n *\n * @param {String | Number} note the note you want to play, specified as a\n * frequency in Hertz (Number) or as a midi\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\n * See \n * Tone. Defaults to 440 hz\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @method triggerAttack\n * @for p5.MonoSynth\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(triggerAttack);\n * background(220);\n * text('tap here for attack, let go to release', 5, 20, width - 20);\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function triggerAttack() {\n * userStartAudio();\n *\n * monoSynth.triggerAttack(\"E3\");\n * }\n *\n * function mouseReleased() {\n * monoSynth.triggerRelease();\n * }\n *
\n */\n triggerAttack(note, velocity, secondsFromNow = 0) {\n var freq = noteToFreq(note);\n var vel = velocity || 0.1;\n this.oscillator.freq(freq, 0, secondsFromNow);\n this.env.ramp(this.output.gain, secondsFromNow, vel);\n }\n\n /**\n * Trigger the release of the Envelope. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @param {Number} secondsFromNow time to trigger the release\n * @method triggerRelease\n * @for p5.MonoSynth\n * @example\n *
\n * let monoSynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(triggerAttack);\n * background(220);\n * text('tap here for attack, let go to release', 5, 20, width - 20);\n * monoSynth = new p5.MonoSynth();\n * }\n *\n * function triggerAttack() {\n * userStartAudio();\n *\n * monoSynth.triggerAttack(\"E3\");\n * }\n *\n * function mouseReleased() {\n * monoSynth.triggerRelease();\n * }\n *
\n */\n triggerRelease(secondsFromNow = 0) {\n this.env.ramp(this.output.gain, secondsFromNow, 0);\n }\n\n /**\n * Set values like a traditional\n * \n * ADSR envelope\n * .\n *\n * @method setADSR\n * @for p5.MonoSynth\n * @param {Number} attackTime Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n */\n setADSR(attack, decay, sustain, release) {\n this.env.setADSR(attack, decay, sustain, release);\n }\n\n /**\n * MonoSynth amp\n * @method amp\n * @for p5.MonoSynth\n * @param {Number} vol desired volume\n * @param {Number} [rampTime] Time to reach new volume\n * @return {Number} new volume value\n */\n amp(vol, rampTime) {\n var t = rampTime || 0;\n if (typeof vol !== 'undefined') {\n this.oscillator.amp(vol, t);\n }\n return this.oscillator.amp().value;\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.MonoSynth\n * @param {Object} unit A p5.sound or Web Audio object\n */\n\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.MonoSynth\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Get rid of the MonoSynth and free up its resources / memory.\n *\n * @method dispose\n * @for p5.MonoSynth\n */\n dispose() {\n super.dispose();\n\n if (this.env) {\n this.env.dispose();\n }\n if (this.oscillator) {\n this.oscillator.dispose();\n }\n }\n}\n\nexport default MonoSynth;\n","/**\n * Listen for onsets (a sharp increase in volume) within a given\n * frequency range.\n *\n * @class p5.OnsetDetect\n * @constructor\n * @param {Number} freqLow Low frequency\n * @param {Number} freqHigh High frequency\n * @param {Number} threshold Amplitude threshold between 0 (no energy) and 1 (maximum)\n * @param {Function} callback Function to call when an onset is detected\n */\nclass OnsetDetect {\n constructor(freqLow, freqHigh, threshold, callback) {\n this.isDetected = false;\n this.freqLow = freqLow;\n this.freqHigh = freqHigh;\n this.treshold = threshold;\n this.energy = 0;\n this.penergy = 0;\n\n // speed of decay\n this.sensitivity = 500;\n\n this.callback = callback;\n }\n\n // callback here too?\n update(fftObject, callback) {\n this.energy = fftObject.getEnergy(this.freqLow, this.freqHigh) / 255;\n\n if (this.isDetected === false) {\n if (this.energy - this.penergy > this.treshold) {\n this.isDetected = true;\n\n if (this.callback) {\n this.callback(this.energy);\n } else if (callback) {\n callback(this.energy);\n }\n\n var self = this;\n setTimeout(function () {\n self.isDetected = false;\n }, this.sensitivity);\n }\n }\n\n this.penergy = this.energy;\n }\n}\n\nexport default OnsetDetect;\n","import p5sound from './main';\nimport TimelineSignal from 'Tone/signal/TimelineSignal.js';\nimport { noteToFreq, freqToMidi } from './helpers';\n\n/**\n * An AudioVoice is used as a single voice for sound synthesis.\n * The PolySynth class holds an array of AudioVoice, and deals\n * with voices allocations, with setting notes to be played, and\n * parameters to be set.\n *\n * @class p5.PolySynth\n * @constructor\n *\n * @param {Number} [synthVoice] A monophonic synth voice inheriting\n * the AudioVoice class. Defaults to p5.MonoSynth\n * @param {Number} [maxVoices] Number of voices, defaults to 8;\n * @example\n *
\n * let polySynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * text('click to play', 20, 20);\n *\n * polySynth = new p5.PolySynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * // note duration (in seconds)\n * let dur = 1.5;\n *\n * // time from now (in seconds)\n * let time = 0;\n *\n * // velocity (volume, from 0 to 1)\n * let vel = 0.1;\n *\n * // notes can overlap with each other\n * polySynth.play('G2', vel, 0, dur);\n * polySynth.play('C3', vel, time += 1/3, dur);\n * polySynth.play('G3', vel, time += 1/3, dur);\n * }\n *
\n **/\nclass PolySynth {\n constructor(audioVoice, maxVoices) {\n //audiovoices will contain maxVoices many monophonic synths\n this.audiovoices = [];\n\n /**\n * An object that holds information about which notes have been played and\n * which notes are currently being played. New notes are added as keys\n * on the fly. While a note has been attacked, but not released, the value of the\n * key is the audiovoice which is generating that note. When notes are released,\n * the value of the key becomes undefined.\n * @property notes\n */\n this.notes = {};\n\n //indices of the most recently used, and least recently used audiovoice\n this._newest = 0;\n this._oldest = 0;\n\n /**\n * A PolySynth must have at least 1 voice, defaults to 8\n * @property polyvalue\n */\n this.maxVoices = maxVoices || 8;\n\n /**\n * Monosynth that generates the sound for each note that is triggered. The\n * p5.PolySynth defaults to using the p5.MonoSynth as its voice.\n * @property AudioVoice\n */\n this.AudioVoice = audioVoice === undefined ? p5.MonoSynth : audioVoice;\n\n /**\n * This value must only change as a note is attacked or released. Due to delay\n * and sustain times, Tone.TimelineSignal is required to schedule the change in value.\n * @private\n * @property {Tone.TimelineSignal} _voicesInUse\n */\n this._voicesInUse = new TimelineSignal(0);\n\n this.output = p5sound.audiocontext.createGain();\n this.connect();\n\n //Construct the appropriate number of audiovoices\n this._allocateVoices();\n p5sound.soundArray.push(this);\n }\n\n /**\n * Construct the appropriate number of audiovoices\n * @private\n * @for p5.PolySynth\n * @method _allocateVoices\n */\n _allocateVoices() {\n for (var i = 0; i < this.maxVoices; i++) {\n this.audiovoices.push(new this.AudioVoice());\n this.audiovoices[i].disconnect();\n this.audiovoices[i].connect(this.output);\n }\n }\n\n /**\n * Play a note by triggering noteAttack and noteRelease with sustain time\n *\n * @method play\n * @for p5.PolySynth\n * @param {Number} [note] midi note to play (ranging from 0 to 127 - 60 being a middle C)\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\n * @example\n *
\n * let polySynth;\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playSynth);\n * background(220);\n * text('click to play', 20, 20);\n *\n * polySynth = new p5.PolySynth();\n * }\n *\n * function playSynth() {\n * userStartAudio();\n *\n * // note duration (in seconds)\n * let dur = 1.5;\n *\n * // time from now (in seconds)\n * let time = 0;\n *\n * // velocity (volume, from 0 to 1)\n * let vel = 0.1;\n *\n * // notes can overlap with each other\n * polySynth.play('G2', vel, 0, dur);\n * polySynth.play('C3', vel, time += 1/3, dur);\n * polySynth.play('G3', vel, time += 1/3, dur);\n * }\n *
\n */\n play(note, velocity, secondsFromNow, susTime = 1) {\n this.noteAttack(note, velocity, secondsFromNow);\n this.noteRelease(note, secondsFromNow + susTime);\n }\n\n /**\n * noteADSR sets the envelope for a specific note that has just been triggered.\n * Using this method modifies the envelope of whichever audiovoice is being used\n * to play the desired note. The envelope should be reset before noteRelease is called\n * in order to prevent the modified envelope from being used on other notes.\n *\n * @method noteADSR\n * @for p5.PolySynth\n * @param {Number} [note] Midi note on which ADSR should be set.\n * @param {Number} [attackTime] Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n **/\n\n noteADSR(note, a, d, s, r, timeFromNow = 0) {\n var now = p5sound.audiocontext.currentTime;\n var t = now + timeFromNow;\n this.audiovoices[this.notes[note].getValueAtTime(t)].setADSR(a, d, s, r);\n }\n\n /**\n * Set the PolySynths global envelope. This method modifies the envelopes of each\n * monosynth so that all notes are played with this envelope.\n *\n * @method setADSR\n * @for p5.PolySynth\n * @param {Number} [attackTime] Time (in seconds before envelope\n * reaches Attack Level\n * @param {Number} [decayTime] Time (in seconds) before envelope\n * reaches Decay/Sustain Level\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\n * The susRatio determines the decayLevel and the level at which the\n * sustain portion of the envelope will sustain.\n * For example, if attackLevel is 0.4, releaseLevel is 0,\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\n * increased to 1.0 (using setRange),\n * then decayLevel would increase proportionally, to become 0.5.\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\n **/\n setADSR(a, d, s, r) {\n this.audiovoices.forEach(function (voice) {\n voice.setADSR(a, d, s, r);\n });\n }\n\n /**\n * Trigger the Attack, and Decay portion of a MonoSynth.\n * Similar to holding down a key on a piano, but it will\n * hold the sustain level until you let go.\n *\n * @method noteAttack\n * @for p5.PolySynth\n * @param {Number} [note] midi note on which attack should be triggered.\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)/\n * @param {Number} [secondsFromNow] time from now (in seconds)\n * @example\n *
\n * let polySynth = new p5.PolySynth();\n * let pitches = ['G', 'D', 'G', 'C'];\n * let octaves = [2, 3, 4];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playChord);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playChord() {\n * userStartAudio();\n *\n * // play a chord: multiple notes at the same time\n * for (let i = 0; i < 4; i++) {\n * let note = random(pitches) + random(octaves);\n * polySynth.noteAttack(note, 0.1);\n * }\n * }\n *\n * function mouseReleased() {\n * // release all voices\n * polySynth.noteRelease();\n * }\n *
\n */\n noteAttack(_note, _velocity, secondsFromNow = 0) {\n //this value is used by this._voicesInUse\n var acTime = p5sound.audiocontext.currentTime + secondsFromNow;\n\n //Convert note to frequency if necessary. This is because entries into this.notes\n //should be based on frequency for the sake of consistency.\n var note = noteToFreq(_note);\n var velocity = _velocity || 0.1;\n\n var currentVoice;\n\n //Release the note if it is already playing\n if (this.notes[note] && this.notes[note].getValueAtTime(acTime) !== null) {\n this.noteRelease(note, 0);\n }\n\n //Check to see how many voices are in use at the time the note will start\n if (this._voicesInUse.getValueAtTime(acTime) < this.maxVoices) {\n currentVoice = Math.max(~~this._voicesInUse.getValueAtTime(acTime), 0);\n }\n //If we are exceeding the polyvalue, bump off the oldest notes and replace\n //with a new note\n else {\n currentVoice = this._oldest;\n\n oldestNote = freqToMidi(\n this.audiovoices[this._oldest].oscillator.freq().value\n );\n this.noteRelease(oldestNote);\n this._oldest = (this._oldest + 1) % (this.maxVoices - 1);\n }\n\n //Overrite the entry in the notes object. A note (frequency value)\n //corresponds to the index of the audiovoice that is playing it\n this.notes[note] = new TimelineSignal();\n this.notes[note].setValueAtTime(currentVoice, acTime);\n\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\n //Add 1 and schedule this value at time 't', when this note will start playing\n var previousVal =\n this._voicesInUse._searchBefore(acTime) === null\n ? 0\n : this._voicesInUse._searchBefore(acTime).value;\n this._voicesInUse.setValueAtTime(previousVal + 1, acTime);\n\n //Then update all scheduled values that follow to increase by 1\n this._updateAfter(acTime, 1);\n\n this._newest = currentVoice;\n //The audiovoice handles the actual scheduling of the note\n if (typeof velocity === 'number') {\n var maxRange = (1 / this._voicesInUse.getValueAtTime(acTime)) * 2;\n velocity = velocity > maxRange ? maxRange : velocity;\n }\n\n // use secondsFromNow because this method will add AudioContext currentTime\n this.audiovoices[currentVoice].triggerAttack(\n note,\n velocity,\n secondsFromNow\n );\n }\n\n /**\n * Private method to ensure accurate values of this._voicesInUse\n * Any time a new value is scheduled, it is necessary to increment all subsequent\n * scheduledValues after attack, and decrement all subsequent\n * scheduledValues after release\n *\n * @private\n * @for p5.PolySynth\n * @param {[type]} time [description]\n * @param {[type]} value [description]\n * @return {[type]} [description]\n */\n _updateAfter(time, value) {\n if (this._voicesInUse._searchAfter(time) === null) {\n return;\n } else {\n this._voicesInUse._searchAfter(time).value += value;\n var nextTime = this._voicesInUse._searchAfter(time).time;\n this._updateAfter(nextTime, value);\n }\n }\n\n /**\n * Trigger the Release of an AudioVoice note. This is similar to releasing\n * the key on a piano and letting the sound fade according to the\n * release level and release time.\n *\n * @method noteRelease\n * @for p5.PolySynth\n * @param {Number} [note] midi note on which attack should be triggered.\n * If no value is provided, all notes will be released.\n * @param {Number} [secondsFromNow] time to trigger the release\n * @example\n *
\n * let polySynth = new p5.PolySynth();\n * let pitches = ['G', 'D', 'G', 'C'];\n * let octaves = [2, 3, 4];\n *\n * function setup() {\n * let cnv = createCanvas(100, 100);\n * cnv.mousePressed(playChord);\n * background(220);\n * text('tap to play', 20, 20);\n * }\n *\n * function playChord() {\n * userStartAudio();\n *\n * // play a chord: multiple notes at the same time\n * for (let i = 0; i < 4; i++) {\n * let note = random(pitches) + random(octaves);\n * polySynth.noteAttack(note, 0.1);\n * }\n * }\n *\n * function mouseReleased() {\n * // release all voices\n * polySynth.noteRelease();\n * }\n *
\n *\n */\n noteRelease(_note, secondsFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var tFromNow = secondsFromNow || 0;\n var t = now + tFromNow;\n\n // if a note value is not provided, release all voices\n if (!_note) {\n this.audiovoices.forEach(function (voice) {\n voice.triggerRelease(tFromNow);\n });\n this._voicesInUse.setValueAtTime(0, t);\n for (var n in this.notes) {\n this.notes[n].dispose();\n delete this.notes[n];\n }\n return;\n }\n\n //Make sure note is in frequency inorder to query the this.notes object\n var note = noteToFreq(_note);\n\n if (!this.notes[note] || this.notes[note].getValueAtTime(t) === null) {\n console.warn('Cannot release a note that is not already playing');\n } else {\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\n //subtract 1 and schedule this value at time 't', when this note will stop playing\n var previousVal = Math.max(\n ~~this._voicesInUse.getValueAtTime(t).value,\n 1\n );\n this._voicesInUse.setValueAtTime(previousVal - 1, t);\n //Then update all scheduled values that follow to decrease by 1 but never go below 0\n if (previousVal > 0) {\n this._updateAfter(t, -1);\n }\n\n this.audiovoices[this.notes[note].getValueAtTime(t)].triggerRelease(\n tFromNow\n );\n this.notes[note].dispose();\n delete this.notes[note];\n\n this._newest =\n this._newest === 0 ? 0 : (this._newest - 1) % (this.maxVoices - 1);\n }\n }\n\n /**\n * Connect to a p5.sound / Web Audio object.\n *\n * @method connect\n * @for p5.PolySynth\n * @param {Object} unit A p5.sound or Web Audio object\n */\n connect(unit) {\n var u = unit || p5sound.input;\n this.output.connect(u.input ? u.input : u);\n }\n\n /**\n * Disconnect all outputs\n *\n * @method disconnect\n * @for p5.PolySynth\n */\n disconnect() {\n if (this.output) {\n this.output.disconnect();\n }\n }\n\n /**\n * Get rid of the MonoSynth and free up its resources / memory.\n *\n * @method dispose\n * @for p5.PolySynth\n */\n dispose() {\n this.audiovoices.forEach(function (voice) {\n voice.dispose();\n });\n\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n }\n}\n\nexport default PolySynth;\n","class Signal {\n constructor() {\n console.warn('p5.Signal is deprecated , Use Tone.js Signal instead ');\n }\n}\n\nexport default Signal;\n","import 'audioworklet-polyfill';\nimport './shims';\n\nimport { getAudioContext, userStartAudio } from './audiocontext';\np5.prototype.getAudioContext = getAudioContext;\np5.prototype.userStartAudio = userStartAudio;\n\nimport './main';\n\nimport {\n sampleRate,\n freqToMidi,\n midiToFreq,\n noteToFreq,\n soundFormats,\n disposeSound,\n _checkFileFormats,\n _mathChain,\n convertToWav,\n interleave,\n writeUTFBytes,\n safeBufferSize,\n saveSound,\n} from './helpers';\np5.prototype.sampleRate = sampleRate;\np5.prototype.freqToMidi = freqToMidi;\np5.prototype.midiToFreq = midiToFreq;\np5.prototype.noteToFreq = noteToFreq;\np5.prototype.soundFormats = soundFormats;\np5.prototype.disposeSound = disposeSound;\np5.prototype._checkFileFormats = _checkFileFormats;\np5.prototype._mathChain = _mathChain;\np5.prototype.convertToWav = convertToWav;\np5.prototype.interleave = interleave;\np5.prototype.writeUTFBytes = writeUTFBytes;\np5.prototype.safeBufferSize = safeBufferSize;\np5.prototype.saveSound = saveSound;\n\n// register removeSound to dispose of p5sound SoundFiles, Convolvers,\n// Oscillators etc when sketch ends\np5.prototype.registerMethod('remove', p5.prototype.disposeSound);\n\nimport './errorHandler';\nimport './audioWorklet';\n\nimport Panner from './panner';\np5.Panner = Panner;\n\nimport SoundFile, { loadSound } from './soundfile';\np5.SoundFile = SoundFile;\np5.prototype.loadSound = loadSound;\n// register preload handling of loadSound\np5.prototype.registerPreloadMethod('loadSound', p5.prototype);\n\nimport Amplitude from './amplitude';\np5.Amplitude = Amplitude;\n\nimport FFT from './fft';\np5.FFT = FFT;\n\nimport Oscillator, { SinOsc, TriOsc, SawOsc, SqrOsc } from './oscillator';\np5.Oscillator = Oscillator;\np5.SinOsc = SinOsc;\np5.TriOsc = TriOsc;\np5.SawOsc = SawOsc;\np5.SqrOsc = SqrOsc;\n\nimport './envelope';\n\nimport Noise from './noise';\np5.Noise = Noise;\n\nimport Pulse from './pulse';\np5.Pulse = Pulse;\n\nimport AudioIn from './audioin';\np5.AudioIn = AudioIn;\n\nimport Effect from './effect';\np5.Effect = Effect;\n\nimport Filter, { LowPass, HighPass, BandPass } from './filter';\np5.Filter = Filter;\np5.LowPass = LowPass;\np5.HighPass = HighPass;\np5.BandPass = BandPass;\n\nimport EQ from './eq';\np5.EQ = EQ;\n\nimport listener3D from './listener3d';\np5.listener3D = listener3D;\n\nimport Panner3D from './panner3d';\np5.Panner3D = Panner3D;\n\nimport Delay from './delay';\np5.Delay = Delay;\n\nimport { Reverb, Convolver, createConvolver } from './reverb';\np5.Reverb = Reverb;\np5.Convolver = Convolver;\np5.prototype.createConvolver = createConvolver;\np5.prototype.registerPreloadMethod('createConvolver', p5.prototype);\n\nimport Metro from './metro';\np5.Metro = Metro;\n\nimport { Phrase, Part, Score } from './looper';\np5.Phrase = Phrase;\np5.Part = Part;\np5.Score = Score;\n\nimport SoundLoop from './soundLoop';\np5.SoundLoop = SoundLoop;\n\nimport Compressor from './compressor';\np5.Compressor = Compressor;\n\nimport peakDetect from './peakDetect';\np5.peakDetect = peakDetect;\n\nimport SoundRecorder from './soundRecorder';\np5.SoundRecorder = SoundRecorder;\n\nimport Distortion from './distortion';\np5.Distortion = Distortion;\n\nimport Gain from './gain';\np5.Gain = Gain;\n\nimport AudioVoice from './audioVoice';\np5.AudioVoice = AudioVoice;\n\nimport MonoSynth from './monosynth';\np5.MonoSynth = MonoSynth;\n\nimport OnsetDetect from './onsetDetect';\np5.OnsetDetect = OnsetDetect;\n\nimport PolySynth from './polysynth';\np5.PolySynth = PolySynth;\n\n// Following are the deprecated classes\nimport Signal from './deprecations/Signal';\np5.Signal = Signal;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 34e57c55..850fc24f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "git", "url": "https://github.com/processing/p5.js-sound.git" }, - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "devDependencies": { "@babel/core": "^7.4.5",