From acdb1b31d056f96a7380829813da0dba50d87edd Mon Sep 17 00:00:00 2001 From: dori Date: Sat, 11 Apr 2020 15:03:24 -0400 Subject: [PATCH 1/3] condition never met --- src/looper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/looper.js b/src/looper.js index c136fe91..4e0ca755 100644 --- a/src/looper.js +++ b/src/looper.js @@ -389,7 +389,7 @@ define(function(require) { var thisScore = this; for (var i in arguments) { - if (arguments[i] && this.parts[i]) { + if (arguments[i]) { this.parts[i] = arguments[i]; this.parts[i].nextPart = this.parts[i + 1]; this.parts[i].onended = function() { From a0f0637db07680d667d2f1501eb844c1cca0225b Mon Sep 17 00:00:00 2001 From: dori Date: Sat, 11 Apr 2020 15:05:25 -0400 Subject: [PATCH 2/3] playnextpart already control the flow --- lib/p5.sound.js | 13 ++++--------- lib/p5.sound.js.map | 2 +- lib/p5.sound.min.js | 4 ++-- lib/p5.sound.min.js.map | 2 +- package.json | 2 +- src/looper.js | 5 ----- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/p5.sound.js b/lib/p5.sound.js index 8580643c..33c4f3ac 100644 --- a/lib/p5.sound.js +++ b/lib/p5.sound.js @@ -1,4 +1,4 @@ -/** [p5.sound] Version: 0.3.12 - 2020-01-06 */ +/** [p5.sound] Version: 0.3.13 - 2020-04-11 */ /** *

p5.sound extends p5 with Web Audio functionality including audio input, @@ -5889,7 +5889,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__; * * @method getCentroid * @for p5.FFT - * @return {Number} Spectral Centroid Frequency Frequency of the spectral centroid in Hz. + * @return {Number} Spectral Centroid Frequency of the spectral centroid in Hz. * * * @example @@ -10303,7 +10303,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__; var thisScore = this; for (var i in arguments) { - if (arguments[i] && this.parts[i]) { + if (arguments[i]) { this.parts[i] = arguments[i]; this.parts[i].nextPart = this.parts[i + 1]; @@ -10320,11 +10320,6 @@ var __WEBPACK_AMD_DEFINE_RESULT__; p5.Score.prototype.onended = function () { if (this.looping) { this.parts[0].start(); - } else { - this.parts[this.parts.length - 1].onended = function () { - this.stop(); - this.resetParts(); - }; } this.currentPart = 0; @@ -10598,7 +10593,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__; } }; /** - * Synchronize loops. Use this method to start two more more loops in synchronization + * Synchronize loops. Use this method to start two or more loops in synchronization * or to start a loop in synchronization with a loop that is already playing * This method will schedule the implicit loop in sync with the explicit master loop * i.e. loopToStart.syncedStart(loopToSyncWith) diff --git a/lib/p5.sound.js.map b/lib/p5.sound.js.map index b495f030..babccacd 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:///./master.js","webpack:///../node_modules/tone/Tone/signal/Signal.js","webpack:///../node_modules/tone/Tone/signal/Multiply.js","webpack:///./effect.js","webpack:///../node_modules/tone/Tone/signal/WaveShaper.js","webpack:///./helpers.js","webpack:///../node_modules/tone/Tone/signal/Add.js","webpack:///../node_modules/tone/Tone/type/Type.js","webpack:///../node_modules/tone/Tone/core/Gain.js","webpack:///./audioWorklet/processorNames.js","webpack:///./errorHandler.js","webpack:///../node_modules/tone/Tone/core/Context.js","webpack:///../node_modules/tone/Tone/signal/Scale.js","webpack:///../node_modules/tone/Tone/signal/TimelineSignal.js","webpack:///./filter.js","webpack:///../node_modules/tone/Tone/signal/Subtract.js","webpack:///./audiocontext.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:///./oscillator.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/tone/Tone/core/Clock.js","webpack:///./monosynth.js","webpack:///./audioVoice.js","webpack:///./polysynth.js","webpack:///./app.js","webpack:///../node_modules/audioworklet-polyfill/dist/audioworklet-polyfill.js","webpack:///./shims.js","webpack:///../node_modules/webpack/buildin/global.js","webpack:///../node_modules/startaudiocontext/StartAudioContext.js","webpack:///./audioWorklet/index.js","webpack:///./audioWorklet/recorderProcessor.js","webpack:///./audioWorklet/soundFileProcessor.js","webpack:///./audioWorklet/amplitudeProcessor.js","webpack:///./panner.js","webpack:///./soundfile.js","webpack:///./amplitude.js","webpack:///./fft.js","webpack:///./signal.js","webpack:///../node_modules/tone/Tone/type/Frequency.js","webpack:///../node_modules/tone/Tone/type/TransportTime.js","webpack:///./envelope.js","webpack:///./pulse.js","webpack:///./noise.js","webpack:///./audioin.js","webpack:///../node_modules/tone/Tone/component/CrossFade.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:///./eq.js","webpack:///./eqFilter.js","webpack:///./panner3d.js","webpack:///./listener3d.js","webpack:///./delay.js","webpack:///./reverb.js","webpack:///./metro.js","webpack:///../node_modules/tone/Tone/core/TimelineState.js","webpack:///./looper.js","webpack:///./soundLoop.js","webpack:///./compressor.js","webpack:///./soundRecorder.js","webpack:///./peakDetect.js","webpack:///./gain.js","webpack:///./distortion.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","audiocontext","Master","limiter","createDynamicsCompressor","threshold","ratio","knee","meter","fftMeter","soundArray","parts","extensions","p5sound","p5","getMasterVolume","masterVolume","vol","tFromNow","currentTime","currentVol","cancelScheduledValues","linearRampToValueAtTime","soundOut","_silentNode","_gain","_param","getConstant","units","Type","Default","convert","SignalBase","Multiply","createInsOuts","_mult","Gain","require","CrossFade","Effect","ac","_drywet","wet","a","b","amp","drywet","fade","u","index","undefined","WaveShaper","mapping","bufferLen","_shaper","createWaveShaper","_curve","curve","isFinite","Float32Array","setMap","len","normalized","oversample","oversampling","RangeError","processorNames","freqToMidi","f","mathlog2","m","round","midiToFreq","noteToFreq","note","wholeNotes","A","B","C","D","E","F","G","toUpperCase","octave","slice","soundFormats","toLowerCase","disposeSound","registerMethod","_checkFileFormats","paths","path","extTest","pop","isFileSupported","pathSplit","pathCore","extension","supported","p","_mathChain","o","math","thisChain","nextChain","type","mathOps","convertToWav","audioBuffer","leftChannel","rightChannel","getChannelData","numberOfChannels","interleaved","interleave","buffer","ArrayBuffer","view","DataView","writeUTFBytes","setUint32","setUint16","lng","volume","setInt16","result","inputIndex","offset","string","setUint8","charCodeAt","safeBufferSize","idealBufferSize","bufferSize","tempAudioWorkletNode","AudioWorkletNode","soundFileProcessor","ScriptProcessorNode","Add","_sum","Time","Frequency","TransportTime","Ticks","NormalRange","AudioRange","Decibels","Interval","BPM","Positive","Cents","Degrees","MIDI","BarsBeatsSixteenths","Samples","Hertz","Note","Milliseconds","Seconds","Notation","toSeconds","time","TimeBase","toFrequency","freq","valueOf","toTicks","Transport","ticks","GainNode","AudioContext","createGainNode","_gainNode","module","exports","recorderProcessor","amplitudeProcessor","CustomError","name","errorTrace","failedPath","err","Error","tempStack","splitStack","originalStack","stack","filter","ln","toneConnect","outNum","inNum","nativeConnect","e","nativeDisconnect","webkitAudioContext","prop","Emitter","_context","_defineProperty","_latencyHint","_lookAhead","_updateInterval","_computedUpdateInterval","_worker","_createWorker","_constants","mixin","bind","URL","webkitURL","blob","Blob","toFixed","blobUrl","createObjectURL","worker","Worker","addEventListener","_lastUpdate","diff","max","createBuffer","arr","constant","createBufferSource","channelCount","channelCountMode","loop","start","lA","blockTime","postMessage","hint","lookAhead","latencyHint","updateInterval","warn","Scale","outputMin","outputMax","_outputMin","_outputMax","_scale","_add","_setRange","min","TimelineSignal","_events","Timeline","_initial","_fromUnits","Linear","Exponential","Target","Curve","Set","getValueAtTime","_toUnits","convertedVal","setValueAtTime","startTime","add","endTime","exponentialRampToValueAtTime","beforeEvent","_searchBefore","_minOutput","setValue","sampleTime","setTargetAtTime","timeConstant","setValueCurveAtTime","duration","scaling","floats","segmentTime","after","cancel","setRampPoint","before","_searchAfter","linearRampToValueBetween","finish","exponentialRampToValueBetween","getAfter","previouVal","previous","getBefore","_exponentialApproach","_curveInterpolate","_linearInterpolate","_exponentialInterpolate","t0","v0","v1","t","exp","t1","progress","lowerIndex","floor","upperIndex","ceil","lowerVal","upperVal","Filter","biquad","createBiquadFilter","setType","_on","_untoggledType","create","process","src","res","frequency","Q","toggle","LowPass","HighPass","BandPass","Subtract","_neg","Negate","global","StartAudioContext","getAudioContext","userStartAudio","elements","callback","elt","Element","map","on","event","events","eventName","off","ev","eventList","args","object","functions","func","emitterFunc","node","outputNumber","inputNumber","overridden","_plusNow","_unaryExpressions","quantize","regexp","method","rh","nextSubdivision","lh","subdiv","_expr","expr","subdivision","addNow","_defaultExpr","_noOp","copy","toNotation","retNotation","_toNotationHelper","retTripletNotation","testNotations","_notationToUnits","notationTime","multiple","notation","primaryExprs","_primaryExpressions","notationExprs","n","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","sub","mult","div","_lfo","lfo","LFO","currentVal","exponentialRampToValue","linearRampToValue","Mult","Oscillator","started","phaseAmount","oscillator","createOscillator","_freqMods","panPosition","connection","panner","Panner","stop","abs","freqNode","self","getAmp","isNaN","phase","getFreq","getType","oscMods","pan","pval","getPan","osc2","delayAmt","dNode","createDelay","delayTime","sigChain","mathObj","chainSource","num","scale","inMin","inMax","outMin","outMax","mapOutMin","mapOutMax","SinOsc","TriOsc","SawOsc","SqrOsc","_timeline","_toRemove","_iterating","memory","Infinity","_search","remove","shift","cancelBefore","beginning","end","midPoint","nextEvent","_iterate","lowerBound","upperBound","forEach","forEachBefore","forEachAfter","forEachFrom","forEachAtTime","_multiply","GreaterThanZero","_thresh","Clock","_nextTick","_lastState","_state","TimelineState","_boundLoop","_loop","state","setStateAtTime","pause","loopInterval","lag","currentState","tickTime","getStateAtTime","AudioVoice","DEFAULT_SUSTAIN","MonoSynth","env","Envelope","setRange","setExp","setADSR","setInput","play","velocity","secondsFromNow","susTime","triggerAttack","triggerRelease","vel","ramp","attack","decay","sustain","release","defineProperties","aTime","dTime","sPercent","rTime","sustime","PolySynth","audioVoice","maxVoices","audiovoices","notes","_newest","_oldest","_voicesInUse","_allocateVoices","noteAttack","noteRelease","noteADSR","d","r","timeFromNow","voice","_note","_velocity","acTime","currentVoice","oldestNote","previousVal","_updateAfter","maxRange","nextTime","p5SOUND","parameters","fill","processor","realm","exec","inputBuffer","outputBuffer","$$processors","$$context","createScriptProcessor","outputChannelCount","Map","properties","c","l","defaultValue","MessageChannel","port2","Processor","port","port1","onaudioprocess","$$audioWorklet","AudioWorklet","addModule","fetch","then","ok","status","text","AudioWorkletProcessor","registerProcessor","parameterDescriptors","document","createElement","style","cssText","appendChild","contentWindow","createTextNode","body","$hook","documentElement","transpile","String","fixSetTarget","setTargetValueAtTime","createDelayNode","createJavaScriptNode","createPeriodicWave","createWaveTable","internal_createGain","internal_createDelay","maxDelayTime","internal_createBufferSource","when","noteGrainOn","noteOn","internal_start","noteOff","internal_stop","playbackRate","internal_createDynamicsCompressor","reduction","internal_createBiquadFilter","detune","internal_createOscillator","setPeriodicWave","setWaveTable","OfflineAudioContext","webkitOfflineAudioContext","navigator","getUserMedia","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","el","isSupported","canPlayType","isOGGSupported","isMP3Supported","isWAVSupported","isAACSupported","isAIFSupported","g","Function","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","querySelectorAll","jquery","toArray","tap","moduleSources","initializedAudioWorklets","loadAudioWorkletModules","all","moduleSrc","objectURL","audioWorklet","preload","_incrementPreload","onWorkletModulesLoad","_decrementPreload","createStereoPanner","stereoPanner","inputChannels","obj","numInputChannels","left","right","channelInterpretation","splitter","createChannelSplitter","createChannelMerger","v","rightVal","cos","leftVal","numChannels","SoundFile","onload","onerror","whileLoading","url","File","FileReader","FileList","file","_onended","_looping","_playing","_paused","_pauseTime","_cues","_cueIDCounter","_lastPos","_counterNode","_workletNode","bufferSourceNodes","bufferSourceNode","reversed","pauseTime","mode","startMillis","load","_whileLoading","_clearOnEnd","registerPreloadMethod","loadSound","location","origin","cordova","alert","errorCallback","request","XMLHttpRequest","evt","_updateProgress","open","responseType","decodeAudioData","response","buff","msg","error","statusText","message","send","reader","readAsArrayBuffer","lengthComputable","percentComplete","loaded","isLoaded","rate","_cueStart","cueStart","cueEnd","setVolume","isPlaying","_initSourceNode","_initCounterNode","_arrayIndex","loopStart","loopEnd","playMode","str","pTime","setLoop","bool","isLooping","isPaused","stopAll","_time","_rampTime","_tFromNow","getVolume","reverse","reverseBuffer","setPitch","newPlaybackRate","getPlaybackRate","jump","cueTime","cTime","dur","channels","frames","getPeaks","width","sampleSize","sampleStep","peaks","chan","currentPos","curVol","onended","getLevel","setPath","setBuffer","buf","size","newBuffer","channelNum","channel","_createCounterBuffer","audioBuf","arrayBuffer","cNode","workletBufferSize","processorOptions","onmessage","data","_onTimeUpdate","processPeaks","_initThreshold","_minThreshold","_minPeaks","bufLen","allPeaks","initialThreshold","minThreshold","minPeaks","offlineContext","startRendering","oncomplete","filteredBuffer","renderedBuffer","bufferData","getPeaksAtThreshold","intervalCounts","countIntervalsBetweenNearbyPeaks","groups","groupNeighborsByTempo","topTempos","sort","intA","intB","count","tempo","bpmVariance","tempoPeaks","getPeaksAtTopTempo","Peak","sampleIndex","amplitude","tempos","intervals","peaksObj","peak","peaksArray","startPeak","endPeak","startPos","endPos","foundInterval","some","intervalCount","tempoCounts","theoreticalTempo","mapTempo","foundTempo","tempoCount","peaksAtTopTempo","key","intervalBPM","peakTime","dif","Cue","id","addCue","cue","removeCue","cueLength","clearCues","playbackTime","callbackTime","_prevUpdateTime","save","fileName","saveSound","getBlob","dataView","thisBufferSourceNode","target","soundFile","_","Amplitude","smoothing","parameterData","normalize","volNorm","stereoVol","stereoVolNorm","toggleNormalize","smooth","FFT","bins","analyser","createAnalyser","fftSize","configurable","smoothingTimeConstant","freqDomain","Uint8Array","frequencyBinCount","timeDomain","bass","lowMid","mid","highMid","treble","waveform","normalArray","_isSafari","timeToFloat","getFloatTimeDomainData","timeToInt","getByteTimeDomainData","scaled","analyze","freqToFloat","getFloatFrequencyData","freqToInt","getByteFrequencyData","getEnergy","frequency1","frequency2","nyquist","swap","lowIndex","highIndex","numFrequencies","toReturn","freq1","freq2","x","getCentroid","cumulative_sum","centroid_normalization","mean_freq_index","spec_centroid_freq","linAverages","N","spectrum","spectrumLength","spectrumStep","linearAverages","groupIndex","specIndex","logAverages","octaveBands","octaveIndex","specIndexFrequency","hi","getOctaveBands","fCtr0","lastFrequencyBand","lo","ctr","newFrequencyBand","fft","_input","midi","midiToFrequency","pitch","noteNumber","noteToScaleIndex","transpose","harmonize","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","l1","t2","l2","t3","l3","aLevel","dLevel","rLevel","_rampHighPercentage","_rampLowPercentage","control","_init","isExponential","sourceToClear","wasTriggered","_setRampAD","_rampAttackTime","checkExpInput","_rampDecayTime","TCDenominator","_rampAttackTC","_rampDecayTC","setRampPercentages","p1","p2","isExp","lastAttack","valToSet","v2","destination1","destination2","AudioIn","Reverb","Noise","Delay","Env","Pulse","w","dcOffset","createDCOffset","dcGain","mW","sig","SignalAdd","mods","currentFreq","freqMod","bufferSource","assignType","_brownNoise","_pinkNoise","_whiteNoise","whiteBuffer","noiseData","random","pinkBuffer","b0","b1","b2","b3","b4","b5","b6","white","brownBuffer","lastOut","noise","inputSources","stream","mediaStream","currentSource","enabled","MediaStreamTrack","mediaDevices","successCallback","audioSource","constraints","audio","echoCancellation","deviceId","createMediaStreamSource","getTracks","track","getSources","onSuccess","onError","resolve","reject","enumerateDevices","devices","device","kind","setSource","active","initialFade","_equalPowerA","EqualPowerGain","_equalPowerB","_invert","Expr","applyBinary","Constructor","_eval","applyUnary","getNumber","literalNumber","_replacements","inputCount","_parseInputs","_nodes","tree","_parseTree","_disposeNodes","_Expressions","signal","glue",",","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","_eqPower","EQFilter","EQ","_eqsize","factor","bands","_newBand","Panner3D","createPanner","panningModel","distanceModel","xVal","yVal","zVal","positionX","positionY","positionZ","orient","orientX","orientY","orientZ","orientationX","orientationY","orientationZ","setFalloff","maxDistance","rolloffFactor","maxDist","rolloff","Listener3D","listener","xValF","yValF","zValF","xValU","yValU","zValU","orientForward","orientUp","forwardX","forwardY","forwardZ","upX","upY","upZ","_split","_merge","_leftGain","_rightGain","leftDelay","rightDelay","_leftFilter","_rightFilter","_maxDelay","maxValue","feedback","_delayTime","_feedback","_filter","_initConvolverNode","_seconds","_decay","_reverse","_buildImpulse","convolverNode","createConvolver","_teardownConvolverNode","_setBuffer","decayRate","rebuild","impulse","impulseL","impulseR","Convolver","impulses","_loadBuffer","cReverb","chunks","addImpulse","resetImpulse","toggleImpulse","Metro","clock","ontick","syncedParts","prevTick","tatumTime","tickCallback","elapsedTime","thisPart","incrementStep","phrases","thisPhrase","phraseArray","sequence","bNum","metroTicks","looping","setBPM","beatTime","tatums","getBPM","getRate","resetSync","part","pushSync","beatLength","initial","Phrase","phraseStep","Part","steps","bLength","partStep","noLoop","metro","addPhrase","array","removePhrase","getPhrase","replaceSequence","onStep","Score","currentPart","thisScore","nextPart","resetPart","playNextPart","resetParts","scoreStep","aScore","SoundLoop","musicalTimeMode","_interval","_bpm","maxIterations","iterations","_calcFreq","syncedStart","otherLoop","_update","_convertNotation","Number","_measure","timeSig","Compressor","compressor","number","SoundRecorder","_inputChannels","_outputChannels","buffers","leftBuffer","rightBuffer","_callback","record","sFile","writeFile","PeakDetect","_framesPerPeak","framesPerPeak","framesSinceLastPeak","cutoff","cutoffMult","energy","penergy","currentValue","isDetected","f1","f2","_onPeak","update","fftObject","nrg","onPeak","makeDistortionCurve","amount","k","numSamples","deg","Distortion","curveAmount","waveShaperNode","getAmount","getOversample"],"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,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;AC5EAA,qEAAO,WAEN,aAgBW,SAAPC,EAAgBC,EAAQC,GAMvBC,KAAKC,QAAQH,IAAsB,IAAXA,EAC3BE,KAAKE,MAAQF,KAAKG,QAAQC,aACP,EAATN,IACVE,KAAKE,MAAQ,IAAIG,MAAMP,IAOpBE,KAAKC,QAAQF,IAAwB,IAAZA,EAC5BC,KAAKM,OAASN,KAAKG,QAAQC,aACP,EAAVL,IACVC,KAAKM,OAAS,IAAID,MAAMP,IAnB1B,IAsoBIS,EAmGJ,OAzrBAV,EAAKW,UAAUC,IAAM,SAASC,EAAQC,EAAOC,GAC5C,GAAIZ,KAAKa,SAASH,GACjBE,EAAWD,OACL,GAAIX,KAAKc,SAASJ,GAAQ,CAChC,I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iBrxC,UAAjB;AACD,GAHD;AAKA;;;;;;;;;;;AASAjD,IAAE,CAAC00C,UAAH,CAAc38C,SAAd,CAAwBC,GAAxB,GAA8B,UAASs8C,MAAT,EAAiBrxC,UAAjB,EAA6B;AACzD,QAAIqxC,MAAJ,EAAY;AACV,UAAIK,WAAW,GAAG30C,EAAE,CAACjI,SAAH,CAAaic,GAAb,CAAiBsgC,MAAjB,EAAyB,GAAzB,EAA8B,GAA9B,EAAmC,CAAnC,EAAsC,IAAtC,CAAlB;AACA,WAAKA,MAAL,GAAcK,WAAd;AACA,WAAKC,cAAL,CAAoBjyC,KAApB,GAA4B0xC,mBAAmB,CAACM,WAAD,CAA/C;AACD;;AACD,QAAI1xC,UAAJ,EAAgB;AACd,WAAK2xC,cAAL,CAAoB3xC,UAApB,GAAiCA,UAAjC;AACD;AACF,GATD;AAWA;;;;;;;;;;AAQAjD,IAAE,CAAC00C,UAAH,CAAc38C,SAAd,CAAwB88C,SAAxB,GAAoC,YAAW;AAC7C,WAAO,KAAKP,MAAZ;AACD,GAFD;AAIA;;;;;;;;;AAOAt0C,IAAE,CAAC00C,UAAH,CAAc38C,SAAd,CAAwB+8C,aAAxB,GAAwC,YAAW;AACjD,WAAO,KAAKF,cAAL,CAAoB3xC,UAA3B;AACD,GAFD;;AAKAjD,IAAE,CAAC00C,UAAH,CAAc38C,SAAd,CAAwB8C,OAAxB,GAAkC,YAAW;AAC3C4G,UAAM,CAAC1J,SAAP,CAAiB8C,OAAjB,CAAyBU,KAAzB,CAA+B,IAA/B;;AACA,QAAI,KAAKq5C,cAAT,EAAyB;AACvB,WAAKA,cAAL,CAAoB75C,UAApB;AACA,WAAK65C,cAAL,GAAsB,IAAtB;AACD;AACF,GAND;AAOD,CA5IK;AAAA,oGAAN,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 = 31);\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","'use strict';\n\n\ndefine(['audiocontext'], function (audiocontext) {\n // Master contains the master sound output.\n var Master = function() {\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 // create a single instance of the p5Sound / master output for use within this sketch\n var 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 */\n p5.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 */\n p5.prototype.masterVolume = function(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 = 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 }\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 */\n p5.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\n p5.soundOut._silentNode = p5sound.audiocontext.createGain();\n p5.soundOut._silentNode.gain.value = 0;\n p5.soundOut._silentNode.connect(p5sound.audiocontext.destination);\n\n\n return p5sound;\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});","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","'use strict';\ndefine(function (require) {\n\n var p5sound = require('master');\n var CrossFade = require('Tone/component/CrossFade');\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 */\n p5.Effect = function() {\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 p5.Effect.prototype.amp = function(vol, rampTime, tFromNow){\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);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow + .001);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime + .001);\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 p5.Effect.prototype.chain = function(){\n if (arguments.length>0){\n this.connect(arguments[0]);\n for(var i=1;i\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 */\n var midiToFreq = p5.prototype.midiToFreq = function(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\n var noteToFreq = function(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 p5.prototype.soundFormats = function() {\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\n p5.prototype.disposeSound = function() {\n for (var i = 0; i < p5sound.soundArray.length; i++) {\n p5sound.soundArray[i].dispose();\n }\n };\n\n // register removeSound to dispose of p5sound SoundFiles, Convolvers,\n // Oscillators etc when sketch ends\n p5.prototype.registerMethod('remove', p5.prototype.disposeSound);\n\n p5.prototype._checkFileFormats = function(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 path = path;\n }\n else {\n var pathSplit = path.split('.');\n var pathCore = pathSplit[pathSplit.length - 1];\n for (var i = 0; i 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\n function 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\n function 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\n function 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(p5sound.audiocontext, processorNames.soundFileProcessor);\n if (tempAudioWorkletNode instanceof ScriptProcessorNode) {\n bufferSize = tempAudioWorkletNode.bufferSize;\n }\n tempAudioWorkletNode.disconnect();\n tempAudioWorkletNode = null;\n\n return bufferSize;\n }\n\n return {\n convertToWav: convertToWav,\n midiToFreq: midiToFreq,\n noteToFreq: noteToFreq,\n safeBufferSize: safeBufferSize\n };\n\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 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});","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});","module.exports = {\n recorderProcessor: 'recorder-processor',\n soundFileProcessor: 'sound-file-processor',\n amplitudeProcessor: 'amplitude-processor'\n};\n","'use strict';\n\ndefine(function () {\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 */\n var 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 var splitStack = tempStack.split('\\n');\n splitStack = splitStack.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 };\n\n return CustomError;\n});\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/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/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});","'use strict';\n\ndefine(function (require) {\n var Effect = require('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 */\n p5.Filter = function (type) {\n\n Effect.call(this);\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\t */\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 p5.Filter.prototype = Object.create(Effect.prototype);\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 p5.Filter.prototype.process = function(src, freq, res, time) {\n src.connect(this.input);\n this.set(freq, res, time);\n };\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 p5.Filter.prototype.set = function(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 p5.Filter.prototype.freq = function(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(this.ac.currentTime + 0.01 + t);\n this.biquad.frequency.exponentialRampToValueAtTime(freq, this.ac.currentTime + 0.02 + t);\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 p5.Filter.prototype.res = function(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(res, this.ac.currentTime + 0.02 + t);\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 p5.Filter.prototype.gain = function(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(gain, this.ac.currentTime + 0.02 + t);\n } else if (gain) {\n gain.connect(this.biquad.gain);\n }\n return this.biquad.gain.value;\n };\n\n\n /**\n * Toggle function. Switches between the specified type and allpass\n *\n * @method toggle\n * @return {boolean} [Toggle value]\n */\n p5.Filter.prototype.toggle = function() {\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 p5.Filter.prototype.setType = function(t) {\n this.biquad.type = t;\n this._untoggledType = this.biquad.type;\n };\n\n p5.Filter.prototype.dispose = function() {\n // remove reference from soundArray\n Effect.prototype.dispose.apply(this);\n if (this.biquad) {\n this.biquad.disconnect();\n delete this.biquad;\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 */\n p5.LowPass = function() {\n p5.Filter.call(this, 'lowpass');\n };\n p5.LowPass.prototype = Object.create(p5.Filter.prototype);\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 */\n p5.HighPass = function() {\n p5.Filter.call(this, 'highpass');\n };\n p5.HighPass.prototype = Object.create(p5.Filter.prototype);\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 */\n p5.BandPass = function() {\n p5.Filter.call(this, 'bandpass');\n };\n p5.BandPass.prototype = Object.create(p5.Filter.prototype);\n\n return p5.Filter;\n});\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});","'use strict';\n\nglobal.TONE_SILENCE_VERSION_LOGGING = true;\n\ndefine(['startaudiocontext', 'Tone/core/Context', 'Tone/core/Tone'], function (StartAudioContext, Context, Tone) {\n // Create the Audio Context\n const audiocontext = new window.AudioContext();\n\n // Tone and p5.sound share the same audio context\n Tone.context.dispose();\n Tone.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 */\n p5.prototype.getAudioContext = function() {\n return audiocontext;\n };\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 */\n p5.prototype.userStartAudio = function(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) { return e.elt});\n }\n return StartAudioContext(audiocontext, elt, callback);\n };\n\n return audiocontext;\n});\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});","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\n\n var Add = require('Tone/signal/Add');\n var Mult = require('Tone/signal/Multiply');\n var Scale = require('Tone/signal/Scale');\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 */\n p5.Oscillator = function(freq, type) {\n if (typeof freq === 'string') {\n var f = type;\n type = freq;\n freq = f;\n } if (typeof type === 'number') {\n var 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(this.f, p5sound.audiocontext.currentTime);\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 p5.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\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 p5.Oscillator.prototype.start = function(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 p5.Oscillator.prototype.stop = function(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 p5.Oscillator.prototype.amp = function(vol, rampTime, tFromNow) {\n var self = this;\n if (typeof vol === 'number') {\n var rampTime = rampTime || 0;\n var tFromNow = tFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n }\n\n else if (vol) {\n vol.connect(self.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n };\n\n // these are now the same thing\n p5.Oscillator.prototype.fade = p5.Oscillator.prototype.amp;\n\n p5.Oscillator.prototype.getAmp = function() {\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 p5.Oscillator.prototype.freq = function(val, rampTime, tFromNow) {\n if (typeof val === 'number' && !isNaN(val)) {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n var rampTime = rampTime || 0;\n var tFromNow = tFromNow || 0;\n var t = now + tFromNow + rampTime;\n // var currentFreq = this.oscillator.frequency.value;\n // this.oscillator.frequency.cancelScheduledValues(now);\n\n if (rampTime === 0) {\n this.oscillator.frequency.setValueAtTime(val, tFromNow + now);\n } else {\n if (val > 0 ) {\n this.oscillator.frequency.exponentialRampToValueAtTime(val, tFromNow + rampTime + now);\n } else {\n this.oscillator.frequency.linearRampToValueAtTime(val, tFromNow + rampTime + now);\n }\n }\n\n // reset phase if oscillator has a phase\n if (this.phaseAmount) {\n this.phase(this.phaseAmount);\n }\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 p5.Oscillator.prototype.getFreq = function() {\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 p5.Oscillator.prototype.setType = function(type) {\n this.oscillator.type = type;\n };\n\n p5.Oscillator.prototype.getType = function() {\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 p5.Oscillator.prototype.connect = function(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n }\n else if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n this.connection = unit.input;\n }\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 p5.Oscillator.prototype.disconnect = function() {\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 p5.Oscillator.prototype.pan = function(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n };\n\n p5.Oscillator.prototype.getPan = function() {\n return this.panPosition;\n };\n\n // get rid of the oscillator\n p5.Oscillator.prototype.dispose = function() {\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 p5.Oscillator.prototype.phase = function(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 // SIGNAL MATH FOR MODULATION //\n // ========================== //\n\n // return sigChain(this, scale, thisChain, nextChain, Scale);\n var sigChain = function(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 * 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 p5.Oscillator.prototype.add = function(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 /**\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 p5.Oscillator.prototype.mult = function(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 p5.Oscillator.prototype.scale = function(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;\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5;\n }\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 // 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 */\n p5.SinOsc = function(freq) {\n p5.Oscillator.call(this, freq, 'sine');\n };\n\n p5.SinOsc.prototype = Object.create(p5.Oscillator.prototype);\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 */\n p5.TriOsc = function(freq) {\n p5.Oscillator.call(this, freq, 'triangle');\n };\n\n p5.TriOsc.prototype = Object.create(p5.Oscillator.prototype);\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 */\n p5.SawOsc = function(freq) {\n p5.Oscillator.call(this, freq, 'sawtooth');\n };\n\n p5.SawOsc.prototype = Object.create(p5.Oscillator.prototype);\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 */\n p5.SqrOsc = function(freq) {\n p5.Oscillator.call(this, freq, 'square');\n };\n\n p5.SqrOsc.prototype = Object.create(p5.Oscillator.prototype);\n\n});\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});","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});","'use strict';\ndefine(function (require) {\n\n var p5sound = require('master');\n var AudioVoice = require('audioVoice');\n var noteToFreq = require('helpers').noteToFreq;\n\n var 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\n p5.MonoSynth = function () {\n AudioVoice.call(this);\n\n this.oscillator = new p5.Oscillator();\n\n this.env = new p5.Envelope();\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 p5.MonoSynth.prototype = Object.create(p5.AudioVoice.prototype);\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 p5.MonoSynth.prototype.play = function (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 p5.MonoSynth.prototype.triggerAttack = function (note, velocity, secondsFromNow) {\n var secondsFromNow = ~~secondsFromNow;\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 p5.MonoSynth.prototype.triggerRelease = function (secondsFromNow) {\n var secondsFromNow = 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 p5.MonoSynth.prototype.setADSR = function (attack,decay,sustain,release) {\n this.env.setADSR(attack, decay, sustain, release);\n };\n\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(p5.MonoSynth.prototype, {\n 'attack': {\n get : function() {\n return this.env.aTime;\n },\n set : function(attack) {\n this.env.setADSR(attack, this.env.dTime,\n this.env.sPercent, this.env.rTime);\n }\n },\n 'decay': {\n get : function() {\n return this.env.dTime;\n },\n set : function(decay) {\n this.env.setADSR(this.env.aTime, decay,\n this.env.sPercent, this.env.rTime);\n }\n },\n 'sustain': {\n get : function() {\n return this.env.sPercent;\n },\n set : function(sustain) {\n this.env.setADSR(this.env.aTime, this.env.dTime,\n sustain, this.env.rTime);\n }\n },\n 'release': {\n get : function() {\n return this.env.rTime;\n },\n set : function(release) {\n this.env.setADSR(this.env.aTime, this.env.dTime,\n this.env.sPercent, release);\n }\n },\n });\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 p5.MonoSynth.prototype.amp = function(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 p5.MonoSynth.prototype.connect = function(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 p5.MonoSynth.prototype.disconnect = function() {\n if (this.output) {\n this.output.disconnect();\n }\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 p5.MonoSynth.prototype.dispose = function() {\n AudioVoice.prototype.dispose.apply(this);\n\n if (this.env) {\n this.env.dispose();\n }\n if (this.oscillator) {\n this.oscillator.dispose();\n }\n };\n\n});\n","'use strict';\ndefine(function() {\n var p5sound = require('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 */\n p5.AudioVoice = function () {\n\t this.ac = p5sound.audiocontext;\n\t this.output = this.ac.createGain();\n\t this.connect();\n\t p5sound.soundArray.push(this);\n };\n\n p5.AudioVoice.prototype.play = function (note, velocity, secondsFromNow, sustime) {\n };\n\n p5.AudioVoice.prototype.triggerAttack = function (note, velocity, secondsFromNow) {\n };\n\n p5.AudioVoice.prototype.triggerRelease = function (secondsFromNow) {\n };\n\n p5.AudioVoice.prototype.amp = function(vol, rampTime) {\n };\n\n /**\n * Connect to p5 objects or Web Audio Nodes\n * @method connect\n * @for p5.AudioVoice\n * @param {Object} unit\n */\n p5.AudioVoice.prototype.connect = function(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 p5.AudioVoice.prototype.disconnect = function() {\n this.output.disconnect();\n };\n\n p5.AudioVoice.prototype.dispose = function() {\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n };\n\n return p5.AudioVoice;\n});\n","'use strict';\ndefine(function (require) {\n\n var p5sound = require('master');\n var TimelineSignal = require('Tone/signal/TimelineSignal');\n var noteToFreq = require('helpers').noteToFreq;\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 **/\n p5.PolySynth = function(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\t * @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 p5.PolySynth.prototype._allocateVoices = function() {\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 p5.PolySynth.prototype.play = function (note,velocity, secondsFromNow, susTime) {\n var susTime = susTime || 1;\n this.noteAttack(note, velocity, secondsFromNow);\n this.noteRelease(note, secondsFromNow + susTime);\n };\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 p5.PolySynth.prototype.noteADSR = function (note,a,d,s,r,timeFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var timeFromNow = timeFromNow || 0;\n var t = now + timeFromNow\n this.audiovoices[ this.notes[note].getValueAtTime(t) ].setADSR(a,d,s,r);\n };\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 p5.PolySynth.prototype.setADSR = function(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 p5.PolySynth.prototype.noteAttack = function (_note, _velocity, secondsFromNow) {\n //this value goes to the audiovoices which handle their own scheduling\n var secondsFromNow = ~~secondsFromNow;\n\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 var oldestNote = p5.prototype.freqToMidi(this.audiovoices[this._oldest].oscillator.freq().value);\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 = this._voicesInUse._searchBefore(acTime) === null ? 0 : 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 this.audiovoices[currentVoice].triggerAttack(note, velocity, secondsFromNow);\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 p5.PolySynth.prototype._updateAfter = function(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 /**\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 p5.PolySynth.prototype.noteRelease = function (_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(~~this._voicesInUse.getValueAtTime(t).value, 1);\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(tFromNow);\n this.notes[note].dispose();\n delete this.notes[note];\n\n this._newest = this._newest === 0 ? 0 : (this._newest - 1) % (this.maxVoices - 1);\n }\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 p5.PolySynth.prototype.connect = function (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 p5.PolySynth.prototype.disconnect = function() {\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 p5.PolySynth.prototype.dispose = function() {\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});\n","'use strict';\n\ndefine(function (require) {\n\n require('audioworklet-polyfill');\n require('shims');\n require('audiocontext');\n var p5SOUND = require('master');\n require('helpers');\n require('errorHandler');\n require('audioWorklet');\n require('panner');\n require('soundfile');\n require('amplitude');\n require('fft');\n require('signal');\n require('oscillator');\n require('envelope');\n require('pulse');\n require('noise');\n require('audioin');\n require('filter');\n require('eq');\n require('panner3d');\n require('listener3d');\n require('delay');\n require('reverb');\n require('metro');\n require('looper');\n require('soundLoop');\n require('compressor');\n require('soundRecorder');\n require('peakDetect');\n require('gain');\n require('monosynth');\n require('polysynth');\n require('distortion');\n require('audioVoice');\n require('monosynth');\n require('polysynth');\n\n return p5SOUND;\n\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].length;\\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].length;\\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);\"","'use strict';\n\ndefine(function (require) {\n\n var p5sound = require('master');\n var ac = p5sound.audiocontext;\n\n // Stereo panner\n // if there is a stereo panner node use it\n if(typeof ac.createStereoPanner !== 'undefined') {\n p5.Panner = function (input, output) {\n this.stereoPanner = this.input = ac.createStereoPanner();\n input.connect(this.stereoPanner);\n this.stereoPanner.connect(output);\n };\n\n p5.Panner.prototype.pan = function(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 p5.Panner.prototype.inputChannels = function() {};\n\n p5.Panner.prototype.connect = function(obj) {\n this.stereoPanner.connect(obj);\n };\n\n p5.Panner.prototype.disconnect = function() {\n if (this.stereoPanner) {\n this.stereoPanner.disconnect();\n }\n };\n\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 p5.Panner = function(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 }\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 p5.Panner.prototype.pan = function(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 p5.Panner.prototype.inputChannels = function(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 p5.Panner.prototype.connect = function(obj) {\n this.output.connect(obj);\n };\n\n p5.Panner.prototype.disconnect = function() {\n if (this.output) {\n this.output.disconnect();\n }\n };\n }\n});\n","'use strict';\n\ndefine(function (require) {\n\n const CustomError = require('errorHandler');\n const p5sound = require('master');\n const ac = p5sound.audiocontext;\n const { midiToFreq, convertToWav, safeBufferSize } = require('helpers');\n var processorNames = require('./audioWorklet/processorNames');\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 */\n p5.SoundFile = function(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 }\n else if(typeof paths === 'object') {\n if (!(window.File && window.FileReader && window.FileList && window.Blob)) {\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 p5.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\n // register preload handling of loadSound\n p5.prototype.registerPreloadMethod('loadSound', p5.prototype);\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 */\n p5.prototype.loadSound = function(path, callback, onerror, whileLoading) {\n // if loading locally without a server\n if (window.location.origin.indexOf('file://') > -1 && window.cordova === 'undefined' ) {\n window.alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS');\n }\n\n var self = this;\n var s = new p5.SoundFile(path, function() {\n if(typeof callback === 'function') {\n callback.apply(self, arguments);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n }, onerror, whileLoading);\n\n return s;\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 p5.SoundFile.prototype.load = function(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('progress', function(evt) {\n self._updateProgress(evt);\n }, false);\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(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('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(msg +'\\n The error stack trace includes: \\n' + err.stack);\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 = 'Unable to load ' + self.url + '. The request status was: ' +\n request.status + ' (' + request.statusText + ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(msg +'\\n The error stack trace includes: \\n' + err.stack);\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 = 'There was no response from the server at ' + self.url + '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(msg +'\\n The error stack trace includes: \\n' + err.stack);\n }\n };\n\n request.send();\n }\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 p5.SoundFile.prototype._updateProgress = function(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 p5.SoundFile.prototype.isLoaded = function() {\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 p5.SoundFile.prototype.play = function(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 { throw 'start time out of range'; }\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 = duration <= this.buffer.duration - cueStart ? duration : 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\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 p5.SoundFile.prototype.playMode = function(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 p5.SoundFile.prototype.pause = function(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 p5.SoundFile.prototype.loop = function(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 p5.SoundFile.prototype.setLoop = function(bool) {\n if (bool === true) {\n this._looping = true;\n }\n else if (bool === false) {\n this._looping = false;\n }\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 p5.SoundFile.prototype.isLooping = function() {\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 p5.SoundFile.prototype.isPlaying = function() {\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 p5.SoundFile.prototype.isPaused = function() {\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 p5.SoundFile.prototype.stop = function(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 }\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 p5.SoundFile.prototype.stopAll = function(_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 this._onended(this);\n }\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 p5.SoundFile.prototype.setVolume = function(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 }\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 // same as setVolume, to match Processing Sound\n p5.SoundFile.prototype.amp = p5.SoundFile.prototype.setVolume;\n\n // these are the same thing\n p5.SoundFile.prototype.fade = p5.SoundFile.prototype.setVolume;\n\n p5.SoundFile.prototype.getVolume = function() {\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 p5.SoundFile.prototype.pan = function(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 p5.SoundFile.prototype.getPan = function() {\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 p5.SoundFile.prototype.rate = function(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 }\n\n else if (playbackRate < 0 && !this.reversed) {\n playbackRate = Math.abs(playbackRate);\n reverse = true;\n }\n\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(Math.abs(playbackRate), now);\n this._counterNode.playbackRate.cancelScheduledValues(now);\n this._counterNode.playbackRate.linearRampToValueAtTime(Math.abs(playbackRate), now);\n }\n\n if (reverse) {\n this.reverseBuffer();\n }\n return this.playbackRate;\n };\n\n // TO DO: document this\n p5.SoundFile.prototype.setPitch = function(num) {\n var newPlaybackRate = midiToFreq(num) / midiToFreq(60);\n this.rate(newPlaybackRate);\n };\n\n p5.SoundFile.prototype.getPlaybackRate = function() {\n return this.playbackRate;\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 p5.SoundFile.prototype.duration = function() {\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 p5.SoundFile.prototype.currentTime = function() {\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 p5.SoundFile.prototype.jump = function(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 p5.SoundFile.prototype.channels = function() {\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 p5.SoundFile.prototype.sampleRate = function() {\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 p5.SoundFile.prototype.frames = function() {\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 p5.SoundFile.prototype.getPeaks = function(length) {\n\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 }\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 p5.SoundFile.prototype.reverseBuffer = function() {\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 p5.SoundFile.prototype.onended = function(callback) {\n this._onended = callback;\n return this;\n };\n\n p5.SoundFile.prototype.add = function() {\n // TO DO\n };\n\n p5.SoundFile.prototype.dispose = function() {\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 p5.SoundFile.prototype.connect = function(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n }\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 p5.SoundFile.prototype.disconnect = function() {\n if (this.panner) {\n this.panner.disconnect();\n }\n };\n\n /**\n */\n p5.SoundFile.prototype.getLevel = function() {\n console.warn('p5.SoundFile.getLevel has been removed from the library. Use p5.Amplitude instead');\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 p5.SoundFile.prototype.setPath = function(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 p5.SoundFile.prototype.setBuffer = function(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 //////////////////////////////////////////////////\n // script processor node with an empty buffer to help\n // keep a sample-accurate position in playback buffer.\n // Inspired by Chinmay Pendharkar's technique for Sonoport --> http://bit.ly/1HwdCsV\n // Copyright [2015] [Sonoport (Asia) Pte. Ltd.],\n // Licensed under the Apache License http://apache.org/licenses/LICENSE-2.0\n ////////////////////////////////////////////////////////////////////////////////////\n\n var _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 // initialize counterNode, set its initial buffer and playbackRate\n p5.SoundFile.prototype._initCounterNode = function() {\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(ac, processorNames.soundFileProcessor, {\n processorOptions: { bufferSize: workletBufferSize }\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 p5.SoundFile.prototype._initSourceNode = function() {\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 /**\n * processPeaks returns an array of timestamps where it thinks there is a beat.\n *\n * This is an asynchronous function that processes the soundfile in an offline audio context,\n * and sends the results to your callback function.\n *\n * The process involves running the soundfile through a lowpass filter, and finding all of the\n * peaks above the initial threshold. If the total number of peaks are below the minimum number of peaks,\n * it decreases the threshold and re-runs the analysis until either minPeaks or minThreshold are reached.\n *\n * @method processPeaks\n * @for p5.SoundFile\n * @param {Function} callback a function to call once this data is returned\n * @param {Number} [initThreshold] initial threshold defaults to 0.9\n * @param {Number} [minThreshold] minimum threshold defaults to 0.22\n * @param {Number} [minPeaks] minimum number of peaks defaults to 200\n * @return {Array} Array of timestamped peaks\n */\n p5.SoundFile.prototype.processPeaks = function(callback, _initThreshold, _minThreshold, _minPeaks) {\n var bufLen = this.buffer.length;\n var sampleRate = this.buffer.sampleRate;\n var buffer = this.buffer;\n var allPeaks = [];\n\n var initialThreshold = _initThreshold || 0.9,\n threshold = initialThreshold,\n minThreshold = _minThreshold || 0.22,\n minPeaks = _minPeaks || 200;\n\n // Create offline context\n var offlineContext = new window.OfflineAudioContext(1, bufLen, sampleRate);\n\n // create buffer source\n var source = offlineContext.createBufferSource();\n source.buffer = buffer;\n\n // Create filter. TO DO: allow custom setting of filter\n var filter = offlineContext.createBiquadFilter();\n filter.type = 'lowpass';\n source.connect(filter);\n filter.connect(offlineContext.destination);\n\n // start playing at time:0\n source.start(0);\n offlineContext.startRendering(); // Render the song\n\n // act on the result\n offlineContext.oncomplete = function(e) {\n if (!self.panner) return;\n var filteredBuffer = e.renderedBuffer;\n var bufferData = filteredBuffer.getChannelData(0);\n\n\n // step 1:\n // create Peak instances, add them to array, with strength and sampleIndex\n do {\n allPeaks = getPeaksAtThreshold(bufferData, threshold);\n threshold -= 0.005;\n } while (Object.keys(allPeaks).length < minPeaks && threshold >= minThreshold);\n\n\n // step 2:\n // find intervals for each peak in the sampleIndex, add tempos array\n var intervalCounts = countIntervalsBetweenNearbyPeaks(allPeaks);\n\n // step 3: find top tempos\n var groups = groupNeighborsByTempo(intervalCounts, filteredBuffer.sampleRate);\n\n // sort top intervals\n var topTempos = groups.sort(function(intA, intB) {\n return intB.count - intA.count;\n\n }).splice(0,5);\n\n // set this SoundFile's tempo to the top tempo ??\n this.tempo = topTempos[0].tempo;\n\n // step 4:\n // new array of peaks at top tempo within a bpmVariance\n var bpmVariance = 5;\n var tempoPeaks = getPeaksAtTopTempo(allPeaks, topTempos[0].tempo, filteredBuffer.sampleRate, bpmVariance);\n\n callback(tempoPeaks);\n };\n };\n\n // process peaks\n var Peak = function(amp, i) {\n this.sampleIndex = i;\n this.amplitude = amp;\n this.tempos = [];\n this.intervals = [];\n };\n\n // 1. for processPeaks() Function to identify peaks above a threshold\n // returns an array of peak indexes as frames (samples) of the original soundfile\n function getPeaksAtThreshold(data, threshold) {\n var peaksObj = {};\n var length = data.length;\n\n for (var i = 0; i < length; i++) {\n if (data[i] > threshold) {\n var amp = data[i];\n var peak = new Peak(amp, i);\n peaksObj[i] = peak;\n // Skip forward ~ 1/8s to get past this peak.\n i += 6000;\n }\n i++;\n }\n return peaksObj;\n }\n\n // 2. for processPeaks()\n function countIntervalsBetweenNearbyPeaks(peaksObj) {\n var intervalCounts = [];\n var peaksArray = Object.keys(peaksObj).sort();\n\n for (var index = 0; index < peaksArray.length; index++) {\n\n // find intervals in comparison to nearby peaks\n for (var i = 0; i < 10; i++) {\n var startPeak = peaksObj[peaksArray[index]];\n var endPeak = peaksObj[peaksArray[index + i]];\n\n if (startPeak && endPeak) {\n var startPos = startPeak.sampleIndex;\n var endPos = endPeak.sampleIndex;\n var interval = endPos - startPos;\n\n // add a sample interval to the startPeak in the allPeaks array\n if (interval > 0) {\n startPeak.intervals.push(interval);\n }\n\n // tally the intervals and return interval counts\n var foundInterval = intervalCounts.some(function(intervalCount) {\n if (intervalCount.interval === interval) {\n intervalCount.count++;\n return intervalCount;\n }\n });\n\n // store with JSON like formatting\n if (!foundInterval) {\n intervalCounts.push({\n interval: interval,\n count: 1,\n });\n }\n }\n }\n }\n\n return intervalCounts;\n }\n\n\n // 3. for processPeaks --> find tempo\n function groupNeighborsByTempo(intervalCounts, sampleRate) {\n var tempoCounts = [];\n\n intervalCounts.forEach(function(intervalCount) {\n\n try {\n // Convert an interval to tempo\n var theoreticalTempo = Math.abs( 60 / (intervalCount.interval / sampleRate ) );\n\n theoreticalTempo = mapTempo(theoreticalTempo);\n\n var foundTempo = tempoCounts.some(function(tempoCount) {\n if (tempoCount.tempo === theoreticalTempo)\n return tempoCount.count += intervalCount.count;\n });\n if (!foundTempo) {\n if (isNaN(theoreticalTempo)) {\n return;\n }\n tempoCounts.push({\n tempo: Math.round(theoreticalTempo),\n count: intervalCount.count\n });\n }\n } catch(e) {\n throw e;\n }\n\n });\n\n return tempoCounts;\n }\n\n // 4. for processPeaks - get peaks at top tempo\n function getPeaksAtTopTempo(peaksObj, tempo, sampleRate, bpmVariance) {\n var peaksAtTopTempo = [];\n var peaksArray = Object.keys(peaksObj).sort();\n\n // TO DO: filter out peaks that have the tempo and return\n for (var i = 0; i < peaksArray.length; i++) {\n var key = peaksArray[i];\n var peak = peaksObj[key];\n\n for (var j = 0; j < peak.intervals.length; j++) {\n var intervalBPM = Math.round(Math.abs( 60 / (peak.intervals[j] / sampleRate) ) );\n\n intervalBPM = mapTempo(intervalBPM);\n\n if ( Math.abs(intervalBPM - tempo) < bpmVariance ) {\n // convert sampleIndex to seconds\n peaksAtTopTempo.push(peak.sampleIndex/sampleRate);\n }\n }\n }\n\n // filter out peaks that are very close to each other\n peaksAtTopTempo = peaksAtTopTempo.filter(function(peakTime, index, arr) {\n var dif = arr[index + 1] - peakTime;\n if (dif > 0.01) {\n return true;\n }\n });\n\n return peaksAtTopTempo;\n }\n\n // helper function for processPeaks\n function mapTempo(theoreticalTempo) {\n // these scenarios create infinite while loop\n if (!isFinite(theoreticalTempo) || theoreticalTempo === 0 ) {\n return;\n }\n\n // Adjust the tempo to fit within the 90-180 BPM range\n while (theoreticalTempo < 90) theoreticalTempo *= 2;\n while (theoreticalTempo > 180 && theoreticalTempo > 90) theoreticalTempo /= 2;\n\n return theoreticalTempo;\n }\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\n var Cue = function(callback, time, id, val) {\n this.callback = callback;\n this.time = time;\n this.id = id;\n this.val = val;\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 p5.SoundFile.prototype.addCue = function(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 p5.SoundFile.prototype.removeCue = function(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 p5.SoundFile.prototype.clearCues = function() {\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 p5.SoundFile.prototype._onTimeUpdate = function(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\n if (~~this._prevUpdateTime <= callbackTime && callbackTime <= playbackTime) {\n\n // pass the scheduled callbackTime as parameter to the callback\n cue.callback(val);\n }\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 p5.SoundFile.prototype.save = function(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 p5.SoundFile.prototype.getBlob = function() {\n const dataView = convertToWav(this.buffer);\n return new Blob([dataView], { type: 'audio/wav' });\n };\n\n // event handler to remove references to the bufferSourceNode when it is done playing\n function _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.map((_, i) => i).reverse().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","'use strict';\n\ndefine(function (require) {\n const p5sound = require('master');\n const { safeBufferSize } = require('helpers');\n const processorNames = require('./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 toggleSound() {\n * if (sound.isPlaying() ){\n * sound.stop();\n * } else {\n * sound.play();\n * }\n * }\n *\n *
\n */\n p5.Amplitude = function(smoothing) {\n\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(this.audiocontext, processorNames.amplitudeProcessor, {\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 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 p5.Amplitude.prototype.setInput = function(source, smoothing) {\n\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('Amplitude input source is not ready! Connecting to master output instead');\n p5sound.meter.connect(this._workletNode);\n }\n\n // if it is a p5.Signal\n else if (source instanceof p5.Signal) {\n source.output.connect(this._workletNode);\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 p5.Amplitude.prototype.connect = function(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 p5.Amplitude.prototype.disconnect = function() {\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 p5.Amplitude.prototype.getLevel = function(channel) {\n if (typeof channel !== 'undefined') {\n if (this.normalize) {\n return this.stereoVolNorm[channel];\n } else {\n return this.stereoVol[channel];\n }\n }\n else if (this.normalize) {\n return this.volNorm;\n }\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 p5.Amplitude.prototype.toggleNormalize = function(bool) {\n if (typeof bool === 'boolean') {\n this.normalize = bool;\n }\n else {\n this.normalize = !this.normalize;\n }\n this._workletNode.port.postMessage({ name: 'toggleNormalize', 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 p5.Amplitude.prototype.smooth = function(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\n p5.Amplitude.prototype.dispose = function() {\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});\n","'use strict';\n\ndefine(function(require) {\n var p5sound = require('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 */\n p5.FFT = function(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 p5.FFT.prototype.setInput = function(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 p5.FFT.prototype.waveform = function() {\n var bins, mode, normalArray;\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 var normalArray = new Array();\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 p5.FFT.prototype.analyze = function() {\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 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 p5.FFT.prototype.getEnergy = function(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(frequency1 / nyquist * this.freqDomain.length);\n var highIndex = Math.round(frequency2 / nyquist * this.freqDomain.length);\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 p5.FFT.prototype.getFreq = function(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 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 p5.FFT.prototype.getCentroid = function() {\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 p5.FFT.prototype.smooth = function(s) {\n if (typeof s !== 'undefined') {\n this.smoothing = s;\n }\n return this.smoothing;\n };\n\n p5.FFT.prototype.dispose = function() {\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 p5.FFT.prototype.linAverages = function(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 p5.FFT.prototype.logAverages = function(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 p5.FFT.prototype.getOctaveBands = function(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 // helper methods to convert type from float (dB) to int (0-255)\n var freqToFloat = function(fft) {\n if (fft.freqDomain instanceof Float32Array === false) {\n fft.freqDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n };\n var freqToInt = function(fft) {\n if (fft.freqDomain instanceof Uint8Array === false) {\n fft.freqDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n };\n var timeToFloat = function(fft) {\n if (fft.timeDomain instanceof Float32Array === false) {\n fft.timeDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n };\n var timeToInt = function(fft) {\n if (fft.timeDomain instanceof Uint8Array === false) {\n fft.timeDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n };\n});\n","'use strict';\n\ndefine(function (require) {\n\n // Signal is built with the Tone.js signal by Yotam Mann\n // https://github.com/TONEnoTONE/Tone.js/\n var Signal = require('Tone/signal/Signal');\n var Add = require('Tone/signal/Add');\n var Mult = require('Tone/signal/Multiply');\n var Scale = require('Tone/signal/Scale');\n\n /**\n *

p5.Signal is a constant audio-rate signal used by p5.Oscillator\n * and p5.Envelope for modulation math.

\n *\n *

This is necessary because Web Audio is processed on a seprate clock.\n * For example, the p5 draw loop runs about 60 times per second. But\n * the audio clock must process samples 44100 times per second. If we\n * want to add a value to each of those samples, we can't do it in the\n * draw loop, but we can do it by adding a constant-rate audio signal.This class mostly functions behind the scenes in p5.sound, and returns\n * a Tone.Signal from the Tone.js library by Yotam Mann.\n * If you want to work directly with audio signals for modular\n * synthesis, check out\n * tone.js.

\n *\n * @class p5.Signal\n * @constructor\n * @return {Tone.Signal} A Signal object from the Tone.js library\n * @example\n *
\n * let carrier, modulator;\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 * carrier = new p5.Oscillator('sine');\n * carrier.start();\n * carrier.amp(1); // set amplitude\n * carrier.freq(220); // set frequency\n *\n * modulator = new p5.Oscillator('sawtooth');\n * modulator.disconnect();\n * modulator.start();\n * modulator.amp(1);\n * modulator.freq(4);\n *\n * // Modulator's default amplitude range is -1 to 1.\n * // Multiply it by -200, so the range is -200 to 200\n * // then add 220 so the range is 20 to 420\n * carrier.freq( modulator.mult(-400).add(220) );\n * }\n *\n * function canvasPressed() {\n * userStartAudio();\n * carrier.amp(1.0);\n * }\n *\n * function mouseReleased() {\n * carrier.amp(0);\n * }\n *
\n */\n p5.Signal = function(value) {\n var s = new Signal(value);\n // p5sound.soundArray.push(s);\n return s; // TODO: is this really a constructor?\n };\n\n /**\n * Fade to value, for smooth transitions\n *\n * @method fade\n * @for p5.Signal\n * @param {Number} value Value to set this signal\n * @param {Number} [secondsFromNow] Length of fade, in seconds from now\n */\n Signal.prototype.fade = Signal.prototype.linearRampToValueAtTime;\n Mult.prototype.fade = Signal.prototype.fade;\n Add.prototype.fade = Signal.prototype.fade;\n Scale.prototype.fade = Signal.prototype.fade;\n\n\n /**\n * Connect a p5.sound object or Web Audio node to this\n * p5.Signal so that its amplitude values can be scaled.\n *\n * @method setInput\n * @for p5.Signal\n * @param {Object} input\n */\n Signal.prototype.setInput = function(_input) {\n _input.connect(this);\n };\n Mult.prototype.setInput = Signal.prototype.setInput;\n Add.prototype.setInput = Signal.prototype.setInput;\n Scale.prototype.setInput = Signal.prototype.setInput;\n\n\n // signals can add / mult / scale themselves\n\n /**\n * Add a constant value to this audio signal,\n * and return the resulting audio signal. Does\n * not change the value of the original signal,\n * instead it returns a new p5.SignalAdd.\n *\n * @method add\n * @for p5.Signal\n * @param {Number} number\n * @return {p5.Signal} object\n */\n Signal.prototype.add = function(num) {\n var add = new Add(num);\n // add.setInput(this);\n this.connect(add);\n return add;\n };\n Mult.prototype.add = Signal.prototype.add;\n Add.prototype.add = Signal.prototype.add;\n Scale.prototype.add = Signal.prototype.add;\n\n /**\n * Multiply this signal by a constant value,\n * and return the resulting audio signal. Does\n * not change the value of the original signal,\n * instead it returns a new p5.SignalMult.\n *\n * @method mult\n * @for p5.Signal\n * @param {Number} number to multiply\n * @return {p5.Signal} object\n */\n Signal.prototype.mult = function(num) {\n var mult = new Mult(num);\n // mult.setInput(this);\n this.connect(mult);\n return mult;\n };\n Mult.prototype.mult = Signal.prototype.mult;\n Add.prototype.mult = Signal.prototype.mult;\n Scale.prototype.mult = Signal.prototype.mult;\n\n /**\n * Scale this signal value to a given range,\n * and return the result as an audio signal. Does\n * not change the value of the original signal,\n * instead it returns a new p5.SignalScale.\n *\n * @method scale\n * @for p5.Signal\n * @param {Number} number to multiply\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.Signal} object\n */\n Signal.prototype.scale = function(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;\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5;\n }\n else {\n mapOutMin = arguments[0];\n mapOutMax = arguments[1];\n }\n var scale = new Scale(mapOutMin, mapOutMax);\n this.connect(scale);\n return scale;\n };\n Mult.prototype.scale = Signal.prototype.scale;\n Add.prototype.scale = Signal.prototype.scale;\n Scale.prototype.scale = Signal.prototype.scale;\n\n});\n\n\n","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});","'use strict';\n\ndefine(function (require) {\n\n var p5sound = require('master');\n var Add = require('Tone/signal/Add');\n var Mult = require('Tone/signal/Multiply');\n var Scale = require('Tone/signal/Scale');\n var TimelineSignal = require('Tone/signal/TimelineSignal');\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 */\n p5.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\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\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.\n p5.Envelope.prototype._init = function () {\n var now = p5sound.audiocontext.currentTime;\n var t = now;\n this.control.setTargetAtTime(0.00001, t, .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 */\n p5.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 */\n p5.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 = typeof sPercent !== 'undefined' ? sPercent * (this.aLevel - this.rLevel) + this.rLevel : 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 */\n p5.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 //\n p5.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(1.0 / this.checkExpInput(1.0 - this._rampHighPercentage));\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\n p5.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(1.0 / this.checkExpInput(1.0 - this._rampHighPercentage));\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 /**\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 */\n p5.Envelope.prototype.setInput = function() {\n for (var i = 0; iPlay 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 */\n p5.Envelope.prototype.play = function(unit, secondsFromNow, susTime) {\n var tFromNow = secondsFromNow || 0;\n var susTime = susTime || 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 /**\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 */\n p5.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 {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n }\n else\n {\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 {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(this.aLevel), t);\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n }\n else\n {\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\n // decay to decay level (if using ADSR, then decay level == sustain level)\n t += this.dTime;\n if (this.isExponential === true)\n {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(this.dLevel), t);\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n }\n else\n {\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 */\n p5.Envelope.prototype.triggerRelease = function(unit, secondsFromNow) {\n\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 {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n }\n else\n {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // release\n t += this.rTime;\n\n if (this.isExponential === true)\n {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(this.rLevel), t);\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n }\n else\n {\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 (optional)\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 */\n p5.Envelope.prototype.ramp = function(unit, secondsFromNow, v1, v2) {\n\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 = 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\n\n p5.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 (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 if (unit instanceof p5.Signal) {\n unit.setValue(0);\n }\n this.output.connect(unit);\n };\n\n p5.Envelope.prototype.disconnect = function() {\n if (this.output) {\n this.output.disconnect();\n }\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 */\n p5.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 */\n p5.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 */\n p5.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\n // get rid of the oscillator\n p5.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\n p5.Env = function(t1, l1, t2, l2, t3, l3) {\n console.warn('WARNING: p5.Env is now deprecated and may be removed in future versions. ' +\n 'Please use the new p5.Envelope instead.');\n p5.Envelope.call(this, t1, l1, t2, l2, t3, l3);\n };\n p5.Env.prototype = Object.create(p5.Envelope.prototype);\n\n});\n","'use strict';\n\ndefine(function (require) {\n\n var p5sound = require('master');\n require('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 */\n p5.Pulse = function(freq, w) {\n p5.Oscillator.call(this, 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 p5.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 p5.Pulse.prototype = Object.create(p5.Oscillator.prototype);\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 p5.Pulse.prototype.width = function(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 var sig = new p5.SignalAdd(-0.5);\n sig.setInput(w);\n sig = sig.mult(-1);\n sig = sig.mult(1.7);\n sig.connect(this.dcGain.gain);\n }\n };\n\n p5.Pulse.prototype.start = function(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 = [this.oscillator.frequency, this.osc2.oscillator.frequency];\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 p5.Pulse.prototype.stop = function(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 p5.Pulse.prototype.freq = function(val, rampTime, tFromNow) {\n if (typeof val === 'number') {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n var rampTime = rampTime || 0;\n var tFromNow = tFromNow || 0;\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(val, tFromNow + rampTime + now);\n this.osc2.oscillator.frequency.cancelScheduledValues(now);\n this.osc2.oscillator.frequency.setValueAtTime(currentFreq, now + tFromNow);\n this.osc2.oscillator.frequency.exponentialRampToValueAtTime(val, tFromNow + rampTime + now);\n\n if (this.freqMod) {\n this.freqMod.output.disconnect();\n this.freqMod = null;\n }\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 // inspiration: http://webaudiodemos.appspot.com/oscilloscope/\n function 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++)\n data[i]=1.0;\n var bufferSource=ac.createBufferSource();\n bufferSource.buffer=buffer;\n bufferSource.loop=true;\n return bufferSource;\n }\n\n});\n","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\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 */\n p5.Noise = function(type) {\n var assignType;\n p5.Oscillator.call(this);\n delete this.f;\n delete this.freq;\n delete this.oscillator;\n\n if (type === 'brown') {\n assignType = _brownNoise;\n } else if (type === 'pink') {\n assignType = _pinkNoise;\n } else {\n assignType = _whiteNoise;\n }\n this.buffer = assignType;\n };\n\n p5.Noise.prototype = Object.create(p5.Oscillator.prototype);\n\n // generate noise buffers\n var _whiteNoise = (function() {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var whiteBuffer = p5sound.audiocontext.createBuffer(1, bufferSize, p5sound.audiocontext.sampleRate);\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\n var _pinkNoise = (function() {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var pinkBuffer = p5sound.audiocontext.createBuffer(1, bufferSize, p5sound.audiocontext.sampleRate);\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.96900 * b2 + white * 0.1538520;\n b3 = 0.86650 * b3 + white * 0.3104856;\n b4 = 0.55000 * b4 + white * 0.5329522;\n b5 = -0.7616 * b5 - white * 0.0168980;\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\n var _brownNoise = (function() {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var brownBuffer = p5sound.audiocontext.createBuffer(1, bufferSize, p5sound.audiocontext.sampleRate);\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 * 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 p5.Noise.prototype.setType = function(type) {\n switch(type) {\n case 'white':\n this.buffer = _whiteNoise;\n break;\n case 'pink':\n this.buffer = _pinkNoise;\n break;\n case 'brown':\n this.buffer = _brownNoise;\n break;\n default:\n this.buffer = _whiteNoise;\n }\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.start(now+.01);\n }\n };\n\n p5.Noise.prototype.getType = function() {\n return this.buffer.type;\n };\n\n p5.Noise.prototype.start = function() {\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 p5.Noise.prototype.stop = function() {\n var now = p5sound.audiocontext.currentTime;\n if (this.noise) {\n this.noise.stop(now);\n this.started = false;\n }\n };\n\n p5.Noise.prototype.dispose = function() {\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});\n","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\n\n // an array of input sources\n p5sound.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 */\n p5.AudioIn = function(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 p5.Amplitude();\n this.output.connect(this.amplitude.input);\n\n if (!window.MediaStreamTrack || !window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia) {\n errorCallback ? errorCallback() : window.alert('This browser does not support MediaStreamTrack and mediaDevices');\n }\n\n // add to soundArray so we can dispose on close\n p5sound.soundArray.push(this);\n };\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 p5.AudioIn.prototype.start = function(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.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 p5.AudioIn.prototype.stop = function() {\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 p5.AudioIn.prototype.connect = function(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n }\n else if (unit.hasOwnProperty('analyser')) {\n this.output.connect(unit.analyser);\n }\n else {\n this.output.connect(unit);\n }\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 p5.AudioIn.prototype.disconnect = function() {\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 p5.AudioIn.prototype.getLevel = function(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 p5.AudioIn.prototype.amp = function(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(currentVol, p5sound.audiocontext.currentTime);\n this.output.gain.linearRampToValueAtTime(vol, rampTime + p5sound.audiocontext.currentTime);\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 and it returns a Promise.\n *\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 p5.AudioIn.prototype.getSources = function (onSuccess, onError) {\n return new Promise( function(resolve, reject) {\n window.navigator.mediaDevices.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('This browser does not support MediaStreamTrack.getSources()');\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 *
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 p5.AudioIn.prototype.setSource = function(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 p5.AudioIn.prototype.dispose = function() {\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});\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","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});","'use strict';\n\ndefine(function (require) {\n\n var Effect = require('effect');\n var EQFilter = require('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 */\n p5.EQ = function(_eqsize) {\n Effect.call(this);\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\n var freq, res;\n for (var i = 0; i < _eqsize; i++) {\n if (i === _eqsize - 1) {\n freq = 21000;\n res = .01;\n } else if (i === 0) {\n freq = 100;\n res = .1;\n }\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 p5.EQ.prototype = Object.create(Effect.prototype);\n\n /**\n * Process an input by connecting it to the EQ\n * @method process\n * @param {Object} src Audio source\n */\n p5.EQ.prototype.process = function (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 p5.EQ.prototype.set = function() {\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 }\n else {\n console.error('Argument mismatch. .set() should be called with ' + this.bands.length*2 +\n ' arguments. (one frequency and gain value pair for each band of the eq)');\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 p5.EQ.prototype._newBand = function(freq, res) {\n return new EQFilter(freq, res);\n };\n\n p5.EQ.prototype.dispose = function () {\n Effect.prototype.dispose.apply(this);\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\n return p5.EQ;\n});\n","'use strict';\n\ndefine(function (require) {\n var Filter = require('filter');\n var p5sound = require('master');\n\n /**\n * EQFilter extends p5.Filter with constraints\n * necessary for the p5.EQ\n *\n * @private\n */\n var EQFilter = function(freq, res) {\n Filter.call(this, 'peaking');\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 EQFilter.prototype = Object.create(Filter.prototype);\n\n EQFilter.prototype.amp = function() {\n console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');\n };\n EQFilter.prototype.drywet = function() {\n console.warn('`drywet()` is not available for p5.EQ bands.');\n };\n EQFilter.prototype.connect = function(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\n EQFilter.prototype.disconnect = function() {\n if (this.biquad) {\n this.biquad.disconnect();\n }\n };\n EQFilter.prototype.dispose = function() {\n // remove reference form soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n this.disconnect();\n delete this.biquad;\n };\n\n return EQFilter;\n});\n","'use strict'\n\ndefine(function (require) {\n var p5sound = require('master');\n var Effect = require('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\tp5.Panner3D = function() {\n Effect.call(this);\n\n /**\n * \n * Web Audio Spatial Panner Node\n *\n * Properties include\n * - panningModel: \"equal power\" or \"HRTF\"\n * - distanceModel: \"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\t};\n\n p5.Panner3D.prototype = Object.create(Effect.prototype);\n\n\n /**\n * Connect an audio sorce\n *\n * @method process\n * @for p5.Panner3D\n * @param {Object} src Input source\n */\n p5.Panner3D.prototype.process = function(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 p5.Panner3D.prototype.set = function(xVal, yVal, zVal, time) {\n this.positionX(xVal,time);\n this.positionY(yVal,time);\n this.positionZ(zVal,time);\n return [this.panner.positionX.value,\n this.panner.positionY.value,\n this.panner.positionZ.value];\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 p5.Panner3D.prototype.positionX = function(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.positionX.value = xVal;\n this.panner.positionX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.positionX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.panner.positionX);\n }\n return this.panner.positionX.value;\n };\n p5.Panner3D.prototype.positionY = function(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.positionY.value = yVal;\n this.panner.positionY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.positionY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.panner.positionY);\n }\n return this.panner.positionY.value;\n };\n p5.Panner3D.prototype.positionZ = function(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.positionZ.value = zVal;\n this.panner.positionZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.positionZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\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 p5.Panner3D.prototype.orient = function(xVal, yVal, zVal, time) {\n this.orientX(xVal,time);\n this.orientY(yVal,time);\n this.orientZ(zVal,time);\n return [this.panner.orientationX.value,\n this.panner.orientationY.value,\n this.panner.orientationZ.value];\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 p5.Panner3D.prototype.orientX = function(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.orientationX.value = xVal;\n this.panner.orientationX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.orientationX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.panner.orientationX);\n }\n return this.panner.orientationX.value;\n };\n p5.Panner3D.prototype.orientY = function(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.orientationY.value = yVal;\n this.panner.orientationY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.orientationY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.panner.orientationY);\n }\n return this.panner.orientationY.value;\n };\n p5.Panner3D.prototype.orientZ = function(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.orientationZ.value = zVal;\n this.panner.orientationZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.orientationZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\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 p5.Panner3D.prototype.setFalloff = function(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 p5.Panner3D.prototype.maxDist = function(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 p5.Panner3D.prototype.rolloff = function(rolloffFactor){\n if (typeof rolloffFactor === 'number') {\n this.panner.rolloffFactor = rolloffFactor;\n }\n return this.panner.rolloffFactor;\n };\n\n p5.Panner3D.dispose = function() {\n Effect.prototype.dispose.apply(this);\n if (this.panner) {\n this.panner.disconnect();\n delete this.panner;\n }\n };\n\n return p5.Panner3D;\n\n});\n","'use strict'\n\ndefine(function (require) {\n var p5sound = require('master');\n var Effect = require('effect');\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 \n\tp5.Listener3D = function(type) {\n this.ac = p5sound.audiocontext;\n this.listener = this.ac.listener;\n\t}; \n\n// /**\n// * Connect an audio sorce\n// * @param {Object} src Input source\n// */\n p5.Listener3D.prototype.process = function(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 p5.Listener3D.prototype.position = function(xVal, yVal, zVal, time) {\n this.positionX(xVal,time);\n this.positionY(yVal,time);\n this.positionZ(zVal,time);\n return [this.listener.positionX.value, \n this.listener.positionY.value,\n this.listener.positionZ.value];\n };\n\n// /**\n// * Getter and setter methods for position coordinates\n// * @return {Number} [updated coordinate value]\n// */\n p5.Listener3D.prototype.positionX = function(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.positionX.value = xVal;\n this.listener.positionX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.positionX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.listener.positionX);\n }\n return this.listener.positionX.value;\n };\n p5.Listener3D.prototype.positionY = function(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.positionY.value = yVal;\n this.listener.positionY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.positionY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.listener.positionY);\n }\n return this.listener.positionY.value;\n };\n p5.Listener3D.prototype.positionZ = function(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.positionZ.value = zVal;\n this.listener.positionZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.positionZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\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 p5.Listener3D.prototype.orient = function(xValF, yValF, zValF, \n xValU, yValU, zValU, time) {\n\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 [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 p5.Listener3D.prototype.orientForward = function(xValF, yValF, zValF, time) {\n this.forwardX(xValF,time);\n this.forwardY(yValF,time);\n this.forwardZ(zValF,time);\n\n return [this.listener.forwardX, \n this.listener.forwardY,\n this.listener.forwardZ];\n };\n\n p5.Listener3D.prototype.orientUp = function(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, \n this.listener.upY,\n this.listener.upZ];\n };\n// /**\n// * Getter and setter methods for orient coordinates\n// * @return {Number} [updated coordinate value]\n// */\n p5.Listener3D.prototype.forwardX = function(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.forwardX.value = xVal;\n this.listener.forwardX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.forwardX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.listener.forwardX);\n }\n return this.listener.forwardX.value;\n };\n p5.Listener3D.prototype.forwardY = function(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.forwardY.value = yVal;\n this.listener.forwardY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.forwardY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.listener.forwardY);\n }\n return this.listener.forwardY.value;\n };\n p5.Listener3D.prototype.forwardZ = function(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.forwardZ.value = zVal;\n this.listener.forwardZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.forwardZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\n } else if (zVal) {\n zVal.connect(this.listener.forwardZ);\n }\n return this.listener.forwardZ.value;\n };\n p5.Listener3D.prototype.upX = function(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(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.listener.upX);\n }\n return this.listener.upX.value;\n };\n p5.Listener3D.prototype.upY = function(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(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.listener.upY);\n }\n return this.listener.upY.value;\n };\n p5.Listener3D.prototype.upZ = function(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(zVal, this.ac.currentTime + 0.02 + t);\n } else if (zVal) {\n zVal.connect(this.listener.upZ);\n }\n return this.listener.upZ.value;\n };\n \n return p5.Listener3D;\n\n});","'use strict';\n\ndefine(function (require) {\n var Filter = require('filter');\n var Effect = require('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 */\n p5.Delay = function() {\n \tEffect.call(this);\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 /**\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(1200, this.ac.currentTime);\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\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 };\n\n p5.Delay.prototype = Object.create(Effect.prototype);\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 p5.Delay.prototype.process = function(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('Delay Time exceeds maximum delay time of ' + this._maxDelay + ' second.');\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 p5.Delay.prototype.delayTime = function(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 }\n\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 p5.Delay.prototype.feedback = function(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 }\n else if (f >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n }\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 p5.Delay.prototype.filter = function(freq, q) {\n this._leftFilter.set(freq, q);\n this._rightFilter.set(freq, q);\n };\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 p5.Delay.prototype.setType = function(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 p5.Delay.prototype.dispose = function() {\n\n Effect.prototype.dispose.apply(this);\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});\n","'use strict';\n\ndefine(function (require) {\n var CustomError = require('errorHandler');\n var Effect = require('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\n\n p5.Reverb = function() {\n Effect.call(this);\n\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\n p5.Reverb.prototype = Object.create(Effect.prototype);\n\n p5.Reverb.prototype._initConvolverNode = function() {\n this.convolverNode = this.ac.createConvolver();\n this.input.connect(this.convolverNode);\n this.convolverNode.connect(this.wet);\n };\n\n p5.Reverb.prototype._teardownConvolverNode = function() {\n if (this.convolverNode) {\n this.convolverNode.disconnect();\n delete this.convolverNode;\n }\n };\n\n p5.Reverb.prototype._setBuffer = function(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 p5.Reverb.prototype.process = function(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 p5.Reverb.prototype.set = function(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 p5.Reverb.prototype._buildImpulse = function() {\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 p5.Reverb.prototype.dispose = function() {\n Effect.prototype.dispose.apply(this);\n this._teardownConvolverNode();\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 */\n p5.Convolver = function(path, callback, errorCallback) {\n \t p5.Reverb.call(this);\n\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 }\n else {\n // parameters\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n };\n\n p5.Convolver.prototype = Object.create(p5.Reverb.prototype);\n\n p5.prototype.registerPreloadMethod('createConvolver', p5.prototype);\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 */\n p5.prototype.createConvolver = function(path, callback, errorCallback) {\n // if loading locally without a server\n if (window.location.origin.indexOf('file://') > -1 && window.cordova === 'undefined') {\n alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS');\n }\n var self = this;\n var cReverb = new p5.Convolver(path, function(buffer) {\n if (typeof callback === 'function') {\n callback(buffer);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n }, errorCallback);\n cReverb.impulses = [];\n return cReverb;\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 p5.Convolver.prototype._loadBuffer = function(path, callback, errorCallback) {\n var path = p5.prototype._checkFileFormats(path);\n var self = this;\n var errorTrace = new Error().stack;\n var ac = p5.prototype.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(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(msg +'\\n The error stack trace includes: \\n' + err.stack);\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 = 'Unable to load ' + self.url +\n '. The request status was: ' + request.status + ' (' + request.statusText + ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(msg +'\\n The error stack trace includes: \\n' + err.stack);\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 = 'There was no response from the server at ' + self.url + '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(msg +'\\n The error stack trace includes: \\n' + err.stack);\n }\n };\n request.send();\n };\n\n p5.Convolver.prototype.set = null;\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 p5.Convolver.prototype.process = function(src) {\n src.connect(this.input);\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 p5.Convolver.prototype.impulses = [];\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 p5.Convolver.prototype.addImpulse = function(path, callback, errorCallback) {\n // if loading locally without a server\n if (window.location.origin.indexOf('file://') > -1 && window.cordova === 'undefined') {\n alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS');\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 p5.Convolver.prototype.resetImpulse = function(path, callback, errorCallback) {\n // if loading locally without a server\n if (window.location.origin.indexOf('file://') > -1 && window.cordova === 'undefined') {\n alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS');\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 p5.Convolver.prototype.toggleImpulse = function(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 p5.Convolver.prototype.dispose = function() {\n p5.Reverb.prototype.dispose.apply(this);\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","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\n\n // requires the Tone.js library's Clock (MIT license, Yotam Mann)\n // https://github.com/TONEnoTONE/Tone.js/\n var Clock = require('Tone/core/Clock');\n\n p5.Metro = function() {\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 p5.Metro.prototype.ontick = function(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 (phraseArray[bNum] !== 0 && (self.metroTicks < phraseArray.length || !thisPhrase.looping) ) {\n thisPhrase.callback(secondsFromNow, phraseArray[bNum]);\n }\n });\n });\n this.metroTicks += 1;\n this.tickCallback(secondsFromNow);\n }\n };\n\n p5.Metro.prototype.setBPM = function(bpm, rampTime) {\n var beatTime = 60 / (bpm*this.tatums);\n var now = p5sound.audiocontext.currentTime;\n this.tatumTime = beatTime;\n\n var rampTime = rampTime || 0;\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 p5.Metro.prototype.getBPM = function() {\n return this.clock.getRate() / this.tatums * 60;\n };\n\n p5.Metro.prototype._init = function() {\n this.metroTicks = 0;\n // this.setBPM(120);\n };\n\n // clear existing synced parts, add only this one\n p5.Metro.prototype.resetSync = function(part) {\n this.syncedParts = [part];\n };\n\n // push a new synced part to the array\n p5.Metro.prototype.pushSync = function(part) {\n this.syncedParts.push(part);\n };\n\n p5.Metro.prototype.start = function(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 p5.Metro.prototype.stop = function(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.stop(now + t);\n };\n\n p5.Metro.prototype.beatLength = function(tatums) {\n this.tatums = 1/tatums / 4; // lowest possible division of a beat\n };\n\n});\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});","'use strict';\n\ndefine(function(require) {\n var p5sound = require('master');\n\n var 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 */\n p5.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 */\n p5.Phrase = function(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 *

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 */\n p5.Part = function(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 p5.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 p5.Part.prototype.setBPM = function(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 p5.Part.prototype.getBPM = function() {\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 p5.Part.prototype.start = function(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 p5.Part.prototype.loop = function(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 p5.Part.prototype.noLoop = function() {\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 p5.Part.prototype.stop = function(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 p5.Part.prototype.pause = function(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 p5.Part.prototype.addPhrase = function(name, callback, array) {\n var p;\n if (arguments.length === 3) {\n p = new p5.Phrase(name, callback, array);\n } else if (arguments[0] instanceof p5.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 p5.Part.prototype.removePhrase = function(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 p5.Part.prototype.getPhrase = function(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 p5.Part.prototype.replaceSequence = function(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 p5.Part.prototype.incrementStep = function(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 p5.Part.prototype.onStep = function(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 */\n p5.Score = function() {\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 p5.Score.prototype.onended = function() {\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 p5.Score.prototype.start = function() {\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 p5.Score.prototype.stop = function() {\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 p5.Score.prototype.pause = function() {\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 p5.Score.prototype.loop = function() {\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 p5.Score.prototype.noLoop = function() {\n this.looping = false;\n };\n\n p5.Score.prototype.resetParts = function() {\n var self = this;\n this.parts.forEach(function(part) {\n self.resetParts[part];\n });\n };\n\n p5.Score.prototype.resetPart = function(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 p5.Score.prototype.setBPM = function(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 function 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\n});\n","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\n var Clock = require('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 */\n p5.SoundLoop = function(callback, interval) {\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 '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 p5.SoundLoop.prototype.start = function(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 p5.SoundLoop.prototype.stop = function(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 * Pause the loop\n * @method pause\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a pausing time\n */\n p5.SoundLoop.prototype.pause = function(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 /**\n * Synchronize loops. Use this method to start two more 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 p5.SoundLoop.prototype.syncedStart = function(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\n /**\n * Updates frequency value, reflected in next callback\n * @private\n * @for p5.SoundLoop\n * @method _update\n */\n p5.SoundLoop.prototype._update = function() {\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 p5.SoundLoop.prototype._calcFreq = function() {\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 this._bpm / 60 / this._convertNotation(this._interval) * (this._timeSignature / 4);\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 p5.SoundLoop.prototype._convertNotation = function(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('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 * Helper conversion methods of measure and note\n * @private\n * @for p5.SoundLoop\n * @method _measure\n */\n p5.SoundLoop.prototype._measure = function(value) {\n return value * this._timeSignature;\n };\n\n /**\n * @private\n * @method _note\n * @for p5.SoundLoop\n */\n p5.SoundLoop.prototype._note = function(value) {\n return this._timeSignature / value ;\n };\n\n\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(p5.SoundLoop.prototype, 'bpm', {\n get : function() {\n return this._bpm;\n },\n set : function(bpm) {\n if (!this.musicalTimeMode) {\n console.warn('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 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(p5.SoundLoop.prototype, 'timeSignature', {\n get : function() {\n return this._timeSignature;\n },\n set : function(timeSig) {\n if (!this.musicalTimeMode) {\n console.warn('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 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(p5.SoundLoop.prototype, '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(p5.SoundLoop.prototype, 'iterations', {\n get : function() {\n return this.clock.ticks;\n }\n });\n\n return p5.SoundLoop;\n});\n","define(function (require) {\n\t'use strict';\n\n\tvar p5sound = require('master');\n\tvar Effect = require('effect');\n var CustomError = require('errorHandler');\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 */\n\tp5.Compressor = function() {\n\t\tEffect.call(this);\n\n /**\n * The p5.Compressor is built with a Web Audio Dynamics Compressor Node\n * \n * @property {AudioNode} compressor\n */\n\n\n\t\tthis.compressor = this.ac.createDynamicsCompressor();\n\n this.input.connect(this.compressor);\n this.compressor.connect(this.wet);\n\t};\n\n\tp5.Compressor.prototype = Object.create(Effect.prototype);\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\tp5.Compressor.prototype.process = function(src, attack, knee,\n ratio, threshold, release) {\n\t\tsrc.connect(this.input);\n\t\tthis.set(attack, knee, ratio, threshold, release);\n\t};\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 p5.Compressor.prototype.set = function (attack, knee,\n ratio, threshold, release) {\n\n if (typeof attack !== 'undefined') {this.attack(attack);}\n if (typeof knee !== 'undefined') {this.knee(knee);}\n if (typeof ratio !== 'undefined') {this.ratio(ratio);}\n if (typeof threshold !== 'undefined') {this.threshold(threshold);}\n if (typeof release !== 'undefined') {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 p5.Compressor.prototype.attack = function (attack, time){\n var t = time || 0;\n if (typeof attack == 'number'){\n this.compressor.attack.value = attack;\n this.compressor.attack.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.attack.linearRampToValueAtTime(attack, this.ac.currentTime + 0.02 + t);\n } else if (typeof attack !== 'undefined') {\n attack.connect(this.compressor.attack);\n }\n return this.compressor.attack.value;\n };\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 p5.Compressor.prototype.knee = function (knee, time){\n var t = time || 0;\n if (typeof knee == 'number'){\n this.compressor.knee.value = knee;\n this.compressor.knee.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.knee.linearRampToValueAtTime(knee, this.ac.currentTime + 0.02 + t);\n } else if (typeof knee !== 'undefined') {\n knee.connect(this.compressor.knee);\n }\n return this.compressor.knee.value;\n };\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 p5.Compressor.prototype.ratio = function (ratio, time){\n var t = time || 0;\n if (typeof ratio == 'number'){\n this.compressor.ratio.value = ratio;\n this.compressor.ratio.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.ratio.linearRampToValueAtTime(ratio, this.ac.currentTime + 0.02 + t);\n } else if (typeof ratio !== 'undefined') {\n ratio.connect(this.compressor.ratio);\n }\n return this.compressor.ratio.value;\n };\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 p5.Compressor.prototype.threshold = function (threshold, time){\n var t = time || 0;\n if (typeof threshold == 'number'){\n this.compressor.threshold.value = threshold;\n this.compressor.threshold.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.threshold.linearRampToValueAtTime(threshold, this.ac.currentTime + 0.02 + t);\n } else if (typeof threshold !== 'undefined') {\n threshold.connect(this.compressor.threshold);\n }\n return this.compressor.threshold.value;\n };\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 p5.Compressor.prototype.release = function (release, time){\n var t = time || 0;\n if (typeof release == 'number'){\n this.compressor.release.value = release;\n this.compressor.release.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.release.linearRampToValueAtTime(release, this.ac.currentTime + 0.02 + t);\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 p5.Compressor.prototype.reduction =function() {\n return this.compressor.reduction.value;\n };\n\n\n\tp5.Compressor.prototype.dispose = function() {\n Effect.prototype.dispose.apply(this);\n if (this.compressor) {\n this.compressor.disconnect();\n delete this.compressor;\n }\n\t};\n\n return p5.Compressor;\n});\n","'use strict';\n\ndefine(function (require) {\n\n // inspiration: recorder.js, Tone.js & typedarray.org\n\n const p5sound = require('master');\n const { convertToWav, safeBufferSize } = require('helpers');\n const processorNames = require('./audioWorklet/processorNames');\n const 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 */\n p5.SoundRecorder = function() {\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(ac, processorNames.recorderProcessor, {\n outputChannelCount: [this._outputChannels],\n processorOptions: {\n numInputChannels: this._inputChannels,\n bufferSize: workletBufferSize\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 p5.SoundRecorder.prototype.setInput = function(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 p5.SoundRecorder.prototype.record = function(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 }\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 p5.SoundRecorder.prototype.stop = function() {\n this._workletNode.port.postMessage({ name: 'stop' });\n };\n\n p5.SoundRecorder.prototype.dispose = function() {\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\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.\n p5.prototype.saveSound = function (soundFile, fileName) {\n const dataView = convertToWav(soundFile.buffer);\n p5.prototype.writeFile([dataView], fileName, 'wav');\n };\n});\n","'use strict';\n\ndefine(function () {\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 */\n p5.PeakDetect = function(freq1, freq2, threshold, _framesPerPeak) {\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 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 /**\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 p5.PeakDetect.prototype.update = function(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\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 p5.PeakDetect.prototype.onPeak = function(callback, val) {\n var self = this;\n\n self._onPeak = function() {\n callback(self.energy, val);\n };\n };\n\n});\n","'use strict';\n\ndefine(function (require) {\n var p5sound = require('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\n p5.Gain = function() {\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\n p5.Gain.prototype.setInput = function(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 p5.Gain.prototype.connect = function(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 p5.Gain.prototype.disconnect = function() {\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 p5.Gain.prototype.amp = function(vol, rampTime, tFromNow) {\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);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n };\n\n p5.Gain.prototype.dispose = function() {\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});\n","'use strict';\n\ndefine(function (require) {\n\n var Effect = require('effect');\n\n /*\n * Adapted from [Kevin Ennis on StackOverflow](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n */\n function 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 */\n p5.Distortion = function(amount, oversample) {\n Effect.call(this);\n\n if (typeof amount === 'undefined') {\n amount = 0.25;\n } if (typeof amount !== 'number') {\n throw new Error('amount must be a number');\n } if (typeof oversample === 'undefined') {\n oversample = '2x';\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 p5.Distortion.prototype = Object.create(Effect.prototype);\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 p5.Distortion.prototype.process = function(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 p5.Distortion.prototype.set = function(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 p5.Distortion.prototype.getAmount = function() {\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 p5.Distortion.prototype.getOversample = function() {\n return this.waveShaperNode.oversample;\n };\n\n\n p5.Distortion.prototype.dispose = function() {\n Effect.prototype.dispose.apply(this);\n if (this.waveShaperNode) {\n this.waveShaperNode.disconnect();\n this.waveShaperNode = null;\n }\n };\n});\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../node_modules/tone/Tone/core/Tone.js","webpack:///./master.js","webpack:///../node_modules/tone/Tone/signal/Signal.js","webpack:///../node_modules/tone/Tone/signal/Multiply.js","webpack:///./effect.js","webpack:///../node_modules/tone/Tone/signal/WaveShaper.js","webpack:///./helpers.js","webpack:///../node_modules/tone/Tone/signal/Add.js","webpack:///../node_modules/tone/Tone/type/Type.js","webpack:///../node_modules/tone/Tone/core/Gain.js","webpack:///./audioWorklet/processorNames.js","webpack:///./errorHandler.js","webpack:///../node_modules/tone/Tone/core/Context.js","webpack:///../node_modules/tone/Tone/signal/Scale.js","webpack:///../node_modules/tone/Tone/signal/TimelineSignal.js","webpack:///./filter.js","webpack:///../node_modules/tone/Tone/signal/Subtract.js","webpack:///./audiocontext.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:///./oscillator.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/tone/Tone/core/Clock.js","webpack:///./monosynth.js","webpack:///./audioVoice.js","webpack:///./polysynth.js","webpack:///./app.js","webpack:///../node_modules/audioworklet-polyfill/dist/audioworklet-polyfill.js","webpack:///./shims.js","webpack:///../node_modules/webpack/buildin/global.js","webpack:///../node_modules/startaudiocontext/StartAudioContext.js","webpack:///./audioWorklet/index.js","webpack:///./audioWorklet/recorderProcessor.js","webpack:///./audioWorklet/soundFileProcessor.js","webpack:///./audioWorklet/amplitudeProcessor.js","webpack:///./panner.js","webpack:///./soundfile.js","webpack:///./amplitude.js","webpack:///./fft.js","webpack:///./signal.js","webpack:///../node_modules/tone/Tone/type/Frequency.js","webpack:///../node_modules/tone/Tone/type/TransportTime.js","webpack:///./envelope.js","webpack:///./pulse.js","webpack:///./noise.js","webpack:///./audioin.js","webpack:///../node_modules/tone/Tone/component/CrossFade.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:///./eq.js","webpack:///./eqFilter.js","webpack:///./panner3d.js","webpack:///./listener3d.js","webpack:///./delay.js","webpack:///./reverb.js","webpack:///./metro.js","webpack:///../node_modules/tone/Tone/core/TimelineState.js","webpack:///./looper.js","webpack:///./soundLoop.js","webpack:///./compressor.js","webpack:///./soundRecorder.js","webpack:///./peakDetect.js","webpack:///./gain.js","webpack:///./distortion.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","audiocontext","Master","limiter","createDynamicsCompressor","threshold","ratio","knee","meter","fftMeter","soundArray","parts","extensions","p5sound","p5","getMasterVolume","masterVolume","vol","tFromNow","currentTime","currentVol","cancelScheduledValues","linearRampToValueAtTime","soundOut","_silentNode","_gain","_param","getConstant","units","Type","Default","convert","SignalBase","Multiply","createInsOuts","_mult","Gain","require","CrossFade","Effect","ac","_drywet","wet","a","b","amp","drywet","fade","u","index","undefined","WaveShaper","mapping","bufferLen","_shaper","createWaveShaper","_curve","curve","isFinite","Float32Array","setMap","len","normalized","oversample","oversampling","RangeError","processorNames","freqToMidi","f","mathlog2","m","round","midiToFreq","noteToFreq","note","wholeNotes","A","B","C","D","E","F","G","toUpperCase","octave","slice","soundFormats","toLowerCase","disposeSound","registerMethod","_checkFileFormats","paths","path","extTest","pop","isFileSupported","pathSplit","pathCore","extension","supported","p","_mathChain","o","math","thisChain","nextChain","type","mathOps","convertToWav","audioBuffer","leftChannel","rightChannel","getChannelData","numberOfChannels","interleaved","interleave","buffer","ArrayBuffer","view","DataView","writeUTFBytes","setUint32","setUint16","lng","volume","setInt16","result","inputIndex","offset","string","setUint8","charCodeAt","safeBufferSize","idealBufferSize","bufferSize","tempAudioWorkletNode","AudioWorkletNode","soundFileProcessor","ScriptProcessorNode","Add","_sum","Time","Frequency","TransportTime","Ticks","NormalRange","AudioRange","Decibels","Interval","BPM","Positive","Cents","Degrees","MIDI","BarsBeatsSixteenths","Samples","Hertz","Note","Milliseconds","Seconds","Notation","toSeconds","time","TimeBase","toFrequency","freq","valueOf","toTicks","Transport","ticks","GainNode","AudioContext","createGainNode","_gainNode","module","exports","recorderProcessor","amplitudeProcessor","CustomError","name","errorTrace","failedPath","err","Error","tempStack","splitStack","originalStack","stack","filter","ln","toneConnect","outNum","inNum","nativeConnect","e","nativeDisconnect","webkitAudioContext","prop","Emitter","_context","_defineProperty","_latencyHint","_lookAhead","_updateInterval","_computedUpdateInterval","_worker","_createWorker","_constants","mixin","bind","URL","webkitURL","blob","Blob","toFixed","blobUrl","createObjectURL","worker","Worker","addEventListener","_lastUpdate","diff","max","createBuffer","arr","constant","createBufferSource","channelCount","channelCountMode","loop","start","lA","blockTime","postMessage","hint","lookAhead","latencyHint","updateInterval","warn","Scale","outputMin","outputMax","_outputMin","_outputMax","_scale","_add","_setRange","min","TimelineSignal","_events","Timeline","_initial","_fromUnits","Linear","Exponential","Target","Curve","Set","getValueAtTime","_toUnits","convertedVal","setValueAtTime","startTime","add","endTime","exponentialRampToValueAtTime","beforeEvent","_searchBefore","_minOutput","setValue","sampleTime","setTargetAtTime","timeConstant","setValueCurveAtTime","duration","scaling","floats","segmentTime","after","cancel","setRampPoint","before","_searchAfter","linearRampToValueBetween","finish","exponentialRampToValueBetween","getAfter","previouVal","previous","getBefore","_exponentialApproach","_curveInterpolate","_linearInterpolate","_exponentialInterpolate","t0","v0","v1","t","exp","t1","progress","lowerIndex","floor","upperIndex","ceil","lowerVal","upperVal","Filter","biquad","createBiquadFilter","setType","_on","_untoggledType","create","process","src","res","frequency","Q","toggle","LowPass","HighPass","BandPass","Subtract","_neg","Negate","global","StartAudioContext","getAudioContext","userStartAudio","elements","callback","elt","Element","map","on","event","events","eventName","off","ev","eventList","args","object","functions","func","emitterFunc","node","outputNumber","inputNumber","overridden","_plusNow","_unaryExpressions","quantize","regexp","method","rh","nextSubdivision","lh","subdiv","_expr","expr","subdivision","addNow","_defaultExpr","_noOp","copy","toNotation","retNotation","_toNotationHelper","retTripletNotation","testNotations","_notationToUnits","notationTime","multiple","notation","primaryExprs","_primaryExpressions","notationExprs","n","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","sub","mult","div","_lfo","lfo","LFO","currentVal","exponentialRampToValue","linearRampToValue","Mult","Oscillator","started","phaseAmount","oscillator","createOscillator","_freqMods","panPosition","connection","panner","Panner","stop","abs","freqNode","self","getAmp","isNaN","phase","getFreq","getType","oscMods","pan","pval","getPan","osc2","delayAmt","dNode","createDelay","delayTime","sigChain","mathObj","chainSource","num","scale","inMin","inMax","outMin","outMax","mapOutMin","mapOutMax","SinOsc","TriOsc","SawOsc","SqrOsc","_timeline","_toRemove","_iterating","memory","Infinity","_search","remove","shift","cancelBefore","beginning","end","midPoint","nextEvent","_iterate","lowerBound","upperBound","forEach","forEachBefore","forEachAfter","forEachFrom","forEachAtTime","_multiply","GreaterThanZero","_thresh","Clock","_nextTick","_lastState","_state","TimelineState","_boundLoop","_loop","state","setStateAtTime","pause","loopInterval","lag","currentState","tickTime","getStateAtTime","AudioVoice","DEFAULT_SUSTAIN","MonoSynth","env","Envelope","setRange","setExp","setADSR","setInput","play","velocity","secondsFromNow","susTime","triggerAttack","triggerRelease","vel","ramp","attack","decay","sustain","release","defineProperties","aTime","dTime","sPercent","rTime","sustime","PolySynth","audioVoice","maxVoices","audiovoices","notes","_newest","_oldest","_voicesInUse","_allocateVoices","noteAttack","noteRelease","noteADSR","d","r","timeFromNow","voice","_note","_velocity","acTime","currentVoice","oldestNote","previousVal","_updateAfter","maxRange","nextTime","p5SOUND","parameters","fill","processor","realm","exec","inputBuffer","outputBuffer","$$processors","$$context","createScriptProcessor","outputChannelCount","Map","properties","c","l","defaultValue","MessageChannel","port2","Processor","port","port1","onaudioprocess","$$audioWorklet","AudioWorklet","addModule","fetch","then","ok","status","text","AudioWorkletProcessor","registerProcessor","parameterDescriptors","document","createElement","style","cssText","appendChild","contentWindow","createTextNode","body","$hook","documentElement","transpile","String","fixSetTarget","setTargetValueAtTime","createDelayNode","createJavaScriptNode","createPeriodicWave","createWaveTable","internal_createGain","internal_createDelay","maxDelayTime","internal_createBufferSource","when","noteGrainOn","noteOn","internal_start","noteOff","internal_stop","playbackRate","internal_createDynamicsCompressor","reduction","internal_createBiquadFilter","detune","internal_createOscillator","setPeriodicWave","setWaveTable","OfflineAudioContext","webkitOfflineAudioContext","navigator","getUserMedia","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","el","isSupported","canPlayType","isOGGSupported","isMP3Supported","isWAVSupported","isAACSupported","isAIFSupported","g","Function","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","querySelectorAll","jquery","toArray","tap","moduleSources","initializedAudioWorklets","loadAudioWorkletModules","all","moduleSrc","objectURL","audioWorklet","preload","_incrementPreload","onWorkletModulesLoad","_decrementPreload","createStereoPanner","stereoPanner","inputChannels","obj","numInputChannels","left","right","channelInterpretation","splitter","createChannelSplitter","createChannelMerger","v","rightVal","cos","leftVal","numChannels","SoundFile","onload","onerror","whileLoading","url","File","FileReader","FileList","file","_onended","_looping","_playing","_paused","_pauseTime","_cues","_cueIDCounter","_lastPos","_counterNode","_workletNode","bufferSourceNodes","bufferSourceNode","reversed","pauseTime","mode","startMillis","load","_whileLoading","_clearOnEnd","registerPreloadMethod","loadSound","location","origin","cordova","alert","errorCallback","request","XMLHttpRequest","evt","_updateProgress","open","responseType","decodeAudioData","response","buff","msg","error","statusText","message","send","reader","readAsArrayBuffer","lengthComputable","percentComplete","loaded","isLoaded","rate","_cueStart","cueStart","cueEnd","setVolume","isPlaying","_initSourceNode","_initCounterNode","_arrayIndex","loopStart","loopEnd","playMode","str","pTime","setLoop","bool","isLooping","isPaused","stopAll","_time","_rampTime","_tFromNow","getVolume","reverse","reverseBuffer","setPitch","newPlaybackRate","getPlaybackRate","jump","cueTime","cTime","dur","channels","frames","getPeaks","width","sampleSize","sampleStep","peaks","chan","currentPos","curVol","onended","getLevel","setPath","setBuffer","buf","size","newBuffer","channelNum","channel","_createCounterBuffer","audioBuf","arrayBuffer","cNode","workletBufferSize","processorOptions","onmessage","data","_onTimeUpdate","processPeaks","_initThreshold","_minThreshold","_minPeaks","bufLen","allPeaks","initialThreshold","minThreshold","minPeaks","offlineContext","startRendering","oncomplete","filteredBuffer","renderedBuffer","bufferData","getPeaksAtThreshold","intervalCounts","countIntervalsBetweenNearbyPeaks","groups","groupNeighborsByTempo","topTempos","sort","intA","intB","count","tempo","bpmVariance","tempoPeaks","getPeaksAtTopTempo","Peak","sampleIndex","amplitude","tempos","intervals","peaksObj","peak","peaksArray","startPeak","endPeak","startPos","endPos","foundInterval","some","intervalCount","tempoCounts","theoreticalTempo","mapTempo","foundTempo","tempoCount","peaksAtTopTempo","key","intervalBPM","peakTime","dif","Cue","id","addCue","cue","removeCue","cueLength","clearCues","playbackTime","callbackTime","_prevUpdateTime","save","fileName","saveSound","getBlob","dataView","thisBufferSourceNode","target","soundFile","_","Amplitude","smoothing","parameterData","normalize","volNorm","stereoVol","stereoVolNorm","toggleNormalize","smooth","FFT","bins","analyser","createAnalyser","fftSize","configurable","smoothingTimeConstant","freqDomain","Uint8Array","frequencyBinCount","timeDomain","bass","lowMid","mid","highMid","treble","waveform","normalArray","_isSafari","timeToFloat","getFloatTimeDomainData","timeToInt","getByteTimeDomainData","scaled","analyze","freqToFloat","getFloatFrequencyData","freqToInt","getByteFrequencyData","getEnergy","frequency1","frequency2","nyquist","swap","lowIndex","highIndex","numFrequencies","toReturn","freq1","freq2","x","getCentroid","cumulative_sum","centroid_normalization","mean_freq_index","spec_centroid_freq","linAverages","N","spectrum","spectrumLength","spectrumStep","linearAverages","groupIndex","specIndex","logAverages","octaveBands","octaveIndex","specIndexFrequency","hi","getOctaveBands","fCtr0","lastFrequencyBand","lo","ctr","newFrequencyBand","fft","_input","midi","midiToFrequency","pitch","noteNumber","noteToScaleIndex","transpose","harmonize","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","l1","t2","l2","t3","l3","aLevel","dLevel","rLevel","_rampHighPercentage","_rampLowPercentage","control","_init","isExponential","sourceToClear","wasTriggered","_setRampAD","_rampAttackTime","checkExpInput","_rampDecayTime","TCDenominator","_rampAttackTC","_rampDecayTC","setRampPercentages","p1","p2","isExp","lastAttack","valToSet","v2","destination1","destination2","AudioIn","Reverb","Noise","Delay","Env","Pulse","w","dcOffset","createDCOffset","dcGain","mW","sig","SignalAdd","mods","currentFreq","freqMod","bufferSource","assignType","_brownNoise","_pinkNoise","_whiteNoise","whiteBuffer","noiseData","random","pinkBuffer","b0","b1","b2","b3","b4","b5","b6","white","brownBuffer","lastOut","noise","inputSources","stream","mediaStream","currentSource","enabled","MediaStreamTrack","mediaDevices","successCallback","audioSource","constraints","audio","echoCancellation","deviceId","createMediaStreamSource","getTracks","track","getSources","onSuccess","onError","resolve","reject","enumerateDevices","devices","device","kind","setSource","active","initialFade","_equalPowerA","EqualPowerGain","_equalPowerB","_invert","Expr","applyBinary","Constructor","_eval","applyUnary","getNumber","literalNumber","_replacements","inputCount","_parseInputs","_nodes","tree","_parseTree","_disposeNodes","_Expressions","signal","glue",",","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","_eqPower","EQFilter","EQ","_eqsize","factor","bands","_newBand","Panner3D","createPanner","panningModel","distanceModel","xVal","yVal","zVal","positionX","positionY","positionZ","orient","orientX","orientY","orientZ","orientationX","orientationY","orientationZ","setFalloff","maxDistance","rolloffFactor","maxDist","rolloff","Listener3D","listener","xValF","yValF","zValF","xValU","yValU","zValU","orientForward","orientUp","forwardX","forwardY","forwardZ","upX","upY","upZ","_split","_merge","_leftGain","_rightGain","leftDelay","rightDelay","_leftFilter","_rightFilter","_maxDelay","maxValue","feedback","_delayTime","_feedback","_filter","_initConvolverNode","_seconds","_decay","_reverse","_buildImpulse","convolverNode","createConvolver","_teardownConvolverNode","_setBuffer","decayRate","rebuild","impulse","impulseL","impulseR","Convolver","impulses","_loadBuffer","cReverb","chunks","addImpulse","resetImpulse","toggleImpulse","Metro","clock","ontick","syncedParts","prevTick","tatumTime","tickCallback","elapsedTime","thisPart","incrementStep","phrases","thisPhrase","phraseArray","sequence","bNum","metroTicks","looping","setBPM","beatTime","tatums","getBPM","getRate","resetSync","part","pushSync","beatLength","initial","Phrase","phraseStep","Part","steps","bLength","partStep","noLoop","metro","addPhrase","array","removePhrase","getPhrase","replaceSequence","onStep","Score","currentPart","thisScore","nextPart","resetPart","playNextPart","scoreStep","resetParts","aScore","SoundLoop","musicalTimeMode","_interval","_bpm","maxIterations","iterations","_calcFreq","syncedStart","otherLoop","_update","_convertNotation","Number","_measure","timeSig","Compressor","compressor","number","SoundRecorder","_inputChannels","_outputChannels","buffers","leftBuffer","rightBuffer","_callback","record","sFile","writeFile","PeakDetect","_framesPerPeak","framesPerPeak","framesSinceLastPeak","cutoff","cutoffMult","energy","penergy","currentValue","isDetected","f1","f2","_onPeak","update","fftObject","nrg","onPeak","makeDistortionCurve","amount","k","numSamples","deg","Distortion","curveAmount","waveShaperNode","getAmount","getOversample"],"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,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;AC5EAA,qEAAO,WAEN,aAgBW,SAAPC,EAAgBC,EAAQC,GAMvBC,KAAKC,QAAQH,IAAsB,IAAXA,EAC3BE,KAAKE,MAAQF,KAAKG,QAAQC,aAC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ent":[" \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 = 31);\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","'use strict';\r\n\r\n\r\ndefine(['audiocontext'], function (audiocontext) {\r\n // Master contains the master sound output.\r\n var Master = function() {\r\n this.input = audiocontext.createGain();\r\n this.output = audiocontext.createGain();\r\n\r\n //put a hard limiter on the output\r\n this.limiter = audiocontext.createDynamicsCompressor();\r\n this.limiter.threshold.value = -3;\r\n this.limiter.ratio.value = 20;\r\n this.limiter.knee.value = 1;\r\n\r\n this.audiocontext = audiocontext;\r\n\r\n this.output.disconnect();\r\n\r\n // connect input to limiter\r\n this.input.connect(this.limiter);\r\n\r\n // connect limiter to output\r\n this.limiter.connect(this.output);\r\n\r\n // meter is just for global Amplitude / FFT analysis\r\n this.meter = audiocontext.createGain();\r\n this.fftMeter = audiocontext.createGain();\r\n this.output.connect(this.meter);\r\n this.output.connect(this.fftMeter);\r\n\r\n // connect output to destination\r\n this.output.connect(this.audiocontext.destination);\r\n\r\n // an array of all sounds in the sketch\r\n this.soundArray = [];\r\n // an array of all musical parts in the sketch\r\n this.parts = [];\r\n\r\n // file extensions to search for\r\n this.extensions = [];\r\n };\r\n\r\n // create a single instance of the p5Sound / master output for use within this sketch\r\n var p5sound = new Master();\r\n\r\n /**\r\n * Returns a number representing the master amplitude (volume) for sound\r\n * in this sketch.\r\n *\r\n * @method getMasterVolume\r\n * @return {Number} Master amplitude (volume) for sound in this sketch.\r\n * Should be between 0.0 (silence) and 1.0.\r\n */\r\n p5.prototype.getMasterVolume = function() {\r\n return p5sound.output.gain.value;\r\n };\r\n\r\n /**\r\n *

Scale the output of all sound in this sketch

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

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

\r\n *\r\n *

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

\r\n *\r\n * @method masterVolume\r\n * @param {Number|Object} volume Volume (amplitude) between 0.0\r\n * and 1.0 or modulating signal/oscillator\r\n * @param {Number} [rampTime] Fade for t seconds\r\n * @param {Number} [timeFromNow] Schedule this event to happen at\r\n * t seconds in the future\r\n */\r\n p5.prototype.masterVolume = function(vol, rampTime, tFromNow) {\r\n if (typeof vol === 'number') {\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n var currentVol = p5sound.output.gain.value;\r\n p5sound.output.gain.cancelScheduledValues(now + tFromNow);\r\n p5sound.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\r\n p5sound.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\r\n }\r\n else if (vol) {\r\n vol.connect(p5sound.output.gain);\r\n } else {\r\n // return the Gain Node\r\n return p5sound.output.gain;\r\n }\r\n };\r\n\r\n /**\r\n * `p5.soundOut` is the p5.sound master output. It sends output to\r\n * the destination of this window's web audio context. It contains\r\n * Web Audio API nodes including a dyanmicsCompressor (.limiter),\r\n * and Gain Nodes for .input and .output.\r\n *\r\n * @property {Object} soundOut\r\n */\r\n p5.prototype.soundOut = p5.soundOut = p5sound;\r\n\r\n // a silent connection to the DesinationNode\r\n // which will ensure that anything connected to it\r\n // will not be garbage collected\r\n p5.soundOut._silentNode = p5sound.audiocontext.createGain();\r\n p5.soundOut._silentNode.gain.value = 0;\r\n p5.soundOut._silentNode.connect(p5sound.audiocontext.destination);\r\n\r\n\r\n return p5sound;\r\n});\r\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});","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","'use strict';\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var CrossFade = require('Tone/component/CrossFade');\r\n\r\n /**\r\n * Effect is a base class for audio effects in p5.
\r\n * This module handles the nodes and methods that are\r\n * common and useful for current and future effects.\r\n *\r\n *\r\n * This class is extended by p5.Distortion,\r\n * p5.Compressor,\r\n * p5.Delay,\r\n * p5.Filter,\r\n * p5.Reverb.\r\n *\r\n * @class p5.Effect\r\n * @constructor\r\n *\r\n * @param {Object} [ac] Reference to the audio context of the p5 object\r\n * @param {AudioNode} [input] Gain Node effect wrapper\r\n * @param {AudioNode} [output] Gain Node effect wrapper\r\n * @param {Object} [_drywet] Tone.JS CrossFade node (defaults to value: 1)\r\n * @param {AudioNode} [wet] Effects that extend this class should connect\r\n * to the wet signal to this gain node, so that dry and wet\r\n * signals are mixed properly.\r\n */\r\n p5.Effect = function() {\r\n this.ac = p5sound.audiocontext;\r\n\r\n this.input = this.ac.createGain();\r\n this.output = this.ac.createGain();\r\n\r\n /**\r\n *\tThe p5.Effect class is built\r\n * \tusing Tone.js CrossFade\r\n * \t@private\r\n */\r\n\r\n this._drywet = new CrossFade(1);\r\n\r\n /**\r\n *\tIn classes that extend\r\n *\tp5.Effect, connect effect nodes\r\n *\tto the wet parameter\r\n */\r\n this.wet = this.ac.createGain();\r\n\r\n this.input.connect(this._drywet.a);\r\n this.wet.connect(this._drywet.b);\r\n this._drywet.connect(this.output);\r\n\r\n this.connect();\r\n\r\n //Add to the soundArray\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Set the output volume of the filter.\r\n *\r\n * @method amp\r\n * @for p5.Effect\r\n * @param {Number} [vol] amplitude between 0 and 1.0\r\n * @param {Number} [rampTime] create a fade that lasts until rampTime\r\n * @param {Number} [tFromNow] schedule this event to happen in tFromNow seconds\r\n */\r\n p5.Effect.prototype.amp = function(vol, rampTime, tFromNow){\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n var currentVol = this.output.gain.value;\r\n this.output.gain.cancelScheduledValues(now);\r\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow + .001);\r\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime + .001);\r\n };\r\n\r\n /**\r\n * Link effects together in a chain\r\n * Example usage: filter.chain(reverb, delay, panner);\r\n * May be used with an open-ended number of arguments\r\n *\r\n * @method chain\r\n * @for p5.Effect\r\n * @param {Object} [arguments] Chain together multiple sound objects\r\n */\r\n p5.Effect.prototype.chain = function(){\r\n if (arguments.length>0){\r\n this.connect(arguments[0]);\r\n for(var i=1;i\r\n * let midiNotes = [60, 64, 67, 72];\r\n * let noteIndex = 0;\r\n * let midiVal, freq;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(startSound);\r\n * osc = new p5.TriOsc();\r\n * env = new p5.Envelope();\r\n * }\r\n *\r\n * function draw() {\r\n * background(220);\r\n * text('tap to play', 10, 20);\r\n * if (midiVal) {\r\n * text('MIDI: ' + midiVal, 10, 40);\r\n * text('Freq: ' + freq, 10, 60);\r\n * }\r\n * }\r\n *\r\n * function startSound() {\r\n * // see also: userStartAudio();\r\n * osc.start();\r\n *\r\n * midiVal = midiNotes[noteIndex % midiNotes.length];\r\n * freq = midiToFreq(midiVal);\r\n * osc.freq(freq);\r\n * env.ramp(osc, 0, 1.0, 0);\r\n *\r\n * noteIndex++;\r\n * }\r\n * \r\n */\r\n var midiToFreq = p5.prototype.midiToFreq = function(m) {\r\n return 440 * Math.pow(2, (m-69)/12.0);\r\n };\r\n\r\n // This method converts ANSI notes specified as a string \"C4\", \"Eb3\" to a frequency\r\n var noteToFreq = function(note) {\r\n if (typeof note !== 'string') {\r\n return note;\r\n }\r\n var wholeNotes = {A:21, B:23, C:24, D:26, E:28, F:29, G:31};\r\n var value = wholeNotes[ note[0].toUpperCase() ];\r\n var octave = ~~note.slice(-1);\r\n value += 12 * (octave -1);\r\n\r\n switch(note[1]) {\r\n case '#':\r\n value += 1;\r\n break;\r\n case 'b':\r\n value -= 1;\r\n break;\r\n default:\r\n break;\r\n }\r\n return midiToFreq(value);\r\n };\r\n\r\n /**\r\n * List the SoundFile formats that you will include. LoadSound\r\n * will search your directory for these extensions, and will pick\r\n * a format that is compatable with the client's web browser.\r\n * Here is a free online file\r\n * converter.\r\n *\r\n * @method soundFormats\r\n * @param {String} [...formats] i.e. 'mp3', 'wav', 'ogg'\r\n * @example\r\n *
\r\n * function preload() {\r\n * // set the global sound formats\r\n * soundFormats('mp3', 'ogg');\r\n *\r\n * // load either beatbox.mp3, or .ogg, depending on browser\r\n * mySound = loadSound('assets/beatbox.mp3');\r\n * }\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * background(220);\r\n * text('sound loaded! tap to play', 10, 20, width - 20);\r\n * cnv.mousePressed(function() {\r\n * mySound.play();\r\n * });\r\n * }\r\n *
\r\n */\r\n p5.prototype.soundFormats = function() {\r\n // reset extensions array\r\n p5sound.extensions = [];\r\n // add extensions\r\n for (var i = 0; i < arguments.length; i++) {\r\n arguments[i] = arguments[i].toLowerCase();\r\n if (['mp3','wav','ogg', 'm4a', 'aac'].indexOf(arguments[i]) > -1) {\r\n p5sound.extensions.push(arguments[i]);\r\n } else {\r\n throw arguments[i] + ' is not a valid sound format!';\r\n }\r\n }\r\n };\r\n\r\n p5.prototype.disposeSound = function() {\r\n for (var i = 0; i < p5sound.soundArray.length; i++) {\r\n p5sound.soundArray[i].dispose();\r\n }\r\n };\r\n\r\n // register removeSound to dispose of p5sound SoundFiles, Convolvers,\r\n // Oscillators etc when sketch ends\r\n p5.prototype.registerMethod('remove', p5.prototype.disposeSound);\r\n\r\n p5.prototype._checkFileFormats = function(paths) {\r\n var path;\r\n // if path is a single string, check to see if extension is provided\r\n if (typeof paths === 'string') {\r\n path = paths;\r\n // see if extension is provided\r\n var extTest = path.split('.').pop();\r\n // if an extension is provided...\r\n if (['mp3','wav','ogg', 'm4a', 'aac'].indexOf(extTest) > -1) {\r\n if (p5.prototype.isFileSupported(extTest)) {\r\n path = path;\r\n }\r\n else {\r\n var pathSplit = path.split('.');\r\n var pathCore = pathSplit[pathSplit.length - 1];\r\n for (var i = 0; i 1) {\r\n rightChannel = audioBuffer.getChannelData(1);\r\n } else {\r\n rightChannel = leftChannel;\r\n }\r\n\r\n var interleaved = interleave(leftChannel, rightChannel);\r\n\r\n // create the buffer and view to create the .WAV file\r\n var buffer = new window.ArrayBuffer(44 + interleaved.length * 2);\r\n var view = new window.DataView(buffer);\r\n\r\n // write the WAV container,\r\n // check spec at: https://web.archive.org/web/20171215131933/http://tiny.systems/software/soundProgrammer/WavFormatDocs.pdf\r\n\r\n // RIFF chunk descriptor\r\n writeUTFBytes(view, 0, 'RIFF');\r\n view.setUint32(4, 36 + interleaved.length * 2, true);\r\n writeUTFBytes(view, 8, 'WAVE');\r\n // FMT sub-chunk\r\n writeUTFBytes(view, 12, 'fmt ');\r\n view.setUint32(16, 16, true);\r\n view.setUint16(20, 1, true);\r\n // stereo (2 channels)\r\n view.setUint16(22, 2, true);\r\n view.setUint32(24, p5sound.audiocontext.sampleRate, true);\r\n view.setUint32(28, p5sound.audiocontext.sampleRate * 4, true);\r\n view.setUint16(32, 4, true);\r\n view.setUint16(34, 16, true);\r\n // data sub-chunk\r\n writeUTFBytes(view, 36, 'data');\r\n view.setUint32(40, interleaved.length * 2, true);\r\n\r\n // write the PCM samples\r\n var lng = interleaved.length;\r\n var index = 44;\r\n var volume = 1;\r\n for (var i = 0; i < lng; i++) {\r\n view.setInt16(index, interleaved[i] * (0x7FFF * volume), true);\r\n index += 2;\r\n }\r\n\r\n return view;\r\n }\r\n\r\n // helper methods to save waves\r\n function interleave(leftChannel, rightChannel) {\r\n var length = leftChannel.length + rightChannel.length;\r\n var result = new Float32Array(length);\r\n\r\n var inputIndex = 0;\r\n\r\n for (var index = 0; index < length;) {\r\n result[index++] = leftChannel[inputIndex];\r\n result[index++] = rightChannel[inputIndex];\r\n inputIndex++;\r\n }\r\n return result;\r\n }\r\n\r\n function writeUTFBytes(view, offset, string) {\r\n var lng = string.length;\r\n for (var i = 0; i < lng; i++) {\r\n view.setUint8(offset + i, string.charCodeAt(i));\r\n }\r\n }\r\n\r\n function safeBufferSize(idealBufferSize) {\r\n let bufferSize = idealBufferSize;\r\n\r\n // if the AudioWorkletNode is actually a ScriptProcessorNode created via polyfill,\r\n // make sure that our chosen buffer size isn't smaller than the buffer size automatically\r\n // selected by the polyfill\r\n // reference: https://github.com/GoogleChromeLabs/audioworklet-polyfill/issues/13#issuecomment-425014930\r\n let tempAudioWorkletNode = new AudioWorkletNode(p5sound.audiocontext, processorNames.soundFileProcessor);\r\n if (tempAudioWorkletNode instanceof ScriptProcessorNode) {\r\n bufferSize = tempAudioWorkletNode.bufferSize;\r\n }\r\n tempAudioWorkletNode.disconnect();\r\n tempAudioWorkletNode = null;\r\n\r\n return bufferSize;\r\n }\r\n\r\n return {\r\n convertToWav: convertToWav,\r\n midiToFreq: midiToFreq,\r\n noteToFreq: noteToFreq,\r\n safeBufferSize: safeBufferSize\r\n };\r\n\r\n});\r\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});","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});","module.exports = {\r\n recorderProcessor: 'recorder-processor',\r\n soundFileProcessor: 'sound-file-processor',\r\n amplitudeProcessor: 'amplitude-processor'\r\n};\r\n","'use strict';\r\n\r\ndefine(function () {\r\n /*\r\n Helper function to generate an error\r\n with a custom stack trace that points to the sketch\r\n and removes other parts of the stack trace.\r\n\r\n @private\r\n @class customError\r\n @constructor\r\n @param {String} name custom error name\r\n @param {String} errorTrace custom error trace\r\n @param {String} failedPath path to the file that failed to load\r\n @property {String} name custom error name\r\n @property {String} message custom error message\r\n @property {String} stack trace the error back to a line in the user's sketch.\r\n Note: this edits out stack trace within p5.js and p5.sound.\r\n @property {String} originalStack unedited, original stack trace\r\n @property {String} failedPath path to the file that failed to load\r\n @return {Error} returns a custom Error object\r\n */\r\n var CustomError = function(name, errorTrace, failedPath) {\r\n var err = new Error();\r\n var tempStack, splitStack;\r\n\r\n err.name = name;\r\n err.originalStack = err.stack + errorTrace;\r\n tempStack = err.stack + errorTrace;\r\n err.failedPath = failedPath;\r\n\r\n // only print the part of the stack trace that refers to the user code:\r\n var splitStack = tempStack.split('\\n');\r\n splitStack = splitStack.filter(function(ln) {\r\n return !ln.match(/(p5.|native code|globalInit)/g);\r\n });\r\n err.stack = splitStack.join('\\n');\r\n\r\n return err; // TODO: is this really a constructor?\r\n };\r\n\r\n return CustomError;\r\n});\r\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/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/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});","'use strict';\r\n\r\ndefine(function (require) {\r\n var Effect = require('effect');\r\n\r\n /**\r\n *

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

\r\n * p5.LowPass:\r\n * Allows frequencies below the cutoff frequency to pass through,\r\n * and attenuates frequencies above the cutoff.
\r\n * p5.HighPass:\r\n * The opposite of a lowpass filter.
\r\n * p5.BandPass:\r\n * Allows a range of frequencies to pass through and attenuates\r\n * the frequencies below and above this frequency range.
\r\n *\r\n * The .res() method controls either width of the\r\n * bandpass, or resonance of the low/highpass cutoff frequency.\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.Filter\r\n * @extends p5.Effect\r\n * @constructor\r\n * @param {String} [type] 'lowpass' (default), 'highpass', 'bandpass'\r\n * @example\r\n *
\r\n * let fft, noise, filter;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100,100);\r\n * cnv.mousePressed(makeNoise);\r\n * fill(255, 0, 255);\r\n *\r\n * filter = new p5.BandPass();\r\n * noise = new p5.Noise();\r\n * noise.disconnect();\r\n * noise.connect(filter);\r\n *\r\n * fft = new p5.FFT();\r\n * }\r\n *\r\n * function draw() {\r\n * background(220);\r\n *\r\n * // set the BandPass frequency based on mouseX\r\n * let freq = map(mouseX, 0, width, 20, 10000);\r\n * freq = constrain(freq, 0, 22050);\r\n * filter.freq(freq);\r\n * // give the filter a narrow band (lower res = wider bandpass)\r\n * filter.res(50);\r\n *\r\n * // draw filtered spectrum\r\n * let spectrum = fft.analyze();\r\n * noStroke();\r\n * for (let i = 0; i < spectrum.length; i++) {\r\n * let x = map(i, 0, spectrum.length, 0, width);\r\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\r\n * rect(x, height, width/spectrum.length, h);\r\n * }\r\n * if (!noise.started) {\r\n * text('tap here and drag to change frequency', 10, 20, width - 20);\r\n * } else {\r\n * text('Frequency: ' + round(freq)+'Hz', 20, 20, width - 20);\r\n * }\r\n * }\r\n *\r\n * function makeNoise() {\r\n * // see also: `userStartAudio()`\r\n * noise.start();\r\n * noise.amp(0.5, 0.2);\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * noise.amp(0, 0.2);\r\n * }\r\n *\r\n *
\r\n */\r\n p5.Filter = function (type) {\r\n\r\n Effect.call(this);\r\n //add extend Effect by adding a Biquad Filter\r\n\r\n /**\r\n * The p5.Filter is built with a\r\n * \r\n * Web Audio BiquadFilter Node.\r\n *\r\n * @property {DelayNode} biquadFilter\r\n\t */\r\n\r\n this.biquad = this.ac.createBiquadFilter();\r\n\r\n this.input.connect(this.biquad);\r\n\r\n this.biquad.connect(this.wet);\r\n\r\n if (type) {\r\n this.setType(type);\r\n }\r\n\r\n //Properties useful for the toggle method.\r\n this._on = true;\r\n this._untoggledType = this.biquad.type;\r\n };\r\n p5.Filter.prototype = Object.create(Effect.prototype);\r\n\r\n\r\n /**\r\n * Filter an audio signal according to a set\r\n * of filter parameters.\r\n *\r\n * @method process\r\n * @param {Object} Signal An object that outputs audio\r\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\r\n * @param {Number} [res] Resonance/Width of the filter frequency\r\n * from 0.001 to 1000\r\n */\r\n p5.Filter.prototype.process = function(src, freq, res, time) {\r\n src.connect(this.input);\r\n this.set(freq, res, time);\r\n };\r\n\r\n\r\n /**\r\n * Set the frequency and the resonance of the filter.\r\n *\r\n * @method set\r\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\r\n * @param {Number} [res] Resonance (Q) from 0.001 to 1000\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n */\r\n p5.Filter.prototype.set = function(freq, res, time) {\r\n if (freq) {\r\n this.freq(freq, time);\r\n }\r\n if (res) {\r\n this.res(res, time);\r\n }\r\n };\r\n\r\n /**\r\n * Set the filter frequency, in Hz, from 10 to 22050 (the range of\r\n * human hearing, although in reality most people hear in a narrower\r\n * range).\r\n *\r\n * @method freq\r\n * @param {Number} freq Filter Frequency\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n * @return {Number} value Returns the current frequency value\r\n */\r\n p5.Filter.prototype.freq = function(freq, time) {\r\n var t = time || 0;\r\n if (freq <= 0) {\r\n freq = 1;\r\n }\r\n if (typeof freq === 'number') {\r\n this.biquad.frequency.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.biquad.frequency.exponentialRampToValueAtTime(freq, this.ac.currentTime + 0.02 + t);\r\n } else if (freq) {\r\n freq.connect(this.biquad.frequency);\r\n }\r\n return this.biquad.frequency.value;\r\n };\r\n\r\n /**\r\n * Controls either width of a bandpass frequency,\r\n * or the resonance of a low/highpass cutoff frequency.\r\n *\r\n * @method res\r\n * @param {Number} res Resonance/Width of filter freq\r\n * from 0.001 to 1000\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n * @return {Number} value Returns the current res value\r\n */\r\n p5.Filter.prototype.res = function(res, time) {\r\n var t = time || 0;\r\n if (typeof res === 'number') {\r\n this.biquad.Q.value = res;\r\n this.biquad.Q.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.biquad.Q.linearRampToValueAtTime(res, this.ac.currentTime + 0.02 + t);\r\n } else if (res) {\r\n res.connect(this.biquad.Q);\r\n }\r\n return this.biquad.Q.value;\r\n };\r\n\r\n /**\r\n * Controls the gain attribute of a Biquad Filter.\r\n * This is distinctly different from .amp() which is inherited from p5.Effect\r\n * .amp() controls the volume via the output gain node\r\n * p5.Filter.gain() controls the gain parameter of a Biquad Filter node.\r\n *\r\n * @method gain\r\n * @param {Number} gain\r\n * @return {Number} Returns the current or updated gain value\r\n */\r\n p5.Filter.prototype.gain = function(gain, time) {\r\n var t = time || 0;\r\n if (typeof gain === 'number') {\r\n this.biquad.gain.value = gain;\r\n this.biquad.gain.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.biquad.gain.linearRampToValueAtTime(gain, this.ac.currentTime + 0.02 + t);\r\n } else if (gain) {\r\n gain.connect(this.biquad.gain);\r\n }\r\n return this.biquad.gain.value;\r\n };\r\n\r\n\r\n /**\r\n * Toggle function. Switches between the specified type and allpass\r\n *\r\n * @method toggle\r\n * @return {boolean} [Toggle value]\r\n */\r\n p5.Filter.prototype.toggle = function() {\r\n this._on = !this._on;\r\n\r\n if (this._on === true) {\r\n this.biquad.type = this._untoggledType;\r\n } else if (this._on === false) {\r\n this.biquad.type = 'allpass';\r\n }\r\n\r\n return this._on;\r\n };\r\n\r\n /**\r\n * Set the type of a p5.Filter. Possible types include:\r\n * \"lowpass\" (default), \"highpass\", \"bandpass\",\r\n * \"lowshelf\", \"highshelf\", \"peaking\", \"notch\",\r\n * \"allpass\".\r\n *\r\n * @method setType\r\n * @param {String} t\r\n */\r\n p5.Filter.prototype.setType = function(t) {\r\n this.biquad.type = t;\r\n this._untoggledType = this.biquad.type;\r\n };\r\n\r\n p5.Filter.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n Effect.prototype.dispose.apply(this);\r\n if (this.biquad) {\r\n this.biquad.disconnect();\r\n delete this.biquad;\r\n }\r\n };\r\n\r\n /**\r\n * Constructor: new p5.LowPass() Filter.\r\n * This is the same as creating a p5.Filter and then calling\r\n * its method setType('lowpass').\r\n * See p5.Filter for methods.\r\n *\r\n * @class p5.LowPass\r\n * @constructor\r\n * @extends p5.Filter\r\n */\r\n p5.LowPass = function() {\r\n p5.Filter.call(this, 'lowpass');\r\n };\r\n p5.LowPass.prototype = Object.create(p5.Filter.prototype);\r\n\r\n /**\r\n * Constructor: new p5.HighPass() Filter.\r\n * This is the same as creating a p5.Filter and then calling\r\n * its method setType('highpass').\r\n * See p5.Filter for methods.\r\n *\r\n * @class p5.HighPass\r\n * @constructor\r\n * @extends p5.Filter\r\n */\r\n p5.HighPass = function() {\r\n p5.Filter.call(this, 'highpass');\r\n };\r\n p5.HighPass.prototype = Object.create(p5.Filter.prototype);\r\n\r\n /**\r\n * Constructor: new p5.BandPass() Filter.\r\n * This is the same as creating a p5.Filter and then calling\r\n * its method setType('bandpass').\r\n * See p5.Filter for methods.\r\n *\r\n * @class p5.BandPass\r\n * @constructor\r\n * @extends p5.Filter\r\n */\r\n p5.BandPass = function() {\r\n p5.Filter.call(this, 'bandpass');\r\n };\r\n p5.BandPass.prototype = Object.create(p5.Filter.prototype);\r\n\r\n return p5.Filter;\r\n});\r\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});","'use strict';\r\n\r\nglobal.TONE_SILENCE_VERSION_LOGGING = true;\r\n\r\ndefine(['startaudiocontext', 'Tone/core/Context', 'Tone/core/Tone'], function (StartAudioContext, Context, Tone) {\r\n // Create the Audio Context\r\n const audiocontext = new window.AudioContext();\r\n\r\n // Tone and p5.sound share the same audio context\r\n Tone.context.dispose();\r\n Tone.setContext(audiocontext);\r\n\r\n /**\r\n *

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

\r\n *\r\n *

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

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

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n * @param {Element|Array} [element(s)] This argument can be an Element,\r\n * Selector String, NodeList, p5.Element,\r\n * jQuery Element, or an Array of any of those.\r\n * @param {Function} [callback] Callback to invoke when the AudioContext\r\n * has started\r\n * @return {Promise} Returns a Promise that resolves when\r\n * the AudioContext state is 'running'\r\n * @method userStartAudio\r\n * @for p5\r\n * @example\r\n *
\r\n * function setup() {\r\n * // mimics the autoplay policy\r\n * getAudioContext().suspend();\r\n *\r\n * let mySynth = new p5.MonoSynth();\r\n *\r\n * // This won't play until the context has resumed\r\n * mySynth.play('A6');\r\n * }\r\n * function draw() {\r\n * background(220);\r\n * textAlign(CENTER, CENTER);\r\n * text(getAudioContext().state, width/2, height/2);\r\n * }\r\n * function mousePressed() {\r\n * userStartAudio();\r\n * }\r\n *
\r\n */\r\n p5.prototype.userStartAudio = function(elements, callback) {\r\n var elt = elements;\r\n if (elements instanceof p5.Element) {\r\n elt = elements.elt;\r\n } else if (elements instanceof Array && elements[0] instanceof p5.Element ) {\r\n elt = elements.map(function(e) { return e.elt});\r\n }\r\n return StartAudioContext(audiocontext, elt, callback);\r\n };\r\n\r\n return audiocontext;\r\n});\r\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});","'use strict';\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n\r\n var Add = require('Tone/signal/Add');\r\n var Mult = require('Tone/signal/Multiply');\r\n var Scale = require('Tone/signal/Scale');\r\n\r\n /**\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n * @class p5.Oscillator\r\n * @constructor\r\n * @param {Number} [freq] frequency defaults to 440Hz\r\n * @param {String} [type] type of oscillator. Options:\r\n * 'sine' (default), 'triangle',\r\n * 'sawtooth', 'square'\r\n * @example\r\n *
\r\n * let osc, playing, freq, amp;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playOscillator);\r\n * osc = new p5.Oscillator('sine');\r\n * }\r\n *\r\n * function draw() {\r\n * background(220)\r\n * freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\r\n * amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\r\n *\r\n * text('tap to play', 20, 20);\r\n * text('freq: ' + freq, 20, 40);\r\n * text('amp: ' + amp, 20, 60);\r\n *\r\n * if (playing) {\r\n * // smooth the transitions by 0.1 seconds\r\n * osc.freq(freq, 0.1);\r\n * osc.amp(amp, 0.1);\r\n * }\r\n * }\r\n *\r\n * function playOscillator() {\r\n * // starting an oscillator on a user gesture will enable audio\r\n * // in browsers that have a strict autoplay policy.\r\n * // See also: userStartAudio();\r\n * osc.start();\r\n * playing = true;\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * // ramp amplitude to 0 over 0.5 seconds\r\n * osc.amp(0, 0.5);\r\n * playing = false;\r\n * }\r\n *
\r\n */\r\n p5.Oscillator = function(freq, type) {\r\n if (typeof freq === 'string') {\r\n var f = type;\r\n type = freq;\r\n freq = f;\r\n } if (typeof type === 'number') {\r\n var f = type;\r\n type = freq;\r\n freq = f;\r\n }\r\n this.started = false;\r\n\r\n // components\r\n this.phaseAmount = undefined;\r\n this.oscillator = p5sound.audiocontext.createOscillator();\r\n this.f = freq || 440.0; // frequency\r\n this.oscillator.type = type || 'sine';\r\n this.oscillator.frequency.setValueAtTime(this.f, p5sound.audiocontext.currentTime);\r\n\r\n // connections\r\n this.output = p5sound.audiocontext.createGain();\r\n\r\n this._freqMods = []; // modulators connected to this oscillator's frequency\r\n\r\n // set default output gain to 0.5\r\n this.output.gain.value = 0.5;\r\n this.output.gain.setValueAtTime(0.5, p5sound.audiocontext.currentTime);\r\n\r\n this.oscillator.connect(this.output);\r\n // stereo panning\r\n this.panPosition = 0.0;\r\n this.connection = p5sound.input; // connect to p5sound by default\r\n this.panner = new p5.Panner(this.output, this.connection, 1);\r\n\r\n //array of math operation signal chaining\r\n this.mathOps = [this.output];\r\n\r\n // add to the soundArray so we can dispose of the osc later\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Start an oscillator.\r\n *\r\n * Starting an oscillator on a user gesture will enable audio in browsers\r\n * that have a strict autoplay policy, including Chrome and most mobile\r\n * devices. See also: `userStartAudio()`.\r\n *\r\n * @method start\r\n * @for p5.Oscillator\r\n * @param {Number} [time] startTime in seconds from now.\r\n * @param {Number} [frequency] frequency in Hz.\r\n */\r\n p5.Oscillator.prototype.start = function(time, f) {\r\n if (this.started) {\r\n var now = p5sound.audiocontext.currentTime;\r\n this.stop(now);\r\n }\r\n if (!this.started) {\r\n var freq = f || this.f;\r\n var type = this.oscillator.type;\r\n\r\n // set old osc free to be garbage collected (memory)\r\n if (this.oscillator) {\r\n this.oscillator.disconnect();\r\n delete this.oscillator;\r\n }\r\n\r\n // var detune = this.oscillator.frequency.value;\r\n this.oscillator = p5sound.audiocontext.createOscillator();\r\n this.oscillator.frequency.value = Math.abs(freq);\r\n this.oscillator.type = type;\r\n // this.oscillator.detune.value = detune;\r\n this.oscillator.connect(this.output);\r\n time = time || 0;\r\n this.oscillator.start(time + p5sound.audiocontext.currentTime);\r\n this.freqNode = this.oscillator.frequency;\r\n\r\n // if other oscillators are already connected to this osc's freq\r\n for (var i in this._freqMods) {\r\n if (typeof this._freqMods[i].connect !== 'undefined') {\r\n this._freqMods[i].connect(this.oscillator.frequency);\r\n }\r\n }\r\n\r\n this.started = true;\r\n }\r\n };\r\n\r\n /**\r\n * Stop an oscillator. Accepts an optional parameter\r\n * to determine how long (in seconds from now) until the\r\n * oscillator stops.\r\n *\r\n * @method stop\r\n * @for p5.Oscillator\r\n * @param {Number} secondsFromNow Time, in seconds from now.\r\n */\r\n p5.Oscillator.prototype.stop = function(time) {\r\n if (this.started) {\r\n var t = time || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n this.oscillator.stop(t + now);\r\n this.started = false;\r\n }\r\n };\r\n\r\n /**\r\n * Set the amplitude between 0 and 1.0. Or, pass in an object\r\n * such as an oscillator to modulate amplitude with an audio signal.\r\n *\r\n * @method amp\r\n * @for p5.Oscillator\r\n * @param {Number|Object} vol between 0 and 1.0\r\n * or a modulating signal/oscillator\r\n * @param {Number} [rampTime] create a fade that lasts rampTime\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n * @return {AudioParam} gain If no value is provided,\r\n * returns the Web Audio API\r\n * AudioParam that controls\r\n * this oscillator's\r\n * gain/amplitude/volume)\r\n */\r\n p5.Oscillator.prototype.amp = function(vol, rampTime, tFromNow) {\r\n var self = this;\r\n if (typeof vol === 'number') {\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\r\n }\r\n\r\n else if (vol) {\r\n vol.connect(self.output.gain);\r\n } else {\r\n // return the Gain Node\r\n return this.output.gain;\r\n }\r\n };\r\n\r\n // these are now the same thing\r\n p5.Oscillator.prototype.fade = p5.Oscillator.prototype.amp;\r\n\r\n p5.Oscillator.prototype.getAmp = function() {\r\n return this.output.gain.value;\r\n };\r\n\r\n /**\r\n * Set frequency of an oscillator to a value. Or, pass in an object\r\n * such as an oscillator to modulate the frequency with an audio signal.\r\n *\r\n * @method freq\r\n * @for p5.Oscillator\r\n * @param {Number|Object} Frequency Frequency in Hz\r\n * or modulating signal/oscillator\r\n * @param {Number} [rampTime] Ramp time (in seconds)\r\n * @param {Number} [timeFromNow] Schedule this event to happen\r\n * at x seconds from now\r\n * @return {AudioParam} Frequency If no value is provided,\r\n * returns the Web Audio API\r\n * AudioParam that controls\r\n * this oscillator's frequency\r\n * @example\r\n *
\r\n * let osc;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playOscillator);\r\n * osc = new p5.Oscillator(300);\r\n * background(220);\r\n * text('tap to play', 20, 20);\r\n * }\r\n *\r\n * function playOscillator() {\r\n * osc.start();\r\n * osc.amp(0.5);\r\n * // start at 700Hz\r\n * osc.freq(700);\r\n * // ramp to 60Hz over 0.7 seconds\r\n * osc.freq(60, 0.7);\r\n * osc.amp(0, 0.1, 0.7);\r\n * }\r\n *
\r\n */\r\n p5.Oscillator.prototype.freq = function(val, rampTime, tFromNow) {\r\n if (typeof val === 'number' && !isNaN(val)) {\r\n this.f = val;\r\n var now = p5sound.audiocontext.currentTime;\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var t = now + tFromNow + rampTime;\r\n // var currentFreq = this.oscillator.frequency.value;\r\n // this.oscillator.frequency.cancelScheduledValues(now);\r\n\r\n if (rampTime === 0) {\r\n this.oscillator.frequency.setValueAtTime(val, tFromNow + now);\r\n } else {\r\n if (val > 0 ) {\r\n this.oscillator.frequency.exponentialRampToValueAtTime(val, tFromNow + rampTime + now);\r\n } else {\r\n this.oscillator.frequency.linearRampToValueAtTime(val, tFromNow + rampTime + now);\r\n }\r\n }\r\n\r\n // reset phase if oscillator has a phase\r\n if (this.phaseAmount) {\r\n this.phase(this.phaseAmount);\r\n }\r\n\r\n } else if (val) {\r\n if (val.output) {\r\n val = val.output;\r\n }\r\n val.connect(this.oscillator.frequency);\r\n\r\n // keep track of what is modulating this param\r\n // so it can be re-connected if\r\n this._freqMods.push( val );\r\n } else {\r\n // return the Frequency Node\r\n return this.oscillator.frequency;\r\n }\r\n };\r\n\r\n p5.Oscillator.prototype.getFreq = function() {\r\n return this.oscillator.frequency.value;\r\n };\r\n\r\n /**\r\n * Set type to 'sine', 'triangle', 'sawtooth' or 'square'.\r\n *\r\n * @method setType\r\n * @for p5.Oscillator\r\n * @param {String} type 'sine', 'triangle', 'sawtooth' or 'square'.\r\n */\r\n p5.Oscillator.prototype.setType = function(type) {\r\n this.oscillator.type = type;\r\n };\r\n\r\n p5.Oscillator.prototype.getType = function() {\r\n return this.oscillator.type;\r\n };\r\n\r\n /**\r\n * Connect to a p5.sound / Web Audio object.\r\n *\r\n * @method connect\r\n * @for p5.Oscillator\r\n * @param {Object} unit A p5.sound or Web Audio object\r\n */\r\n p5.Oscillator.prototype.connect = function(unit) {\r\n if (!unit) {\r\n this.panner.connect(p5sound.input);\r\n }\r\n else if (unit.hasOwnProperty('input')) {\r\n this.panner.connect(unit.input);\r\n this.connection = unit.input;\r\n }\r\n else {\r\n this.panner.connect(unit);\r\n this.connection = unit;\r\n }\r\n };\r\n\r\n /**\r\n * Disconnect all outputs\r\n *\r\n * @method disconnect\r\n * @for p5.Oscillator\r\n */\r\n p5.Oscillator.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n if (this.panner) {\r\n this.panner.disconnect();\r\n if (this.output) {\r\n this.output.connect(this.panner);\r\n }\r\n }\r\n this.oscMods = [];\r\n };\r\n\r\n /**\r\n * Pan between Left (-1) and Right (1)\r\n *\r\n * @method pan\r\n * @for p5.Oscillator\r\n * @param {Number} panning Number between -1 and 1\r\n * @param {Number} timeFromNow schedule this event to happen\r\n * seconds from now\r\n */\r\n p5.Oscillator.prototype.pan = function(pval, tFromNow) {\r\n this.panPosition = pval;\r\n this.panner.pan(pval, tFromNow);\r\n };\r\n\r\n p5.Oscillator.prototype.getPan = function() {\r\n return this.panPosition;\r\n };\r\n\r\n // get rid of the oscillator\r\n p5.Oscillator.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n\r\n if (this.oscillator) {\r\n var now = p5sound.audiocontext.currentTime;\r\n this.stop(now);\r\n this.disconnect();\r\n this.panner = null;\r\n this.oscillator = null;\r\n }\r\n // if it is a Pulse\r\n if (this.osc2) {\r\n this.osc2.dispose();\r\n }\r\n };\r\n\r\n /**\r\n * Set the phase of an oscillator between 0.0 and 1.0.\r\n * In this implementation, phase is a delay time\r\n * based on the oscillator's current frequency.\r\n *\r\n * @method phase\r\n * @for p5.Oscillator\r\n * @param {Number} phase float between 0.0 and 1.0\r\n */\r\n p5.Oscillator.prototype.phase = function(p) {\r\n var delayAmt = p5.prototype.map(p, 0, 1.0, 0, 1/this.f);\r\n var now = p5sound.audiocontext.currentTime;\r\n\r\n this.phaseAmount = p;\r\n\r\n if (!this.dNode) {\r\n // create a delay node\r\n this.dNode = p5sound.audiocontext.createDelay();\r\n // put the delay node in between output and panner\r\n this.oscillator.disconnect();\r\n this.oscillator.connect(this.dNode);\r\n this.dNode.connect(this.output);\r\n }\r\n\r\n // set delay time to match phase:\r\n this.dNode.delayTime.setValueAtTime(delayAmt, now);\r\n };\r\n\r\n // ========================== //\r\n // SIGNAL MATH FOR MODULATION //\r\n // ========================== //\r\n\r\n // return sigChain(this, scale, thisChain, nextChain, Scale);\r\n var sigChain = function(o, mathObj, thisChain, nextChain, type) {\r\n var chainSource = o.oscillator;\r\n // if this type of math already exists in the chain, replace it\r\n for (var i in o.mathOps) {\r\n if (o.mathOps[i] instanceof type) {\r\n chainSource.disconnect();\r\n o.mathOps[i].dispose();\r\n thisChain = i;\r\n // assume nextChain is output gain node unless...\r\n if (thisChain < o.mathOps.length - 2) {\r\n nextChain = o.mathOps[i+1];\r\n }\r\n }\r\n }\r\n if (thisChain === o.mathOps.length - 1) {\r\n o.mathOps.push(nextChain);\r\n }\r\n // assume source is the oscillator unless i > 0\r\n if (i > 0) {\r\n chainSource = o.mathOps[i-1];\r\n }\r\n chainSource.disconnect();\r\n chainSource.connect(mathObj);\r\n mathObj.connect(nextChain);\r\n o.mathOps[thisChain] = mathObj;\r\n return o;\r\n };\r\n\r\n /**\r\n * Add a value to the p5.Oscillator's output amplitude,\r\n * and return the oscillator. Calling this method again\r\n * will override the initial add() with a new value.\r\n *\r\n * @method add\r\n * @for p5.Oscillator\r\n * @param {Number} number Constant number to add\r\n * @return {p5.Oscillator} Oscillator Returns this oscillator\r\n * with scaled output\r\n *\r\n */\r\n p5.Oscillator.prototype.add = function(num) {\r\n var add = new Add(num);\r\n var thisChain = this.mathOps.length-1;\r\n var nextChain = this.output;\r\n return sigChain(this, add, thisChain, nextChain, Add);\r\n };\r\n\r\n /**\r\n * Multiply the p5.Oscillator's output amplitude\r\n * by a fixed value (i.e. turn it up!). Calling this method\r\n * again will override the initial mult() with a new value.\r\n *\r\n * @method mult\r\n * @for p5.Oscillator\r\n * @param {Number} number Constant number to multiply\r\n * @return {p5.Oscillator} Oscillator Returns this oscillator\r\n * with multiplied output\r\n */\r\n p5.Oscillator.prototype.mult = function(num) {\r\n var mult = new Mult(num);\r\n var thisChain = this.mathOps.length-1;\r\n var nextChain = this.output;\r\n return sigChain(this, mult, thisChain, nextChain, Mult);\r\n };\r\n\r\n /**\r\n * Scale this oscillator's amplitude values to a given\r\n * range, and return the oscillator. Calling this method\r\n * again will override the initial scale() with new values.\r\n *\r\n * @method scale\r\n * @for p5.Oscillator\r\n * @param {Number} inMin input range minumum\r\n * @param {Number} inMax input range maximum\r\n * @param {Number} outMin input range minumum\r\n * @param {Number} outMax input range maximum\r\n * @return {p5.Oscillator} Oscillator Returns this oscillator\r\n * with scaled output\r\n */\r\n p5.Oscillator.prototype.scale = function(inMin, inMax, outMin, outMax) {\r\n var mapOutMin, mapOutMax;\r\n if (arguments.length === 4) {\r\n mapOutMin = p5.prototype.map(outMin, inMin, inMax, 0, 1) - 0.5;\r\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5;\r\n }\r\n else {\r\n mapOutMin = arguments[0];\r\n mapOutMax = arguments[1];\r\n }\r\n var scale = new Scale(mapOutMin, mapOutMax);\r\n var thisChain = this.mathOps.length-1;\r\n var nextChain = this.output;\r\n return sigChain(this, scale, thisChain, nextChain, Scale);\r\n\r\n // this.output.disconnect();\r\n // this.output.connect(scale)\r\n };\r\n\r\n // ============================== //\r\n // SinOsc, TriOsc, SqrOsc, SawOsc //\r\n // ============================== //\r\n\r\n /**\r\n * Constructor: new p5.SinOsc().\r\n * This creates a Sine Wave Oscillator and is\r\n * equivalent to new p5.Oscillator('sine')\r\n * or creating a p5.Oscillator and then calling\r\n * its method setType('sine').\r\n * See p5.Oscillator for methods.\r\n *\r\n * @class p5.SinOsc\r\n * @constructor\r\n * @extends p5.Oscillator\r\n * @param {Number} [freq] Set the frequency\r\n */\r\n p5.SinOsc = function(freq) {\r\n p5.Oscillator.call(this, freq, 'sine');\r\n };\r\n\r\n p5.SinOsc.prototype = Object.create(p5.Oscillator.prototype);\r\n\r\n /**\r\n * Constructor: new p5.TriOsc().\r\n * This creates a Triangle Wave Oscillator and is\r\n * equivalent to new p5.Oscillator('triangle')\r\n * or creating a p5.Oscillator and then calling\r\n * its method setType('triangle').\r\n * See p5.Oscillator for methods.\r\n *\r\n * @class p5.TriOsc\r\n * @constructor\r\n * @extends p5.Oscillator\r\n * @param {Number} [freq] Set the frequency\r\n */\r\n p5.TriOsc = function(freq) {\r\n p5.Oscillator.call(this, freq, 'triangle');\r\n };\r\n\r\n p5.TriOsc.prototype = Object.create(p5.Oscillator.prototype);\r\n\r\n /**\r\n * Constructor: new p5.SawOsc().\r\n * This creates a SawTooth Wave Oscillator and is\r\n * equivalent to new p5.Oscillator('sawtooth')\r\n * or creating a p5.Oscillator and then calling\r\n * its method setType('sawtooth').\r\n * See p5.Oscillator for methods.\r\n *\r\n * @class p5.SawOsc\r\n * @constructor\r\n * @extends p5.Oscillator\r\n * @param {Number} [freq] Set the frequency\r\n */\r\n p5.SawOsc = function(freq) {\r\n p5.Oscillator.call(this, freq, 'sawtooth');\r\n };\r\n\r\n p5.SawOsc.prototype = Object.create(p5.Oscillator.prototype);\r\n\r\n /**\r\n * Constructor: new p5.SqrOsc().\r\n * This creates a Square Wave Oscillator and is\r\n * equivalent to new p5.Oscillator('square')\r\n * or creating a p5.Oscillator and then calling\r\n * its method setType('square').\r\n * See p5.Oscillator for methods.\r\n *\r\n * @class p5.SqrOsc\r\n * @constructor\r\n * @extends p5.Oscillator\r\n * @param {Number} [freq] Set the frequency\r\n */\r\n p5.SqrOsc = function(freq) {\r\n p5.Oscillator.call(this, freq, 'square');\r\n };\r\n\r\n p5.SqrOsc.prototype = Object.create(p5.Oscillator.prototype);\r\n\r\n});\r\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});","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});","'use strict';\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var AudioVoice = require('audioVoice');\r\n var noteToFreq = require('helpers').noteToFreq;\r\n\r\n var DEFAULT_SUSTAIN = 0.15;\r\n\r\n /**\r\n * A MonoSynth is used as a single voice for sound synthesis.\r\n * This is a class to be used in conjunction with the PolySynth\r\n * class. Custom synthetisers should be built inheriting from\r\n * this class.\r\n *\r\n * @class p5.MonoSynth\r\n * @constructor\r\n * @example\r\n *
\r\n * let monoSynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSynth);\r\n * background(220);\r\n * textAlign(CENTER);\r\n * text('tap to play', width/2, height/2);\r\n *\r\n * monoSynth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function playSynth() {\r\n * userStartAudio();\r\n *\r\n * let note = random(['Fb4', 'G4']);\r\n * // note velocity (volume, from 0 to 1)\r\n * let velocity = random();\r\n * // time from now (in seconds)\r\n * let time = 0;\r\n * // note duration (in seconds)\r\n * let dur = 1/6;\r\n *\r\n * monoSynth.play(note, velocity, time, dur);\r\n * }\r\n *
\r\n **/\r\n\r\n p5.MonoSynth = function () {\r\n AudioVoice.call(this);\r\n\r\n this.oscillator = new p5.Oscillator();\r\n\r\n this.env = new p5.Envelope();\r\n this.env.setRange(1, 0);\r\n this.env.setExp(true);\r\n\r\n //set params\r\n this.setADSR(0.02, 0.25, 0.05, 0.35);\r\n\r\n // oscillator --> env --> this.output (gain) --> p5.soundOut\r\n this.oscillator.disconnect();\r\n this.oscillator.connect(this.output);\r\n\r\n this.env.disconnect();\r\n this.env.setInput(this.output.gain);\r\n\r\n // reset oscillator gain to 1.0\r\n this.oscillator.output.gain.value = 1.0;\r\n\r\n this.oscillator.start();\r\n this.connect();\r\n\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n p5.MonoSynth.prototype = Object.create(p5.AudioVoice.prototype);\r\n\r\n /**\r\n * Play tells the MonoSynth to start playing a note. This method schedules\r\n * the calling of .triggerAttack and .triggerRelease.\r\n *\r\n * @method play\r\n * @for p5.MonoSynth\r\n * @param {String | Number} note the note you want to play, specified as a\r\n * frequency in Hertz (Number) or as a midi\r\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\r\n * See \r\n * Tone. Defaults to 440 hz.\r\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\r\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\r\n * @param {Number} [sustainTime] time to sustain before releasing the envelope. Defaults to 0.15 seconds.\r\n * @example\r\n *
\r\n * let monoSynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSynth);\r\n * background(220);\r\n * textAlign(CENTER);\r\n * text('tap to play', width/2, height/2);\r\n *\r\n * monoSynth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function playSynth() {\r\n * userStartAudio();\r\n *\r\n * let note = random(['Fb4', 'G4']);\r\n * // note velocity (volume, from 0 to 1)\r\n * let velocity = random();\r\n * // time from now (in seconds)\r\n * let time = 0;\r\n * // note duration (in seconds)\r\n * let dur = 1/6;\r\n *\r\n * monoSynth.play(note, velocity, time, dur);\r\n * }\r\n *
\r\n *\r\n */\r\n p5.MonoSynth.prototype.play = function (note, velocity, secondsFromNow, susTime) {\r\n this.triggerAttack(note, velocity, ~~secondsFromNow);\r\n this.triggerRelease(~~secondsFromNow + (susTime || DEFAULT_SUSTAIN));\r\n };\r\n\r\n /**\r\n * Trigger the Attack, and Decay portion of the Envelope.\r\n * Similar to holding down a key on a piano, but it will\r\n * hold the sustain level until you let go.\r\n *\r\n * @param {String | Number} note the note you want to play, specified as a\r\n * frequency in Hertz (Number) or as a midi\r\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\r\n * See \r\n * Tone. Defaults to 440 hz\r\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\r\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\r\n * @method triggerAttack\r\n * @for p5.MonoSynth\r\n * @example\r\n *
\r\n * let monoSynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(triggerAttack);\r\n * background(220);\r\n * text('tap here for attack, let go to release', 5, 20, width - 20);\r\n * monoSynth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function triggerAttack() {\r\n * userStartAudio();\r\n *\r\n * monoSynth.triggerAttack(\"E3\");\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * monoSynth.triggerRelease();\r\n * }\r\n *
\r\n */\r\n p5.MonoSynth.prototype.triggerAttack = function (note, velocity, secondsFromNow) {\r\n var secondsFromNow = ~~secondsFromNow;\r\n var freq = noteToFreq(note);\r\n var vel = velocity || 0.1;\r\n this.oscillator.freq(freq, 0, secondsFromNow);\r\n this.env.ramp(this.output.gain, secondsFromNow, vel);\r\n };\r\n\r\n /**\r\n * Trigger the release of the Envelope. This is similar to releasing\r\n * the key on a piano and letting the sound fade according to the\r\n * release level and release time.\r\n *\r\n * @param {Number} secondsFromNow time to trigger the release\r\n * @method triggerRelease\r\n * @for p5.MonoSynth\r\n * @example\r\n *
\r\n * let monoSynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(triggerAttack);\r\n * background(220);\r\n * text('tap here for attack, let go to release', 5, 20, width - 20);\r\n * monoSynth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function triggerAttack() {\r\n * userStartAudio();\r\n *\r\n * monoSynth.triggerAttack(\"E3\");\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * monoSynth.triggerRelease();\r\n * }\r\n *
\r\n */\r\n p5.MonoSynth.prototype.triggerRelease = function (secondsFromNow) {\r\n var secondsFromNow = secondsFromNow || 0;\r\n this.env.ramp(this.output.gain, secondsFromNow, 0);\r\n };\r\n\r\n /**\r\n * Set values like a traditional\r\n * \r\n * ADSR envelope\r\n * .\r\n *\r\n * @method setADSR\r\n * @for p5.MonoSynth\r\n * @param {Number} attackTime Time (in seconds before envelope\r\n * reaches Attack Level\r\n * @param {Number} [decayTime] Time (in seconds) before envelope\r\n * reaches Decay/Sustain Level\r\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\r\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\r\n * The susRatio determines the decayLevel and the level at which the\r\n * sustain portion of the envelope will sustain.\r\n * For example, if attackLevel is 0.4, releaseLevel is 0,\r\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\r\n * increased to 1.0 (using setRange),\r\n * then decayLevel would increase proportionally, to become 0.5.\r\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\r\n */\r\n p5.MonoSynth.prototype.setADSR = function (attack,decay,sustain,release) {\r\n this.env.setADSR(attack, decay, sustain, release);\r\n };\r\n\r\n\r\n /**\r\n * Getters and Setters\r\n * @property {Number} attack\r\n * @for p5.MonoSynth\r\n */\r\n /**\r\n * @property {Number} decay\r\n * @for p5.MonoSynth\r\n */\r\n /**\r\n * @property {Number} sustain\r\n * @for p5.MonoSynth\r\n */\r\n /**\r\n * @property {Number} release\r\n * @for p5.MonoSynth\r\n */\r\n Object.defineProperties(p5.MonoSynth.prototype, {\r\n 'attack': {\r\n get : function() {\r\n return this.env.aTime;\r\n },\r\n set : function(attack) {\r\n this.env.setADSR(attack, this.env.dTime,\r\n this.env.sPercent, this.env.rTime);\r\n }\r\n },\r\n 'decay': {\r\n get : function() {\r\n return this.env.dTime;\r\n },\r\n set : function(decay) {\r\n this.env.setADSR(this.env.aTime, decay,\r\n this.env.sPercent, this.env.rTime);\r\n }\r\n },\r\n 'sustain': {\r\n get : function() {\r\n return this.env.sPercent;\r\n },\r\n set : function(sustain) {\r\n this.env.setADSR(this.env.aTime, this.env.dTime,\r\n sustain, this.env.rTime);\r\n }\r\n },\r\n 'release': {\r\n get : function() {\r\n return this.env.rTime;\r\n },\r\n set : function(release) {\r\n this.env.setADSR(this.env.aTime, this.env.dTime,\r\n this.env.sPercent, release);\r\n }\r\n },\r\n });\r\n\r\n\r\n /**\r\n * MonoSynth amp\r\n * @method amp\r\n * @for p5.MonoSynth\r\n * @param {Number} vol desired volume\r\n * @param {Number} [rampTime] Time to reach new volume\r\n * @return {Number} new volume value\r\n */\r\n p5.MonoSynth.prototype.amp = function(vol, rampTime) {\r\n var t = rampTime || 0;\r\n if (typeof vol !== 'undefined') {\r\n this.oscillator.amp(vol, t);\r\n }\r\n return this.oscillator.amp().value;\r\n };\r\n\r\n /**\r\n * Connect to a p5.sound / Web Audio object.\r\n *\r\n * @method connect\r\n * @for p5.MonoSynth\r\n * @param {Object} unit A p5.sound or Web Audio object\r\n */\r\n\r\n p5.MonoSynth.prototype.connect = function(unit) {\r\n var u = unit || p5sound.input;\r\n this.output.connect(u.input ? u.input : u);\r\n };\r\n\r\n /**\r\n * Disconnect all outputs\r\n *\r\n * @method disconnect\r\n * @for p5.MonoSynth\r\n */\r\n p5.MonoSynth.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n };\r\n\r\n\r\n /**\r\n * Get rid of the MonoSynth and free up its resources / memory.\r\n *\r\n * @method dispose\r\n * @for p5.MonoSynth\r\n */\r\n p5.MonoSynth.prototype.dispose = function() {\r\n AudioVoice.prototype.dispose.apply(this);\r\n\r\n if (this.env) {\r\n this.env.dispose();\r\n }\r\n if (this.oscillator) {\r\n this.oscillator.dispose();\r\n }\r\n };\r\n\r\n});\r\n","'use strict';\r\ndefine(function() {\r\n var p5sound = require('master');\r\n\r\n /**\r\n * Base class for monophonic synthesizers. Any extensions of this class\r\n * should follow the API and implement the methods below in order to\r\n * remain compatible with p5.PolySynth();\r\n *\r\n * @class p5.AudioVoice\r\n * @constructor\r\n */\r\n p5.AudioVoice = function () {\r\n\t this.ac = p5sound.audiocontext;\r\n\t this.output = this.ac.createGain();\r\n\t this.connect();\r\n\t p5sound.soundArray.push(this);\r\n };\r\n\r\n p5.AudioVoice.prototype.play = function (note, velocity, secondsFromNow, sustime) {\r\n };\r\n\r\n p5.AudioVoice.prototype.triggerAttack = function (note, velocity, secondsFromNow) {\r\n };\r\n\r\n p5.AudioVoice.prototype.triggerRelease = function (secondsFromNow) {\r\n };\r\n\r\n p5.AudioVoice.prototype.amp = function(vol, rampTime) {\r\n };\r\n\r\n /**\r\n * Connect to p5 objects or Web Audio Nodes\r\n * @method connect\r\n * @for p5.AudioVoice\r\n * @param {Object} unit\r\n */\r\n p5.AudioVoice.prototype.connect = function(unit) {\r\n var u = unit || p5sound.input;\r\n this.output.connect(u.input ? u.input : u);\r\n };\r\n\r\n /**\r\n * Disconnect from soundOut\r\n * @method disconnect\r\n * @for p5.AudioVoice\r\n */\r\n p5.AudioVoice.prototype.disconnect = function() {\r\n this.output.disconnect();\r\n };\r\n\r\n p5.AudioVoice.prototype.dispose = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n delete this.output;\r\n }\r\n };\r\n\r\n return p5.AudioVoice;\r\n});\r\n","'use strict';\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var TimelineSignal = require('Tone/signal/TimelineSignal');\r\n var noteToFreq = require('helpers').noteToFreq;\r\n\r\n /**\r\n * An AudioVoice is used as a single voice for sound synthesis.\r\n * The PolySynth class holds an array of AudioVoice, and deals\r\n * with voices allocations, with setting notes to be played, and\r\n * parameters to be set.\r\n *\r\n * @class p5.PolySynth\r\n * @constructor\r\n *\r\n * @param {Number} [synthVoice] A monophonic synth voice inheriting\r\n * the AudioVoice class. Defaults to p5.MonoSynth\r\n * @param {Number} [maxVoices] Number of voices, defaults to 8;\r\n * @example\r\n *
\r\n * let polySynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSynth);\r\n * background(220);\r\n * text('click to play', 20, 20);\r\n *\r\n * polySynth = new p5.PolySynth();\r\n * }\r\n *\r\n * function playSynth() {\r\n * userStartAudio();\r\n *\r\n * // note duration (in seconds)\r\n * let dur = 1.5;\r\n *\r\n * // time from now (in seconds)\r\n * let time = 0;\r\n *\r\n * // velocity (volume, from 0 to 1)\r\n * let vel = 0.1;\r\n *\r\n * // notes can overlap with each other\r\n * polySynth.play('G2', vel, 0, dur);\r\n * polySynth.play('C3', vel, time += 1/3, dur);\r\n * polySynth.play('G3', vel, time += 1/3, dur);\r\n * }\r\n *
\r\n **/\r\n p5.PolySynth = function(audioVoice, maxVoices) {\r\n //audiovoices will contain maxVoices many monophonic synths\r\n this.audiovoices = [];\r\n\r\n /**\r\n * An object that holds information about which notes have been played and\r\n * which notes are currently being played. New notes are added as keys\r\n * on the fly. While a note has been attacked, but not released, the value of the\r\n * key is the audiovoice which is generating that note. When notes are released,\r\n * the value of the key becomes undefined.\r\n * @property notes\r\n */\r\n this.notes = {};\r\n\r\n //indices of the most recently used, and least recently used audiovoice\r\n this._newest = 0;\r\n this._oldest = 0;\r\n\r\n /**\r\n * A PolySynth must have at least 1 voice, defaults to 8\r\n * @property polyvalue\r\n */\r\n this.maxVoices = maxVoices || 8;\r\n\r\n /**\r\n * Monosynth that generates the sound for each note that is triggered. The\r\n * p5.PolySynth defaults to using the p5.MonoSynth as its voice.\r\n * @property AudioVoice\r\n */\r\n this.AudioVoice = audioVoice === undefined ? p5.MonoSynth : audioVoice;\r\n\r\n /**\r\n * This value must only change as a note is attacked or released. Due to delay\r\n * and sustain times, Tone.TimelineSignal is required to schedule the change in value.\r\n\t * @private\r\n * @property {Tone.TimelineSignal} _voicesInUse\r\n */\r\n this._voicesInUse = new TimelineSignal(0);\r\n\r\n this.output = p5sound.audiocontext.createGain();\r\n this.connect();\r\n\r\n //Construct the appropriate number of audiovoices\r\n this._allocateVoices();\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Construct the appropriate number of audiovoices\r\n * @private\r\n * @for p5.PolySynth\r\n * @method _allocateVoices\r\n */\r\n p5.PolySynth.prototype._allocateVoices = function() {\r\n for(var i = 0; i< this.maxVoices; i++) {\r\n this.audiovoices.push(new this.AudioVoice());\r\n this.audiovoices[i].disconnect();\r\n this.audiovoices[i].connect(this.output);\r\n }\r\n };\r\n\r\n /**\r\n * Play a note by triggering noteAttack and noteRelease with sustain time\r\n *\r\n * @method play\r\n * @for p5.PolySynth\r\n * @param {Number} [note] midi note to play (ranging from 0 to 127 - 60 being a middle C)\r\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\r\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\r\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\r\n * @example\r\n *
\r\n * let polySynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSynth);\r\n * background(220);\r\n * text('click to play', 20, 20);\r\n *\r\n * polySynth = new p5.PolySynth();\r\n * }\r\n *\r\n * function playSynth() {\r\n * userStartAudio();\r\n *\r\n * // note duration (in seconds)\r\n * let dur = 1.5;\r\n *\r\n * // time from now (in seconds)\r\n * let time = 0;\r\n *\r\n * // velocity (volume, from 0 to 1)\r\n * let vel = 0.1;\r\n *\r\n * // notes can overlap with each other\r\n * polySynth.play('G2', vel, 0, dur);\r\n * polySynth.play('C3', vel, time += 1/3, dur);\r\n * polySynth.play('G3', vel, time += 1/3, dur);\r\n * }\r\n *
\r\n */\r\n p5.PolySynth.prototype.play = function (note,velocity, secondsFromNow, susTime) {\r\n var susTime = susTime || 1;\r\n this.noteAttack(note, velocity, secondsFromNow);\r\n this.noteRelease(note, secondsFromNow + susTime);\r\n };\r\n\r\n\r\n /**\r\n * noteADSR sets the envelope for a specific note that has just been triggered.\r\n * Using this method modifies the envelope of whichever audiovoice is being used\r\n * to play the desired note. The envelope should be reset before noteRelease is called\r\n * in order to prevent the modified envelope from being used on other notes.\r\n *\r\n * @method noteADSR\r\n * @for p5.PolySynth\r\n * @param {Number} [note] Midi note on which ADSR should be set.\r\n * @param {Number} [attackTime] Time (in seconds before envelope\r\n * reaches Attack Level\r\n * @param {Number} [decayTime] Time (in seconds) before envelope\r\n * reaches Decay/Sustain Level\r\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\r\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\r\n * The susRatio determines the decayLevel and the level at which the\r\n * sustain portion of the envelope will sustain.\r\n * For example, if attackLevel is 0.4, releaseLevel is 0,\r\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\r\n * increased to 1.0 (using setRange),\r\n * then decayLevel would increase proportionally, to become 0.5.\r\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\r\n **/\r\n\r\n p5.PolySynth.prototype.noteADSR = function (note,a,d,s,r,timeFromNow) {\r\n var now = p5sound.audiocontext.currentTime;\r\n var timeFromNow = timeFromNow || 0;\r\n var t = now + timeFromNow\r\n this.audiovoices[ this.notes[note].getValueAtTime(t) ].setADSR(a,d,s,r);\r\n };\r\n\r\n\r\n /**\r\n * Set the PolySynths global envelope. This method modifies the envelopes of each\r\n * monosynth so that all notes are played with this envelope.\r\n *\r\n * @method setADSR\r\n * @for p5.PolySynth\r\n * @param {Number} [attackTime] Time (in seconds before envelope\r\n * reaches Attack Level\r\n * @param {Number} [decayTime] Time (in seconds) before envelope\r\n * reaches Decay/Sustain Level\r\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\r\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\r\n * The susRatio determines the decayLevel and the level at which the\r\n * sustain portion of the envelope will sustain.\r\n * For example, if attackLevel is 0.4, releaseLevel is 0,\r\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\r\n * increased to 1.0 (using setRange),\r\n * then decayLevel would increase proportionally, to become 0.5.\r\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\r\n **/\r\n p5.PolySynth.prototype.setADSR = function(a,d,s,r) {\r\n this.audiovoices.forEach(function(voice) {\r\n voice.setADSR(a,d,s,r);\r\n });\r\n };\r\n\r\n /**\r\n * Trigger the Attack, and Decay portion of a MonoSynth.\r\n * Similar to holding down a key on a piano, but it will\r\n * hold the sustain level until you let go.\r\n *\r\n * @method noteAttack\r\n * @for p5.PolySynth\r\n * @param {Number} [note] midi note on which attack should be triggered.\r\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)/\r\n * @param {Number} [secondsFromNow] time from now (in seconds)\r\n * @example\r\n *
\r\n * let polySynth = new p5.PolySynth();\r\n * let pitches = ['G', 'D', 'G', 'C'];\r\n * let octaves = [2, 3, 4];\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playChord);\r\n * background(220);\r\n * text('tap to play', 20, 20);\r\n * }\r\n *\r\n * function playChord() {\r\n * userStartAudio();\r\n *\r\n * // play a chord: multiple notes at the same time\r\n * for (let i = 0; i < 4; i++) {\r\n * let note = random(pitches) + random(octaves);\r\n * polySynth.noteAttack(note, 0.1);\r\n * }\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * // release all voices\r\n * polySynth.noteRelease();\r\n * }\r\n *
\r\n */\r\n p5.PolySynth.prototype.noteAttack = function (_note, _velocity, secondsFromNow) {\r\n //this value goes to the audiovoices which handle their own scheduling\r\n var secondsFromNow = ~~secondsFromNow;\r\n\r\n //this value is used by this._voicesInUse\r\n var acTime = p5sound.audiocontext.currentTime + secondsFromNow;\r\n\r\n //Convert note to frequency if necessary. This is because entries into this.notes\r\n //should be based on frequency for the sake of consistency.\r\n var note = noteToFreq(_note);\r\n var velocity = _velocity || 0.1;\r\n\r\n var currentVoice;\r\n\r\n //Release the note if it is already playing\r\n if (this.notes[note] && this.notes[note].getValueAtTime(acTime) !== null) {\r\n this.noteRelease(note, 0);\r\n }\r\n\r\n //Check to see how many voices are in use at the time the note will start\r\n if (this._voicesInUse.getValueAtTime(acTime) < this.maxVoices) {\r\n currentVoice = Math.max(~~this._voicesInUse.getValueAtTime(acTime), 0);\r\n }\r\n //If we are exceeding the polyvalue, bump off the oldest notes and replace\r\n //with a new note\r\n else {\r\n currentVoice = this._oldest;\r\n\r\n var oldestNote = p5.prototype.freqToMidi(this.audiovoices[this._oldest].oscillator.freq().value);\r\n this.noteRelease(oldestNote);\r\n this._oldest = ( this._oldest + 1 ) % (this.maxVoices - 1);\r\n }\r\n\r\n //Overrite the entry in the notes object. A note (frequency value)\r\n //corresponds to the index of the audiovoice that is playing it\r\n this.notes[note] = new TimelineSignal();\r\n this.notes[note].setValueAtTime(currentVoice, acTime);\r\n\r\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\r\n //Add 1 and schedule this value at time 't', when this note will start playing\r\n var previousVal = this._voicesInUse._searchBefore(acTime) === null ? 0 : this._voicesInUse._searchBefore(acTime).value;\r\n this._voicesInUse.setValueAtTime(previousVal + 1, acTime);\r\n\r\n //Then update all scheduled values that follow to increase by 1\r\n this._updateAfter(acTime, 1);\r\n\r\n this._newest = currentVoice;\r\n //The audiovoice handles the actual scheduling of the note\r\n if (typeof velocity === 'number') {\r\n var maxRange = 1 / this._voicesInUse.getValueAtTime(acTime) * 2;\r\n velocity = velocity > maxRange ? maxRange : velocity;\r\n }\r\n this.audiovoices[currentVoice].triggerAttack(note, velocity, secondsFromNow);\r\n };\r\n\r\n /**\r\n * Private method to ensure accurate values of this._voicesInUse\r\n * Any time a new value is scheduled, it is necessary to increment all subsequent\r\n * scheduledValues after attack, and decrement all subsequent\r\n * scheduledValues after release\r\n *\r\n * @private\r\n * @for p5.PolySynth\r\n * @param {[type]} time [description]\r\n * @param {[type]} value [description]\r\n * @return {[type]} [description]\r\n */\r\n p5.PolySynth.prototype._updateAfter = function(time, value) {\r\n if(this._voicesInUse._searchAfter(time) === null) {\r\n return;\r\n } else{\r\n this._voicesInUse._searchAfter(time).value += value;\r\n var nextTime = this._voicesInUse._searchAfter(time).time;\r\n this._updateAfter(nextTime, value);\r\n }\r\n };\r\n\r\n\r\n /**\r\n * Trigger the Release of an AudioVoice note. This is similar to releasing\r\n * the key on a piano and letting the sound fade according to the\r\n * release level and release time.\r\n *\r\n * @method noteRelease\r\n * @for p5.PolySynth\r\n * @param {Number} [note] midi note on which attack should be triggered.\r\n * If no value is provided, all notes will be released.\r\n * @param {Number} [secondsFromNow] time to trigger the release\r\n * @example\r\n *
\r\n * let polySynth = new p5.PolySynth();\r\n * let pitches = ['G', 'D', 'G', 'C'];\r\n * let octaves = [2, 3, 4];\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playChord);\r\n * background(220);\r\n * text('tap to play', 20, 20);\r\n * }\r\n *\r\n * function playChord() {\r\n * userStartAudio();\r\n *\r\n * // play a chord: multiple notes at the same time\r\n * for (let i = 0; i < 4; i++) {\r\n * let note = random(pitches) + random(octaves);\r\n * polySynth.noteAttack(note, 0.1);\r\n * }\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * // release all voices\r\n * polySynth.noteRelease();\r\n * }\r\n *
\r\n *\r\n */\r\n p5.PolySynth.prototype.noteRelease = function (_note,secondsFromNow) {\r\n var now = p5sound.audiocontext.currentTime;\r\n var tFromNow = secondsFromNow || 0;\r\n var t = now + tFromNow;\r\n\r\n // if a note value is not provided, release all voices\r\n if (!_note) {\r\n this.audiovoices.forEach(function(voice) {\r\n voice.triggerRelease(tFromNow)\r\n });\r\n this._voicesInUse.setValueAtTime(0, t);\r\n for (var n in this.notes) {\r\n this.notes[n].dispose();\r\n delete this.notes[n];\r\n }\r\n return;\r\n }\r\n\r\n //Make sure note is in frequency inorder to query the this.notes object\r\n var note = noteToFreq(_note);\r\n\r\n if (!this.notes[note] || this.notes[note].getValueAtTime(t) === null) {\r\n console.warn('Cannot release a note that is not already playing');\r\n } else {\r\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\r\n //subtract 1 and schedule this value at time 't', when this note will stop playing\r\n var previousVal = Math.max(~~this._voicesInUse.getValueAtTime(t).value, 1);\r\n this._voicesInUse.setValueAtTime(previousVal - 1, t);\r\n //Then update all scheduled values that follow to decrease by 1 but never go below 0\r\n if (previousVal > 0) {\r\n this._updateAfter(t, -1);\r\n }\r\n\r\n this.audiovoices[ this.notes[note].getValueAtTime(t) ].triggerRelease(tFromNow);\r\n this.notes[note].dispose();\r\n delete this.notes[note];\r\n\r\n this._newest = this._newest === 0 ? 0 : (this._newest - 1) % (this.maxVoices - 1);\r\n }\r\n\r\n };\r\n\r\n /**\r\n * Connect to a p5.sound / Web Audio object.\r\n *\r\n * @method connect\r\n * @for p5.PolySynth\r\n * @param {Object} unit A p5.sound or Web Audio object\r\n */\r\n p5.PolySynth.prototype.connect = function (unit) {\r\n var u = unit || p5sound.input;\r\n this.output.connect(u.input ? u.input : u);\r\n };\r\n\r\n /**\r\n * Disconnect all outputs\r\n *\r\n * @method disconnect\r\n * @for p5.PolySynth\r\n */\r\n p5.PolySynth.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n };\r\n\r\n /**\r\n * Get rid of the MonoSynth and free up its resources / memory.\r\n *\r\n * @method dispose\r\n * @for p5.PolySynth\r\n */\r\n p5.PolySynth.prototype.dispose = function() {\r\n this.audiovoices.forEach(function(voice) {\r\n voice.dispose();\r\n });\r\n\r\n if (this.output) {\r\n this.output.disconnect();\r\n delete this.output;\r\n }\r\n };\r\n\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n require('audioworklet-polyfill');\r\n require('shims');\r\n require('audiocontext');\r\n var p5SOUND = require('master');\r\n require('helpers');\r\n require('errorHandler');\r\n require('audioWorklet');\r\n require('panner');\r\n require('soundfile');\r\n require('amplitude');\r\n require('fft');\r\n require('signal');\r\n require('oscillator');\r\n require('envelope');\r\n require('pulse');\r\n require('noise');\r\n require('audioin');\r\n require('filter');\r\n require('eq');\r\n require('panner3d');\r\n require('listener3d');\r\n require('delay');\r\n require('reverb');\r\n require('metro');\r\n require('looper');\r\n require('soundLoop');\r\n require('compressor');\r\n require('soundRecorder');\r\n require('peakDetect');\r\n require('gain');\r\n require('monosynth');\r\n require('polysynth');\r\n require('distortion');\r\n require('audioVoice');\r\n require('monosynth');\r\n require('polysynth');\r\n\r\n return p5SOUND;\r\n\r\n});\r\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].length;\\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].length;\\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);\"","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var ac = p5sound.audiocontext;\r\n\r\n // Stereo panner\r\n // if there is a stereo panner node use it\r\n if(typeof ac.createStereoPanner !== 'undefined') {\r\n p5.Panner = function (input, output) {\r\n this.stereoPanner = this.input = ac.createStereoPanner();\r\n input.connect(this.stereoPanner);\r\n this.stereoPanner.connect(output);\r\n };\r\n\r\n p5.Panner.prototype.pan = function(val, tFromNow) {\r\n var time = tFromNow || 0;\r\n var t = ac.currentTime + time;\r\n\r\n this.stereoPanner.pan.linearRampToValueAtTime(val, t);\r\n };\r\n\r\n //not implemented because stereopanner\r\n //node does not require this and will automatically\r\n //convert single channel or multichannel to stereo.\r\n //tested with single and stereo, not with (>2) multichannel\r\n p5.Panner.prototype.inputChannels = function() {};\r\n\r\n p5.Panner.prototype.connect = function(obj) {\r\n this.stereoPanner.connect(obj);\r\n };\r\n\r\n p5.Panner.prototype.disconnect = function() {\r\n if (this.stereoPanner) {\r\n this.stereoPanner.disconnect();\r\n }\r\n };\r\n\r\n } else {\r\n // if there is no createStereoPanner object\r\n // such as in safari 7.1.7 at the time of writing this\r\n // use this method to create the effect\r\n p5.Panner = function(input, output, numInputChannels) {\r\n this.input = ac.createGain();\r\n input.connect(this.input);\r\n\r\n this.left = ac.createGain();\r\n this.right = ac.createGain();\r\n this.left.channelInterpretation = 'discrete';\r\n this.right.channelInterpretation = 'discrete';\r\n\r\n // if input is stereo\r\n if (numInputChannels > 1) {\r\n this.splitter = ac.createChannelSplitter(2);\r\n this.input.connect(this.splitter);\r\n\r\n this.splitter.connect(this.left, 1);\r\n this.splitter.connect(this.right, 0);\r\n }\r\n else {\r\n this.input.connect(this.left);\r\n this.input.connect(this.right);\r\n }\r\n\r\n this.output = ac.createChannelMerger(2);\r\n this.left.connect(this.output, 0, 1);\r\n this.right.connect(this.output, 0, 0);\r\n this.output.connect(output);\r\n };\r\n\r\n // -1 is left, +1 is right\r\n p5.Panner.prototype.pan = function(val, tFromNow) {\r\n var time = tFromNow || 0;\r\n var t = ac.currentTime + time;\r\n var v = (val + 1) / 2;\r\n var rightVal = Math.cos(v*Math.PI/2);\r\n var leftVal = Math.sin(v * Math.PI/2);\r\n this.left.gain.linearRampToValueAtTime(leftVal, t);\r\n this.right.gain.linearRampToValueAtTime(rightVal, t);\r\n };\r\n\r\n p5.Panner.prototype.inputChannels = function(numChannels) {\r\n if (numChannels === 1) {\r\n this.input.disconnect();\r\n this.input.connect(this.left);\r\n this.input.connect(this.right);\r\n } else if (numChannels === 2) {\r\n if (typeof(this.splitter === 'undefined')) {\r\n this.splitter = ac.createChannelSplitter(2);\r\n }\r\n this.input.disconnect();\r\n this.input.connect(this.splitter);\r\n this.splitter.connect(this.left, 1);\r\n this.splitter.connect(this.right, 0);\r\n }\r\n };\r\n\r\n p5.Panner.prototype.connect = function(obj) {\r\n this.output.connect(obj);\r\n };\r\n\r\n p5.Panner.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n };\r\n }\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n const CustomError = require('errorHandler');\r\n const p5sound = require('master');\r\n const ac = p5sound.audiocontext;\r\n const { midiToFreq, convertToWav, safeBufferSize } = require('helpers');\r\n var processorNames = require('./audioWorklet/processorNames');\r\n\r\n /**\r\n *

SoundFile object with a path to a file.

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

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

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

\r\n *\r\n *

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

\r\n *\r\n *

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

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

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

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

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

\r\n *\r\n * @method logAverages\r\n * @for p5.FFT\r\n * @param {Array} octaveBands Array of Octave Bands objects for grouping\r\n * @return {Array} logAverages Array of average amplitude values for each group\r\n */\r\n p5.FFT.prototype.logAverages = function(octaveBands) {\r\n var nyquist = p5sound.audiocontext.sampleRate / 2;\r\n var spectrum = this.freqDomain;\r\n var spectrumLength = spectrum.length;\r\n\r\n var logAverages = new Array(octaveBands.length);\r\n // Keep a second index for the current average group and place the values accordingly\r\n // With only one loop in the spectrum data\r\n var octaveIndex = 0;\r\n\r\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\r\n var specIndexFrequency = Math.round(\r\n specIndex * nyquist / this.freqDomain.length\r\n );\r\n\r\n // Increase the group index if the current frequency exceeds the limits of the band\r\n if (specIndexFrequency > octaveBands[octaveIndex].hi) {\r\n octaveIndex++;\r\n }\r\n\r\n logAverages[octaveIndex] =\r\n logAverages[octaveIndex] !== undefined\r\n ? (logAverages[octaveIndex] + spectrum[specIndex]) / 2\r\n : spectrum[specIndex];\r\n }\r\n\r\n return logAverages;\r\n };\r\n\r\n /**\r\n * Calculates and Returns the 1/N\r\n * Octave Bands\r\n * N defaults to 3 and minimum central frequency to 15.625Hz.\r\n * (1/3 Octave Bands ~= 31 Frequency Bands)\r\n * Setting fCtr0 to a central value of a higher octave will ignore the lower bands\r\n * and produce less frequency groups.\r\n *\r\n * @method getOctaveBands\r\n * @for p5.FFT\r\n * @param {Number} N Specifies the 1/N type of generated octave bands\r\n * @param {Number} fCtr0 Minimum central frequency for the lowest band\r\n * @return {Array} octaveBands Array of octave band objects with their bounds\r\n */\r\n p5.FFT.prototype.getOctaveBands = function(N, fCtr0) {\r\n var N = N || 3; // Default to 1/3 Octave Bands\r\n var fCtr0 = fCtr0 || 15.625; // Minimum central frequency, defaults to 15.625Hz\r\n\r\n var octaveBands = [];\r\n var lastFrequencyBand = {\r\n lo: fCtr0 / Math.pow(2, 1 / (2 * N)),\r\n ctr: fCtr0,\r\n hi: fCtr0 * Math.pow(2, 1 / (2 * N))\r\n };\r\n octaveBands.push(lastFrequencyBand);\r\n\r\n var nyquist = p5sound.audiocontext.sampleRate / 2;\r\n while (lastFrequencyBand.hi < nyquist) {\r\n var newFrequencyBand = {};\r\n newFrequencyBand.lo = lastFrequencyBand.hi;\r\n newFrequencyBand.ctr = lastFrequencyBand.ctr * Math.pow(2, 1 / N);\r\n newFrequencyBand.hi = newFrequencyBand.ctr * Math.pow(2, 1 / (2 * N));\r\n\r\n octaveBands.push(newFrequencyBand);\r\n lastFrequencyBand = newFrequencyBand;\r\n }\r\n\r\n return octaveBands;\r\n };\r\n\r\n // helper methods to convert type from float (dB) to int (0-255)\r\n var freqToFloat = function(fft) {\r\n if (fft.freqDomain instanceof Float32Array === false) {\r\n fft.freqDomain = new Float32Array(fft.analyser.frequencyBinCount);\r\n }\r\n };\r\n var freqToInt = function(fft) {\r\n if (fft.freqDomain instanceof Uint8Array === false) {\r\n fft.freqDomain = new Uint8Array(fft.analyser.frequencyBinCount);\r\n }\r\n };\r\n var timeToFloat = function(fft) {\r\n if (fft.timeDomain instanceof Float32Array === false) {\r\n fft.timeDomain = new Float32Array(fft.analyser.frequencyBinCount);\r\n }\r\n };\r\n var timeToInt = function(fft) {\r\n if (fft.timeDomain instanceof Uint8Array === false) {\r\n fft.timeDomain = new Uint8Array(fft.analyser.frequencyBinCount);\r\n }\r\n };\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n // Signal is built with the Tone.js signal by Yotam Mann\r\n // https://github.com/TONEnoTONE/Tone.js/\r\n var Signal = require('Tone/signal/Signal');\r\n var Add = require('Tone/signal/Add');\r\n var Mult = require('Tone/signal/Multiply');\r\n var Scale = require('Tone/signal/Scale');\r\n\r\n /**\r\n *

p5.Signal is a constant audio-rate signal used by p5.Oscillator\r\n * and p5.Envelope for modulation math.

\r\n *\r\n *

This is necessary because Web Audio is processed on a seprate clock.\r\n * For example, the p5 draw loop runs about 60 times per second. But\r\n * the audio clock must process samples 44100 times per second. If we\r\n * want to add a value to each of those samples, we can't do it in the\r\n * draw loop, but we can do it by adding a constant-rate audio signal.This class mostly functions behind the scenes in p5.sound, and returns\r\n * a Tone.Signal from the Tone.js library by Yotam Mann.\r\n * If you want to work directly with audio signals for modular\r\n * synthesis, check out\r\n * tone.js.

\r\n *\r\n * @class p5.Signal\r\n * @constructor\r\n * @return {Tone.Signal} A Signal object from the Tone.js library\r\n * @example\r\n *
\r\n * let carrier, modulator;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(canvasPressed);\r\n * background(220);\r\n * text('tap to play', 20, 20);\r\n *\r\n * carrier = new p5.Oscillator('sine');\r\n * carrier.start();\r\n * carrier.amp(1); // set amplitude\r\n * carrier.freq(220); // set frequency\r\n *\r\n * modulator = new p5.Oscillator('sawtooth');\r\n * modulator.disconnect();\r\n * modulator.start();\r\n * modulator.amp(1);\r\n * modulator.freq(4);\r\n *\r\n * // Modulator's default amplitude range is -1 to 1.\r\n * // Multiply it by -200, so the range is -200 to 200\r\n * // then add 220 so the range is 20 to 420\r\n * carrier.freq( modulator.mult(-400).add(220) );\r\n * }\r\n *\r\n * function canvasPressed() {\r\n * userStartAudio();\r\n * carrier.amp(1.0);\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * carrier.amp(0);\r\n * }\r\n *
\r\n */\r\n p5.Signal = function(value) {\r\n var s = new Signal(value);\r\n // p5sound.soundArray.push(s);\r\n return s; // TODO: is this really a constructor?\r\n };\r\n\r\n /**\r\n * Fade to value, for smooth transitions\r\n *\r\n * @method fade\r\n * @for p5.Signal\r\n * @param {Number} value Value to set this signal\r\n * @param {Number} [secondsFromNow] Length of fade, in seconds from now\r\n */\r\n Signal.prototype.fade = Signal.prototype.linearRampToValueAtTime;\r\n Mult.prototype.fade = Signal.prototype.fade;\r\n Add.prototype.fade = Signal.prototype.fade;\r\n Scale.prototype.fade = Signal.prototype.fade;\r\n\r\n\r\n /**\r\n * Connect a p5.sound object or Web Audio node to this\r\n * p5.Signal so that its amplitude values can be scaled.\r\n *\r\n * @method setInput\r\n * @for p5.Signal\r\n * @param {Object} input\r\n */\r\n Signal.prototype.setInput = function(_input) {\r\n _input.connect(this);\r\n };\r\n Mult.prototype.setInput = Signal.prototype.setInput;\r\n Add.prototype.setInput = Signal.prototype.setInput;\r\n Scale.prototype.setInput = Signal.prototype.setInput;\r\n\r\n\r\n // signals can add / mult / scale themselves\r\n\r\n /**\r\n * Add a constant value to this audio signal,\r\n * and return the resulting audio signal. Does\r\n * not change the value of the original signal,\r\n * instead it returns a new p5.SignalAdd.\r\n *\r\n * @method add\r\n * @for p5.Signal\r\n * @param {Number} number\r\n * @return {p5.Signal} object\r\n */\r\n Signal.prototype.add = function(num) {\r\n var add = new Add(num);\r\n // add.setInput(this);\r\n this.connect(add);\r\n return add;\r\n };\r\n Mult.prototype.add = Signal.prototype.add;\r\n Add.prototype.add = Signal.prototype.add;\r\n Scale.prototype.add = Signal.prototype.add;\r\n\r\n /**\r\n * Multiply this signal by a constant value,\r\n * and return the resulting audio signal. Does\r\n * not change the value of the original signal,\r\n * instead it returns a new p5.SignalMult.\r\n *\r\n * @method mult\r\n * @for p5.Signal\r\n * @param {Number} number to multiply\r\n * @return {p5.Signal} object\r\n */\r\n Signal.prototype.mult = function(num) {\r\n var mult = new Mult(num);\r\n // mult.setInput(this);\r\n this.connect(mult);\r\n return mult;\r\n };\r\n Mult.prototype.mult = Signal.prototype.mult;\r\n Add.prototype.mult = Signal.prototype.mult;\r\n Scale.prototype.mult = Signal.prototype.mult;\r\n\r\n /**\r\n * Scale this signal value to a given range,\r\n * and return the result as an audio signal. Does\r\n * not change the value of the original signal,\r\n * instead it returns a new p5.SignalScale.\r\n *\r\n * @method scale\r\n * @for p5.Signal\r\n * @param {Number} number to multiply\r\n * @param {Number} inMin input range minumum\r\n * @param {Number} inMax input range maximum\r\n * @param {Number} outMin input range minumum\r\n * @param {Number} outMax input range maximum\r\n * @return {p5.Signal} object\r\n */\r\n Signal.prototype.scale = function(inMin, inMax, outMin, outMax) {\r\n var mapOutMin, mapOutMax;\r\n if (arguments.length === 4) {\r\n mapOutMin = p5.prototype.map(outMin, inMin, inMax, 0, 1) - 0.5;\r\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5;\r\n }\r\n else {\r\n mapOutMin = arguments[0];\r\n mapOutMax = arguments[1];\r\n }\r\n var scale = new Scale(mapOutMin, mapOutMax);\r\n this.connect(scale);\r\n return scale;\r\n };\r\n Mult.prototype.scale = Signal.prototype.scale;\r\n Add.prototype.scale = Signal.prototype.scale;\r\n Scale.prototype.scale = Signal.prototype.scale;\r\n\r\n});\r\n\r\n\r\n","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});","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var Add = require('Tone/signal/Add');\r\n var Mult = require('Tone/signal/Multiply');\r\n var Scale = require('Tone/signal/Scale');\r\n var TimelineSignal = require('Tone/signal/TimelineSignal');\r\n\r\n /**\r\n *

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

\r\n *

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

\r\n *

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

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

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

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n * @class p5.AudioIn\r\n * @constructor\r\n * @param {Function} [errorCallback] A function to call if there is an error\r\n * accessing the AudioIn. For example,\r\n * Safari and iOS devices do not\r\n * currently allow microphone access.\r\n * @example\r\n *
\r\n * let mic;\r\n *\r\n * function setup(){\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(userStartAudio);\r\n * textAlign(CENTER);\r\n * mic = new p5.AudioIn();\r\n * mic.start();\r\n * }\r\n *\r\n * function draw(){\r\n * background(0);\r\n * fill(255);\r\n * text('tap to start', width/2, 20);\r\n *\r\n * micLevel = mic.getLevel();\r\n * let y = height - micLevel * height;\r\n * ellipse(width/2, y, 10, 10);\r\n * }\r\n *
\r\n */\r\n p5.AudioIn = function(errorCallback) {\r\n // set up audio input\r\n /**\r\n * @property {GainNode} input\r\n */\r\n this.input = p5sound.audiocontext.createGain();\r\n /**\r\n * @property {GainNode} output\r\n */\r\n this.output = p5sound.audiocontext.createGain();\r\n\r\n /**\r\n * @property {MediaStream|null} stream\r\n */\r\n this.stream = null;\r\n /**\r\n * @property {MediaStreamAudioSourceNode|null} mediaStream\r\n */\r\n this.mediaStream = null;\r\n /**\r\n * @property {Number|null} currentSource\r\n */\r\n this.currentSource = null;\r\n\r\n /**\r\n * Client must allow browser to access their microphone / audioin source.\r\n * Default: false. Will become true when the client enables access.\r\n *\r\n * @property {Boolean} enabled\r\n */\r\n this.enabled = false;\r\n\r\n /**\r\n * Input amplitude, connect to it by default but not to master out\r\n *\r\n * @property {p5.Amplitude} amplitude\r\n */\r\n this.amplitude = new p5.Amplitude();\r\n this.output.connect(this.amplitude.input);\r\n\r\n if (!window.MediaStreamTrack || !window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia) {\r\n errorCallback ? errorCallback() : window.alert('This browser does not support MediaStreamTrack and mediaDevices');\r\n }\r\n\r\n // add to soundArray so we can dispose on close\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Start processing audio input. This enables the use of other\r\n * AudioIn methods like getLevel(). Note that by default, AudioIn\r\n * is not connected to p5.sound's output. So you won't hear\r\n * anything unless you use the connect() method.
\r\n *\r\n * Certain browsers limit access to the user's microphone. For example,\r\n * Chrome only allows access from localhost and over https. For this reason,\r\n * you may want to include an errorCallback—a function that is called in case\r\n * the browser won't provide mic access.\r\n *\r\n * @method start\r\n * @for p5.AudioIn\r\n * @param {Function} [successCallback] Name of a function to call on\r\n * success.\r\n * @param {Function} [errorCallback] Name of a function to call if\r\n * there was an error. For example,\r\n * some browsers do not support\r\n * getUserMedia.\r\n */\r\n p5.AudioIn.prototype.start = function(successCallback, errorCallback) {\r\n var self = this;\r\n\r\n if (this.stream) {\r\n this.stop();\r\n }\r\n\r\n // set the audio source\r\n var audioSource = p5sound.inputSources[self.currentSource];\r\n var constraints = {\r\n audio: {\r\n sampleRate: p5sound.audiocontext.sampleRate,\r\n echoCancellation: false\r\n }\r\n };\r\n\r\n // if developers determine which source to use\r\n if (p5sound.inputSources[this.currentSource]) {\r\n constraints.audio.deviceId = audioSource.deviceId;\r\n }\r\n\r\n window.navigator.mediaDevices.getUserMedia( constraints )\r\n .then( function(stream) {\r\n self.stream = stream;\r\n self.enabled = true;\r\n // Wrap a MediaStreamSourceNode around the live input\r\n self.mediaStream = p5sound.audiocontext.createMediaStreamSource(stream);\r\n self.mediaStream.connect(self.output);\r\n // only send to the Amplitude reader, so we can see it but not hear it.\r\n self.amplitude.setInput(self.output);\r\n if (successCallback) successCallback();\r\n })\r\n .catch( function(err) {\r\n if (errorCallback) errorCallback(err);\r\n else console.error(err);\r\n });\r\n };\r\n\r\n /**\r\n * Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().\r\n * If re-starting, the user may be prompted for permission access.\r\n *\r\n * @method stop\r\n * @for p5.AudioIn\r\n */\r\n p5.AudioIn.prototype.stop = function() {\r\n if (this.stream) {\r\n this.stream.getTracks().forEach(function(track) {\r\n track.stop();\r\n });\r\n\r\n this.mediaStream.disconnect();\r\n\r\n delete this.mediaStream;\r\n delete this.stream;\r\n }\r\n };\r\n\r\n /**\r\n * Connect to an audio unit. If no parameter is provided, will\r\n * connect to the master output (i.e. your speakers).
\r\n *\r\n * @method connect\r\n * @for p5.AudioIn\r\n * @param {Object} [unit] An object that accepts audio input,\r\n * such as an FFT\r\n */\r\n p5.AudioIn.prototype.connect = function(unit) {\r\n if (unit) {\r\n if (unit.hasOwnProperty('input')) {\r\n this.output.connect(unit.input);\r\n }\r\n else if (unit.hasOwnProperty('analyser')) {\r\n this.output.connect(unit.analyser);\r\n }\r\n else {\r\n this.output.connect(unit);\r\n }\r\n }\r\n else {\r\n this.output.connect(p5sound.input);\r\n }\r\n };\r\n\r\n /**\r\n * Disconnect the AudioIn from all audio units. For example, if\r\n * connect() had been called, disconnect() will stop sending\r\n * signal to your speakers.
\r\n *\r\n * @method disconnect\r\n * @for p5.AudioIn\r\n */\r\n p5.AudioIn.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n // stay connected to amplitude even if not outputting to p5\r\n this.output.connect(this.amplitude.input);\r\n }\r\n };\r\n\r\n /**\r\n * Read the Amplitude (volume level) of an AudioIn. The AudioIn\r\n * class contains its own instance of the Amplitude class to help\r\n * make it easy to get a microphone's volume level. Accepts an\r\n * optional smoothing value (0.0 < 1.0). NOTE: AudioIn must\r\n * .start() before using .getLevel().
\r\n *\r\n * @method getLevel\r\n * @for p5.AudioIn\r\n * @param {Number} [smoothing] Smoothing is 0.0 by default.\r\n * Smooths values based on previous values.\r\n * @return {Number} Volume level (between 0.0 and 1.0)\r\n */\r\n p5.AudioIn.prototype.getLevel = function(smoothing) {\r\n if (smoothing) {\r\n this.amplitude.smoothing = smoothing;\r\n }\r\n return this.amplitude.getLevel();\r\n };\r\n\r\n /**\r\n * Set amplitude (volume) of a mic input between 0 and 1.0.
\r\n *\r\n * @method amp\r\n * @for p5.AudioIn\r\n * @param {Number} vol between 0 and 1.0\r\n * @param {Number} [time] ramp time (optional)\r\n */\r\n p5.AudioIn.prototype.amp = function(vol, t) {\r\n if (t) {\r\n var rampTime = t || 0;\r\n var currentVol = this.output.gain.value;\r\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\r\n this.output.gain.setValueAtTime(currentVol, p5sound.audiocontext.currentTime);\r\n this.output.gain.linearRampToValueAtTime(vol, rampTime + p5sound.audiocontext.currentTime);\r\n } else {\r\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\r\n this.output.gain.setValueAtTime(vol, p5sound.audiocontext.currentTime);\r\n }\r\n };\r\n\r\n /**\r\n * Returns a list of available input sources. This is a wrapper\r\n * for and it returns a Promise.\r\n *\r\n * @method getSources\r\n * @for p5.AudioIn\r\n * @param {Function} [successCallback] This callback function handles the sources when they\r\n * have been enumerated. The callback function\r\n * receives the deviceList array as its only argument\r\n * @param {Function} [errorCallback] This optional callback receives the error\r\n * message as its argument.\r\n * @returns {Promise} Returns a Promise that can be used in place of the callbacks, similar\r\n * to the enumerateDevices() method\r\n * @example\r\n *
\r\n * let audioIn;\r\n *\r\n * function setup(){\r\n * text('getting sources...', 0, 20);\r\n * audioIn = new p5.AudioIn();\r\n * audioIn.getSources(gotSources);\r\n * }\r\n *\r\n * function gotSources(deviceList) {\r\n * if (deviceList.length > 0) {\r\n * //set the source to the first item in the deviceList array\r\n * audioIn.setSource(0);\r\n * let currentSource = deviceList[audioIn.currentSource];\r\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\r\n * }\r\n * }\r\n *
\r\n */\r\n p5.AudioIn.prototype.getSources = function (onSuccess, onError) {\r\n return new Promise( function(resolve, reject) {\r\n window.navigator.mediaDevices.enumerateDevices()\r\n .then( function(devices) {\r\n p5sound.inputSources = devices.filter(function(device) {\r\n return device.kind === 'audioinput';\r\n });\r\n resolve(p5sound.inputSources);\r\n if (onSuccess) {\r\n onSuccess(p5sound.inputSources);\r\n }\r\n })\r\n .catch( function(error) {\r\n reject(error);\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error('This browser does not support MediaStreamTrack.getSources()');\r\n }\r\n });\r\n });\r\n };\r\n\r\n /**\r\n * Set the input source. Accepts a number representing a\r\n * position in the array returned by getSources().\r\n * This is only available in browsers that support\r\n *
navigator.mediaDevices.enumerateDevices().
\r\n *\r\n * @method setSource\r\n * @for p5.AudioIn\r\n * @param {number} num position of input source in the array\r\n * @example\r\n *
\r\n * let audioIn;\r\n *\r\n * function setup(){\r\n * text('getting sources...', 0, 20);\r\n * audioIn = new p5.AudioIn();\r\n * audioIn.getSources(gotSources);\r\n * }\r\n *\r\n * function gotSources(deviceList) {\r\n * if (deviceList.length > 0) {\r\n * //set the source to the first item in the deviceList array\r\n * audioIn.setSource(0);\r\n * let currentSource = deviceList[audioIn.currentSource];\r\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\r\n * }\r\n * }\r\n *
\r\n */\r\n p5.AudioIn.prototype.setSource = function(num) {\r\n if (p5sound.inputSources.length > 0 && num < p5sound.inputSources.length) {\r\n // set the current source\r\n this.currentSource = num;\r\n console.log('set source to ', p5sound.inputSources[this.currentSource]);\r\n } else {\r\n console.log('unable to set input source');\r\n }\r\n\r\n // restart stream if currently active\r\n if (this.stream && this.stream.active) {\r\n this.start();\r\n }\r\n };\r\n\r\n // private method\r\n p5.AudioIn.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n\r\n this.stop();\r\n\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n if (this.amplitude) {\r\n this.amplitude.disconnect();\r\n }\r\n delete this.amplitude;\r\n delete this.output;\r\n };\r\n\r\n});\r\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","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});","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n var Effect = require('effect');\r\n var EQFilter = require('eqFilter');\r\n\r\n /**\r\n * p5.EQ is an audio effect that performs the function of a multiband\r\n * audio equalizer. Equalization is used to adjust the balance of\r\n * frequency compoenents of an audio signal. This process is commonly used\r\n * in sound production and recording to change the waveform before it reaches\r\n * a sound output device. EQ can also be used as an audio effect to create\r\n * interesting distortions by filtering out parts of the spectrum. p5.EQ is\r\n * built using a chain of Web Audio Biquad Filter Nodes and can be\r\n * instantiated with 3 or 8 bands. Bands can be added or removed from\r\n * the EQ by directly modifying p5.EQ.bands (the array that stores filters).\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.EQ\r\n * @constructor\r\n * @extends p5.Effect\r\n * @param {Number} [_eqsize] Constructor will accept 3 or 8, defaults to 3\r\n * @return {Object} p5.EQ object\r\n *\r\n * @example\r\n *
\r\n * let eq, soundFile\r\n * let eqBandIndex = 0;\r\n * let eqBandNames = ['lows', 'mids', 'highs'];\r\n *\r\n * function preload() {\r\n * soundFormats('mp3', 'ogg');\r\n * soundFile = loadSound('assets/beat');\r\n * }\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(toggleSound);\r\n *\r\n * eq = new p5.EQ(eqBandNames.length);\r\n * soundFile.disconnect();\r\n * eq.process(soundFile);\r\n * }\r\n *\r\n * function draw() {\r\n * background(30);\r\n * noStroke();\r\n * fill(255);\r\n * textAlign(CENTER);\r\n * text('filtering ', 50, 25);\r\n *\r\n * fill(255, 40, 255);\r\n * textSize(26);\r\n * text(eqBandNames[eqBandIndex], 50, 55);\r\n *\r\n * fill(255);\r\n * textSize(9);\r\n *\r\n * if (!soundFile.isPlaying()) {\r\n * text('tap to play', 50, 80);\r\n * } else {\r\n * text('tap to filter next band', 50, 80)\r\n * }\r\n * }\r\n *\r\n * function toggleSound() {\r\n * if (!soundFile.isPlaying()) {\r\n * soundFile.play();\r\n * } else {\r\n * eqBandIndex = (eqBandIndex + 1) % eq.bands.length;\r\n * }\r\n *\r\n * for (let i = 0; i < eq.bands.length; i++) {\r\n * eq.bands[i].gain(0);\r\n * }\r\n * // filter the band we want to filter\r\n * eq.bands[eqBandIndex].gain(-40);\r\n * }\r\n *
\r\n */\r\n p5.EQ = function(_eqsize) {\r\n Effect.call(this);\r\n\r\n //p5.EQ can be of size (3) or (8), defaults to 3\r\n _eqsize = _eqsize === 3 || _eqsize === 8 ? _eqsize : 3;\r\n\r\n var factor;\r\n _eqsize === 3 ? factor = Math.pow(2,3) : factor = 2;\r\n\r\n /**\r\n * The p5.EQ is built with abstracted p5.Filter objects.\r\n * To modify any bands, use methods of the \r\n * p5.Filter API, especially `gain` and `freq`.\r\n * Bands are stored in an array, with indices 0 - 3, or 0 - 7\r\n * @property {Array} bands\r\n *\r\n */\r\n this.bands = [];\r\n\r\n\r\n var freq, res;\r\n for (var i = 0; i < _eqsize; i++) {\r\n if (i === _eqsize - 1) {\r\n freq = 21000;\r\n res = .01;\r\n } else if (i === 0) {\r\n freq = 100;\r\n res = .1;\r\n }\r\n else if (i===1) {\r\n freq = _eqsize === 3 ? 360 * factor : 360;\r\n res = 1;\r\n }else {\r\n freq = this.bands[i-1].freq() * factor;\r\n res = 1;\r\n }\r\n this.bands[i] = this._newBand(freq, res);\r\n\r\n if (i>0) {\r\n this.bands[i-1].connect(this.bands[i].biquad);\r\n } else {\r\n this.input.connect(this.bands[i].biquad);\r\n }\r\n }\r\n this.bands[_eqsize-1].connect(this.output);\r\n };\r\n p5.EQ.prototype = Object.create(Effect.prototype);\r\n\r\n /**\r\n * Process an input by connecting it to the EQ\r\n * @method process\r\n * @param {Object} src Audio source\r\n */\r\n p5.EQ.prototype.process = function (src) {\r\n src.connect(this.input);\r\n };\r\n\r\n // /**\r\n // * Set the frequency and gain of each band in the EQ. This method should be\r\n // * called with 3 or 8 frequency and gain pairs, depending on the size of the EQ.\r\n // * ex. eq.set(freq0, gain0, freq1, gain1, freq2, gain2);\r\n // *\r\n // * @method set\r\n // * @for p5.EQ\r\n // * @param {Number} [freq0] Frequency value for band with index 0\r\n // * @param {Number} [gain0] Gain value for band with index 0\r\n // * @param {Number} [freq1] Frequency value for band with index 1\r\n // * @param {Number} [gain1] Gain value for band with index 1\r\n // * @param {Number} [freq2] Frequency value for band with index 2\r\n // * @param {Number} [gain2] Gain value for band with index 2\r\n // * @param {Number} [freq3] Frequency value for band with index 3\r\n // * @param {Number} [gain3] Gain value for band with index 3\r\n // * @param {Number} [freq4] Frequency value for band with index 4\r\n // * @param {Number} [gain4] Gain value for band with index 4\r\n // * @param {Number} [freq5] Frequency value for band with index 5\r\n // * @param {Number} [gain5] Gain value for band with index 5\r\n // * @param {Number} [freq6] Frequency value for band with index 6\r\n // * @param {Number} [gain6] Gain value for band with index 6\r\n // * @param {Number} [freq7] Frequency value for band with index 7\r\n // * @param {Number} [gain7] Gain value for band with index 7\r\n // */\r\n p5.EQ.prototype.set = function() {\r\n if (arguments.length === this.bands.length * 2) {\r\n for (var i = 0; i < arguments.length; i+=2) {\r\n this.bands[i/2].freq(arguments[i]);\r\n this.bands[i/2].gain(arguments[i+1]);\r\n }\r\n }\r\n else {\r\n console.error('Argument mismatch. .set() should be called with ' + this.bands.length*2 +\r\n ' arguments. (one frequency and gain value pair for each band of the eq)');\r\n }\r\n };\r\n\r\n /**\r\n * Add a new band. Creates a p5.Filter and strips away everything but\r\n * the raw biquad filter. This method returns an abstracted p5.Filter,\r\n * which can be added to p5.EQ.bands, in order to create new EQ bands.\r\n * @private\r\n * @for p5.EQ\r\n * @method _newBand\r\n * @param {Number} freq\r\n * @param {Number} res\r\n * @return {Object} Abstracted Filter\r\n */\r\n p5.EQ.prototype._newBand = function(freq, res) {\r\n return new EQFilter(freq, res);\r\n };\r\n\r\n p5.EQ.prototype.dispose = function () {\r\n Effect.prototype.dispose.apply(this);\r\n\r\n if (this.bands) {\r\n while (this.bands.length > 0) {\r\n delete this.bands.pop().dispose();\r\n }\r\n delete this.bands;\r\n }\r\n };\r\n\r\n return p5.EQ;\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n var Filter = require('filter');\r\n var p5sound = require('master');\r\n\r\n /**\r\n * EQFilter extends p5.Filter with constraints\r\n * necessary for the p5.EQ\r\n *\r\n * @private\r\n */\r\n var EQFilter = function(freq, res) {\r\n Filter.call(this, 'peaking');\r\n this.disconnect();\r\n this.set(freq, res);\r\n this.biquad.gain.value = 0;\r\n delete this.input;\r\n delete this.output;\r\n delete this._drywet;\r\n delete this.wet;\r\n\r\n };\r\n EQFilter.prototype = Object.create(Filter.prototype);\r\n\r\n EQFilter.prototype.amp = function() {\r\n console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');\r\n };\r\n EQFilter.prototype.drywet = function() {\r\n console.warn('`drywet()` is not available for p5.EQ bands.');\r\n };\r\n EQFilter.prototype.connect = function(unit) {\r\n var u = unit || p5.soundOut.input;\r\n if (this.biquad) {\r\n this.biquad.connect(u.input ? u.input : u);\r\n } else {\r\n this.output.connect(u.input ? u.input : u);\r\n }\r\n };\r\n\r\n EQFilter.prototype.disconnect = function() {\r\n if (this.biquad) {\r\n this.biquad.disconnect();\r\n }\r\n };\r\n EQFilter.prototype.dispose = function() {\r\n // remove reference form soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n this.disconnect();\r\n delete this.biquad;\r\n };\r\n\r\n return EQFilter;\r\n});\r\n","'use strict'\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n var Effect = require('effect');\r\n\r\n /**\r\n * Panner3D is based on the \r\n * Web Audio Spatial Panner Node.\r\n * This panner is a spatial processing node that allows audio to be positioned\r\n * and oriented in 3D space.\r\n *\r\n * The position is relative to an \r\n * Audio Context Listener, which can be accessed\r\n * by p5.soundOut.audiocontext.listener\r\n *\r\n *\r\n * @class p5.Panner3D\r\n * @constructor\r\n */\r\n\tp5.Panner3D = function() {\r\n Effect.call(this);\r\n\r\n /**\r\n * \r\n * Web Audio Spatial Panner Node\r\n *\r\n * Properties include\r\n * - panningModel: \"equal power\" or \"HRTF\"\r\n * - distanceModel: \"linear\", \"inverse\", or \"exponential\"\r\n *\r\n * @property {AudioNode} panner\r\n *\r\n */\r\n this.panner = this.ac.createPanner();\r\n this.panner.panningModel = 'HRTF';\r\n this.panner.distanceModel = 'linear';\r\n this.panner.connect(this.output);\r\n this.input.connect(this.panner);\r\n\t};\r\n\r\n p5.Panner3D.prototype = Object.create(Effect.prototype);\r\n\r\n\r\n /**\r\n * Connect an audio sorce\r\n *\r\n * @method process\r\n * @for p5.Panner3D\r\n * @param {Object} src Input source\r\n */\r\n p5.Panner3D.prototype.process = function(src) {\r\n src.connect(this.input);\r\n }\r\n /**\r\n * Set the X,Y,Z position of the Panner\r\n * @method set\r\n * @for p5.Panner3D\r\n * @param {Number} xVal\r\n * @param {Number} yVal\r\n * @param {Number} zVal\r\n * @param {Number} time\r\n * @return {Array} Updated x, y, z values as an array\r\n */\r\n p5.Panner3D.prototype.set = function(xVal, yVal, zVal, time) {\r\n this.positionX(xVal,time);\r\n this.positionY(yVal,time);\r\n this.positionZ(zVal,time);\r\n return [this.panner.positionX.value,\r\n this.panner.positionY.value,\r\n this.panner.positionZ.value];\r\n };\r\n\r\n /**\r\n * Getter and setter methods for position coordinates\r\n * @method positionX\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n /**\r\n * Getter and setter methods for position coordinates\r\n * @method positionY\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n /**\r\n * Getter and setter methods for position coordinates\r\n * @method positionZ\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n p5.Panner3D.prototype.positionX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.panner.positionX.value = xVal;\r\n this.panner.positionX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.positionX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.panner.positionX);\r\n }\r\n return this.panner.positionX.value;\r\n };\r\n p5.Panner3D.prototype.positionY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.panner.positionY.value = yVal;\r\n this.panner.positionY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.positionY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.panner.positionY);\r\n }\r\n return this.panner.positionY.value;\r\n };\r\n p5.Panner3D.prototype.positionZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.panner.positionZ.value = zVal;\r\n this.panner.positionZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.positionZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.panner.positionZ);\r\n }\r\n return this.panner.positionZ.value;\r\n };\r\n\r\n /**\r\n * Set the X,Y,Z position of the Panner\r\n * @method orient\r\n * @for p5.Panner3D\r\n * @param {Number} xVal\r\n * @param {Number} yVal\r\n * @param {Number} zVal\r\n * @param {Number} time\r\n * @return {Array} Updated x, y, z values as an array\r\n */\r\n p5.Panner3D.prototype.orient = function(xVal, yVal, zVal, time) {\r\n this.orientX(xVal,time);\r\n this.orientY(yVal,time);\r\n this.orientZ(zVal,time);\r\n return [this.panner.orientationX.value,\r\n this.panner.orientationY.value,\r\n this.panner.orientationZ.value];\r\n };\r\n\r\n /**\r\n * Getter and setter methods for orient coordinates\r\n * @method orientX\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n /**\r\n * Getter and setter methods for orient coordinates\r\n * @method orientY\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n /**\r\n * Getter and setter methods for orient coordinates\r\n * @method orientZ\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n p5.Panner3D.prototype.orientX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.panner.orientationX.value = xVal;\r\n this.panner.orientationX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.orientationX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.panner.orientationX);\r\n }\r\n return this.panner.orientationX.value;\r\n };\r\n p5.Panner3D.prototype.orientY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.panner.orientationY.value = yVal;\r\n this.panner.orientationY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.orientationY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.panner.orientationY);\r\n }\r\n return this.panner.orientationY.value;\r\n };\r\n p5.Panner3D.prototype.orientZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.panner.orientationZ.value = zVal;\r\n this.panner.orientationZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.orientationZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.panner.orientationZ);\r\n }\r\n return this.panner.orientationZ.value;\r\n };\r\n\r\n /**\r\n * Set the rolloff factor and max distance\r\n * @method setFalloff\r\n * @for p5.Panner3D\r\n * @param {Number} [maxDistance]\r\n * @param {Number} [rolloffFactor]\r\n */\r\n p5.Panner3D.prototype.setFalloff = function(maxDistance, rolloffFactor) {\r\n this.maxDist(maxDistance);\r\n this.rolloff(rolloffFactor);\r\n };\r\n /**\r\n * Maxium distance between the source and the listener\r\n * @method maxDist\r\n * @for p5.Panner3D\r\n * @param {Number} maxDistance\r\n * @return {Number} updated value\r\n */\r\n p5.Panner3D.prototype.maxDist = function(maxDistance){\r\n if (typeof maxDistance === 'number') {\r\n this.panner.maxDistance = maxDistance;\r\n }\r\n return this.panner.maxDistance;\r\n };\r\n\r\n /**\r\n * How quickly the volume is reduced as the source moves away from the listener\r\n * @method rollof\r\n * @for p5.Panner3D\r\n * @param {Number} rolloffFactor\r\n * @return {Number} updated value\r\n */\r\n p5.Panner3D.prototype.rolloff = function(rolloffFactor){\r\n if (typeof rolloffFactor === 'number') {\r\n this.panner.rolloffFactor = rolloffFactor;\r\n }\r\n return this.panner.rolloffFactor;\r\n };\r\n\r\n p5.Panner3D.dispose = function() {\r\n Effect.prototype.dispose.apply(this);\r\n if (this.panner) {\r\n this.panner.disconnect();\r\n delete this.panner;\r\n }\r\n };\r\n\r\n return p5.Panner3D;\r\n\r\n});\r\n","'use strict'\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n var Effect = require('effect');\r\n\r\n// /**\r\n// * listener is a class that can construct both a Spatial Panner\r\n// * and a Spatial Listener. The panner is based on the \r\n// * Web Audio Spatial Panner Node\r\n// * https://www.w3.org/TR/webaudio/#the-listenernode-interface\r\n// * This panner is a spatial processing node that allows audio to be positioned\r\n// * and oriented in 3D space. \r\n// *\r\n// * The Listener modifies the properties of the Audio Context Listener. \r\n// * Both objects types use the same methods. The default is a spatial panner.\r\n// *\r\n// * p5.Panner3D - Constructs a Spatial Panner
\r\n// * p5.Listener3D - Constructs a Spatial Listener
\r\n// *\r\n// * @class listener\r\n// * @constructor\r\n// * @return {Object} p5.Listener3D Object\r\n// *\r\n// * @param {Web Audio Node} listener Web Audio Spatial Panning Node\r\n// * @param {AudioParam} listener.panningModel \"equal power\" or \"HRTF\"\r\n// * @param {AudioParam} listener.distanceModel \"linear\", \"inverse\", or \"exponential\"\r\n// * @param {String} [type] [Specify construction of a spatial panner or listener]\r\n// */\r\n \r\n\tp5.Listener3D = function(type) {\r\n this.ac = p5sound.audiocontext;\r\n this.listener = this.ac.listener;\r\n\t}; \r\n\r\n// /**\r\n// * Connect an audio sorce\r\n// * @param {Object} src Input source\r\n// */\r\n p5.Listener3D.prototype.process = function(src) {\r\n src.connect(this.input);\r\n }\r\n// /**\r\n// * Set the X,Y,Z position of the Panner\r\n// * @param {[Number]} xVal\r\n// * @param {[Number]} yVal\r\n// * @param {[Number]} zVal\r\n// * @param {[Number]} time\r\n// * @return {[Array]} [Updated x, y, z values as an array]\r\n// */\r\n p5.Listener3D.prototype.position = function(xVal, yVal, zVal, time) {\r\n this.positionX(xVal,time);\r\n this.positionY(yVal,time);\r\n this.positionZ(zVal,time);\r\n return [this.listener.positionX.value, \r\n this.listener.positionY.value,\r\n this.listener.positionZ.value];\r\n };\r\n\r\n// /**\r\n// * Getter and setter methods for position coordinates\r\n// * @return {Number} [updated coordinate value]\r\n// */\r\n p5.Listener3D.prototype.positionX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.listener.positionX.value = xVal;\r\n this.listener.positionX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.positionX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.listener.positionX);\r\n }\r\n return this.listener.positionX.value;\r\n };\r\n p5.Listener3D.prototype.positionY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.listener.positionY.value = yVal;\r\n this.listener.positionY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.positionY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.listener.positionY);\r\n }\r\n return this.listener.positionY.value;\r\n };\r\n p5.Listener3D.prototype.positionZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.listener.positionZ.value = zVal;\r\n this.listener.positionZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.positionZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.listener.positionZ);\r\n }\r\n return this.listener.positionZ.value;\r\n };\r\n\r\n// cannot define method when class definition is commented\r\n// /**\r\n// * Overrides the listener orient() method because Listener has slightly\r\n// * different params. In human terms, Forward vectors are the direction the \r\n// * nose is pointing. Up vectors are the direction of the top of the head.\r\n// *\r\n// * @method orient\r\n// * @param {Number} xValF Forward vector X direction\r\n// * @param {Number} yValF Forward vector Y direction\r\n// * @param {Number} zValF Forward vector Z direction\r\n// * @param {Number} xValU Up vector X direction\r\n// * @param {Number} yValU Up vector Y direction\r\n// * @param {Number} zValU Up vector Z direction\r\n// * @param {Number} time \r\n// * @return {Array} All orienation params\r\n// */\r\n p5.Listener3D.prototype.orient = function(xValF, yValF, zValF, \r\n xValU, yValU, zValU, time) {\r\n\r\n if (arguments.length === 3 || arguments.length === 4) {\r\n time = arguments[3];\r\n this.orientForward(xValF, yValF, zValF, time);\r\n } else if (arguments.length === 6 || arguments === 7) {\r\n this.orientForward(xValF, yValF, zValF);\r\n this.orientUp(xValU, yValU, zValU, time);\r\n }\r\n \r\n return [this.listener.forwardX.value, \r\n this.listener.forwardY.value,\r\n this.listener.forwardZ.value,\r\n this.listener.upX.value,\r\n this.listener.upY.value,\r\n this.listener.upZ.value];\r\n };\r\n\r\n\r\n p5.Listener3D.prototype.orientForward = function(xValF, yValF, zValF, time) {\r\n this.forwardX(xValF,time);\r\n this.forwardY(yValF,time);\r\n this.forwardZ(zValF,time);\r\n\r\n return [this.listener.forwardX, \r\n this.listener.forwardY,\r\n this.listener.forwardZ];\r\n };\r\n\r\n p5.Listener3D.prototype.orientUp = function(xValU, yValU, zValU, time) {\r\n this.upX(xValU,time);\r\n this.upY(yValU,time);\r\n this.upZ(zValU,time);\r\n\r\n return [this.listener.upX, \r\n this.listener.upY,\r\n this.listener.upZ];\r\n };\r\n// /**\r\n// * Getter and setter methods for orient coordinates\r\n// * @return {Number} [updated coordinate value]\r\n// */\r\n p5.Listener3D.prototype.forwardX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.listener.forwardX.value = xVal;\r\n this.listener.forwardX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.forwardX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.listener.forwardX);\r\n }\r\n return this.listener.forwardX.value;\r\n };\r\n p5.Listener3D.prototype.forwardY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.listener.forwardY.value = yVal;\r\n this.listener.forwardY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.forwardY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.listener.forwardY);\r\n }\r\n return this.listener.forwardY.value;\r\n };\r\n p5.Listener3D.prototype.forwardZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.listener.forwardZ.value = zVal;\r\n this.listener.forwardZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.forwardZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.listener.forwardZ);\r\n }\r\n return this.listener.forwardZ.value;\r\n };\r\n p5.Listener3D.prototype.upX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.listener.upX.value = xVal;\r\n this.listener.upX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.upX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.listener.upX);\r\n }\r\n return this.listener.upX.value;\r\n };\r\n p5.Listener3D.prototype.upY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.listener.upY.value = yVal;\r\n this.listener.upY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.upY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.listener.upY);\r\n }\r\n return this.listener.upY.value;\r\n };\r\n p5.Listener3D.prototype.upZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.listener.upZ.value = zVal;\r\n this.listener.upZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.upZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.listener.upZ);\r\n }\r\n return this.listener.upZ.value;\r\n };\r\n \r\n return p5.Listener3D;\r\n\r\n});","'use strict';\r\n\r\ndefine(function (require) {\r\n var Filter = require('filter');\r\n var Effect = require('effect');\r\n\r\n /**\r\n * Delay is an echo effect. It processes an existing sound source,\r\n * and outputs a delayed version of that sound. The p5.Delay can\r\n * produce different effects depending on the delayTime, feedback,\r\n * filter, and type. In the example below, a feedback of 0.5 (the\r\n * default value) will produce a looping delay that decreases in\r\n * volume by 50% each repeat. A filter will cut out the high\r\n * frequencies so that the delay does not sound as piercing as the\r\n * original source.\r\n *\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n * @class p5.Delay\r\n * @extends p5.Effect\r\n * @constructor\r\n * @example\r\n *
\r\n * let osc;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * background(220);\r\n * textAlign(CENTER);\r\n * text('tap to play', width/2, height/2);\r\n *\r\n * osc = new p5.Oscillator('square');\r\n * osc.amp(0.5);\r\n * delay = new p5.Delay();\r\n *\r\n * // delay.process() accepts 4 parameters:\r\n * // source, delayTime (in seconds), feedback, filter frequency\r\n * delay.process(osc, 0.12, .7, 2300);\r\n *\r\n * cnv.mousePressed(oscStart);\r\n * }\r\n *\r\n * function oscStart() {\r\n * osc.start();\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * osc.stop();\r\n * }\r\n *
\r\n */\r\n p5.Delay = function() {\r\n \tEffect.call(this);\r\n\r\n this._split = this.ac.createChannelSplitter(2);\r\n this._merge = this.ac.createChannelMerger(2);\r\n\r\n this._leftGain = this.ac.createGain();\r\n this._rightGain = this.ac.createGain();\r\n\r\n /**\r\n * The p5.Delay is built with two\r\n * \r\n * Web Audio Delay Nodes, one for each stereo channel.\r\n *\r\n * @for p5.Delay\r\n * @property {DelayNode} leftDelay\r\n */\r\n this.leftDelay = this.ac.createDelay();\r\n /**\r\n * The p5.Delay is built with two\r\n * \r\n * Web Audio Delay Nodes, one for each stereo channel.\r\n * @for p5.Delay\r\n * @property {DelayNode} rightDelay\r\n */\r\n this.rightDelay = this.ac.createDelay();\r\n\r\n this._leftFilter = new Filter();\r\n this._rightFilter = new Filter();\r\n this._leftFilter.disconnect();\r\n this._rightFilter.disconnect();\r\n\r\n this._leftFilter.biquad.frequency.setValueAtTime(1200, this.ac.currentTime);\r\n this._rightFilter.biquad.frequency.setValueAtTime(1200, this.ac.currentTime);\r\n this._leftFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\r\n this._rightFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\r\n\r\n // graph routing\r\n this.input.connect(this._split);\r\n this.leftDelay.connect(this._leftGain);\r\n this.rightDelay.connect(this._rightGain);\r\n this._leftGain.connect(this._leftFilter.input);\r\n this._rightGain.connect(this._rightFilter.input);\r\n this._merge.connect(this.wet);\r\n\r\n\r\n this._leftFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\r\n this._rightFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\r\n\r\n // default routing\r\n this.setType(0);\r\n\r\n this._maxDelay = this.leftDelay.delayTime.maxValue;\r\n\r\n // set initial feedback to 0.5\r\n this.feedback(0.5);\r\n\r\n\r\n };\r\n\r\n p5.Delay.prototype = Object.create(Effect.prototype);\r\n /**\r\n * Add delay to an audio signal according to a set\r\n * of delay parameters.\r\n *\r\n * @method process\r\n * @for p5.Delay\r\n * @param {Object} Signal An object that outputs audio\r\n * @param {Number} [delayTime] Time (in seconds) of the delay/echo.\r\n * Some browsers limit delayTime to\r\n * 1 second.\r\n * @param {Number} [feedback] sends the delay back through itself\r\n * in a loop that decreases in volume\r\n * each time.\r\n * @param {Number} [lowPass] Cutoff frequency. Only frequencies\r\n * below the lowPass will be part of the\r\n * delay.\r\n */\r\n p5.Delay.prototype.process = function(src, _delayTime, _feedback, _filter) {\r\n var feedback = _feedback || 0;\r\n var delayTime = _delayTime || 0;\r\n if (feedback >= 1.0) {\r\n throw new Error('Feedback value will force a positive feedback loop.');\r\n }\r\n if (delayTime >= this._maxDelay) {\r\n throw new Error('Delay Time exceeds maximum delay time of ' + this._maxDelay + ' second.');\r\n }\r\n\r\n src.connect(this.input);\r\n this.leftDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\r\n this.rightDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\r\n this._leftGain.gain.value = feedback;\r\n this._rightGain.gain.value = feedback;\r\n\r\n if (_filter) {\r\n this._leftFilter.freq(_filter);\r\n this._rightFilter.freq(_filter);\r\n }\r\n };\r\n\r\n /**\r\n * Set the delay (echo) time, in seconds. Usually this value will be\r\n * a floating point number between 0.0 and 1.0.\r\n *\r\n * @method delayTime\r\n * @for p5.Delay\r\n * @param {Number} delayTime Time (in seconds) of the delay\r\n */\r\n p5.Delay.prototype.delayTime = function(t) {\r\n // if t is an audio node...\r\n if (typeof t !== 'number') {\r\n t.connect(this.leftDelay.delayTime);\r\n t.connect(this.rightDelay.delayTime);\r\n }\r\n\r\n else {\r\n this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\r\n this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\r\n this.leftDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\r\n this.rightDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\r\n }\r\n };\r\n\r\n /**\r\n * Feedback occurs when Delay sends its signal back through its input\r\n * in a loop. The feedback amount determines how much signal to send each\r\n * time through the loop. A feedback greater than 1.0 is not desirable because\r\n * it will increase the overall output each time through the loop,\r\n * creating an infinite feedback loop. The default value is 0.5\r\n *\r\n * @method feedback\r\n * @for p5.Delay\r\n * @param {Number|Object} feedback 0.0 to 1.0, or an object such as an\r\n * Oscillator that can be used to\r\n * modulate this param\r\n * @returns {Number} Feedback value\r\n *\r\n */\r\n p5.Delay.prototype.feedback = function(f) {\r\n // if f is an audio node...\r\n if (f && typeof f !== 'number') {\r\n f.connect(this._leftGain.gain);\r\n f.connect(this._rightGain.gain);\r\n }\r\n else if (f >= 1.0) {\r\n throw new Error('Feedback value will force a positive feedback loop.');\r\n }\r\n else if (typeof f === 'number') {\r\n this._leftGain.gain.value = f;\r\n this._rightGain.gain.value = f;\r\n }\r\n\r\n // return value of feedback\r\n return this._leftGain.gain.value;\r\n };\r\n\r\n /**\r\n * Set a lowpass filter frequency for the delay. A lowpass filter\r\n * will cut off any frequencies higher than the filter frequency.\r\n *\r\n * @method filter\r\n * @for p5.Delay\r\n * @param {Number|Object} cutoffFreq A lowpass filter will cut off any\r\n * frequencies higher than the filter frequency.\r\n * @param {Number|Object} res Resonance of the filter frequency\r\n * cutoff, or an object (i.e. a p5.Oscillator)\r\n * that can be used to modulate this parameter.\r\n * High numbers (i.e. 15) will produce a resonance,\r\n * low numbers (i.e. .2) will produce a slope.\r\n */\r\n p5.Delay.prototype.filter = function(freq, q) {\r\n this._leftFilter.set(freq, q);\r\n this._rightFilter.set(freq, q);\r\n };\r\n\r\n\r\n /**\r\n * Choose a preset type of delay. 'pingPong' bounces the signal\r\n * from the left to the right channel to produce a stereo effect.\r\n * Any other parameter will revert to the default delay setting.\r\n *\r\n * @method setType\r\n * @for p5.Delay\r\n * @param {String|Number} type 'pingPong' (1) or 'default' (0)\r\n */\r\n p5.Delay.prototype.setType = function(t) {\r\n if (t === 1) {\r\n t = 'pingPong';\r\n }\r\n this._split.disconnect();\r\n this._leftFilter.disconnect();\r\n this._rightFilter.disconnect();\r\n this._split.connect(this.leftDelay, 0);\r\n this._split.connect(this.rightDelay, 1);\r\n switch(t) {\r\n case 'pingPong':\r\n this._rightFilter.setType( this._leftFilter.biquad.type );\r\n this._leftFilter.output.connect(this._merge, 0, 0);\r\n this._rightFilter.output.connect(this._merge, 0, 1);\r\n this._leftFilter.output.connect(this.rightDelay);\r\n this._rightFilter.output.connect(this.leftDelay);\r\n break;\r\n default:\r\n this._leftFilter.output.connect(this._merge, 0, 0);\r\n this._rightFilter.output.connect(this._merge, 0, 1);\r\n this._leftFilter.output.connect(this.leftDelay);\r\n this._rightFilter.output.connect(this.rightDelay);\r\n }\r\n };\r\n\r\n // DocBlocks for methods inherited from p5.Effect\r\n /**\r\n * Set the output level of the delay effect.\r\n *\r\n * @method amp\r\n * @for p5.Delay\r\n * @param {Number} volume amplitude between 0 and 1.0\r\n * @param {Number} [rampTime] create a fade that lasts rampTime\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n */\r\n /**\r\n * Send output to a p5.sound or web audio object\r\n *\r\n * @method connect\r\n * @for p5.Delay\r\n * @param {Object} unit\r\n */\r\n /**\r\n * Disconnect all output.\r\n *\r\n * @method disconnect\r\n * @for p5.Delay\r\n */\r\n\r\n p5.Delay.prototype.dispose = function() {\r\n\r\n Effect.prototype.dispose.apply(this);\r\n\r\n this._split.disconnect();\r\n this._leftFilter.dispose();\r\n this._rightFilter.dispose();\r\n this._merge.disconnect();\r\n this._leftGain.disconnect();\r\n this._rightGain.disconnect();\r\n this.leftDelay.disconnect();\r\n this.rightDelay.disconnect();\r\n\r\n this._split = undefined;\r\n this._leftFilter = undefined;\r\n this._rightFilter = undefined;\r\n this._merge = undefined;\r\n this._leftGain = undefined;\r\n this._rightGain = undefined;\r\n this.leftDelay = undefined;\r\n this.rightDelay = undefined;\r\n };\r\n\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n var CustomError = require('errorHandler');\r\n var Effect = require('effect');\r\n\r\n /**\r\n * Reverb adds depth to a sound through a large number of decaying\r\n * echoes. It creates the perception that sound is occurring in a\r\n * physical space. The p5.Reverb has paramters for Time (how long does the\r\n * reverb last) and decayRate (how much the sound decays with each echo)\r\n * that can be set with the .set() or .process() methods. The p5.Convolver\r\n * extends p5.Reverb allowing you to recreate the sound of actual physical\r\n * spaces through convolution.\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.Reverb\r\n * @extends p5.Effect\r\n * @constructor\r\n * @example\r\n *
\r\n * let soundFile, reverb;\r\n * function preload() {\r\n * soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\r\n * }\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSound);\r\n *\r\n * reverb = new p5.Reverb();\r\n * soundFile.disconnect(); // so we'll only hear reverb...\r\n *\r\n * // connect soundFile to reverb, process w/\r\n * // 3 second reverbTime, decayRate of 2%\r\n * reverb.process(soundFile, 3, 2);\r\n * }\r\n *\r\n * function draw() {\r\n * let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);\r\n * // 1 = all reverb, 0 = no reverb\r\n * reverb.drywet(dryWet);\r\n *\r\n * background(220);\r\n * text('tap to play', 10, 20);\r\n * text('dry/wet: ' + round(dryWet * 100) + '%', 10, height - 20);\r\n * }\r\n *\r\n * function playSound() {\r\n * soundFile.play();\r\n * }\r\n *
\r\n */\r\n\r\n\r\n p5.Reverb = function() {\r\n Effect.call(this);\r\n\r\n this._initConvolverNode();\r\n\r\n // otherwise, Safari distorts\r\n this.input.gain.value = 0.5;\r\n\r\n // default params\r\n this._seconds = 3;\r\n this._decay = 2;\r\n this._reverse = false;\r\n\r\n this._buildImpulse();\r\n\r\n };\r\n\r\n p5.Reverb.prototype = Object.create(Effect.prototype);\r\n\r\n p5.Reverb.prototype._initConvolverNode = function() {\r\n this.convolverNode = this.ac.createConvolver();\r\n this.input.connect(this.convolverNode);\r\n this.convolverNode.connect(this.wet);\r\n };\r\n\r\n p5.Reverb.prototype._teardownConvolverNode = function() {\r\n if (this.convolverNode) {\r\n this.convolverNode.disconnect();\r\n delete this.convolverNode;\r\n }\r\n };\r\n\r\n p5.Reverb.prototype._setBuffer = function(audioBuffer) {\r\n this._teardownConvolverNode();\r\n this._initConvolverNode();\r\n this.convolverNode.buffer = audioBuffer;\r\n };\r\n /**\r\n * Connect a source to the reverb, and assign reverb parameters.\r\n *\r\n * @method process\r\n * @for p5.Reverb\r\n * @param {Object} src p5.sound / Web Audio object with a sound\r\n * output.\r\n * @param {Number} [seconds] Duration of the reverb, in seconds.\r\n * Min: 0, Max: 10. Defaults to 3.\r\n * @param {Number} [decayRate] Percentage of decay with each echo.\r\n * Min: 0, Max: 100. Defaults to 2.\r\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\r\n */\r\n p5.Reverb.prototype.process = function(src, seconds, decayRate, reverse) {\r\n src.connect(this.input);\r\n var rebuild = false;\r\n if (seconds) {\r\n this._seconds = seconds;\r\n rebuild = true;\r\n }\r\n if (decayRate) {\r\n this._decay = decayRate;\r\n }\r\n if (reverse) {\r\n this._reverse = reverse;\r\n }\r\n if (rebuild) {\r\n this._buildImpulse();\r\n }\r\n };\r\n\r\n /**\r\n * Set the reverb settings. Similar to .process(), but without\r\n * assigning a new input.\r\n *\r\n * @method set\r\n * @for p5.Reverb\r\n * @param {Number} [seconds] Duration of the reverb, in seconds.\r\n * Min: 0, Max: 10. Defaults to 3.\r\n * @param {Number} [decayRate] Percentage of decay with each echo.\r\n * Min: 0, Max: 100. Defaults to 2.\r\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\r\n */\r\n p5.Reverb.prototype.set = function(seconds, decayRate, reverse) {\r\n var rebuild = false;\r\n if (seconds) {\r\n this._seconds = seconds;\r\n rebuild = true;\r\n }\r\n if (decayRate) {\r\n this._decay = decayRate;\r\n }\r\n if (reverse) {\r\n this._reverse = reverse;\r\n }\r\n if (rebuild) {\r\n this._buildImpulse();\r\n }\r\n };\r\n\r\n // DocBlocks for methods inherited from p5.Effect\r\n /**\r\n * Set the output level of the reverb effect.\r\n *\r\n * @method amp\r\n * @for p5.Reverb\r\n * @param {Number} volume amplitude between 0 and 1.0\r\n * @param {Number} [rampTime] create a fade that lasts rampTime\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n */\r\n /**\r\n * Send output to a p5.sound or web audio object\r\n *\r\n * @method connect\r\n * @for p5.Reverb\r\n * @param {Object} unit\r\n */\r\n /**\r\n * Disconnect all output.\r\n *\r\n * @method disconnect\r\n * @for p5.Reverb\r\n */\r\n\r\n /**\r\n * Inspired by Simple Reverb by Jordan Santell\r\n * https://github.com/web-audio-components/simple-reverb/blob/master/index.js\r\n *\r\n * Utility function for building an impulse response\r\n * based on the module parameters.\r\n *\r\n * @private\r\n */\r\n p5.Reverb.prototype._buildImpulse = function() {\r\n var rate = this.ac.sampleRate;\r\n var length = rate*this._seconds;\r\n var decay = this._decay;\r\n var impulse = this.ac.createBuffer(2, length, rate);\r\n var impulseL = impulse.getChannelData(0);\r\n var impulseR = impulse.getChannelData(1);\r\n var n, i;\r\n for (i = 0; i < length; i++) {\r\n n = this._reverse ? length - i : i;\r\n impulseL[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\r\n impulseR[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\r\n }\r\n this._setBuffer(impulse);\r\n };\r\n\r\n p5.Reverb.prototype.dispose = function() {\r\n Effect.prototype.dispose.apply(this);\r\n this._teardownConvolverNode();\r\n };\r\n\r\n // =======================================================================\r\n // *** p5.Convolver ***\r\n // =======================================================================\r\n\r\n /**\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

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

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 */\n p5.Part = function(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 p5.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 p5.Part.prototype.setBPM = function(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 p5.Part.prototype.getBPM = function() {\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 p5.Part.prototype.start = function(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 p5.Part.prototype.loop = function(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 p5.Part.prototype.noLoop = function() {\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 p5.Part.prototype.stop = function(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 p5.Part.prototype.pause = function(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 p5.Part.prototype.addPhrase = function(name, callback, array) {\n var p;\n if (arguments.length === 3) {\n p = new p5.Phrase(name, callback, array);\n } else if (arguments[0] instanceof p5.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 p5.Part.prototype.removePhrase = function(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 p5.Part.prototype.getPhrase = function(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 p5.Part.prototype.replaceSequence = function(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 p5.Part.prototype.incrementStep = function(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 p5.Part.prototype.onStep = function(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 */\n p5.Score = function() {\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]) {\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 p5.Score.prototype.onended = function() {\n if (this.looping) {\n // this.resetParts();\n this.parts[0].start();\n }\n this.currentPart = 0;\n };\n\n /**\n * Start playback of the score.\n *\n * @method start\n * @for p5.Score\n */\n p5.Score.prototype.start = function() {\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 p5.Score.prototype.stop = function() {\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 p5.Score.prototype.pause = function() {\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 p5.Score.prototype.loop = function() {\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 p5.Score.prototype.noLoop = function() {\n this.looping = false;\n };\n\n p5.Score.prototype.resetParts = function() {\n var self = this;\n this.parts.forEach(function(part) {\n self.resetParts[part];\n });\n };\n\n p5.Score.prototype.resetPart = function(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 p5.Score.prototype.setBPM = function(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 function 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\n});\n","'use strict';\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n var Clock = require('Tone/core/Clock');\r\n\r\n /**\r\n * SoundLoop\r\n *\r\n * @class p5.SoundLoop\r\n * @constructor\r\n *\r\n * @param {Function} callback this function will be called on each iteration of theloop\r\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.\r\n *\r\n * @example\r\n *
\r\n * let synth, soundLoop;\r\n * let notePattern = [60, 62, 64, 67, 69, 72];\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(canvasPressed);\r\n * colorMode(HSB);\r\n * background(0, 0, 86);\r\n * text('tap to start/stop', 10, 20);\r\n *\r\n * //the looper's callback is passed the timeFromNow\r\n * //this value should be used as a reference point from\r\n * //which to schedule sounds\r\n * let intervalInSeconds = 0.2;\r\n * soundLoop = new p5.SoundLoop(onSoundLoop, intervalInSeconds);\r\n *\r\n * synth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function canvasPressed() {\r\n * // ensure audio is enabled\r\n * userStartAudio();\r\n *\r\n * if (soundLoop.isPlaying) {\r\n * soundLoop.stop();\r\n * } else {\r\n * // start the loop\r\n * soundLoop.start();\r\n * }\r\n * }\r\n *\r\n * function onSoundLoop(timeFromNow) {\r\n * let noteIndex = (soundLoop.iterations - 1) % notePattern.length;\r\n * let note = midiToFreq(notePattern[noteIndex]);\r\n * synth.play(note, 0.5, timeFromNow);\r\n * background(noteIndex * 360 / notePattern.length, 50, 100);\r\n * }\r\n *
\r\n */\r\n p5.SoundLoop = function(callback, interval) {\r\n this.callback = callback;\r\n /**\r\n * musicalTimeMode uses Tone.Time convention\r\n * true if string, false if number\r\n * @property {Boolean} musicalTimeMode\r\n */\r\n this.musicalTimeMode = typeof this._interval === 'number' ? false : true;\r\n\r\n this._interval = interval || 1;\r\n\r\n /**\r\n * musicalTimeMode variables\r\n * modify these only when the interval is specified in musicalTime format as a string\r\n */\r\n this._timeSignature = 4;\r\n this._bpm = 60;\r\n\r\n this.isPlaying = false;\r\n\r\n /**\r\n * Set a limit to the number of loops to play. defaults to Infinity\r\n * @property {Number} maxIterations\r\n */\r\n this.maxIterations = Infinity;\r\n var self = this;\r\n\r\n this.clock = new Clock({\r\n 'callback' : function(time) {\r\n var timeFromNow = time - p5sound.audiocontext.currentTime;\r\n /**\r\n * Do not initiate the callback if timeFromNow is < 0\r\n * This ususually occurs for a few milliseconds when the page\r\n * is not fully loaded\r\n *\r\n * The callback should only be called until maxIterations is reached\r\n */\r\n if (timeFromNow > 0 && self.iterations <= self.maxIterations) {\r\n self.callback(timeFromNow);}\r\n },\r\n 'frequency' : this._calcFreq()\r\n });\r\n };\r\n\r\n /**\r\n * Start the loop\r\n * @method start\r\n * @for p5.SoundLoop\r\n * @param {Number} [timeFromNow] schedule a starting time\r\n */\r\n p5.SoundLoop.prototype.start = function(timeFromNow) {\r\n var t = timeFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n if (!this.isPlaying) {\r\n this.clock.start(now + t);\r\n this.isPlaying = true;\r\n }\r\n };\r\n\r\n /**\r\n * Stop the loop\r\n * @method stop\r\n * @for p5.SoundLoop\r\n * @param {Number} [timeFromNow] schedule a stopping time\r\n */\r\n p5.SoundLoop.prototype.stop = function(timeFromNow) {\r\n var t = timeFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n if (this.isPlaying) {\r\n this.clock.stop(now + t);\r\n this.isPlaying = false;\r\n }\r\n };\r\n /**\r\n * Pause the loop\r\n * @method pause\r\n * @for p5.SoundLoop\r\n * @param {Number} [timeFromNow] schedule a pausing time\r\n */\r\n p5.SoundLoop.prototype.pause = function(timeFromNow) {\r\n var t = timeFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n if (this.isPlaying) {\r\n this.clock.pause(now + t);\r\n this.isPlaying = false;\r\n }\r\n };\r\n\r\n\r\n /**\r\n * Synchronize loops. Use this method to start two or more loops in synchronization\r\n * or to start a loop in synchronization with a loop that is already playing\r\n * This method will schedule the implicit loop in sync with the explicit master loop\r\n * i.e. loopToStart.syncedStart(loopToSyncWith)\r\n *\r\n * @method syncedStart\r\n * @for p5.SoundLoop\r\n * @param {Object} otherLoop a p5.SoundLoop to sync with\r\n * @param {Number} [timeFromNow] Start the loops in sync after timeFromNow seconds\r\n */\r\n p5.SoundLoop.prototype.syncedStart = function(otherLoop, timeFromNow) {\r\n var t = timeFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n\r\n if (!otherLoop.isPlaying) {\r\n otherLoop.clock.start(now + t);\r\n otherLoop.isPlaying = true;\r\n this.clock.start(now + t);\r\n this.isPlaying = true;\r\n } else if (otherLoop.isPlaying) {\r\n var time = otherLoop.clock._nextTick - p5sound.audiocontext.currentTime;\r\n this.clock.start(now + time);\r\n this.isPlaying = true;\r\n }\r\n };\r\n\r\n\r\n /**\r\n * Updates frequency value, reflected in next callback\r\n * @private\r\n * @for p5.SoundLoop\r\n * @method _update\r\n */\r\n p5.SoundLoop.prototype._update = function() {\r\n this.clock.frequency.value = this._calcFreq();\r\n };\r\n\r\n /**\r\n * Calculate the frequency of the clock's callback based on bpm, interval, and timesignature\r\n * @private\r\n * @for p5.SoundLoop\r\n * @method _calcFreq\r\n * @return {Number} new clock frequency value\r\n */\r\n p5.SoundLoop.prototype._calcFreq = function() {\r\n //Seconds mode, bpm / timesignature has no effect\r\n if (typeof this._interval === 'number') {\r\n this.musicalTimeMode = false;\r\n return 1 / this._interval;\r\n }\r\n //Musical timing mode, calculate interval based bpm, interval,and time signature\r\n else if (typeof this._interval === 'string') {\r\n this.musicalTimeMode = true;\r\n return this._bpm / 60 / this._convertNotation(this._interval) * (this._timeSignature / 4);\r\n }\r\n };\r\n\r\n /**\r\n * Convert notation from musical time format to seconds\r\n * Uses Tone.Time convention\r\n * @private\r\n * @for p5.SoundLoop\r\n * @method _convertNotation\r\n * @param {String} value value to be converted\r\n * @return {Number} converted value in seconds\r\n */\r\n p5.SoundLoop.prototype._convertNotation = function(value) {\r\n var type = value.slice(-1);\r\n value = Number(value.slice(0,-1));\r\n switch (type) {\r\n case 'm':\r\n return this._measure(value);\r\n case 'n':\r\n return this._note(value);\r\n default:\r\n console.warn('Specified interval is not formatted correctly. See Tone.js '+\r\n 'timing reference for more info: https://github.com/Tonejs/Tone.js/wiki/Time');\r\n }\r\n };\r\n\r\n /**\r\n * Helper conversion methods of measure and note\r\n * @private\r\n * @for p5.SoundLoop\r\n * @method _measure\r\n */\r\n p5.SoundLoop.prototype._measure = function(value) {\r\n return value * this._timeSignature;\r\n };\r\n\r\n /**\r\n * @private\r\n * @method _note\r\n * @for p5.SoundLoop\r\n */\r\n p5.SoundLoop.prototype._note = function(value) {\r\n return this._timeSignature / value ;\r\n };\r\n\r\n\r\n /**\r\n * Getters and Setters, setting any paramter will result in a change in the clock's\r\n * frequency, that will be reflected after the next callback\r\n * beats per minute (defaults to 60)\r\n * @property {Number} bpm\r\n * @for p5.SoundLoop\r\n */\r\n Object.defineProperty(p5.SoundLoop.prototype, 'bpm', {\r\n get : function() {\r\n return this._bpm;\r\n },\r\n set : function(bpm) {\r\n if (!this.musicalTimeMode) {\r\n console.warn('Changing the BPM in \"seconds\" mode has no effect. '+\r\n 'BPM is only relevant in musicalTimeMode '+\r\n 'when the interval is specified as a string '+\r\n '(\"2n\", \"4n\", \"1m\"...etc)');\r\n }\r\n this._bpm = bpm;\r\n this._update();\r\n }\r\n });\r\n\r\n /**\r\n * number of quarter notes in a measure (defaults to 4)\r\n * @property {Number} timeSignature\r\n * @for p5.SoundLoop\r\n */\r\n Object.defineProperty(p5.SoundLoop.prototype, 'timeSignature', {\r\n get : function() {\r\n return this._timeSignature;\r\n },\r\n set : function(timeSig) {\r\n if (!this.musicalTimeMode) {\r\n console.warn('Changing the timeSignature in \"seconds\" mode has no effect. '+\r\n 'BPM is only relevant in musicalTimeMode '+\r\n 'when the interval is specified as a string '+\r\n '(\"2n\", \"4n\", \"1m\"...etc)');\r\n }\r\n this._timeSignature = timeSig;\r\n this._update();\r\n }\r\n });\r\n\r\n /**\r\n * length of the loops interval\r\n * @property {Number|String} interval\r\n * @for p5.SoundLoop\r\n */\r\n Object.defineProperty(p5.SoundLoop.prototype, 'interval', {\r\n get : function() {\r\n return this._interval;\r\n },\r\n set : function(interval) {\r\n this.musicalTimeMode = typeof interval === 'Number'? false : true;\r\n this._interval = interval;\r\n this._update();\r\n }\r\n });\r\n\r\n /**\r\n * how many times the callback has been called so far\r\n * @property {Number} iterations\r\n * @for p5.SoundLoop\r\n * @readonly\r\n */\r\n Object.defineProperty(p5.SoundLoop.prototype, 'iterations', {\r\n get : function() {\r\n return this.clock.ticks;\r\n }\r\n });\r\n\r\n return p5.SoundLoop;\r\n});\r\n","define(function (require) {\r\n\t'use strict';\r\n\r\n\tvar p5sound = require('master');\r\n\tvar Effect = require('effect');\r\n var CustomError = require('errorHandler');\r\n\r\n /**\r\n * Compressor is an audio effect class that performs dynamics compression\r\n * on an audio input source. This is a very commonly used technique in music\r\n * and sound production. Compression creates an overall louder, richer,\r\n * and fuller sound by lowering the volume of louds and raising that of softs.\r\n * Compression can be used to avoid clipping (sound distortion due to\r\n * peaks in volume) and is especially useful when many sounds are played\r\n * at once. Compression can be used on indivudal sound sources in addition\r\n * to the master output.\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.Compressor\r\n * @constructor\r\n * @extends p5.Effect\r\n *\r\n *\r\n */\r\n\tp5.Compressor = function() {\r\n\t\tEffect.call(this);\r\n\r\n /**\r\n * The p5.Compressor is built with a Web Audio Dynamics Compressor Node\r\n * \r\n * @property {AudioNode} compressor\r\n */\r\n\r\n\r\n\t\tthis.compressor = this.ac.createDynamicsCompressor();\r\n\r\n this.input.connect(this.compressor);\r\n this.compressor.connect(this.wet);\r\n\t};\r\n\r\n\tp5.Compressor.prototype = Object.create(Effect.prototype);\r\n\r\n /**\r\n * Performs the same function as .connect, but also accepts\r\n * optional parameters to set compressor's audioParams\r\n * @method process\r\n * @for p5.Compressor\r\n *\r\n * @param {Object} src Sound source to be connected\r\n *\r\n * @param {Number} [attack] The amount of time (in seconds) to reduce the gain by 10dB,\r\n * default = .003, range 0 - 1\r\n * @param {Number} [knee] A decibel value representing the range above the\r\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\r\n * default = 30, range 0 - 40\r\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\r\n * default = 12, range 1 - 20\r\n * @param {Number} [threshold] The decibel value above which the compression will start taking effect\r\n * default = -24, range -100 - 0\r\n * @param {Number} [release] The amount of time (in seconds) to increase the gain by 10dB\r\n * default = .25, range 0 - 1\r\n */\r\n\tp5.Compressor.prototype.process = function(src, attack, knee,\r\n ratio, threshold, release) {\r\n\t\tsrc.connect(this.input);\r\n\t\tthis.set(attack, knee, ratio, threshold, release);\r\n\t};\r\n\r\n /**\r\n * Set the paramters of a compressor.\r\n * @method set\r\n * @for p5.Compressor\r\n * @param {Number} attack The amount of time (in seconds) to reduce the gain by 10dB,\r\n * default = .003, range 0 - 1\r\n * @param {Number} knee A decibel value representing the range above the\r\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\r\n * default = 30, range 0 - 40\r\n * @param {Number} ratio The amount of dB change in input for a 1 dB change in output\r\n * default = 12, range 1 - 20\r\n * @param {Number} threshold The decibel value above which the compression will start taking effect\r\n * default = -24, range -100 - 0\r\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\r\n * default = .25, range 0 - 1\r\n */\r\n p5.Compressor.prototype.set = function (attack, knee,\r\n ratio, threshold, release) {\r\n\r\n if (typeof attack !== 'undefined') {this.attack(attack);}\r\n if (typeof knee !== 'undefined') {this.knee(knee);}\r\n if (typeof ratio !== 'undefined') {this.ratio(ratio);}\r\n if (typeof threshold !== 'undefined') {this.threshold(threshold);}\r\n if (typeof release !== 'undefined') {this.release(release);}\r\n };\r\n\r\n\r\n /**\r\n * Get current attack or set value w/ time ramp\r\n *\r\n *\r\n * @method attack\r\n * @for p5.Compressor\r\n * @param {Number} [attack] Attack is the amount of time (in seconds) to reduce the gain by 10dB,\r\n * default = .003, range 0 - 1\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.attack = function (attack, time){\r\n var t = time || 0;\r\n if (typeof attack == 'number'){\r\n this.compressor.attack.value = attack;\r\n this.compressor.attack.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.attack.linearRampToValueAtTime(attack, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof attack !== 'undefined') {\r\n attack.connect(this.compressor.attack);\r\n }\r\n return this.compressor.attack.value;\r\n };\r\n\r\n\r\n /**\r\n * Get current knee or set value w/ time ramp\r\n *\r\n * @method knee\r\n * @for p5.Compressor\r\n * @param {Number} [knee] A decibel value representing the range above the\r\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\r\n * default = 30, range 0 - 40\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.knee = function (knee, time){\r\n var t = time || 0;\r\n if (typeof knee == 'number'){\r\n this.compressor.knee.value = knee;\r\n this.compressor.knee.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.knee.linearRampToValueAtTime(knee, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof knee !== 'undefined') {\r\n knee.connect(this.compressor.knee);\r\n }\r\n return this.compressor.knee.value;\r\n };\r\n\r\n\r\n /**\r\n * Get current ratio or set value w/ time ramp\r\n * @method ratio\r\n * @for p5.Compressor\r\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\r\n * default = 12, range 1 - 20\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.ratio = function (ratio, time){\r\n var t = time || 0;\r\n if (typeof ratio == 'number'){\r\n this.compressor.ratio.value = ratio;\r\n this.compressor.ratio.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.ratio.linearRampToValueAtTime(ratio, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof ratio !== 'undefined') {\r\n ratio.connect(this.compressor.ratio);\r\n }\r\n return this.compressor.ratio.value;\r\n };\r\n\r\n\r\n /**\r\n * Get current threshold or set value w/ time ramp\r\n * @method threshold\r\n * @for p5.Compressor\r\n * @param {Number} threshold The decibel value above which the compression will start taking effect\r\n * default = -24, range -100 - 0\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.threshold = function (threshold, time){\r\n var t = time || 0;\r\n if (typeof threshold == 'number'){\r\n this.compressor.threshold.value = threshold;\r\n this.compressor.threshold.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.threshold.linearRampToValueAtTime(threshold, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof threshold !== 'undefined') {\r\n threshold.connect(this.compressor.threshold);\r\n }\r\n return this.compressor.threshold.value;\r\n };\r\n\r\n\r\n /**\r\n * Get current release or set value w/ time ramp\r\n * @method release\r\n * @for p5.Compressor\r\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\r\n * default = .25, range 0 - 1\r\n *\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.release = function (release, time){\r\n var t = time || 0;\r\n if (typeof release == 'number'){\r\n this.compressor.release.value = release;\r\n this.compressor.release.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.release.linearRampToValueAtTime(release, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof number !== 'undefined') {\r\n release.connect(this.compressor.release);\r\n }\r\n return this.compressor.release.value;\r\n };\r\n\r\n /**\r\n * Return the current reduction value\r\n *\r\n * @method reduction\r\n * @for p5.Compressor\r\n * @return {Number} Value of the amount of gain reduction that is applied to the signal\r\n */\r\n p5.Compressor.prototype.reduction =function() {\r\n return this.compressor.reduction.value;\r\n };\r\n\r\n\r\n\tp5.Compressor.prototype.dispose = function() {\r\n Effect.prototype.dispose.apply(this);\r\n if (this.compressor) {\r\n this.compressor.disconnect();\r\n delete this.compressor;\r\n }\r\n\t};\r\n\r\n return p5.Compressor;\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n // inspiration: recorder.js, Tone.js & typedarray.org\r\n\r\n const p5sound = require('master');\r\n const { convertToWav, safeBufferSize } = require('helpers');\r\n const processorNames = require('./audioWorklet/processorNames');\r\n const ac = p5sound.audiocontext;\r\n\r\n /**\r\n *

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

\r\n *

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

\r\n *\r\n * @class p5.SoundRecorder\r\n * @constructor\r\n * @example\r\n *
\r\n * let mic, recorder, soundFile;\r\n * let state = 0;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(canvasPressed);\r\n * background(220);\r\n * textAlign(CENTER, CENTER);\r\n *\r\n * // create an audio in\r\n * mic = new p5.AudioIn();\r\n *\r\n * // prompts user to enable their browser mic\r\n * mic.start();\r\n *\r\n * // create a sound recorder\r\n * recorder = new p5.SoundRecorder();\r\n *\r\n * // connect the mic to the recorder\r\n * recorder.setInput(mic);\r\n *\r\n * // this sound file will be used to\r\n * // playback & save the recording\r\n * soundFile = new p5.SoundFile();\r\n *\r\n * text('tap to record', width/2, height/2);\r\n * }\r\n *\r\n * function canvasPressed() {\r\n * // ensure audio is enabled\r\n * userStartAudio();\r\n *\r\n * // make sure user enabled the mic\r\n * if (state === 0 && mic.enabled) {\r\n *\r\n * // record to our p5.SoundFile\r\n * recorder.record(soundFile);\r\n *\r\n * background(255,0,0);\r\n * text('Recording!', width/2, height/2);\r\n * state++;\r\n * }\r\n * else if (state === 1) {\r\n * background(0,255,0);\r\n *\r\n * // stop recorder and\r\n * // send result to soundFile\r\n * recorder.stop();\r\n *\r\n * text('Done! Tap to play and download', width/2, height/2, width - 20);\r\n * state++;\r\n * }\r\n *\r\n * else if (state === 2) {\r\n * soundFile.play(); // play the result!\r\n * save(soundFile, 'mySound.wav');\r\n * state++;\r\n * }\r\n * }\r\n *
\r\n */\r\n p5.SoundRecorder = function() {\r\n this.input = ac.createGain();\r\n this.output = ac.createGain();\r\n\r\n this._inputChannels = 2;\r\n this._outputChannels = 2; // stereo output, even if input is mono\r\n\r\n const workletBufferSize = safeBufferSize(1024);\r\n\r\n this._workletNode = new AudioWorkletNode(ac, processorNames.recorderProcessor, {\r\n outputChannelCount: [this._outputChannels],\r\n processorOptions: {\r\n numInputChannels: this._inputChannels,\r\n bufferSize: workletBufferSize\r\n }\r\n });\r\n\r\n this._workletNode.port.onmessage = function(event) {\r\n if (event.data.name === 'buffers') {\r\n const buffers = [\r\n new Float32Array(event.data.leftBuffer),\r\n new Float32Array(event.data.rightBuffer)\r\n ];\r\n this._callback(buffers);\r\n }\r\n }.bind(this);\r\n\r\n /**\r\n * callback invoked when the recording is over\r\n * @private\r\n * @type Function(Float32Array)\r\n */\r\n this._callback = function() {};\r\n\r\n // connections\r\n this._workletNode.connect(p5.soundOut._silentNode);\r\n this.setInput();\r\n\r\n // add this p5.SoundFile to the soundArray\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Connect a specific device to the p5.SoundRecorder.\r\n * If no parameter is given, p5.SoundRecorer will record\r\n * all audible p5.sound from your sketch.\r\n *\r\n * @method setInput\r\n * @for p5.SoundRecorder\r\n * @param {Object} [unit] p5.sound object or a web audio unit\r\n * that outputs sound\r\n */\r\n p5.SoundRecorder.prototype.setInput = function(unit) {\r\n this.input.disconnect();\r\n this.input = null;\r\n this.input = ac.createGain();\r\n this.input.connect(this._workletNode);\r\n this.input.connect(this.output);\r\n if (unit) {\r\n unit.connect(this.input);\r\n } else {\r\n p5.soundOut.output.connect(this.input);\r\n }\r\n };\r\n\r\n /**\r\n * Start recording. To access the recording, provide\r\n * a p5.SoundFile as the first parameter. The p5.SoundRecorder\r\n * will send its recording to that p5.SoundFile for playback once\r\n * recording is complete. Optional parameters include duration\r\n * (in seconds) of the recording, and a callback function that\r\n * will be called once the complete recording has been\r\n * transfered to the p5.SoundFile.\r\n *\r\n * @method record\r\n * @for p5.SoundRecorder\r\n * @param {p5.SoundFile} soundFile p5.SoundFile\r\n * @param {Number} [duration] Time (in seconds)\r\n * @param {Function} [callback] The name of a function that will be\r\n * called once the recording completes\r\n */\r\n p5.SoundRecorder.prototype.record = function(sFile, duration, callback) {\r\n this._workletNode.port.postMessage({ name: 'start', duration: duration });\r\n\r\n if (sFile && callback) {\r\n this._callback = function(buffer) {\r\n sFile.setBuffer(buffer);\r\n callback();\r\n };\r\n }\r\n else if (sFile) {\r\n this._callback = function(buffer) {\r\n sFile.setBuffer(buffer);\r\n };\r\n }\r\n };\r\n\r\n /**\r\n * Stop the recording. Once the recording is stopped,\r\n * the results will be sent to the p5.SoundFile that\r\n * was given on .record(), and if a callback function\r\n * was provided on record, that function will be called.\r\n *\r\n * @method stop\r\n * @for p5.SoundRecorder\r\n */\r\n p5.SoundRecorder.prototype.stop = function() {\r\n this._workletNode.port.postMessage({ name: 'stop' });\r\n };\r\n\r\n p5.SoundRecorder.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n\r\n this._callback = function() {};\r\n if (this.input) {\r\n this.input.disconnect();\r\n }\r\n this.input = null;\r\n this._workletNode = null;\r\n };\r\n\r\n\r\n /**\r\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\r\n * to download the file to their device.\r\n * For uploading audio to a server, use\r\n * `p5.SoundFile.saveBlob`.\r\n *\r\n * @for p5\r\n * @method saveSound\r\n * @param {p5.SoundFile} soundFile p5.SoundFile that you wish to save\r\n * @param {String} fileName name of the resulting .wav file.\r\n */\r\n // add to p5.prototype as this is used by the p5 `save()` method.\r\n p5.prototype.saveSound = function (soundFile, fileName) {\r\n const dataView = convertToWav(soundFile.buffer);\r\n p5.prototype.writeFile([dataView], fileName, 'wav');\r\n };\r\n});\r\n","'use strict';\r\n\r\ndefine(function () {\r\n /**\r\n *

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

\r\n *

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

\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n * @class p5.PeakDetect\r\n * @constructor\r\n * @param {Number} [freq1] lowFrequency - defaults to 20Hz\r\n * @param {Number} [freq2] highFrequency - defaults to 20000 Hz\r\n * @param {Number} [threshold] Threshold for detecting a beat between 0 and 1\r\n * scaled logarithmically where 0.1 is 1/2 the loudness\r\n * of 1.0. Defaults to 0.35.\r\n * @param {Number} [framesPerPeak] Defaults to 20.\r\n * @example\r\n *
\r\n *\r\n * var cnv, soundFile, fft, peakDetect;\r\n * var ellipseWidth = 10;\r\n *\r\n * function preload() {\r\n * soundFile = loadSound('assets/beat.mp3');\r\n * }\r\n *\r\n * function setup() {\r\n * background(0);\r\n * noStroke();\r\n * fill(255);\r\n * textAlign(CENTER);\r\n *\r\n * // p5.PeakDetect requires a p5.FFT\r\n * fft = new p5.FFT();\r\n * peakDetect = new p5.PeakDetect();\r\n * }\r\n *\r\n * function draw() {\r\n * background(0);\r\n * text('click to play/pause', width/2, height/2);\r\n *\r\n * // peakDetect accepts an fft post-analysis\r\n * fft.analyze();\r\n * peakDetect.update(fft);\r\n *\r\n * if ( peakDetect.isDetected ) {\r\n * ellipseWidth = 50;\r\n * } else {\r\n * ellipseWidth *= 0.95;\r\n * }\r\n *\r\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\r\n * }\r\n *\r\n * // toggle play/stop when canvas is clicked\r\n * function mouseClicked() {\r\n * if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\r\n * if (soundFile.isPlaying() ) {\r\n * soundFile.stop();\r\n * } else {\r\n * soundFile.play();\r\n * }\r\n * }\r\n * }\r\n *
\r\n */\r\n p5.PeakDetect = function(freq1, freq2, threshold, _framesPerPeak) {\r\n // framesPerPeak determines how often to look for a beat.\r\n // If a beat is provided, try to look for a beat based on bpm\r\n this.framesPerPeak = _framesPerPeak || 20;\r\n this.framesSinceLastPeak = 0;\r\n this.decayRate = 0.95;\r\n\r\n this.threshold = threshold || 0.35;\r\n this.cutoff = 0;\r\n\r\n // how much to increase the cutoff\r\n // TO DO: document this / figure out how to make it accessible\r\n this.cutoffMult = 1.5;\r\n\r\n this.energy = 0;\r\n this.penergy = 0;\r\n\r\n // TO DO: document this property / figure out how to make it accessible\r\n this.currentValue = 0;\r\n\r\n /**\r\n * isDetected is set to true when a peak is detected.\r\n *\r\n * @attribute isDetected {Boolean}\r\n * @default false\r\n */\r\n this.isDetected = false;\r\n\r\n this.f1 = freq1 || 40;\r\n this.f2 = freq2 || 20000;\r\n\r\n // function to call when a peak is detected\r\n this._onPeak = function() {};\r\n };\r\n\r\n\r\n /**\r\n * The update method is run in the draw loop.\r\n *\r\n * Accepts an FFT object. You must call .analyze()\r\n * on the FFT object prior to updating the peakDetect\r\n * because it relies on a completed FFT analysis.\r\n *\r\n * @method update\r\n * @param {p5.FFT} fftObject A p5.FFT object\r\n */\r\n p5.PeakDetect.prototype.update = function(fftObject) {\r\n var nrg = this.energy = fftObject.getEnergy(this.f1,this.f2)/255;\r\n if (nrg > this.cutoff && nrg > this.threshold && nrg-this.penergy > 0) {\r\n\r\n // trigger callback\r\n this._onPeak();\r\n this.isDetected = true;\r\n\r\n // debounce\r\n this.cutoff = nrg * this.cutoffMult;\r\n this.framesSinceLastPeak = 0;\r\n } else {\r\n this.isDetected = false;\r\n if (this.framesSinceLastPeak <= this.framesPerPeak) {\r\n this.framesSinceLastPeak++;\r\n } else {\r\n this.cutoff *= this.decayRate;\r\n this.cutoff = Math.max(this.cutoff, this.threshold);\r\n }\r\n }\r\n\r\n this.currentValue = nrg;\r\n this.penergy = nrg;\r\n };\r\n\r\n /**\r\n * onPeak accepts two arguments: a function to call when\r\n * a peak is detected. The value of the peak,\r\n * between 0.0 and 1.0, is passed to the callback.\r\n *\r\n * @method onPeak\r\n * @param {Function} callback Name of a function that will\r\n * be called when a peak is\r\n * detected.\r\n * @param {Object} [val] Optional value to pass\r\n * into the function when\r\n * a peak is detected.\r\n * @example\r\n *
\r\n * var cnv, soundFile, fft, peakDetect;\r\n * var ellipseWidth = 0;\r\n *\r\n * function preload() {\r\n * soundFile = loadSound('assets/beat.mp3');\r\n * }\r\n *\r\n * function setup() {\r\n * cnv = createCanvas(100,100);\r\n * textAlign(CENTER);\r\n *\r\n * fft = new p5.FFT();\r\n * peakDetect = new p5.PeakDetect();\r\n *\r\n * setupSound();\r\n *\r\n * // when a beat is detected, call triggerBeat()\r\n * peakDetect.onPeak(triggerBeat);\r\n * }\r\n *\r\n * function draw() {\r\n * background(0);\r\n * fill(255);\r\n * text('click to play', width/2, height/2);\r\n *\r\n * fft.analyze();\r\n * peakDetect.update(fft);\r\n *\r\n * ellipseWidth *= 0.95;\r\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\r\n * }\r\n *\r\n * // this function is called by peakDetect.onPeak\r\n * function triggerBeat() {\r\n * ellipseWidth = 50;\r\n * }\r\n *\r\n * // mouseclick starts/stops sound\r\n * function setupSound() {\r\n * cnv.mouseClicked( function() {\r\n * if (soundFile.isPlaying() ) {\r\n * soundFile.stop();\r\n * } else {\r\n * soundFile.play();\r\n * }\r\n * });\r\n * }\r\n *
\r\n */\r\n p5.PeakDetect.prototype.onPeak = function(callback, val) {\r\n var self = this;\r\n\r\n self._onPeak = function() {\r\n callback(self.energy, val);\r\n };\r\n };\r\n\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n\r\n /**\r\n * A gain node is usefull to set the relative volume of sound.\r\n * It's typically used to build mixers.\r\n *\r\n * @class p5.Gain\r\n * @constructor\r\n * @example\r\n *
\r\n *\r\n * // load two soundfile and crossfade beetween them\r\n * let sound1,sound2;\r\n * let sound1Gain, sound2Gain, masterGain;\r\n * function preload(){\r\n * soundFormats('ogg', 'mp3');\r\n * sound1 = loadSound('assets/Damscray_-_Dancing_Tiger_01');\r\n * sound2 = loadSound('assets/beat');\r\n * }\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(startSound);\r\n * // create a 'master' gain to which we will connect both soundfiles\r\n * masterGain = new p5.Gain();\r\n * masterGain.connect();\r\n * sound1.disconnect(); // diconnect from p5 output\r\n * sound1Gain = new p5.Gain(); // setup a gain node\r\n * sound1Gain.setInput(sound1); // connect the first sound to its input\r\n * sound1Gain.connect(masterGain); // connect its output to the 'master'\r\n * sound2.disconnect();\r\n * sound2Gain = new p5.Gain();\r\n * sound2Gain.setInput(sound2);\r\n * sound2Gain.connect(masterGain);\r\n * }\r\n * function startSound() {\r\n * sound1.loop();\r\n * sound2.loop();\r\n * loop();\r\n * }\r\n * function mouseReleased() {\r\n * sound1.stop();\r\n * sound2.stop();\r\n * }\r\n * function draw(){\r\n * background(220);\r\n * textAlign(CENTER);\r\n * textSize(11);\r\n * fill(0);\r\n * if (!sound1.isPlaying()) {\r\n * text('tap and drag to play', width/2, height/2);\r\n * return;\r\n * }\r\n * // map the horizontal position of the mouse to values useable for volume * control of sound1\r\n * var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);\r\n * var sound2Volume = 1-sound1Volume;\r\n * sound1Gain.amp(sound1Volume);\r\n * sound2Gain.amp(sound2Volume);\r\n * // map the vertical position of the mouse to values useable for 'master * volume control'\r\n * var masterVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\r\n * masterGain.amp(masterVolume);\r\n * text('master', width/2, height - masterVolume * height * 0.9)\r\n * fill(255, 0, 255);\r\n * textAlign(LEFT);\r\n * text('sound1', 5, height - sound1Volume * height * 0.9);\r\n * textAlign(RIGHT);\r\n * text('sound2', width - 5, height - sound2Volume * height * 0.9);\r\n * }\r\n *
\r\n */\r\n\r\n p5.Gain = function() {\r\n this.ac = p5sound.audiocontext;\r\n\r\n this.input = this.ac.createGain();\r\n this.output = this.ac.createGain();\r\n\r\n // otherwise, Safari distorts\r\n this.input.gain.value = 0.5;\r\n this.input.connect(this.output);\r\n\r\n // add to the soundArray\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Connect a source to the gain node.\r\n *\r\n * @method setInput\r\n * @for p5.Gain\r\n * @param {Object} src p5.sound / Web Audio object with a sound\r\n * output.\r\n */\r\n\r\n\r\n p5.Gain.prototype.setInput = function(src) {\r\n src.connect(this.input);\r\n };\r\n\r\n /**\r\n * Send output to a p5.sound or web audio object\r\n *\r\n * @method connect\r\n * @for p5.Gain\r\n * @param {Object} unit\r\n */\r\n p5.Gain.prototype.connect = function(unit) {\r\n var u = unit || p5.soundOut.input;\r\n this.output.connect(u.input ? u.input : u);\r\n };\r\n\r\n /**\r\n * Disconnect all output.\r\n *\r\n * @method disconnect\r\n * @for p5.Gain\r\n */\r\n p5.Gain.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n };\r\n\r\n /**\r\n * Set the output level of the gain node.\r\n *\r\n * @method amp\r\n * @for p5.Gain\r\n * @param {Number} volume amplitude between 0 and 1.0\r\n * @param {Number} [rampTime] create a fade that lasts rampTime\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n */\r\n p5.Gain.prototype.amp = function(vol, rampTime, tFromNow) {\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n var currentVol = this.output.gain.value;\r\n this.output.gain.cancelScheduledValues(now);\r\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\r\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\r\n };\r\n\r\n p5.Gain.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n if (this.output) {\r\n this.output.disconnect();\r\n delete this.output;\r\n }\r\n if (this.input) {\r\n this.input.disconnect();\r\n delete this.input;\r\n }\r\n };\r\n\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n var Effect = require('effect');\r\n\r\n /*\r\n * Adapted from [Kevin Ennis on StackOverflow](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\r\n */\r\n function makeDistortionCurve(amount) {\r\n var k = typeof amount === 'number' ? amount : 50;\r\n var numSamples = 44100;\r\n var curve = new Float32Array(numSamples);\r\n var deg = Math.PI / 180;\r\n var i = 0;\r\n var x;\r\n for ( ; i < numSamples; ++i ) {\r\n x = i * 2 / numSamples - 1;\r\n curve[i] = ( 3 + k ) * x * 20 * deg / ( Math.PI + k * Math.abs(x) );\r\n }\r\n return curve;\r\n }\r\n\r\n /**\r\n * A Distortion effect created with a Waveshaper Node,\r\n * with an approach adapted from\r\n * [Kevin Ennis](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.Distortion\r\n * @extends p5.Effect\r\n * @constructor\r\n * @param {Number} [amount=0.25] Unbounded distortion amount.\r\n * Normal values range from 0-1.\r\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\r\n *\r\n */\r\n p5.Distortion = function(amount, oversample) {\r\n Effect.call(this);\r\n\r\n if (typeof amount === 'undefined') {\r\n amount = 0.25;\r\n } if (typeof amount !== 'number') {\r\n throw new Error('amount must be a number');\r\n } if (typeof oversample === 'undefined') {\r\n oversample = '2x';\r\n } if (typeof oversample !== 'string') {\r\n throw new Error('oversample must be a String');\r\n }\r\n\r\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\r\n\r\n /**\r\n * The p5.Distortion is built with a\r\n * \r\n * Web Audio WaveShaper Node.\r\n *\r\n * @property {AudioNode} WaveShaperNode\r\n */\r\n this.waveShaperNode = this.ac.createWaveShaper();\r\n\r\n this.amount = curveAmount;\r\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\r\n this.waveShaperNode.oversample = oversample;\r\n\r\n this.input.connect(this.waveShaperNode);\r\n\r\n this.waveShaperNode.connect(this.wet);\r\n };\r\n\r\n p5.Distortion.prototype = Object.create(Effect.prototype);\r\n\r\n\r\n /**\r\n * Process a sound source, optionally specify amount and oversample values.\r\n *\r\n * @method process\r\n * @for p5.Distortion\r\n * @param {Number} [amount=0.25] Unbounded distortion amount.\r\n * Normal values range from 0-1.\r\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\r\n */\r\n p5.Distortion.prototype.process = function(src, amount, oversample) {\r\n src.connect(this.input);\r\n this.set(amount, oversample);\r\n };\r\n\r\n /**\r\n * Set the amount and oversample of the waveshaper distortion.\r\n *\r\n * @method set\r\n * @for p5.Distortion\r\n * @param {Number} [amount=0.25] Unbounded distortion amount.\r\n * Normal values range from 0-1.\r\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\r\n */\r\n p5.Distortion.prototype.set = function(amount, oversample) {\r\n if (amount) {\r\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\r\n this.amount = curveAmount;\r\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\r\n }\r\n if (oversample) {\r\n this.waveShaperNode.oversample = oversample;\r\n }\r\n };\r\n\r\n /**\r\n * Return the distortion amount, typically between 0-1.\r\n *\r\n * @method getAmount\r\n * @for p5.Distortion\r\n * @return {Number} Unbounded distortion amount.\r\n * Normal values range from 0-1.\r\n */\r\n p5.Distortion.prototype.getAmount = function() {\r\n return this.amount;\r\n };\r\n\r\n /**\r\n * Return the oversampling.\r\n *\r\n * @method getOversample\r\n * @for p5.Distortion\r\n * @return {String} Oversample can either be 'none', '2x', or '4x'.\r\n */\r\n p5.Distortion.prototype.getOversample = function() {\r\n return this.waveShaperNode.oversample;\r\n };\r\n\r\n\r\n p5.Distortion.prototype.dispose = function() {\r\n Effect.prototype.dispose.apply(this);\r\n if (this.waveShaperNode) {\r\n this.waveShaperNode.disconnect();\r\n this.waveShaperNode = null;\r\n }\r\n };\r\n});\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/lib/p5.sound.min.js b/lib/p5.sound.min.js index fe65a81f..3e34c40f 100644 --- a/lib/p5.sound.min.js +++ b/lib/p5.sound.min.js @@ -1,3 +1,3 @@ -/** [p5.sound] Version: 0.3.12 - 2020-01-06 */ - !function(n){var i={};function o(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,o),e.l=!0,e.exports}o.m=n,o.c=i,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=31)}([function(t,e,n){var i;void 0===(i=function(){"use strict";function c(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 o,r=this._events.getBefore(n.time);o=null===r?this._initial:r.value,i=this._exponentialApproach(n.time,o,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,o){return n+(e-n)*Math.exp(-(o-t)/i)},u.TimelineSignal.prototype._linearInterpolate=function(t,e,n,i,o){return e+(o-t)/(n-t)*(i-e)},u.TimelineSignal.prototype._exponentialInterpolate=function(t,e,n,i,o){return(e=Math.max(this._minOutput,e))*Math.pow(i/e,(o-t)/(n-t))},u.TimelineSignal.prototype._curveInterpolate=function(t,e,n,i){var o=e.length;if(t+n<=i)return e[o-1];if(i<=t)return e[0];var r=(i-t)/n,s=Math.floor((o-1)*r),a=Math.ceil((o-1)*r),u=e[s],p=e[a];return a===s?u:this._linearInterpolate(s,u,a,p,r*(o-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=o)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var e=n(4);return p5.Filter=function(t){e.call(this),this.biquad=this.ac.createBiquadFilter(),this.input.connect(this.biquad),this.biquad.connect(this.wet),t&&this.setType(t),this._on=!0,this._untoggledType=this.biquad.type},p5.Filter.prototype=Object.create(e.prototype),p5.Filter.prototype.process=function(t,e,n,i){t.connect(this.input),this.set(e,n,i)},p5.Filter.prototype.set=function(t,e,n){t&&this.freq(t,n),e&&this.res(e,n)},p5.Filter.prototype.freq=function(t,e){var n=e||0;return t<=0&&(t=1),"number"==typeof t?(this.biquad.frequency.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.frequency.exponentialRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.frequency),this.biquad.frequency.value},p5.Filter.prototype.res=function(t,e){var n=e||0;return"number"==typeof t?(this.biquad.Q.value=t,this.biquad.Q.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.Q.linearRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.Q),this.biquad.Q.value},p5.Filter.prototype.gain=function(t,e){var n=e||0;return"number"==typeof t?(this.biquad.gain.value=t,this.biquad.gain.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.gain.linearRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.gain),this.biquad.gain.value},p5.Filter.prototype.toggle=function(){return this._on=!this._on,!0===this._on?this.biquad.type=this._untoggledType:!1===this._on&&(this.biquad.type="allpass"),this._on},p5.Filter.prototype.setType=function(t){this.biquad.type=t,this._untoggledType=this.biquad.type},p5.Filter.prototype.dispose=function(){e.prototype.dispose.apply(this),this.biquad&&(this.biquad.disconnect(),delete this.biquad)},p5.LowPass=function(){p5.Filter.call(this,"lowpass")},p5.LowPass.prototype=Object.create(p5.Filter.prototype),p5.HighPass=function(){p5.Filter.call(this,"highpass")},p5.HighPass.prototype=Object.create(p5.Filter.prototype),p5.BandPass=function(){p5.Filter.call(this,"bandpass")},p5.BandPass.prototype=Object.create(p5.Filter.prototype),p5.Filter}.call(e,n,e,t))||(t.exports=i)},function(t,e,n){var i,o;i=[n(0),n(7),n(25),n(2),n(9)],void 0===(o=function(e){"use strict";return e.Subtract=function(t){this.createInsOuts(2,0),this._sum=this.input[0]=this.output=new e.Gain,this._neg=new e.Negate,this._param=this.input[1]=new e.Signal(t),this._param.chain(this._neg,this._sum)},e.extend(e.Subtract,e.Signal),e.Subtract.prototype.dispose=function(){return e.prototype.dispose.call(this),this._neg.dispose(),this._neg=null,this._sum.disconnect(),this._sum=null,this._param.dispose(),this._param=null,this},e.Subtract}.apply(e,i))||(t.exports=o)},function(i,o,r){"use strict";(function(t){var e,n;t.TONE_SILENCE_VERSION_LOGGING=!0,e=[r(35),r(12),r(0)],void 0===(n=function(i,t,e){var o=new window.AudioContext;return e.context.dispose(),e.setContext(o),p5.prototype.getAudioContext=function(){return o},p5.prototype.userStartAudio=function(t,e){var n=t;return t instanceof p5.Element?n=t.elt:t instanceof Array&&t[0]instanceof p5.Element&&(n=t.map(function(t){return t.elt})),i(o,n,e)},o}.apply(o,e))||(i.exports=n)}).call(this,r(34))},function(t,e,n){var i,o;i=[n(0)],void 0===(o=function(s){"use strict";return s.Emitter=function(){this._events={}},s.extend(s.Emitter),s.Emitter.prototype.on=function(t,e){for(var n=t.split(/\W+/),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 o;r.time>t?i=o:r.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=o)},function(t,e,n){var i,o;i=[n(0),n(3),n(2)],void 0===(o=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=o)},function(t,e,n){var i,o;i=[n(0),n(2),n(3),n(5)],void 0===(o=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=o)},function(t,e,n){var i,o;i=[n(0),n(14),n(66),n(18),n(12)],void 0===(o=function(o){"use strict";return o.Clock=function(){o.Emitter.call(this);var t=this.optionsObject(arguments,["callback","frequency"],o.Clock.defaults);this.callback=t.callback,this._nextTick=0,this._lastState=o.State.Stopped,this.frequency=new o.TimelineSignal(t.frequency,o.Type.Frequency),this._readOnly("frequency"),this.ticks=0,this._state=new o.TimelineState(o.State.Stopped),this._boundLoop=this._loop.bind(this),this.context.on("tick",this._boundLoop)},o.extend(o.Clock,o.Emitter),o.Clock.defaults={callback:o.noOp,frequency:1,lookAhead:"auto"},Object.defineProperty(o.Clock.prototype,"state",{get:function(){return this._state.getValueAtTime(this.now())}}),o.Clock.prototype.start=function(t,e){return t=this.toSeconds(t),this._state.getValueAtTime(t)!==o.State.Started&&this._state.add({state:o.State.Started,time:t,offset:e}),this},o.Clock.prototype.stop=function(t){return t=this.toSeconds(t),this._state.cancel(t),this._state.setStateAtTime(o.State.Stopped,t),this},o.Clock.prototype.pause=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)===o.State.Started&&this._state.setStateAtTime(o.State.Paused,t),this},o.Clock.prototype._loop=function(){for(var t=this.now()+this.context.lookAhead+this.context.updateInterval+2*this.context.lag;t>this._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===o.State.Started?(this._nextTick=n.time,this.isUndef(n.offset)||(this.ticks=n.offset),this.emit("start",n.time,this.ticks)):e===o.State.Stopped?(this.ticks=0,this.emit("stop",n.time)):e===o.State.Paused&&this.emit("pause",n.time)}var i=this._nextTick;this.frequency&&(this._nextTick+=1/this.frequency.getValueAtTime(this._nextTick),e===o.State.Started&&(this.callback(i),this.ticks++))}},o.Clock.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},o.Clock.prototype.dispose=function(){o.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},o.Clock}.apply(e,i))||(t.exports=o)},function(t,e,i){"use strict";var n;void 0===(n=function(t){var n=i(1),e=i(29),r=i(6).noteToFreq;p5.MonoSynth=function(){e.call(this),this.oscillator=new p5.Oscillator,this.env=new p5.Envelope,this.env.setRange(1,0),this.env.setExp(!0),this.setADSR(.02,.25,.05,.35),this.oscillator.disconnect(),this.oscillator.connect(this.output),this.env.disconnect(),this.env.setInput(this.output.gain),this.oscillator.output.gain.value=1,this.oscillator.start(),this.connect(),n.soundArray.push(this)},p5.MonoSynth.prototype=Object.create(p5.AudioVoice.prototype),p5.MonoSynth.prototype.play=function(t,e,n,i){this.triggerAttack(t,e,~~n),this.triggerRelease(~~n+(i||.15))},p5.MonoSynth.prototype.triggerAttack=function(t,e,n){n=~~n;var i=r(t),o=e||.1;this.oscillator.freq(i,0,n),this.env.ramp(this.output.gain,n,o)},p5.MonoSynth.prototype.triggerRelease=function(t){t=t||0;this.env.ramp(this.output.gain,t,0)},p5.MonoSynth.prototype.setADSR=function(t,e,n,i){this.env.setADSR(t,e,n,i)},Object.defineProperties(p5.MonoSynth.prototype,{attack:{get:function(){return this.env.aTime},set:function(t){this.env.setADSR(t,this.env.dTime,this.env.sPercent,this.env.rTime)}},decay:{get:function(){return this.env.dTime},set:function(t){this.env.setADSR(this.env.aTime,t,this.env.sPercent,this.env.rTime)}},sustain:{get:function(){return this.env.sPercent},set:function(t){this.env.setADSR(this.env.aTime,this.env.dTime,t,this.env.rTime)}},release:{get:function(){return this.env.rTime},set:function(t){this.env.setADSR(this.env.aTime,this.env.dTime,this.env.sPercent,t)}}}),p5.MonoSynth.prototype.amp=function(t,e){var n=e||0;return void 0!==t&&this.oscillator.amp(t,n),this.oscillator.amp().value},p5.MonoSynth.prototype.connect=function(t){var e=t||n.input;this.output.connect(e.input?e.input:e)},p5.MonoSynth.prototype.disconnect=function(){this.output&&this.output.disconnect()},p5.MonoSynth.prototype.dispose=function(){e.prototype.dispose.apply(this),this.env&&this.env.dispose(),this.oscillator&&this.oscillator.dispose()}}.call(e,i,e,t))||(t.exports=n)},function(t,e,i){"use strict";var n;void 0===(n=function(){var n=i(1);return p5.AudioVoice=function(){this.ac=n.audiocontext,this.output=this.ac.createGain(),this.connect(),n.soundArray.push(this)},p5.AudioVoice.prototype.play=function(t,e,n,i){},p5.AudioVoice.prototype.triggerAttack=function(t,e,n){},p5.AudioVoice.prototype.triggerRelease=function(t){},p5.AudioVoice.prototype.amp=function(t,e){},p5.AudioVoice.prototype.connect=function(t){var e=t||n.input;this.output.connect(e.input?e.input:e)},p5.AudioVoice.prototype.disconnect=function(){this.output.disconnect()},p5.AudioVoice.prototype.dispose=function(){this.output&&(this.output.disconnect(),delete this.output)},p5.AudioVoice}.call(e,i,e,t))||(t.exports=n)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var c=n(1),h=n(14),l=n(6).noteToFreq;p5.PolySynth=function(t,e){this.audiovoices=[],this.notes={},this._newest=0,this._oldest=0,this.maxVoices=e||8,this.AudioVoice=void 0===t?p5.MonoSynth:t,this._voicesInUse=new h(0),this.output=c.audiocontext.createGain(),this.connect(),this._allocateVoices(),c.soundArray.push(this)},p5.PolySynth.prototype._allocateVoices=function(){for(var t=0;t= 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].length;\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].length;\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){"use strict";var i;function o(t){return(o="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)}void 0===(i=function(t){var a=n(1).audiocontext;void 0!==a.createStereoPanner?(p5.Panner=function(t,e){this.stereoPanner=this.input=a.createStereoPanner(),t.connect(this.stereoPanner),this.stereoPanner.connect(e)},p5.Panner.prototype.pan=function(t,e){var n=e||0,i=a.currentTime+n;this.stereoPanner.pan.linearRampToValueAtTime(t,i)},p5.Panner.prototype.inputChannels=function(){},p5.Panner.prototype.connect=function(t){this.stereoPanner.connect(t)},p5.Panner.prototype.disconnect=function(){this.stereoPanner&&this.stereoPanner.disconnect()}):(p5.Panner=function(t,e,n){this.input=a.createGain(),t.connect(this.input),this.left=a.createGain(),this.right=a.createGain(),this.left.channelInterpretation="discrete",this.right.channelInterpretation="discrete",1this.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))},p5.SoundFile.prototype.channels=function(){return this.buffer.numberOfChannels},p5.SoundFile.prototype.sampleRate=function(){return this.buffer.sampleRate},p5.SoundFile.prototype.frames=function(){return this.buffer.length},p5.SoundFile.prototype.getPeaks=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,o=e.numberOfChannels,r=new Float32Array(Math.round(t)),s=0;sr[u])&&(r[u]=h)}return r}},p5.SoundFile.prototype.reverseBuffer=function(){if(!this.buffer)throw"SoundFile is not done loading";var t=this._lastPos/p.sampleRate,e=this.getVolume();this.setVolume(0,.001);for(var n=this.buffer.numberOfChannels,i=0;ie){var r=t[o],s=new c(r,o);n[o]=s,o+=6e3}o++}return n}function m(t){if(isFinite(t)&&0!==t){for(;t<90;)t*=2;for(;180t[r].hi&&r++,o[r]=void 0!==o[r]?(o[r]+n[s])/2:n[s]}return o},p5.FFT.prototype.getOctaveBands=function(t,e){t=t||3;var n=[],i={lo:(e=e||15.625)/Math.pow(2,1/(2*t)),ctr:e,hi:e*Math.pow(2,1/(2*t))};n.push(i);for(var o=c.audiocontext.sampleRate/2;i.hi=this._maxDelay)throw new Error("Delay Time exceeds maximum delay time of "+this._maxDelay+" second.");t.connect(this.input),this.leftDelay.delayTime.setValueAtTime(r,this.ac.currentTime),this.rightDelay.delayTime.setValueAtTime(r,this.ac.currentTime),this._leftGain.gain.value=o,this._rightGain.gain.value=o,i&&(this._leftFilter.freq(i),this._rightFilter.freq(i))},p5.Delay.prototype.delayTime=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))},p5.Delay.prototype.feedback=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},p5.Delay.prototype.filter=function(t,e){this._leftFilter.set(t,e),this._rightFilter.set(t,e)},p5.Delay.prototype.setType=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)}},p5.Delay.prototype.dispose=function(){n.prototype.dispose.apply(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}}.call(e,i,e,t))||(t.exports=n)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var p=n(11),e=n(4);p5.Reverb=function(){e.call(this),this._initConvolverNode(),this.input.gain.value=.5,this._seconds=3,this._decay=2,this._reverse=!1,this._buildImpulse()},p5.Reverb.prototype=Object.create(e.prototype),p5.Reverb.prototype._initConvolverNode=function(){this.convolverNode=this.ac.createConvolver(),this.input.connect(this.convolverNode),this.convolverNode.connect(this.wet)},p5.Reverb.prototype._teardownConvolverNode=function(){this.convolverNode&&(this.convolverNode.disconnect(),delete this.convolverNode)},p5.Reverb.prototype._setBuffer=function(t){this._teardownConvolverNode(),this._initConvolverNode(),this.convolverNode.buffer=t},p5.Reverb.prototype.process=function(t,e,n,i){t.connect(this.input);var o=!1;e&&(this._seconds=e,o=!0),n&&(this._decay=n),i&&(this._reverse=i),o&&this._buildImpulse()},p5.Reverb.prototype.set=function(t,e,n){var i=!1;t&&(this._seconds=t,i=!0),e&&(this._decay=e),n&&(this._reverse=n),i&&this._buildImpulse()},p5.Reverb.prototype._buildImpulse=function(){var t,e,n=this.ac.sampleRate,i=n*this._seconds,o=this._decay,r=this.ac.createBuffer(2,i,n),s=r.getChannelData(0),a=r.getChannelData(1);for(e=0;e=t.parts.length?(t.scoreStep=0,t.onended()):(t.scoreStep=0,t.parts[t.currentPart-1].stop(),t.parts[t.currentPart].start())}p5.prototype.setBPM=function(t,e){for(var n in o=t,i.parts)i.parts[n]&&i.parts[n].setBPM(t,e)},p5.Phrase=function(t,e,n){this.phraseStep=0,this.name=t,this.callback=e,this.sequence=n},p5.Part=function(t,e){this.length=t||0,this.partStep=0,this.phrases=[],this.isPlaying=!1,this.noLoop(),this.tatums=e||.0625,this.metro=new p5.Metro,this.metro._init(),this.metro.beatLength(this.tatums),this.metro.setBPM(o),i.parts.push(this),this.callback=function(){}},p5.Part.prototype.setBPM=function(t,e){this.metro.setBPM(t,e)},p5.Part.prototype.getBPM=function(){return this.metro.getBPM()},p5.Part.prototype.start=function(t){if(!this.isPlaying){this.isPlaying=!0,this.metro.resetSync(this);var e=t||0;this.metro.start(e)}},p5.Part.prototype.loop=function(t){this.looping=!0,this.onended=function(){this.partStep=0};var e=t||0;this.start(e)},p5.Part.prototype.noLoop=function(){this.looping=!1,this.onended=function(){this.stop()}},p5.Part.prototype.stop=function(t){this.partStep=0,this.pause(t)},p5.Part.prototype.pause=function(t){this.isPlaying=!1;var e=t||0;this.metro.stop(e)},p5.Part.prototype.addPhrase=function(t,e,n){var i;if(3===arguments.length)i=new p5.Phrase(t,e,n);else{if(!(t instanceof p5.Phrase))throw"invalid input. addPhrase accepts name, callback, array or a p5.Phrase";i=t}this.phrases.push(i),i.sequence.length>this.length&&(this.length=i.sequence.length)},p5.Part.prototype.removePhrase=function(t){for(var e in this.phrases)this.phrases[e].name===t&&this.phrases.splice(e,1)},p5.Part.prototype.getPhrase=function(t){for(var e in this.phrases)if(this.phrases[e].name===t)return this.phrases[e]},p5.Part.prototype.replaceSequence=function(t,e){for(var n in this.phrases)this.phrases[n].name===t&&(this.phrases[n].sequence=e)},p5.Part.prototype.incrementStep=function(t){this.partStepthis.cutoff&&e>this.threshold&&0t)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 o,r=this._events.getBefore(n.time);o=null===r?this._initial:r.value,i=this._exponentialApproach(n.time,o,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,o){return n+(e-n)*Math.exp(-(o-t)/i)},u.TimelineSignal.prototype._linearInterpolate=function(t,e,n,i,o){return e+(o-t)/(n-t)*(i-e)},u.TimelineSignal.prototype._exponentialInterpolate=function(t,e,n,i,o){return(e=Math.max(this._minOutput,e))*Math.pow(i/e,(o-t)/(n-t))},u.TimelineSignal.prototype._curveInterpolate=function(t,e,n,i){var o=e.length;if(t+n<=i)return e[o-1];if(i<=t)return e[0];var r=(i-t)/n,s=Math.floor((o-1)*r),a=Math.ceil((o-1)*r),u=e[s],p=e[a];return a===s?u:this._linearInterpolate(s,u,a,p,r*(o-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=o)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var e=n(4);return p5.Filter=function(t){e.call(this),this.biquad=this.ac.createBiquadFilter(),this.input.connect(this.biquad),this.biquad.connect(this.wet),t&&this.setType(t),this._on=!0,this._untoggledType=this.biquad.type},p5.Filter.prototype=Object.create(e.prototype),p5.Filter.prototype.process=function(t,e,n,i){t.connect(this.input),this.set(e,n,i)},p5.Filter.prototype.set=function(t,e,n){t&&this.freq(t,n),e&&this.res(e,n)},p5.Filter.prototype.freq=function(t,e){var n=e||0;return t<=0&&(t=1),"number"==typeof t?(this.biquad.frequency.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.frequency.exponentialRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.frequency),this.biquad.frequency.value},p5.Filter.prototype.res=function(t,e){var n=e||0;return"number"==typeof t?(this.biquad.Q.value=t,this.biquad.Q.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.Q.linearRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.Q),this.biquad.Q.value},p5.Filter.prototype.gain=function(t,e){var n=e||0;return"number"==typeof t?(this.biquad.gain.value=t,this.biquad.gain.cancelScheduledValues(this.ac.currentTime+.01+n),this.biquad.gain.linearRampToValueAtTime(t,this.ac.currentTime+.02+n)):t&&t.connect(this.biquad.gain),this.biquad.gain.value},p5.Filter.prototype.toggle=function(){return this._on=!this._on,!0===this._on?this.biquad.type=this._untoggledType:!1===this._on&&(this.biquad.type="allpass"),this._on},p5.Filter.prototype.setType=function(t){this.biquad.type=t,this._untoggledType=this.biquad.type},p5.Filter.prototype.dispose=function(){e.prototype.dispose.apply(this),this.biquad&&(this.biquad.disconnect(),delete this.biquad)},p5.LowPass=function(){p5.Filter.call(this,"lowpass")},p5.LowPass.prototype=Object.create(p5.Filter.prototype),p5.HighPass=function(){p5.Filter.call(this,"highpass")},p5.HighPass.prototype=Object.create(p5.Filter.prototype),p5.BandPass=function(){p5.Filter.call(this,"bandpass")},p5.BandPass.prototype=Object.create(p5.Filter.prototype),p5.Filter}.call(e,n,e,t))||(t.exports=i)},function(t,e,n){var i,o;i=[n(0),n(7),n(25),n(2),n(9)],void 0===(o=function(e){"use strict";return e.Subtract=function(t){this.createInsOuts(2,0),this._sum=this.input[0]=this.output=new e.Gain,this._neg=new e.Negate,this._param=this.input[1]=new e.Signal(t),this._param.chain(this._neg,this._sum)},e.extend(e.Subtract,e.Signal),e.Subtract.prototype.dispose=function(){return e.prototype.dispose.call(this),this._neg.dispose(),this._neg=null,this._sum.disconnect(),this._sum=null,this._param.dispose(),this._param=null,this},e.Subtract}.apply(e,i))||(t.exports=o)},function(i,o,r){"use strict";(function(t){var e,n;t.TONE_SILENCE_VERSION_LOGGING=!0,e=[r(35),r(12),r(0)],void 0===(n=function(i,t,e){var o=new window.AudioContext;return e.context.dispose(),e.setContext(o),p5.prototype.getAudioContext=function(){return o},p5.prototype.userStartAudio=function(t,e){var n=t;return t instanceof p5.Element?n=t.elt:t instanceof Array&&t[0]instanceof p5.Element&&(n=t.map(function(t){return t.elt})),i(o,n,e)},o}.apply(o,e))||(i.exports=n)}).call(this,r(34))},function(t,e,n){var i,o;i=[n(0)],void 0===(o=function(s){"use strict";return s.Emitter=function(){this._events={}},s.extend(s.Emitter),s.Emitter.prototype.on=function(t,e){for(var n=t.split(/\W+/),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 o;r.time>t?i=o:r.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=o)},function(t,e,n){var i,o;i=[n(0),n(3),n(2)],void 0===(o=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=o)},function(t,e,n){var i,o;i=[n(0),n(2),n(3),n(5)],void 0===(o=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=o)},function(t,e,n){var i,o;i=[n(0),n(14),n(66),n(18),n(12)],void 0===(o=function(o){"use strict";return o.Clock=function(){o.Emitter.call(this);var t=this.optionsObject(arguments,["callback","frequency"],o.Clock.defaults);this.callback=t.callback,this._nextTick=0,this._lastState=o.State.Stopped,this.frequency=new o.TimelineSignal(t.frequency,o.Type.Frequency),this._readOnly("frequency"),this.ticks=0,this._state=new o.TimelineState(o.State.Stopped),this._boundLoop=this._loop.bind(this),this.context.on("tick",this._boundLoop)},o.extend(o.Clock,o.Emitter),o.Clock.defaults={callback:o.noOp,frequency:1,lookAhead:"auto"},Object.defineProperty(o.Clock.prototype,"state",{get:function(){return this._state.getValueAtTime(this.now())}}),o.Clock.prototype.start=function(t,e){return t=this.toSeconds(t),this._state.getValueAtTime(t)!==o.State.Started&&this._state.add({state:o.State.Started,time:t,offset:e}),this},o.Clock.prototype.stop=function(t){return t=this.toSeconds(t),this._state.cancel(t),this._state.setStateAtTime(o.State.Stopped,t),this},o.Clock.prototype.pause=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)===o.State.Started&&this._state.setStateAtTime(o.State.Paused,t),this},o.Clock.prototype._loop=function(){for(var t=this.now()+this.context.lookAhead+this.context.updateInterval+2*this.context.lag;t>this._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===o.State.Started?(this._nextTick=n.time,this.isUndef(n.offset)||(this.ticks=n.offset),this.emit("start",n.time,this.ticks)):e===o.State.Stopped?(this.ticks=0,this.emit("stop",n.time)):e===o.State.Paused&&this.emit("pause",n.time)}var i=this._nextTick;this.frequency&&(this._nextTick+=1/this.frequency.getValueAtTime(this._nextTick),e===o.State.Started&&(this.callback(i),this.ticks++))}},o.Clock.prototype.getStateAtTime=function(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)},o.Clock.prototype.dispose=function(){o.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},o.Clock}.apply(e,i))||(t.exports=o)},function(t,e,i){"use strict";var n;void 0===(n=function(t){var n=i(1),e=i(29),r=i(6).noteToFreq;p5.MonoSynth=function(){e.call(this),this.oscillator=new p5.Oscillator,this.env=new p5.Envelope,this.env.setRange(1,0),this.env.setExp(!0),this.setADSR(.02,.25,.05,.35),this.oscillator.disconnect(),this.oscillator.connect(this.output),this.env.disconnect(),this.env.setInput(this.output.gain),this.oscillator.output.gain.value=1,this.oscillator.start(),this.connect(),n.soundArray.push(this)},p5.MonoSynth.prototype=Object.create(p5.AudioVoice.prototype),p5.MonoSynth.prototype.play=function(t,e,n,i){this.triggerAttack(t,e,~~n),this.triggerRelease(~~n+(i||.15))},p5.MonoSynth.prototype.triggerAttack=function(t,e,n){n=~~n;var i=r(t),o=e||.1;this.oscillator.freq(i,0,n),this.env.ramp(this.output.gain,n,o)},p5.MonoSynth.prototype.triggerRelease=function(t){t=t||0;this.env.ramp(this.output.gain,t,0)},p5.MonoSynth.prototype.setADSR=function(t,e,n,i){this.env.setADSR(t,e,n,i)},Object.defineProperties(p5.MonoSynth.prototype,{attack:{get:function(){return this.env.aTime},set:function(t){this.env.setADSR(t,this.env.dTime,this.env.sPercent,this.env.rTime)}},decay:{get:function(){return this.env.dTime},set:function(t){this.env.setADSR(this.env.aTime,t,this.env.sPercent,this.env.rTime)}},sustain:{get:function(){return this.env.sPercent},set:function(t){this.env.setADSR(this.env.aTime,this.env.dTime,t,this.env.rTime)}},release:{get:function(){return this.env.rTime},set:function(t){this.env.setADSR(this.env.aTime,this.env.dTime,this.env.sPercent,t)}}}),p5.MonoSynth.prototype.amp=function(t,e){var n=e||0;return void 0!==t&&this.oscillator.amp(t,n),this.oscillator.amp().value},p5.MonoSynth.prototype.connect=function(t){var e=t||n.input;this.output.connect(e.input?e.input:e)},p5.MonoSynth.prototype.disconnect=function(){this.output&&this.output.disconnect()},p5.MonoSynth.prototype.dispose=function(){e.prototype.dispose.apply(this),this.env&&this.env.dispose(),this.oscillator&&this.oscillator.dispose()}}.call(e,i,e,t))||(t.exports=n)},function(t,e,i){"use strict";var n;void 0===(n=function(){var n=i(1);return p5.AudioVoice=function(){this.ac=n.audiocontext,this.output=this.ac.createGain(),this.connect(),n.soundArray.push(this)},p5.AudioVoice.prototype.play=function(t,e,n,i){},p5.AudioVoice.prototype.triggerAttack=function(t,e,n){},p5.AudioVoice.prototype.triggerRelease=function(t){},p5.AudioVoice.prototype.amp=function(t,e){},p5.AudioVoice.prototype.connect=function(t){var e=t||n.input;this.output.connect(e.input?e.input:e)},p5.AudioVoice.prototype.disconnect=function(){this.output.disconnect()},p5.AudioVoice.prototype.dispose=function(){this.output&&(this.output.disconnect(),delete this.output)},p5.AudioVoice}.call(e,i,e,t))||(t.exports=n)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var c=n(1),h=n(14),l=n(6).noteToFreq;p5.PolySynth=function(t,e){this.audiovoices=[],this.notes={},this._newest=0,this._oldest=0,this.maxVoices=e||8,this.AudioVoice=void 0===t?p5.MonoSynth:t,this._voicesInUse=new h(0),this.output=c.audiocontext.createGain(),this.connect(),this._allocateVoices(),c.soundArray.push(this)},p5.PolySynth.prototype._allocateVoices=function(){for(var t=0;t= 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].length;\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].length;\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){"use strict";var i;function o(t){return(o="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)}void 0===(i=function(t){var a=n(1).audiocontext;void 0!==a.createStereoPanner?(p5.Panner=function(t,e){this.stereoPanner=this.input=a.createStereoPanner(),t.connect(this.stereoPanner),this.stereoPanner.connect(e)},p5.Panner.prototype.pan=function(t,e){var n=e||0,i=a.currentTime+n;this.stereoPanner.pan.linearRampToValueAtTime(t,i)},p5.Panner.prototype.inputChannels=function(){},p5.Panner.prototype.connect=function(t){this.stereoPanner.connect(t)},p5.Panner.prototype.disconnect=function(){this.stereoPanner&&this.stereoPanner.disconnect()}):(p5.Panner=function(t,e,n){this.input=a.createGain(),t.connect(this.input),this.left=a.createGain(),this.right=a.createGain(),this.left.channelInterpretation="discrete",this.right.channelInterpretation="discrete",1this.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))},p5.SoundFile.prototype.channels=function(){return this.buffer.numberOfChannels},p5.SoundFile.prototype.sampleRate=function(){return this.buffer.sampleRate},p5.SoundFile.prototype.frames=function(){return this.buffer.length},p5.SoundFile.prototype.getPeaks=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,o=e.numberOfChannels,r=new Float32Array(Math.round(t)),s=0;sr[u])&&(r[u]=h)}return r}},p5.SoundFile.prototype.reverseBuffer=function(){if(!this.buffer)throw"SoundFile is not done loading";var t=this._lastPos/p.sampleRate,e=this.getVolume();this.setVolume(0,.001);for(var n=this.buffer.numberOfChannels,i=0;ie){var r=t[o],s=new c(r,o);n[o]=s,o+=6e3}o++}return n}function m(t){if(isFinite(t)&&0!==t){for(;t<90;)t*=2;for(;180t[r].hi&&r++,o[r]=void 0!==o[r]?(o[r]+n[s])/2:n[s]}return o},p5.FFT.prototype.getOctaveBands=function(t,e){t=t||3;var n=[],i={lo:(e=e||15.625)/Math.pow(2,1/(2*t)),ctr:e,hi:e*Math.pow(2,1/(2*t))};n.push(i);for(var o=c.audiocontext.sampleRate/2;i.hi=this._maxDelay)throw new Error("Delay Time exceeds maximum delay time of "+this._maxDelay+" second.");t.connect(this.input),this.leftDelay.delayTime.setValueAtTime(r,this.ac.currentTime),this.rightDelay.delayTime.setValueAtTime(r,this.ac.currentTime),this._leftGain.gain.value=o,this._rightGain.gain.value=o,i&&(this._leftFilter.freq(i),this._rightFilter.freq(i))},p5.Delay.prototype.delayTime=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))},p5.Delay.prototype.feedback=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},p5.Delay.prototype.filter=function(t,e){this._leftFilter.set(t,e),this._rightFilter.set(t,e)},p5.Delay.prototype.setType=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)}},p5.Delay.prototype.dispose=function(){n.prototype.dispose.apply(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}}.call(e,i,e,t))||(t.exports=n)},function(t,e,n){"use strict";var i;void 0===(i=function(t){var p=n(11),e=n(4);p5.Reverb=function(){e.call(this),this._initConvolverNode(),this.input.gain.value=.5,this._seconds=3,this._decay=2,this._reverse=!1,this._buildImpulse()},p5.Reverb.prototype=Object.create(e.prototype),p5.Reverb.prototype._initConvolverNode=function(){this.convolverNode=this.ac.createConvolver(),this.input.connect(this.convolverNode),this.convolverNode.connect(this.wet)},p5.Reverb.prototype._teardownConvolverNode=function(){this.convolverNode&&(this.convolverNode.disconnect(),delete this.convolverNode)},p5.Reverb.prototype._setBuffer=function(t){this._teardownConvolverNode(),this._initConvolverNode(),this.convolverNode.buffer=t},p5.Reverb.prototype.process=function(t,e,n,i){t.connect(this.input);var o=!1;e&&(this._seconds=e,o=!0),n&&(this._decay=n),i&&(this._reverse=i),o&&this._buildImpulse()},p5.Reverb.prototype.set=function(t,e,n){var i=!1;t&&(this._seconds=t,i=!0),e&&(this._decay=e),n&&(this._reverse=n),i&&this._buildImpulse()},p5.Reverb.prototype._buildImpulse=function(){var t,e,n=this.ac.sampleRate,i=n*this._seconds,o=this._decay,r=this.ac.createBuffer(2,i,n),s=r.getChannelData(0),a=r.getChannelData(1);for(e=0;e=t.parts.length?(t.scoreStep=0,t.onended()):(t.scoreStep=0,t.parts[t.currentPart-1].stop(),t.parts[t.currentPart].start())}p5.prototype.setBPM=function(t,e){for(var n in o=t,i.parts)i.parts[n]&&i.parts[n].setBPM(t,e)},p5.Phrase=function(t,e,n){this.phraseStep=0,this.name=t,this.callback=e,this.sequence=n},p5.Part=function(t,e){this.length=t||0,this.partStep=0,this.phrases=[],this.isPlaying=!1,this.noLoop(),this.tatums=e||.0625,this.metro=new p5.Metro,this.metro._init(),this.metro.beatLength(this.tatums),this.metro.setBPM(o),i.parts.push(this),this.callback=function(){}},p5.Part.prototype.setBPM=function(t,e){this.metro.setBPM(t,e)},p5.Part.prototype.getBPM=function(){return this.metro.getBPM()},p5.Part.prototype.start=function(t){if(!this.isPlaying){this.isPlaying=!0,this.metro.resetSync(this);var e=t||0;this.metro.start(e)}},p5.Part.prototype.loop=function(t){this.looping=!0,this.onended=function(){this.partStep=0};var e=t||0;this.start(e)},p5.Part.prototype.noLoop=function(){this.looping=!1,this.onended=function(){this.stop()}},p5.Part.prototype.stop=function(t){this.partStep=0,this.pause(t)},p5.Part.prototype.pause=function(t){this.isPlaying=!1;var e=t||0;this.metro.stop(e)},p5.Part.prototype.addPhrase=function(t,e,n){var i;if(3===arguments.length)i=new p5.Phrase(t,e,n);else{if(!(t instanceof p5.Phrase))throw"invalid input. addPhrase accepts name, callback, array or a p5.Phrase";i=t}this.phrases.push(i),i.sequence.length>this.length&&(this.length=i.sequence.length)},p5.Part.prototype.removePhrase=function(t){for(var e in this.phrases)this.phrases[e].name===t&&this.phrases.splice(e,1)},p5.Part.prototype.getPhrase=function(t){for(var e in this.phrases)if(this.phrases[e].name===t)return this.phrases[e]},p5.Part.prototype.replaceSequence=function(t,e){for(var n in this.phrases)this.phrases[n].name===t&&(this.phrases[n].sequence=e)},p5.Part.prototype.incrementStep=function(t){this.partStepthis.cutoff&&e>this.threshold&&0 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","'use strict';\n\n\ndefine(['audiocontext'], function (audiocontext) {\n // Master contains the master sound output.\n var Master = function() {\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 // create a single instance of the p5Sound / master output for use within this sketch\n var 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 */\n p5.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 */\n p5.prototype.masterVolume = function(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 = 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 }\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 */\n p5.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\n p5.soundOut._silentNode = p5sound.audiocontext.createGain();\n p5.soundOut._silentNode.gain.value = 0;\n p5.soundOut._silentNode.connect(p5sound.audiocontext.destination);\n\n\n return p5sound;\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});","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","'use strict';\ndefine(function (require) {\n\n var p5sound = require('master');\n var CrossFade = require('Tone/component/CrossFade');\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 */\n p5.Effect = function() {\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 p5.Effect.prototype.amp = function(vol, rampTime, tFromNow){\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);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow + .001);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime + .001);\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 p5.Effect.prototype.chain = function(){\n if (arguments.length>0){\n this.connect(arguments[0]);\n for(var i=1;i\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 */\n var midiToFreq = p5.prototype.midiToFreq = function(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\n var noteToFreq = function(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 p5.prototype.soundFormats = function() {\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\n p5.prototype.disposeSound = function() {\n for (var i = 0; i < p5sound.soundArray.length; i++) {\n p5sound.soundArray[i].dispose();\n }\n };\n\n // register removeSound to dispose of p5sound SoundFiles, Convolvers,\n // Oscillators etc when sketch ends\n p5.prototype.registerMethod('remove', p5.prototype.disposeSound);\n\n p5.prototype._checkFileFormats = function(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 path = path;\n }\n else {\n var pathSplit = path.split('.');\n var pathCore = pathSplit[pathSplit.length - 1];\n for (var i = 0; i 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\n function 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\n function 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\n function 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(p5sound.audiocontext, processorNames.soundFileProcessor);\n if (tempAudioWorkletNode instanceof ScriptProcessorNode) {\n bufferSize = tempAudioWorkletNode.bufferSize;\n }\n tempAudioWorkletNode.disconnect();\n tempAudioWorkletNode = null;\n\n return bufferSize;\n }\n\n return {\n convertToWav: convertToWav,\n midiToFreq: midiToFreq,\n noteToFreq: noteToFreq,\n safeBufferSize: safeBufferSize\n };\n\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 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});","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});","module.exports = {\n recorderProcessor: 'recorder-processor',\n soundFileProcessor: 'sound-file-processor',\n amplitudeProcessor: 'amplitude-processor'\n};\n","'use strict';\n\ndefine(function () {\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 */\n var 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 var splitStack = tempStack.split('\\n');\n splitStack = splitStack.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 };\n\n return CustomError;\n});\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/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/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});","'use strict';\n\ndefine(function (require) {\n var Effect = require('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 */\n p5.Filter = function (type) {\n\n Effect.call(this);\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\t */\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 p5.Filter.prototype = Object.create(Effect.prototype);\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 p5.Filter.prototype.process = function(src, freq, res, time) {\n src.connect(this.input);\n this.set(freq, res, time);\n };\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 p5.Filter.prototype.set = function(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 p5.Filter.prototype.freq = function(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(this.ac.currentTime + 0.01 + t);\n this.biquad.frequency.exponentialRampToValueAtTime(freq, this.ac.currentTime + 0.02 + t);\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 p5.Filter.prototype.res = function(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(res, this.ac.currentTime + 0.02 + t);\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 p5.Filter.prototype.gain = function(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(gain, this.ac.currentTime + 0.02 + t);\n } else if (gain) {\n gain.connect(this.biquad.gain);\n }\n return this.biquad.gain.value;\n };\n\n\n /**\n * Toggle function. Switches between the specified type and allpass\n *\n * @method toggle\n * @return {boolean} [Toggle value]\n */\n p5.Filter.prototype.toggle = function() {\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 p5.Filter.prototype.setType = function(t) {\n this.biquad.type = t;\n this._untoggledType = this.biquad.type;\n };\n\n p5.Filter.prototype.dispose = function() {\n // remove reference from soundArray\n Effect.prototype.dispose.apply(this);\n if (this.biquad) {\n this.biquad.disconnect();\n delete this.biquad;\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 */\n p5.LowPass = function() {\n p5.Filter.call(this, 'lowpass');\n };\n p5.LowPass.prototype = Object.create(p5.Filter.prototype);\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 */\n p5.HighPass = function() {\n p5.Filter.call(this, 'highpass');\n };\n p5.HighPass.prototype = Object.create(p5.Filter.prototype);\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 */\n p5.BandPass = function() {\n p5.Filter.call(this, 'bandpass');\n };\n p5.BandPass.prototype = Object.create(p5.Filter.prototype);\n\n return p5.Filter;\n});\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});","'use strict';\n\nglobal.TONE_SILENCE_VERSION_LOGGING = true;\n\ndefine(['startaudiocontext', 'Tone/core/Context', 'Tone/core/Tone'], function (StartAudioContext, Context, Tone) {\n // Create the Audio Context\n const audiocontext = new window.AudioContext();\n\n // Tone and p5.sound share the same audio context\n Tone.context.dispose();\n Tone.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 */\n p5.prototype.getAudioContext = function() {\n return audiocontext;\n };\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 */\n p5.prototype.userStartAudio = function(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) { return e.elt});\n }\n return StartAudioContext(audiocontext, elt, callback);\n };\n\n return audiocontext;\n});\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});","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\n\n var Add = require('Tone/signal/Add');\n var Mult = require('Tone/signal/Multiply');\n var Scale = require('Tone/signal/Scale');\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 */\n p5.Oscillator = function(freq, type) {\n if (typeof freq === 'string') {\n var f = type;\n type = freq;\n freq = f;\n } if (typeof type === 'number') {\n var 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(this.f, p5sound.audiocontext.currentTime);\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 p5.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\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 p5.Oscillator.prototype.start = function(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 p5.Oscillator.prototype.stop = function(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 p5.Oscillator.prototype.amp = function(vol, rampTime, tFromNow) {\n var self = this;\n if (typeof vol === 'number') {\n var rampTime = rampTime || 0;\n var tFromNow = tFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n }\n\n else if (vol) {\n vol.connect(self.output.gain);\n } else {\n // return the Gain Node\n return this.output.gain;\n }\n };\n\n // these are now the same thing\n p5.Oscillator.prototype.fade = p5.Oscillator.prototype.amp;\n\n p5.Oscillator.prototype.getAmp = function() {\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 p5.Oscillator.prototype.freq = function(val, rampTime, tFromNow) {\n if (typeof val === 'number' && !isNaN(val)) {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n var rampTime = rampTime || 0;\n var tFromNow = tFromNow || 0;\n var t = now + tFromNow + rampTime;\n // var currentFreq = this.oscillator.frequency.value;\n // this.oscillator.frequency.cancelScheduledValues(now);\n\n if (rampTime === 0) {\n this.oscillator.frequency.setValueAtTime(val, tFromNow + now);\n } else {\n if (val > 0 ) {\n this.oscillator.frequency.exponentialRampToValueAtTime(val, tFromNow + rampTime + now);\n } else {\n this.oscillator.frequency.linearRampToValueAtTime(val, tFromNow + rampTime + now);\n }\n }\n\n // reset phase if oscillator has a phase\n if (this.phaseAmount) {\n this.phase(this.phaseAmount);\n }\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 p5.Oscillator.prototype.getFreq = function() {\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 p5.Oscillator.prototype.setType = function(type) {\n this.oscillator.type = type;\n };\n\n p5.Oscillator.prototype.getType = function() {\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 p5.Oscillator.prototype.connect = function(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n }\n else if (unit.hasOwnProperty('input')) {\n this.panner.connect(unit.input);\n this.connection = unit.input;\n }\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 p5.Oscillator.prototype.disconnect = function() {\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 p5.Oscillator.prototype.pan = function(pval, tFromNow) {\n this.panPosition = pval;\n this.panner.pan(pval, tFromNow);\n };\n\n p5.Oscillator.prototype.getPan = function() {\n return this.panPosition;\n };\n\n // get rid of the oscillator\n p5.Oscillator.prototype.dispose = function() {\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 p5.Oscillator.prototype.phase = function(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 // SIGNAL MATH FOR MODULATION //\n // ========================== //\n\n // return sigChain(this, scale, thisChain, nextChain, Scale);\n var sigChain = function(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 * 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 p5.Oscillator.prototype.add = function(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 /**\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 p5.Oscillator.prototype.mult = function(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 p5.Oscillator.prototype.scale = function(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;\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5;\n }\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 // 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 */\n p5.SinOsc = function(freq) {\n p5.Oscillator.call(this, freq, 'sine');\n };\n\n p5.SinOsc.prototype = Object.create(p5.Oscillator.prototype);\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 */\n p5.TriOsc = function(freq) {\n p5.Oscillator.call(this, freq, 'triangle');\n };\n\n p5.TriOsc.prototype = Object.create(p5.Oscillator.prototype);\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 */\n p5.SawOsc = function(freq) {\n p5.Oscillator.call(this, freq, 'sawtooth');\n };\n\n p5.SawOsc.prototype = Object.create(p5.Oscillator.prototype);\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 */\n p5.SqrOsc = function(freq) {\n p5.Oscillator.call(this, freq, 'square');\n };\n\n p5.SqrOsc.prototype = Object.create(p5.Oscillator.prototype);\n\n});\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});","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});","'use strict';\ndefine(function (require) {\n\n var p5sound = require('master');\n var AudioVoice = require('audioVoice');\n var noteToFreq = require('helpers').noteToFreq;\n\n var 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\n p5.MonoSynth = function () {\n AudioVoice.call(this);\n\n this.oscillator = new p5.Oscillator();\n\n this.env = new p5.Envelope();\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 p5.MonoSynth.prototype = Object.create(p5.AudioVoice.prototype);\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 p5.MonoSynth.prototype.play = function (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 p5.MonoSynth.prototype.triggerAttack = function (note, velocity, secondsFromNow) {\n var secondsFromNow = ~~secondsFromNow;\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 p5.MonoSynth.prototype.triggerRelease = function (secondsFromNow) {\n var secondsFromNow = 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 p5.MonoSynth.prototype.setADSR = function (attack,decay,sustain,release) {\n this.env.setADSR(attack, decay, sustain, release);\n };\n\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(p5.MonoSynth.prototype, {\n 'attack': {\n get : function() {\n return this.env.aTime;\n },\n set : function(attack) {\n this.env.setADSR(attack, this.env.dTime,\n this.env.sPercent, this.env.rTime);\n }\n },\n 'decay': {\n get : function() {\n return this.env.dTime;\n },\n set : function(decay) {\n this.env.setADSR(this.env.aTime, decay,\n this.env.sPercent, this.env.rTime);\n }\n },\n 'sustain': {\n get : function() {\n return this.env.sPercent;\n },\n set : function(sustain) {\n this.env.setADSR(this.env.aTime, this.env.dTime,\n sustain, this.env.rTime);\n }\n },\n 'release': {\n get : function() {\n return this.env.rTime;\n },\n set : function(release) {\n this.env.setADSR(this.env.aTime, this.env.dTime,\n this.env.sPercent, release);\n }\n },\n });\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 p5.MonoSynth.prototype.amp = function(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 p5.MonoSynth.prototype.connect = function(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 p5.MonoSynth.prototype.disconnect = function() {\n if (this.output) {\n this.output.disconnect();\n }\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 p5.MonoSynth.prototype.dispose = function() {\n AudioVoice.prototype.dispose.apply(this);\n\n if (this.env) {\n this.env.dispose();\n }\n if (this.oscillator) {\n this.oscillator.dispose();\n }\n };\n\n});\n","'use strict';\ndefine(function() {\n var p5sound = require('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 */\n p5.AudioVoice = function () {\n\t this.ac = p5sound.audiocontext;\n\t this.output = this.ac.createGain();\n\t this.connect();\n\t p5sound.soundArray.push(this);\n };\n\n p5.AudioVoice.prototype.play = function (note, velocity, secondsFromNow, sustime) {\n };\n\n p5.AudioVoice.prototype.triggerAttack = function (note, velocity, secondsFromNow) {\n };\n\n p5.AudioVoice.prototype.triggerRelease = function (secondsFromNow) {\n };\n\n p5.AudioVoice.prototype.amp = function(vol, rampTime) {\n };\n\n /**\n * Connect to p5 objects or Web Audio Nodes\n * @method connect\n * @for p5.AudioVoice\n * @param {Object} unit\n */\n p5.AudioVoice.prototype.connect = function(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 p5.AudioVoice.prototype.disconnect = function() {\n this.output.disconnect();\n };\n\n p5.AudioVoice.prototype.dispose = function() {\n if (this.output) {\n this.output.disconnect();\n delete this.output;\n }\n };\n\n return p5.AudioVoice;\n});\n","'use strict';\ndefine(function (require) {\n\n var p5sound = require('master');\n var TimelineSignal = require('Tone/signal/TimelineSignal');\n var noteToFreq = require('helpers').noteToFreq;\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 **/\n p5.PolySynth = function(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\t * @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 p5.PolySynth.prototype._allocateVoices = function() {\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 p5.PolySynth.prototype.play = function (note,velocity, secondsFromNow, susTime) {\n var susTime = susTime || 1;\n this.noteAttack(note, velocity, secondsFromNow);\n this.noteRelease(note, secondsFromNow + susTime);\n };\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 p5.PolySynth.prototype.noteADSR = function (note,a,d,s,r,timeFromNow) {\n var now = p5sound.audiocontext.currentTime;\n var timeFromNow = timeFromNow || 0;\n var t = now + timeFromNow\n this.audiovoices[ this.notes[note].getValueAtTime(t) ].setADSR(a,d,s,r);\n };\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 p5.PolySynth.prototype.setADSR = function(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 p5.PolySynth.prototype.noteAttack = function (_note, _velocity, secondsFromNow) {\n //this value goes to the audiovoices which handle their own scheduling\n var secondsFromNow = ~~secondsFromNow;\n\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 var oldestNote = p5.prototype.freqToMidi(this.audiovoices[this._oldest].oscillator.freq().value);\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 = this._voicesInUse._searchBefore(acTime) === null ? 0 : 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 this.audiovoices[currentVoice].triggerAttack(note, velocity, secondsFromNow);\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 p5.PolySynth.prototype._updateAfter = function(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 /**\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 p5.PolySynth.prototype.noteRelease = function (_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(~~this._voicesInUse.getValueAtTime(t).value, 1);\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(tFromNow);\n this.notes[note].dispose();\n delete this.notes[note];\n\n this._newest = this._newest === 0 ? 0 : (this._newest - 1) % (this.maxVoices - 1);\n }\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 p5.PolySynth.prototype.connect = function (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 p5.PolySynth.prototype.disconnect = function() {\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 p5.PolySynth.prototype.dispose = function() {\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});\n","'use strict';\n\ndefine(function (require) {\n\n require('audioworklet-polyfill');\n require('shims');\n require('audiocontext');\n var p5SOUND = require('master');\n require('helpers');\n require('errorHandler');\n require('audioWorklet');\n require('panner');\n require('soundfile');\n require('amplitude');\n require('fft');\n require('signal');\n require('oscillator');\n require('envelope');\n require('pulse');\n require('noise');\n require('audioin');\n require('filter');\n require('eq');\n require('panner3d');\n require('listener3d');\n require('delay');\n require('reverb');\n require('metro');\n require('looper');\n require('soundLoop');\n require('compressor');\n require('soundRecorder');\n require('peakDetect');\n require('gain');\n require('monosynth');\n require('polysynth');\n require('distortion');\n require('audioVoice');\n require('monosynth');\n require('polysynth');\n\n return p5SOUND;\n\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].length;\\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].length;\\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);\"","'use strict';\n\ndefine(function (require) {\n\n var p5sound = require('master');\n var ac = p5sound.audiocontext;\n\n // Stereo panner\n // if there is a stereo panner node use it\n if(typeof ac.createStereoPanner !== 'undefined') {\n p5.Panner = function (input, output) {\n this.stereoPanner = this.input = ac.createStereoPanner();\n input.connect(this.stereoPanner);\n this.stereoPanner.connect(output);\n };\n\n p5.Panner.prototype.pan = function(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 p5.Panner.prototype.inputChannels = function() {};\n\n p5.Panner.prototype.connect = function(obj) {\n this.stereoPanner.connect(obj);\n };\n\n p5.Panner.prototype.disconnect = function() {\n if (this.stereoPanner) {\n this.stereoPanner.disconnect();\n }\n };\n\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 p5.Panner = function(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 }\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 p5.Panner.prototype.pan = function(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 p5.Panner.prototype.inputChannels = function(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 p5.Panner.prototype.connect = function(obj) {\n this.output.connect(obj);\n };\n\n p5.Panner.prototype.disconnect = function() {\n if (this.output) {\n this.output.disconnect();\n }\n };\n }\n});\n","'use strict';\n\ndefine(function (require) {\n\n const CustomError = require('errorHandler');\n const p5sound = require('master');\n const ac = p5sound.audiocontext;\n const { midiToFreq, convertToWav, safeBufferSize } = require('helpers');\n var processorNames = require('./audioWorklet/processorNames');\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 */\n p5.SoundFile = function(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 }\n else if(typeof paths === 'object') {\n if (!(window.File && window.FileReader && window.FileList && window.Blob)) {\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 p5.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\n // register preload handling of loadSound\n p5.prototype.registerPreloadMethod('loadSound', p5.prototype);\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 */\n p5.prototype.loadSound = function(path, callback, onerror, whileLoading) {\n // if loading locally without a server\n if (window.location.origin.indexOf('file://') > -1 && window.cordova === 'undefined' ) {\n window.alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS');\n }\n\n var self = this;\n var s = new p5.SoundFile(path, function() {\n if(typeof callback === 'function') {\n callback.apply(self, arguments);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n }, onerror, whileLoading);\n\n return s;\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 p5.SoundFile.prototype.load = function(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('progress', function(evt) {\n self._updateProgress(evt);\n }, false);\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(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('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(msg +'\\n The error stack trace includes: \\n' + err.stack);\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 = 'Unable to load ' + self.url + '. The request status was: ' +\n request.status + ' (' + request.statusText + ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(msg +'\\n The error stack trace includes: \\n' + err.stack);\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 = 'There was no response from the server at ' + self.url + '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(msg +'\\n The error stack trace includes: \\n' + err.stack);\n }\n };\n\n request.send();\n }\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 p5.SoundFile.prototype._updateProgress = function(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 p5.SoundFile.prototype.isLoaded = function() {\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 p5.SoundFile.prototype.play = function(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 { throw 'start time out of range'; }\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 = duration <= this.buffer.duration - cueStart ? duration : 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\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 p5.SoundFile.prototype.playMode = function(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 p5.SoundFile.prototype.pause = function(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 p5.SoundFile.prototype.loop = function(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 p5.SoundFile.prototype.setLoop = function(bool) {\n if (bool === true) {\n this._looping = true;\n }\n else if (bool === false) {\n this._looping = false;\n }\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 p5.SoundFile.prototype.isLooping = function() {\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 p5.SoundFile.prototype.isPlaying = function() {\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 p5.SoundFile.prototype.isPaused = function() {\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 p5.SoundFile.prototype.stop = function(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 }\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 p5.SoundFile.prototype.stopAll = function(_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 this._onended(this);\n }\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 p5.SoundFile.prototype.setVolume = function(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 }\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 // same as setVolume, to match Processing Sound\n p5.SoundFile.prototype.amp = p5.SoundFile.prototype.setVolume;\n\n // these are the same thing\n p5.SoundFile.prototype.fade = p5.SoundFile.prototype.setVolume;\n\n p5.SoundFile.prototype.getVolume = function() {\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 p5.SoundFile.prototype.pan = function(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 p5.SoundFile.prototype.getPan = function() {\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 p5.SoundFile.prototype.rate = function(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 }\n\n else if (playbackRate < 0 && !this.reversed) {\n playbackRate = Math.abs(playbackRate);\n reverse = true;\n }\n\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(Math.abs(playbackRate), now);\n this._counterNode.playbackRate.cancelScheduledValues(now);\n this._counterNode.playbackRate.linearRampToValueAtTime(Math.abs(playbackRate), now);\n }\n\n if (reverse) {\n this.reverseBuffer();\n }\n return this.playbackRate;\n };\n\n // TO DO: document this\n p5.SoundFile.prototype.setPitch = function(num) {\n var newPlaybackRate = midiToFreq(num) / midiToFreq(60);\n this.rate(newPlaybackRate);\n };\n\n p5.SoundFile.prototype.getPlaybackRate = function() {\n return this.playbackRate;\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 p5.SoundFile.prototype.duration = function() {\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 p5.SoundFile.prototype.currentTime = function() {\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 p5.SoundFile.prototype.jump = function(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 p5.SoundFile.prototype.channels = function() {\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 p5.SoundFile.prototype.sampleRate = function() {\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 p5.SoundFile.prototype.frames = function() {\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 p5.SoundFile.prototype.getPeaks = function(length) {\n\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 }\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 p5.SoundFile.prototype.reverseBuffer = function() {\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 p5.SoundFile.prototype.onended = function(callback) {\n this._onended = callback;\n return this;\n };\n\n p5.SoundFile.prototype.add = function() {\n // TO DO\n };\n\n p5.SoundFile.prototype.dispose = function() {\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 p5.SoundFile.prototype.connect = function(unit) {\n if (!unit) {\n this.panner.connect(p5sound.input);\n }\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 p5.SoundFile.prototype.disconnect = function() {\n if (this.panner) {\n this.panner.disconnect();\n }\n };\n\n /**\n */\n p5.SoundFile.prototype.getLevel = function() {\n console.warn('p5.SoundFile.getLevel has been removed from the library. Use p5.Amplitude instead');\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 p5.SoundFile.prototype.setPath = function(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 p5.SoundFile.prototype.setBuffer = function(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 //////////////////////////////////////////////////\n // script processor node with an empty buffer to help\n // keep a sample-accurate position in playback buffer.\n // Inspired by Chinmay Pendharkar's technique for Sonoport --> http://bit.ly/1HwdCsV\n // Copyright [2015] [Sonoport (Asia) Pte. Ltd.],\n // Licensed under the Apache License http://apache.org/licenses/LICENSE-2.0\n ////////////////////////////////////////////////////////////////////////////////////\n\n var _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 // initialize counterNode, set its initial buffer and playbackRate\n p5.SoundFile.prototype._initCounterNode = function() {\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(ac, processorNames.soundFileProcessor, {\n processorOptions: { bufferSize: workletBufferSize }\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 p5.SoundFile.prototype._initSourceNode = function() {\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 /**\n * processPeaks returns an array of timestamps where it thinks there is a beat.\n *\n * This is an asynchronous function that processes the soundfile in an offline audio context,\n * and sends the results to your callback function.\n *\n * The process involves running the soundfile through a lowpass filter, and finding all of the\n * peaks above the initial threshold. If the total number of peaks are below the minimum number of peaks,\n * it decreases the threshold and re-runs the analysis until either minPeaks or minThreshold are reached.\n *\n * @method processPeaks\n * @for p5.SoundFile\n * @param {Function} callback a function to call once this data is returned\n * @param {Number} [initThreshold] initial threshold defaults to 0.9\n * @param {Number} [minThreshold] minimum threshold defaults to 0.22\n * @param {Number} [minPeaks] minimum number of peaks defaults to 200\n * @return {Array} Array of timestamped peaks\n */\n p5.SoundFile.prototype.processPeaks = function(callback, _initThreshold, _minThreshold, _minPeaks) {\n var bufLen = this.buffer.length;\n var sampleRate = this.buffer.sampleRate;\n var buffer = this.buffer;\n var allPeaks = [];\n\n var initialThreshold = _initThreshold || 0.9,\n threshold = initialThreshold,\n minThreshold = _minThreshold || 0.22,\n minPeaks = _minPeaks || 200;\n\n // Create offline context\n var offlineContext = new window.OfflineAudioContext(1, bufLen, sampleRate);\n\n // create buffer source\n var source = offlineContext.createBufferSource();\n source.buffer = buffer;\n\n // Create filter. TO DO: allow custom setting of filter\n var filter = offlineContext.createBiquadFilter();\n filter.type = 'lowpass';\n source.connect(filter);\n filter.connect(offlineContext.destination);\n\n // start playing at time:0\n source.start(0);\n offlineContext.startRendering(); // Render the song\n\n // act on the result\n offlineContext.oncomplete = function(e) {\n if (!self.panner) return;\n var filteredBuffer = e.renderedBuffer;\n var bufferData = filteredBuffer.getChannelData(0);\n\n\n // step 1:\n // create Peak instances, add them to array, with strength and sampleIndex\n do {\n allPeaks = getPeaksAtThreshold(bufferData, threshold);\n threshold -= 0.005;\n } while (Object.keys(allPeaks).length < minPeaks && threshold >= minThreshold);\n\n\n // step 2:\n // find intervals for each peak in the sampleIndex, add tempos array\n var intervalCounts = countIntervalsBetweenNearbyPeaks(allPeaks);\n\n // step 3: find top tempos\n var groups = groupNeighborsByTempo(intervalCounts, filteredBuffer.sampleRate);\n\n // sort top intervals\n var topTempos = groups.sort(function(intA, intB) {\n return intB.count - intA.count;\n\n }).splice(0,5);\n\n // set this SoundFile's tempo to the top tempo ??\n this.tempo = topTempos[0].tempo;\n\n // step 4:\n // new array of peaks at top tempo within a bpmVariance\n var bpmVariance = 5;\n var tempoPeaks = getPeaksAtTopTempo(allPeaks, topTempos[0].tempo, filteredBuffer.sampleRate, bpmVariance);\n\n callback(tempoPeaks);\n };\n };\n\n // process peaks\n var Peak = function(amp, i) {\n this.sampleIndex = i;\n this.amplitude = amp;\n this.tempos = [];\n this.intervals = [];\n };\n\n // 1. for processPeaks() Function to identify peaks above a threshold\n // returns an array of peak indexes as frames (samples) of the original soundfile\n function getPeaksAtThreshold(data, threshold) {\n var peaksObj = {};\n var length = data.length;\n\n for (var i = 0; i < length; i++) {\n if (data[i] > threshold) {\n var amp = data[i];\n var peak = new Peak(amp, i);\n peaksObj[i] = peak;\n // Skip forward ~ 1/8s to get past this peak.\n i += 6000;\n }\n i++;\n }\n return peaksObj;\n }\n\n // 2. for processPeaks()\n function countIntervalsBetweenNearbyPeaks(peaksObj) {\n var intervalCounts = [];\n var peaksArray = Object.keys(peaksObj).sort();\n\n for (var index = 0; index < peaksArray.length; index++) {\n\n // find intervals in comparison to nearby peaks\n for (var i = 0; i < 10; i++) {\n var startPeak = peaksObj[peaksArray[index]];\n var endPeak = peaksObj[peaksArray[index + i]];\n\n if (startPeak && endPeak) {\n var startPos = startPeak.sampleIndex;\n var endPos = endPeak.sampleIndex;\n var interval = endPos - startPos;\n\n // add a sample interval to the startPeak in the allPeaks array\n if (interval > 0) {\n startPeak.intervals.push(interval);\n }\n\n // tally the intervals and return interval counts\n var foundInterval = intervalCounts.some(function(intervalCount) {\n if (intervalCount.interval === interval) {\n intervalCount.count++;\n return intervalCount;\n }\n });\n\n // store with JSON like formatting\n if (!foundInterval) {\n intervalCounts.push({\n interval: interval,\n count: 1,\n });\n }\n }\n }\n }\n\n return intervalCounts;\n }\n\n\n // 3. for processPeaks --> find tempo\n function groupNeighborsByTempo(intervalCounts, sampleRate) {\n var tempoCounts = [];\n\n intervalCounts.forEach(function(intervalCount) {\n\n try {\n // Convert an interval to tempo\n var theoreticalTempo = Math.abs( 60 / (intervalCount.interval / sampleRate ) );\n\n theoreticalTempo = mapTempo(theoreticalTempo);\n\n var foundTempo = tempoCounts.some(function(tempoCount) {\n if (tempoCount.tempo === theoreticalTempo)\n return tempoCount.count += intervalCount.count;\n });\n if (!foundTempo) {\n if (isNaN(theoreticalTempo)) {\n return;\n }\n tempoCounts.push({\n tempo: Math.round(theoreticalTempo),\n count: intervalCount.count\n });\n }\n } catch(e) {\n throw e;\n }\n\n });\n\n return tempoCounts;\n }\n\n // 4. for processPeaks - get peaks at top tempo\n function getPeaksAtTopTempo(peaksObj, tempo, sampleRate, bpmVariance) {\n var peaksAtTopTempo = [];\n var peaksArray = Object.keys(peaksObj).sort();\n\n // TO DO: filter out peaks that have the tempo and return\n for (var i = 0; i < peaksArray.length; i++) {\n var key = peaksArray[i];\n var peak = peaksObj[key];\n\n for (var j = 0; j < peak.intervals.length; j++) {\n var intervalBPM = Math.round(Math.abs( 60 / (peak.intervals[j] / sampleRate) ) );\n\n intervalBPM = mapTempo(intervalBPM);\n\n if ( Math.abs(intervalBPM - tempo) < bpmVariance ) {\n // convert sampleIndex to seconds\n peaksAtTopTempo.push(peak.sampleIndex/sampleRate);\n }\n }\n }\n\n // filter out peaks that are very close to each other\n peaksAtTopTempo = peaksAtTopTempo.filter(function(peakTime, index, arr) {\n var dif = arr[index + 1] - peakTime;\n if (dif > 0.01) {\n return true;\n }\n });\n\n return peaksAtTopTempo;\n }\n\n // helper function for processPeaks\n function mapTempo(theoreticalTempo) {\n // these scenarios create infinite while loop\n if (!isFinite(theoreticalTempo) || theoreticalTempo === 0 ) {\n return;\n }\n\n // Adjust the tempo to fit within the 90-180 BPM range\n while (theoreticalTempo < 90) theoreticalTempo *= 2;\n while (theoreticalTempo > 180 && theoreticalTempo > 90) theoreticalTempo /= 2;\n\n return theoreticalTempo;\n }\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\n var Cue = function(callback, time, id, val) {\n this.callback = callback;\n this.time = time;\n this.id = id;\n this.val = val;\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 p5.SoundFile.prototype.addCue = function(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 p5.SoundFile.prototype.removeCue = function(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 p5.SoundFile.prototype.clearCues = function() {\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 p5.SoundFile.prototype._onTimeUpdate = function(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\n if (~~this._prevUpdateTime <= callbackTime && callbackTime <= playbackTime) {\n\n // pass the scheduled callbackTime as parameter to the callback\n cue.callback(val);\n }\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 p5.SoundFile.prototype.save = function(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 p5.SoundFile.prototype.getBlob = function() {\n const dataView = convertToWav(this.buffer);\n return new Blob([dataView], { type: 'audio/wav' });\n };\n\n // event handler to remove references to the bufferSourceNode when it is done playing\n function _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.map((_, i) => i).reverse().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","'use strict';\n\ndefine(function (require) {\n const p5sound = require('master');\n const { safeBufferSize } = require('helpers');\n const processorNames = require('./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 toggleSound() {\n * if (sound.isPlaying() ){\n * sound.stop();\n * } else {\n * sound.play();\n * }\n * }\n *\n *
\n */\n p5.Amplitude = function(smoothing) {\n\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(this.audiocontext, processorNames.amplitudeProcessor, {\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 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 p5.Amplitude.prototype.setInput = function(source, smoothing) {\n\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('Amplitude input source is not ready! Connecting to master output instead');\n p5sound.meter.connect(this._workletNode);\n }\n\n // if it is a p5.Signal\n else if (source instanceof p5.Signal) {\n source.output.connect(this._workletNode);\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 p5.Amplitude.prototype.connect = function(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 p5.Amplitude.prototype.disconnect = function() {\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 p5.Amplitude.prototype.getLevel = function(channel) {\n if (typeof channel !== 'undefined') {\n if (this.normalize) {\n return this.stereoVolNorm[channel];\n } else {\n return this.stereoVol[channel];\n }\n }\n else if (this.normalize) {\n return this.volNorm;\n }\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 p5.Amplitude.prototype.toggleNormalize = function(bool) {\n if (typeof bool === 'boolean') {\n this.normalize = bool;\n }\n else {\n this.normalize = !this.normalize;\n }\n this._workletNode.port.postMessage({ name: 'toggleNormalize', 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 p5.Amplitude.prototype.smooth = function(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\n p5.Amplitude.prototype.dispose = function() {\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});\n","'use strict';\n\ndefine(function(require) {\n var p5sound = require('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 */\n p5.FFT = function(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 p5.FFT.prototype.setInput = function(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 p5.FFT.prototype.waveform = function() {\n var bins, mode, normalArray;\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 var normalArray = new Array();\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 p5.FFT.prototype.analyze = function() {\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 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 p5.FFT.prototype.getEnergy = function(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(frequency1 / nyquist * this.freqDomain.length);\n var highIndex = Math.round(frequency2 / nyquist * this.freqDomain.length);\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 p5.FFT.prototype.getFreq = function(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 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 p5.FFT.prototype.getCentroid = function() {\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 p5.FFT.prototype.smooth = function(s) {\n if (typeof s !== 'undefined') {\n this.smoothing = s;\n }\n return this.smoothing;\n };\n\n p5.FFT.prototype.dispose = function() {\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 p5.FFT.prototype.linAverages = function(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 p5.FFT.prototype.logAverages = function(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 p5.FFT.prototype.getOctaveBands = function(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 // helper methods to convert type from float (dB) to int (0-255)\n var freqToFloat = function(fft) {\n if (fft.freqDomain instanceof Float32Array === false) {\n fft.freqDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n };\n var freqToInt = function(fft) {\n if (fft.freqDomain instanceof Uint8Array === false) {\n fft.freqDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n };\n var timeToFloat = function(fft) {\n if (fft.timeDomain instanceof Float32Array === false) {\n fft.timeDomain = new Float32Array(fft.analyser.frequencyBinCount);\n }\n };\n var timeToInt = function(fft) {\n if (fft.timeDomain instanceof Uint8Array === false) {\n fft.timeDomain = new Uint8Array(fft.analyser.frequencyBinCount);\n }\n };\n});\n","'use strict';\n\ndefine(function (require) {\n\n // Signal is built with the Tone.js signal by Yotam Mann\n // https://github.com/TONEnoTONE/Tone.js/\n var Signal = require('Tone/signal/Signal');\n var Add = require('Tone/signal/Add');\n var Mult = require('Tone/signal/Multiply');\n var Scale = require('Tone/signal/Scale');\n\n /**\n *

p5.Signal is a constant audio-rate signal used by p5.Oscillator\n * and p5.Envelope for modulation math.

\n *\n *

This is necessary because Web Audio is processed on a seprate clock.\n * For example, the p5 draw loop runs about 60 times per second. But\n * the audio clock must process samples 44100 times per second. If we\n * want to add a value to each of those samples, we can't do it in the\n * draw loop, but we can do it by adding a constant-rate audio signal.This class mostly functions behind the scenes in p5.sound, and returns\n * a Tone.Signal from the Tone.js library by Yotam Mann.\n * If you want to work directly with audio signals for modular\n * synthesis, check out\n * tone.js.

\n *\n * @class p5.Signal\n * @constructor\n * @return {Tone.Signal} A Signal object from the Tone.js library\n * @example\n *
\n * let carrier, modulator;\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 * carrier = new p5.Oscillator('sine');\n * carrier.start();\n * carrier.amp(1); // set amplitude\n * carrier.freq(220); // set frequency\n *\n * modulator = new p5.Oscillator('sawtooth');\n * modulator.disconnect();\n * modulator.start();\n * modulator.amp(1);\n * modulator.freq(4);\n *\n * // Modulator's default amplitude range is -1 to 1.\n * // Multiply it by -200, so the range is -200 to 200\n * // then add 220 so the range is 20 to 420\n * carrier.freq( modulator.mult(-400).add(220) );\n * }\n *\n * function canvasPressed() {\n * userStartAudio();\n * carrier.amp(1.0);\n * }\n *\n * function mouseReleased() {\n * carrier.amp(0);\n * }\n *
\n */\n p5.Signal = function(value) {\n var s = new Signal(value);\n // p5sound.soundArray.push(s);\n return s; // TODO: is this really a constructor?\n };\n\n /**\n * Fade to value, for smooth transitions\n *\n * @method fade\n * @for p5.Signal\n * @param {Number} value Value to set this signal\n * @param {Number} [secondsFromNow] Length of fade, in seconds from now\n */\n Signal.prototype.fade = Signal.prototype.linearRampToValueAtTime;\n Mult.prototype.fade = Signal.prototype.fade;\n Add.prototype.fade = Signal.prototype.fade;\n Scale.prototype.fade = Signal.prototype.fade;\n\n\n /**\n * Connect a p5.sound object or Web Audio node to this\n * p5.Signal so that its amplitude values can be scaled.\n *\n * @method setInput\n * @for p5.Signal\n * @param {Object} input\n */\n Signal.prototype.setInput = function(_input) {\n _input.connect(this);\n };\n Mult.prototype.setInput = Signal.prototype.setInput;\n Add.prototype.setInput = Signal.prototype.setInput;\n Scale.prototype.setInput = Signal.prototype.setInput;\n\n\n // signals can add / mult / scale themselves\n\n /**\n * Add a constant value to this audio signal,\n * and return the resulting audio signal. Does\n * not change the value of the original signal,\n * instead it returns a new p5.SignalAdd.\n *\n * @method add\n * @for p5.Signal\n * @param {Number} number\n * @return {p5.Signal} object\n */\n Signal.prototype.add = function(num) {\n var add = new Add(num);\n // add.setInput(this);\n this.connect(add);\n return add;\n };\n Mult.prototype.add = Signal.prototype.add;\n Add.prototype.add = Signal.prototype.add;\n Scale.prototype.add = Signal.prototype.add;\n\n /**\n * Multiply this signal by a constant value,\n * and return the resulting audio signal. Does\n * not change the value of the original signal,\n * instead it returns a new p5.SignalMult.\n *\n * @method mult\n * @for p5.Signal\n * @param {Number} number to multiply\n * @return {p5.Signal} object\n */\n Signal.prototype.mult = function(num) {\n var mult = new Mult(num);\n // mult.setInput(this);\n this.connect(mult);\n return mult;\n };\n Mult.prototype.mult = Signal.prototype.mult;\n Add.prototype.mult = Signal.prototype.mult;\n Scale.prototype.mult = Signal.prototype.mult;\n\n /**\n * Scale this signal value to a given range,\n * and return the result as an audio signal. Does\n * not change the value of the original signal,\n * instead it returns a new p5.SignalScale.\n *\n * @method scale\n * @for p5.Signal\n * @param {Number} number to multiply\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.Signal} object\n */\n Signal.prototype.scale = function(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;\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5;\n }\n else {\n mapOutMin = arguments[0];\n mapOutMax = arguments[1];\n }\n var scale = new Scale(mapOutMin, mapOutMax);\n this.connect(scale);\n return scale;\n };\n Mult.prototype.scale = Signal.prototype.scale;\n Add.prototype.scale = Signal.prototype.scale;\n Scale.prototype.scale = Signal.prototype.scale;\n\n});\n\n\n","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});","'use strict';\n\ndefine(function (require) {\n\n var p5sound = require('master');\n var Add = require('Tone/signal/Add');\n var Mult = require('Tone/signal/Multiply');\n var Scale = require('Tone/signal/Scale');\n var TimelineSignal = require('Tone/signal/TimelineSignal');\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 */\n p5.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\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\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.\n p5.Envelope.prototype._init = function () {\n var now = p5sound.audiocontext.currentTime;\n var t = now;\n this.control.setTargetAtTime(0.00001, t, .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 */\n p5.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 */\n p5.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 = typeof sPercent !== 'undefined' ? sPercent * (this.aLevel - this.rLevel) + this.rLevel : 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 */\n p5.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 //\n p5.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(1.0 / this.checkExpInput(1.0 - this._rampHighPercentage));\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\n p5.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(1.0 / this.checkExpInput(1.0 - this._rampHighPercentage));\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 /**\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 */\n p5.Envelope.prototype.setInput = function() {\n for (var i = 0; iPlay 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 */\n p5.Envelope.prototype.play = function(unit, secondsFromNow, susTime) {\n var tFromNow = secondsFromNow || 0;\n var susTime = susTime || 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 /**\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 */\n p5.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 {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n }\n else\n {\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 {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(this.aLevel), t);\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n }\n else\n {\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\n // decay to decay level (if using ADSR, then decay level == sustain level)\n t += this.dTime;\n if (this.isExponential === true)\n {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(this.dLevel), t);\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n }\n else\n {\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 */\n p5.Envelope.prototype.triggerRelease = function(unit, secondsFromNow) {\n\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 {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(valToSet), t);\n }\n else\n {\n this.control.linearRampToValueAtTime(valToSet, t);\n }\n\n // release\n t += this.rTime;\n\n if (this.isExponential === true)\n {\n this.control.exponentialRampToValueAtTime(this.checkExpInput(this.rLevel), t);\n valToSet = this.checkExpInput(this.control.getValueAtTime(t));\n this.control.cancelScheduledValues(t);\n this.control.exponentialRampToValueAtTime(valToSet, t);\n }\n else\n {\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 (optional)\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 */\n p5.Envelope.prototype.ramp = function(unit, secondsFromNow, v1, v2) {\n\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 = 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\n\n p5.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 (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 if (unit instanceof p5.Signal) {\n unit.setValue(0);\n }\n this.output.connect(unit);\n };\n\n p5.Envelope.prototype.disconnect = function() {\n if (this.output) {\n this.output.disconnect();\n }\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 */\n p5.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 */\n p5.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 */\n p5.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\n // get rid of the oscillator\n p5.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\n p5.Env = function(t1, l1, t2, l2, t3, l3) {\n console.warn('WARNING: p5.Env is now deprecated and may be removed in future versions. ' +\n 'Please use the new p5.Envelope instead.');\n p5.Envelope.call(this, t1, l1, t2, l2, t3, l3);\n };\n p5.Env.prototype = Object.create(p5.Envelope.prototype);\n\n});\n","'use strict';\n\ndefine(function (require) {\n\n var p5sound = require('master');\n require('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 */\n p5.Pulse = function(freq, w) {\n p5.Oscillator.call(this, 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 p5.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 p5.Pulse.prototype = Object.create(p5.Oscillator.prototype);\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 p5.Pulse.prototype.width = function(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 var sig = new p5.SignalAdd(-0.5);\n sig.setInput(w);\n sig = sig.mult(-1);\n sig = sig.mult(1.7);\n sig.connect(this.dcGain.gain);\n }\n };\n\n p5.Pulse.prototype.start = function(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 = [this.oscillator.frequency, this.osc2.oscillator.frequency];\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 p5.Pulse.prototype.stop = function(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 p5.Pulse.prototype.freq = function(val, rampTime, tFromNow) {\n if (typeof val === 'number') {\n this.f = val;\n var now = p5sound.audiocontext.currentTime;\n var rampTime = rampTime || 0;\n var tFromNow = tFromNow || 0;\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(val, tFromNow + rampTime + now);\n this.osc2.oscillator.frequency.cancelScheduledValues(now);\n this.osc2.oscillator.frequency.setValueAtTime(currentFreq, now + tFromNow);\n this.osc2.oscillator.frequency.exponentialRampToValueAtTime(val, tFromNow + rampTime + now);\n\n if (this.freqMod) {\n this.freqMod.output.disconnect();\n this.freqMod = null;\n }\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 // inspiration: http://webaudiodemos.appspot.com/oscilloscope/\n function 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++)\n data[i]=1.0;\n var bufferSource=ac.createBufferSource();\n bufferSource.buffer=buffer;\n bufferSource.loop=true;\n return bufferSource;\n }\n\n});\n","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\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 */\n p5.Noise = function(type) {\n var assignType;\n p5.Oscillator.call(this);\n delete this.f;\n delete this.freq;\n delete this.oscillator;\n\n if (type === 'brown') {\n assignType = _brownNoise;\n } else if (type === 'pink') {\n assignType = _pinkNoise;\n } else {\n assignType = _whiteNoise;\n }\n this.buffer = assignType;\n };\n\n p5.Noise.prototype = Object.create(p5.Oscillator.prototype);\n\n // generate noise buffers\n var _whiteNoise = (function() {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var whiteBuffer = p5sound.audiocontext.createBuffer(1, bufferSize, p5sound.audiocontext.sampleRate);\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\n var _pinkNoise = (function() {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var pinkBuffer = p5sound.audiocontext.createBuffer(1, bufferSize, p5sound.audiocontext.sampleRate);\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.96900 * b2 + white * 0.1538520;\n b3 = 0.86650 * b3 + white * 0.3104856;\n b4 = 0.55000 * b4 + white * 0.5329522;\n b5 = -0.7616 * b5 - white * 0.0168980;\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\n var _brownNoise = (function() {\n var bufferSize = 2 * p5sound.audiocontext.sampleRate;\n var brownBuffer = p5sound.audiocontext.createBuffer(1, bufferSize, p5sound.audiocontext.sampleRate);\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 * 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 p5.Noise.prototype.setType = function(type) {\n switch(type) {\n case 'white':\n this.buffer = _whiteNoise;\n break;\n case 'pink':\n this.buffer = _pinkNoise;\n break;\n case 'brown':\n this.buffer = _brownNoise;\n break;\n default:\n this.buffer = _whiteNoise;\n }\n if (this.started) {\n var now = p5sound.audiocontext.currentTime;\n this.stop(now);\n this.start(now+.01);\n }\n };\n\n p5.Noise.prototype.getType = function() {\n return this.buffer.type;\n };\n\n p5.Noise.prototype.start = function() {\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 p5.Noise.prototype.stop = function() {\n var now = p5sound.audiocontext.currentTime;\n if (this.noise) {\n this.noise.stop(now);\n this.started = false;\n }\n };\n\n p5.Noise.prototype.dispose = function() {\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});\n","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\n\n // an array of input sources\n p5sound.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 */\n p5.AudioIn = function(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 p5.Amplitude();\n this.output.connect(this.amplitude.input);\n\n if (!window.MediaStreamTrack || !window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia) {\n errorCallback ? errorCallback() : window.alert('This browser does not support MediaStreamTrack and mediaDevices');\n }\n\n // add to soundArray so we can dispose on close\n p5sound.soundArray.push(this);\n };\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 p5.AudioIn.prototype.start = function(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.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 p5.AudioIn.prototype.stop = function() {\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 p5.AudioIn.prototype.connect = function(unit) {\n if (unit) {\n if (unit.hasOwnProperty('input')) {\n this.output.connect(unit.input);\n }\n else if (unit.hasOwnProperty('analyser')) {\n this.output.connect(unit.analyser);\n }\n else {\n this.output.connect(unit);\n }\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 p5.AudioIn.prototype.disconnect = function() {\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 p5.AudioIn.prototype.getLevel = function(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 p5.AudioIn.prototype.amp = function(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(currentVol, p5sound.audiocontext.currentTime);\n this.output.gain.linearRampToValueAtTime(vol, rampTime + p5sound.audiocontext.currentTime);\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 and it returns a Promise.\n *\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 p5.AudioIn.prototype.getSources = function (onSuccess, onError) {\n return new Promise( function(resolve, reject) {\n window.navigator.mediaDevices.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('This browser does not support MediaStreamTrack.getSources()');\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 *
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 p5.AudioIn.prototype.setSource = function(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 p5.AudioIn.prototype.dispose = function() {\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});\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","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});","'use strict';\n\ndefine(function (require) {\n\n var Effect = require('effect');\n var EQFilter = require('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 */\n p5.EQ = function(_eqsize) {\n Effect.call(this);\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\n var freq, res;\n for (var i = 0; i < _eqsize; i++) {\n if (i === _eqsize - 1) {\n freq = 21000;\n res = .01;\n } else if (i === 0) {\n freq = 100;\n res = .1;\n }\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 p5.EQ.prototype = Object.create(Effect.prototype);\n\n /**\n * Process an input by connecting it to the EQ\n * @method process\n * @param {Object} src Audio source\n */\n p5.EQ.prototype.process = function (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 p5.EQ.prototype.set = function() {\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 }\n else {\n console.error('Argument mismatch. .set() should be called with ' + this.bands.length*2 +\n ' arguments. (one frequency and gain value pair for each band of the eq)');\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 p5.EQ.prototype._newBand = function(freq, res) {\n return new EQFilter(freq, res);\n };\n\n p5.EQ.prototype.dispose = function () {\n Effect.prototype.dispose.apply(this);\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\n return p5.EQ;\n});\n","'use strict';\n\ndefine(function (require) {\n var Filter = require('filter');\n var p5sound = require('master');\n\n /**\n * EQFilter extends p5.Filter with constraints\n * necessary for the p5.EQ\n *\n * @private\n */\n var EQFilter = function(freq, res) {\n Filter.call(this, 'peaking');\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 EQFilter.prototype = Object.create(Filter.prototype);\n\n EQFilter.prototype.amp = function() {\n console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');\n };\n EQFilter.prototype.drywet = function() {\n console.warn('`drywet()` is not available for p5.EQ bands.');\n };\n EQFilter.prototype.connect = function(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\n EQFilter.prototype.disconnect = function() {\n if (this.biquad) {\n this.biquad.disconnect();\n }\n };\n EQFilter.prototype.dispose = function() {\n // remove reference form soundArray\n var index = p5sound.soundArray.indexOf(this);\n p5sound.soundArray.splice(index, 1);\n this.disconnect();\n delete this.biquad;\n };\n\n return EQFilter;\n});\n","'use strict'\n\ndefine(function (require) {\n var p5sound = require('master');\n var Effect = require('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\tp5.Panner3D = function() {\n Effect.call(this);\n\n /**\n * \n * Web Audio Spatial Panner Node\n *\n * Properties include\n * - panningModel: \"equal power\" or \"HRTF\"\n * - distanceModel: \"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\t};\n\n p5.Panner3D.prototype = Object.create(Effect.prototype);\n\n\n /**\n * Connect an audio sorce\n *\n * @method process\n * @for p5.Panner3D\n * @param {Object} src Input source\n */\n p5.Panner3D.prototype.process = function(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 p5.Panner3D.prototype.set = function(xVal, yVal, zVal, time) {\n this.positionX(xVal,time);\n this.positionY(yVal,time);\n this.positionZ(zVal,time);\n return [this.panner.positionX.value,\n this.panner.positionY.value,\n this.panner.positionZ.value];\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 p5.Panner3D.prototype.positionX = function(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.positionX.value = xVal;\n this.panner.positionX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.positionX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.panner.positionX);\n }\n return this.panner.positionX.value;\n };\n p5.Panner3D.prototype.positionY = function(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.positionY.value = yVal;\n this.panner.positionY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.positionY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.panner.positionY);\n }\n return this.panner.positionY.value;\n };\n p5.Panner3D.prototype.positionZ = function(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.positionZ.value = zVal;\n this.panner.positionZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.positionZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\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 p5.Panner3D.prototype.orient = function(xVal, yVal, zVal, time) {\n this.orientX(xVal,time);\n this.orientY(yVal,time);\n this.orientZ(zVal,time);\n return [this.panner.orientationX.value,\n this.panner.orientationY.value,\n this.panner.orientationZ.value];\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 p5.Panner3D.prototype.orientX = function(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.panner.orientationX.value = xVal;\n this.panner.orientationX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.orientationX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.panner.orientationX);\n }\n return this.panner.orientationX.value;\n };\n p5.Panner3D.prototype.orientY = function(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.panner.orientationY.value = yVal;\n this.panner.orientationY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.orientationY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.panner.orientationY);\n }\n return this.panner.orientationY.value;\n };\n p5.Panner3D.prototype.orientZ = function(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.panner.orientationZ.value = zVal;\n this.panner.orientationZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.panner.orientationZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\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 p5.Panner3D.prototype.setFalloff = function(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 p5.Panner3D.prototype.maxDist = function(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 p5.Panner3D.prototype.rolloff = function(rolloffFactor){\n if (typeof rolloffFactor === 'number') {\n this.panner.rolloffFactor = rolloffFactor;\n }\n return this.panner.rolloffFactor;\n };\n\n p5.Panner3D.dispose = function() {\n Effect.prototype.dispose.apply(this);\n if (this.panner) {\n this.panner.disconnect();\n delete this.panner;\n }\n };\n\n return p5.Panner3D;\n\n});\n","'use strict'\n\ndefine(function (require) {\n var p5sound = require('master');\n var Effect = require('effect');\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 \n\tp5.Listener3D = function(type) {\n this.ac = p5sound.audiocontext;\n this.listener = this.ac.listener;\n\t}; \n\n// /**\n// * Connect an audio sorce\n// * @param {Object} src Input source\n// */\n p5.Listener3D.prototype.process = function(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 p5.Listener3D.prototype.position = function(xVal, yVal, zVal, time) {\n this.positionX(xVal,time);\n this.positionY(yVal,time);\n this.positionZ(zVal,time);\n return [this.listener.positionX.value, \n this.listener.positionY.value,\n this.listener.positionZ.value];\n };\n\n// /**\n// * Getter and setter methods for position coordinates\n// * @return {Number} [updated coordinate value]\n// */\n p5.Listener3D.prototype.positionX = function(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.positionX.value = xVal;\n this.listener.positionX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.positionX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.listener.positionX);\n }\n return this.listener.positionX.value;\n };\n p5.Listener3D.prototype.positionY = function(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.positionY.value = yVal;\n this.listener.positionY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.positionY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.listener.positionY);\n }\n return this.listener.positionY.value;\n };\n p5.Listener3D.prototype.positionZ = function(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.positionZ.value = zVal;\n this.listener.positionZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.positionZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\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 p5.Listener3D.prototype.orient = function(xValF, yValF, zValF, \n xValU, yValU, zValU, time) {\n\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 [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 p5.Listener3D.prototype.orientForward = function(xValF, yValF, zValF, time) {\n this.forwardX(xValF,time);\n this.forwardY(yValF,time);\n this.forwardZ(zValF,time);\n\n return [this.listener.forwardX, \n this.listener.forwardY,\n this.listener.forwardZ];\n };\n\n p5.Listener3D.prototype.orientUp = function(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, \n this.listener.upY,\n this.listener.upZ];\n };\n// /**\n// * Getter and setter methods for orient coordinates\n// * @return {Number} [updated coordinate value]\n// */\n p5.Listener3D.prototype.forwardX = function(xVal, time) {\n var t = time || 0;\n if (typeof xVal === 'number') {\n this.listener.forwardX.value = xVal;\n this.listener.forwardX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.forwardX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.listener.forwardX);\n }\n return this.listener.forwardX.value;\n };\n p5.Listener3D.prototype.forwardY = function(yVal, time) {\n var t = time || 0;\n if (typeof yVal === 'number') {\n this.listener.forwardY.value = yVal;\n this.listener.forwardY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.forwardY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.listener.forwardY);\n }\n return this.listener.forwardY.value;\n };\n p5.Listener3D.prototype.forwardZ = function(zVal, time) {\n var t = time || 0;\n if (typeof zVal === 'number') {\n this.listener.forwardZ.value = zVal;\n this.listener.forwardZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.listener.forwardZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\n } else if (zVal) {\n zVal.connect(this.listener.forwardZ);\n }\n return this.listener.forwardZ.value;\n };\n p5.Listener3D.prototype.upX = function(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(xVal, this.ac.currentTime + 0.02 + t);\n } else if (xVal) {\n xVal.connect(this.listener.upX);\n }\n return this.listener.upX.value;\n };\n p5.Listener3D.prototype.upY = function(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(yVal, this.ac.currentTime + 0.02 + t);\n } else if (yVal) {\n yVal.connect(this.listener.upY);\n }\n return this.listener.upY.value;\n };\n p5.Listener3D.prototype.upZ = function(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(zVal, this.ac.currentTime + 0.02 + t);\n } else if (zVal) {\n zVal.connect(this.listener.upZ);\n }\n return this.listener.upZ.value;\n };\n \n return p5.Listener3D;\n\n});","'use strict';\n\ndefine(function (require) {\n var Filter = require('filter');\n var Effect = require('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 */\n p5.Delay = function() {\n \tEffect.call(this);\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 /**\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(1200, this.ac.currentTime);\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\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 };\n\n p5.Delay.prototype = Object.create(Effect.prototype);\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 p5.Delay.prototype.process = function(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('Delay Time exceeds maximum delay time of ' + this._maxDelay + ' second.');\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 p5.Delay.prototype.delayTime = function(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 }\n\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 p5.Delay.prototype.feedback = function(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 }\n else if (f >= 1.0) {\n throw new Error('Feedback value will force a positive feedback loop.');\n }\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 p5.Delay.prototype.filter = function(freq, q) {\n this._leftFilter.set(freq, q);\n this._rightFilter.set(freq, q);\n };\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 p5.Delay.prototype.setType = function(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 p5.Delay.prototype.dispose = function() {\n\n Effect.prototype.dispose.apply(this);\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});\n","'use strict';\n\ndefine(function (require) {\n var CustomError = require('errorHandler');\n var Effect = require('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\n\n p5.Reverb = function() {\n Effect.call(this);\n\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\n p5.Reverb.prototype = Object.create(Effect.prototype);\n\n p5.Reverb.prototype._initConvolverNode = function() {\n this.convolverNode = this.ac.createConvolver();\n this.input.connect(this.convolverNode);\n this.convolverNode.connect(this.wet);\n };\n\n p5.Reverb.prototype._teardownConvolverNode = function() {\n if (this.convolverNode) {\n this.convolverNode.disconnect();\n delete this.convolverNode;\n }\n };\n\n p5.Reverb.prototype._setBuffer = function(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 p5.Reverb.prototype.process = function(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 p5.Reverb.prototype.set = function(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 p5.Reverb.prototype._buildImpulse = function() {\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 p5.Reverb.prototype.dispose = function() {\n Effect.prototype.dispose.apply(this);\n this._teardownConvolverNode();\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 */\n p5.Convolver = function(path, callback, errorCallback) {\n \t p5.Reverb.call(this);\n\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 }\n else {\n // parameters\n this._seconds = 3;\n this._decay = 2;\n this._reverse = false;\n\n this._buildImpulse();\n }\n\n };\n\n p5.Convolver.prototype = Object.create(p5.Reverb.prototype);\n\n p5.prototype.registerPreloadMethod('createConvolver', p5.prototype);\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 */\n p5.prototype.createConvolver = function(path, callback, errorCallback) {\n // if loading locally without a server\n if (window.location.origin.indexOf('file://') > -1 && window.cordova === 'undefined') {\n alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS');\n }\n var self = this;\n var cReverb = new p5.Convolver(path, function(buffer) {\n if (typeof callback === 'function') {\n callback(buffer);\n }\n\n if (typeof self._decrementPreload === 'function') {\n self._decrementPreload();\n }\n }, errorCallback);\n cReverb.impulses = [];\n return cReverb;\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 p5.Convolver.prototype._loadBuffer = function(path, callback, errorCallback) {\n var path = p5.prototype._checkFileFormats(path);\n var self = this;\n var errorTrace = new Error().stack;\n var ac = p5.prototype.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(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(msg +'\\n The error stack trace includes: \\n' + err.stack);\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 = 'Unable to load ' + self.url +\n '. The request status was: ' + request.status + ' (' + request.statusText + ')';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(msg +'\\n The error stack trace includes: \\n' + err.stack);\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 = 'There was no response from the server at ' + self.url + '. Check the url and internet connectivity.';\n\n if (errorCallback) {\n err.message = msg;\n errorCallback(err);\n } else {\n console.error(msg +'\\n The error stack trace includes: \\n' + err.stack);\n }\n };\n request.send();\n };\n\n p5.Convolver.prototype.set = null;\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 p5.Convolver.prototype.process = function(src) {\n src.connect(this.input);\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 p5.Convolver.prototype.impulses = [];\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 p5.Convolver.prototype.addImpulse = function(path, callback, errorCallback) {\n // if loading locally without a server\n if (window.location.origin.indexOf('file://') > -1 && window.cordova === 'undefined') {\n alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS');\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 p5.Convolver.prototype.resetImpulse = function(path, callback, errorCallback) {\n // if loading locally without a server\n if (window.location.origin.indexOf('file://') > -1 && window.cordova === 'undefined') {\n alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS');\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 p5.Convolver.prototype.toggleImpulse = function(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 p5.Convolver.prototype.dispose = function() {\n p5.Reverb.prototype.dispose.apply(this);\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","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\n\n // requires the Tone.js library's Clock (MIT license, Yotam Mann)\n // https://github.com/TONEnoTONE/Tone.js/\n var Clock = require('Tone/core/Clock');\n\n p5.Metro = function() {\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 p5.Metro.prototype.ontick = function(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 (phraseArray[bNum] !== 0 && (self.metroTicks < phraseArray.length || !thisPhrase.looping) ) {\n thisPhrase.callback(secondsFromNow, phraseArray[bNum]);\n }\n });\n });\n this.metroTicks += 1;\n this.tickCallback(secondsFromNow);\n }\n };\n\n p5.Metro.prototype.setBPM = function(bpm, rampTime) {\n var beatTime = 60 / (bpm*this.tatums);\n var now = p5sound.audiocontext.currentTime;\n this.tatumTime = beatTime;\n\n var rampTime = rampTime || 0;\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 p5.Metro.prototype.getBPM = function() {\n return this.clock.getRate() / this.tatums * 60;\n };\n\n p5.Metro.prototype._init = function() {\n this.metroTicks = 0;\n // this.setBPM(120);\n };\n\n // clear existing synced parts, add only this one\n p5.Metro.prototype.resetSync = function(part) {\n this.syncedParts = [part];\n };\n\n // push a new synced part to the array\n p5.Metro.prototype.pushSync = function(part) {\n this.syncedParts.push(part);\n };\n\n p5.Metro.prototype.start = function(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 p5.Metro.prototype.stop = function(timeFromNow) {\n var t = timeFromNow || 0;\n var now = p5sound.audiocontext.currentTime;\n this.clock.stop(now + t);\n };\n\n p5.Metro.prototype.beatLength = function(tatums) {\n this.tatums = 1/tatums / 4; // lowest possible division of a beat\n };\n\n});\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});","'use strict';\n\ndefine(function(require) {\n var p5sound = require('master');\n\n var 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 */\n p5.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 */\n p5.Phrase = function(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 *

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 */\n p5.Part = function(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 p5.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 p5.Part.prototype.setBPM = function(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 p5.Part.prototype.getBPM = function() {\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 p5.Part.prototype.start = function(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 p5.Part.prototype.loop = function(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 p5.Part.prototype.noLoop = function() {\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 p5.Part.prototype.stop = function(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 p5.Part.prototype.pause = function(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 p5.Part.prototype.addPhrase = function(name, callback, array) {\n var p;\n if (arguments.length === 3) {\n p = new p5.Phrase(name, callback, array);\n } else if (arguments[0] instanceof p5.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 p5.Part.prototype.removePhrase = function(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 p5.Part.prototype.getPhrase = function(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 p5.Part.prototype.replaceSequence = function(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 p5.Part.prototype.incrementStep = function(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 p5.Part.prototype.onStep = function(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 */\n p5.Score = function() {\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 p5.Score.prototype.onended = function() {\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 p5.Score.prototype.start = function() {\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 p5.Score.prototype.stop = function() {\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 p5.Score.prototype.pause = function() {\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 p5.Score.prototype.loop = function() {\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 p5.Score.prototype.noLoop = function() {\n this.looping = false;\n };\n\n p5.Score.prototype.resetParts = function() {\n var self = this;\n this.parts.forEach(function(part) {\n self.resetParts[part];\n });\n };\n\n p5.Score.prototype.resetPart = function(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 p5.Score.prototype.setBPM = function(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 function 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\n});\n","'use strict';\n\ndefine(function (require) {\n var p5sound = require('master');\n var Clock = require('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 */\n p5.SoundLoop = function(callback, interval) {\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 '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 p5.SoundLoop.prototype.start = function(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 p5.SoundLoop.prototype.stop = function(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 * Pause the loop\n * @method pause\n * @for p5.SoundLoop\n * @param {Number} [timeFromNow] schedule a pausing time\n */\n p5.SoundLoop.prototype.pause = function(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 /**\n * Synchronize loops. Use this method to start two more 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 p5.SoundLoop.prototype.syncedStart = function(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\n /**\n * Updates frequency value, reflected in next callback\n * @private\n * @for p5.SoundLoop\n * @method _update\n */\n p5.SoundLoop.prototype._update = function() {\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 p5.SoundLoop.prototype._calcFreq = function() {\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 this._bpm / 60 / this._convertNotation(this._interval) * (this._timeSignature / 4);\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 p5.SoundLoop.prototype._convertNotation = function(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('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 * Helper conversion methods of measure and note\n * @private\n * @for p5.SoundLoop\n * @method _measure\n */\n p5.SoundLoop.prototype._measure = function(value) {\n return value * this._timeSignature;\n };\n\n /**\n * @private\n * @method _note\n * @for p5.SoundLoop\n */\n p5.SoundLoop.prototype._note = function(value) {\n return this._timeSignature / value ;\n };\n\n\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(p5.SoundLoop.prototype, 'bpm', {\n get : function() {\n return this._bpm;\n },\n set : function(bpm) {\n if (!this.musicalTimeMode) {\n console.warn('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 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(p5.SoundLoop.prototype, 'timeSignature', {\n get : function() {\n return this._timeSignature;\n },\n set : function(timeSig) {\n if (!this.musicalTimeMode) {\n console.warn('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 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(p5.SoundLoop.prototype, '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(p5.SoundLoop.prototype, 'iterations', {\n get : function() {\n return this.clock.ticks;\n }\n });\n\n return p5.SoundLoop;\n});\n","define(function (require) {\n\t'use strict';\n\n\tvar p5sound = require('master');\n\tvar Effect = require('effect');\n var CustomError = require('errorHandler');\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 */\n\tp5.Compressor = function() {\n\t\tEffect.call(this);\n\n /**\n * The p5.Compressor is built with a Web Audio Dynamics Compressor Node\n * \n * @property {AudioNode} compressor\n */\n\n\n\t\tthis.compressor = this.ac.createDynamicsCompressor();\n\n this.input.connect(this.compressor);\n this.compressor.connect(this.wet);\n\t};\n\n\tp5.Compressor.prototype = Object.create(Effect.prototype);\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\tp5.Compressor.prototype.process = function(src, attack, knee,\n ratio, threshold, release) {\n\t\tsrc.connect(this.input);\n\t\tthis.set(attack, knee, ratio, threshold, release);\n\t};\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 p5.Compressor.prototype.set = function (attack, knee,\n ratio, threshold, release) {\n\n if (typeof attack !== 'undefined') {this.attack(attack);}\n if (typeof knee !== 'undefined') {this.knee(knee);}\n if (typeof ratio !== 'undefined') {this.ratio(ratio);}\n if (typeof threshold !== 'undefined') {this.threshold(threshold);}\n if (typeof release !== 'undefined') {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 p5.Compressor.prototype.attack = function (attack, time){\n var t = time || 0;\n if (typeof attack == 'number'){\n this.compressor.attack.value = attack;\n this.compressor.attack.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.attack.linearRampToValueAtTime(attack, this.ac.currentTime + 0.02 + t);\n } else if (typeof attack !== 'undefined') {\n attack.connect(this.compressor.attack);\n }\n return this.compressor.attack.value;\n };\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 p5.Compressor.prototype.knee = function (knee, time){\n var t = time || 0;\n if (typeof knee == 'number'){\n this.compressor.knee.value = knee;\n this.compressor.knee.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.knee.linearRampToValueAtTime(knee, this.ac.currentTime + 0.02 + t);\n } else if (typeof knee !== 'undefined') {\n knee.connect(this.compressor.knee);\n }\n return this.compressor.knee.value;\n };\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 p5.Compressor.prototype.ratio = function (ratio, time){\n var t = time || 0;\n if (typeof ratio == 'number'){\n this.compressor.ratio.value = ratio;\n this.compressor.ratio.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.ratio.linearRampToValueAtTime(ratio, this.ac.currentTime + 0.02 + t);\n } else if (typeof ratio !== 'undefined') {\n ratio.connect(this.compressor.ratio);\n }\n return this.compressor.ratio.value;\n };\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 p5.Compressor.prototype.threshold = function (threshold, time){\n var t = time || 0;\n if (typeof threshold == 'number'){\n this.compressor.threshold.value = threshold;\n this.compressor.threshold.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.threshold.linearRampToValueAtTime(threshold, this.ac.currentTime + 0.02 + t);\n } else if (typeof threshold !== 'undefined') {\n threshold.connect(this.compressor.threshold);\n }\n return this.compressor.threshold.value;\n };\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 p5.Compressor.prototype.release = function (release, time){\n var t = time || 0;\n if (typeof release == 'number'){\n this.compressor.release.value = release;\n this.compressor.release.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\n this.compressor.release.linearRampToValueAtTime(release, this.ac.currentTime + 0.02 + t);\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 p5.Compressor.prototype.reduction =function() {\n return this.compressor.reduction.value;\n };\n\n\n\tp5.Compressor.prototype.dispose = function() {\n Effect.prototype.dispose.apply(this);\n if (this.compressor) {\n this.compressor.disconnect();\n delete this.compressor;\n }\n\t};\n\n return p5.Compressor;\n});\n","'use strict';\n\ndefine(function (require) {\n\n // inspiration: recorder.js, Tone.js & typedarray.org\n\n const p5sound = require('master');\n const { convertToWav, safeBufferSize } = require('helpers');\n const processorNames = require('./audioWorklet/processorNames');\n const 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 */\n p5.SoundRecorder = function() {\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(ac, processorNames.recorderProcessor, {\n outputChannelCount: [this._outputChannels],\n processorOptions: {\n numInputChannels: this._inputChannels,\n bufferSize: workletBufferSize\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 p5.SoundRecorder.prototype.setInput = function(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 p5.SoundRecorder.prototype.record = function(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 }\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 p5.SoundRecorder.prototype.stop = function() {\n this._workletNode.port.postMessage({ name: 'stop' });\n };\n\n p5.SoundRecorder.prototype.dispose = function() {\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\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.\n p5.prototype.saveSound = function (soundFile, fileName) {\n const dataView = convertToWav(soundFile.buffer);\n p5.prototype.writeFile([dataView], fileName, 'wav');\n };\n});\n","'use strict';\n\ndefine(function () {\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 */\n p5.PeakDetect = function(freq1, freq2, threshold, _framesPerPeak) {\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 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 /**\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 p5.PeakDetect.prototype.update = function(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\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 p5.PeakDetect.prototype.onPeak = function(callback, val) {\n var self = this;\n\n self._onPeak = function() {\n callback(self.energy, val);\n };\n };\n\n});\n","'use strict';\n\ndefine(function (require) {\n var p5sound = require('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\n p5.Gain = function() {\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\n p5.Gain.prototype.setInput = function(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 p5.Gain.prototype.connect = function(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 p5.Gain.prototype.disconnect = function() {\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 p5.Gain.prototype.amp = function(vol, rampTime, tFromNow) {\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);\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\n };\n\n p5.Gain.prototype.dispose = function() {\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});\n","'use strict';\n\ndefine(function (require) {\n\n var Effect = require('effect');\n\n /*\n * Adapted from [Kevin Ennis on StackOverflow](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\n */\n function 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 */\n p5.Distortion = function(amount, oversample) {\n Effect.call(this);\n\n if (typeof amount === 'undefined') {\n amount = 0.25;\n } if (typeof amount !== 'number') {\n throw new Error('amount must be a number');\n } if (typeof oversample === 'undefined') {\n oversample = '2x';\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 p5.Distortion.prototype = Object.create(Effect.prototype);\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 p5.Distortion.prototype.process = function(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 p5.Distortion.prototype.set = function(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 p5.Distortion.prototype.getAmount = function() {\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 p5.Distortion.prototype.getOversample = function() {\n return this.waveShaperNode.oversample;\n };\n\n\n p5.Distortion.prototype.dispose = function() {\n Effect.prototype.dispose.apply(this);\n if (this.waveShaperNode) {\n this.waveShaperNode.disconnect();\n this.waveShaperNode = null;\n }\n };\n});\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../node_modules/tone/Tone/core/Tone.js","webpack:///./master.js","webpack:///../node_modules/tone/Tone/signal/Signal.js","webpack:///../node_modules/tone/Tone/signal/Multiply.js","webpack:///./effect.js","webpack:///../node_modules/tone/Tone/signal/WaveShaper.js","webpack:///./helpers.js","webpack:///../node_modules/tone/Tone/signal/Add.js","webpack:///../node_modules/tone/Tone/type/Type.js","webpack:///../node_modules/tone/Tone/core/Gain.js","webpack:///./audioWorklet/processorNames.js","webpack:///./errorHandler.js","webpack:///../node_modules/tone/Tone/core/Context.js","webpack:///../node_modules/tone/Tone/signal/Scale.js","webpack:///../node_modules/tone/Tone/signal/TimelineSignal.js","webpack:///./filter.js","webpack:///../node_modules/tone/Tone/signal/Subtract.js","webpack:///./audiocontext.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:///./oscillator.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/tone/Tone/core/Clock.js","webpack:///./monosynth.js","webpack:///./audioVoice.js","webpack:///./polysynth.js","webpack:///./app.js","webpack:///../node_modules/audioworklet-polyfill/dist/audioworklet-polyfill.js","webpack:///./shims.js","webpack:///../node_modules/webpack/buildin/global.js","webpack:///../node_modules/startaudiocontext/StartAudioContext.js","webpack:///./audioWorklet/index.js","webpack:///./audioWorklet/recorderProcessor.js","webpack:///./audioWorklet/soundFileProcessor.js","webpack:///./audioWorklet/amplitudeProcessor.js","webpack:///./panner.js","webpack:///./soundfile.js","webpack:///./amplitude.js","webpack:///./fft.js","webpack:///./signal.js","webpack:///../node_modules/tone/Tone/type/Frequency.js","webpack:///../node_modules/tone/Tone/type/TransportTime.js","webpack:///./envelope.js","webpack:///./pulse.js","webpack:///./noise.js","webpack:///./audioin.js","webpack:///../node_modules/tone/Tone/component/CrossFade.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:///./eq.js","webpack:///./eqFilter.js","webpack:///./panner3d.js","webpack:///./listener3d.js","webpack:///./delay.js","webpack:///./reverb.js","webpack:///./metro.js","webpack:///../node_modules/tone/Tone/core/TimelineState.js","webpack:///./looper.js","webpack:///./soundLoop.js","webpack:///./compressor.js","webpack:///./soundRecorder.js","webpack:///./peakDetect.js","webpack:///./gain.js","webpack:///./distortion.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","__WEBPACK_AMD_DEFINE_ARRAY__","__WEBPACK_AMD_DEFINE_RESULT__","undefined","audiocontext","p5sound","limiter","createDynamicsCompressor","threshold","ratio","knee","meter","fftMeter","soundArray","parts","extensions","p5","getMasterVolume","masterVolume","vol","tFromNow","currentTime","currentVol","cancelScheduledValues","linearRampToValueAtTime","soundOut","_silentNode","_gain","_param","getConstant","units","Type","Default","convert","SignalBase","Multiply","createInsOuts","_mult","Gain","require","CrossFade","Effect","ac","_drywet","wet","a","b","amp","drywet","fade","u","index","WaveShaper","mapping","bufferLen","_shaper","createWaveShaper","_curve","curve","isFinite","Float32Array","setMap","len","normalized","oversample","oversampling","RangeError","processorNames","freqToMidi","f","mathlog2","round","midiToFreq","writeUTFBytes","view","offset","string","lng","setUint8","charCodeAt","soundFormats","toLowerCase","disposeSound","registerMethod","_checkFileFormats","paths","path","extTest","pop","isFileSupported","pathSplit","pathCore","extension","_typeof","_mathChain","math","thisChain","nextChain","type","mathOps","convertToWav","audioBuffer","leftChannel","interleaved","rightChannel","result","inputIndex","interleave","getChannelData","numberOfChannels","buffer","ArrayBuffer","DataView","setUint32","setUint16","setInt16","noteToFreq","note","A","B","C","D","E","F","G","toUpperCase","slice","safeBufferSize","idealBufferSize","bufferSize","tempAudioWorkletNode","AudioWorkletNode","soundFileProcessor","ScriptProcessorNode","Add","_sum","Time","Frequency","TransportTime","Ticks","NormalRange","AudioRange","Decibels","Interval","BPM","Positive","Cents","Degrees","MIDI","BarsBeatsSixteenths","Samples","Hertz","Note","Milliseconds","Seconds","Notation","toSeconds","time","TimeBase","toFrequency","freq","valueOf","toTicks","Transport","ticks","GainNode","AudioContext","createGainNode","_gainNode","recorderProcessor","amplitudeProcessor","errorTrace","failedPath","tempStack","splitStack","err","Error","originalStack","stack","filter","ln","toneConnect","outNum","inNum","nativeConnect","e","nativeDisconnect","webkitAudioContext","prop","Emitter","_context","_defineProperty","_latencyHint","_lookAhead","_updateInterval","_computedUpdateInterval","_worker","_createWorker","_constants","mixin","URL","webkitURL","blob","Blob","toFixed","blobUrl","createObjectURL","worker","Worker","addEventListener","_lastUpdate","diff","max","createBuffer","arr","constant","createBufferSource","channelCount","channelCountMode","loop","start","lA","blockTime","postMessage","hint","lookAhead","latencyHint","updateInterval","supported","Scale","outputMin","outputMax","_outputMin","_outputMax","_scale","_add","_setRange","min","TimelineSignal","_events","Timeline","_initial","_fromUnits","Linear","Exponential","Target","Curve","Set","getValueAtTime","_toUnits","convertedVal","setValueAtTime","startTime","add","endTime","exponentialRampToValueAtTime","beforeEvent","_searchBefore","_minOutput","setValue","sampleTime","setTargetAtTime","timeConstant","setValueCurveAtTime","duration","scaling","floats","segmentTime","after","cancel","setRampPoint","before","_searchAfter","linearRampToValueBetween","finish","exponentialRampToValueBetween","getAfter","previouVal","previous","getBefore","_exponentialApproach","_curveInterpolate","_linearInterpolate","_exponentialInterpolate","t0","v0","v1","exp","t1","progress","lowerIndex","floor","upperIndex","ceil","lowerVal","upperVal","Filter","biquad","createBiquadFilter","setType","_on","_untoggledType","process","src","res","frequency","Q","toggle","LowPass","HighPass","BandPass","Subtract","_neg","Negate","global","StartAudioContext","getAudioContext","userStartAudio","elements","callback","elt","Element","map","on","event","events","eventName","off","ev","eventList","args","functions","func","emitterFunc","node","outputNumber","inputNumber","overridden","_plusNow","_unaryExpressions","quantize","regexp","method","rh","nextSubdivision","lh","subdiv","_expr","expr","subdivision","addNow","_defaultExpr","_noOp","copy","toNotation","retNotation","_toNotationHelper","retTripletNotation","testNotations","_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","Mult","Oscillator","started","phaseAmount","oscillator","createOscillator","_freqMods","panPosition","connection","panner","Panner","stop","abs","freqNode","getAmp","isNaN","phase","getFreq","getType","oscMods","pan","pval","getPan","osc2","delayAmt","dNode","createDelay","delayTime","sigChain","mathObj","chainSource","num","scale","inMin","inMax","outMin","outMax","mapOutMin","mapOutMax","SinOsc","TriOsc","SawOsc","SqrOsc","_timeline","_toRemove","_iterating","memory","Infinity","_search","remove","shift","cancelBefore","beginning","end","midPoint","nextEvent","_iterate","lowerBound","upperBound","forEach","forEachBefore","forEachAfter","forEachFrom","forEachAtTime","_multiply","GreaterThanZero","_thresh","Clock","_nextTick","_lastState","_state","TimelineState","_boundLoop","_loop","state","setStateAtTime","pause","loopInterval","lag","currentState","tickTime","getStateAtTime","AudioVoice","MonoSynth","env","Envelope","setRange","setExp","setADSR","setInput","play","velocity","secondsFromNow","susTime","triggerAttack","triggerRelease","vel","ramp","attack","decay","sustain","release","defineProperties","aTime","dTime","sPercent","rTime","sustime","PolySynth","audioVoice","maxVoices","audiovoices","notes","_newest","_oldest","_voicesInUse","_allocateVoices","noteAttack","noteRelease","noteADSR","timeFromNow","voice","_note","_velocity","currentVoice","acTime","oldestNote","previousVal","_updateAfter","maxRange","nextTime","p5SOUND","parameters","fill","processor","realm","exec","inputBuffer","outputBuffer","$$processors","$$context","self","createScriptProcessor","outputChannelCount","Map","properties","defaultValue","MessageChannel","port2","Processor","port","port1","onaudioprocess","$$audioWorklet","AudioWorklet","addModule","fetch","then","ok","status","text","AudioWorkletProcessor","registerProcessor","parameterDescriptors","document","createElement","style","cssText","appendChild","contentWindow","createTextNode","body","$hook","console","documentElement","transpile","String","fixSetTarget","setTargetValueAtTime","createDelayNode","createJavaScriptNode","createPeriodicWave","createWaveTable","internal_createGain","internal_createDelay","maxDelayTime","internal_createBufferSource","internal_start","when","noteGrainOn","noteOn","internal_stop","noteOff","playbackRate","internal_createDynamicsCompressor","reduction","internal_createBiquadFilter","detune","internal_createOscillator","setPeriodicWave","setWaveTable","OfflineAudioContext","webkitOfflineAudioContext","navigator","getUserMedia","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","el","isSupported","canPlayType","g","Function","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","querySelectorAll","jquery","toArray","tap","moduleSources","initializedAudioWorklets","preload","_incrementPreload","onWorkletModulesLoad","_decrementPreload","all","moduleSrc","objectURL","audioWorklet","__webpack_exports__","createStereoPanner","stereoPanner","inputChannels","obj","numInputChannels","left","right","channelInterpretation","splitter","createChannelSplitter","createChannelMerger","v","rightVal","cos","leftVal","numChannels","CustomError","_require","SoundFile","onload","onerror","whileLoading","url","File","FileReader","FileList","file","_onended","_looping","_playing","_paused","_pauseTime","_cues","_cueIDCounter","_lastPos","_counterNode","_workletNode","bufferSourceNodes","bufferSourceNode","reversed","pauseTime","startMillis","load","_whileLoading","_clearOnEnd","thisBufferSourceNode","target","soundFile","_","reverse","registerPreloadMethod","loadSound","location","origin","cordova","alert","errorCallback","request","XMLHttpRequest","evt","_updateProgress","open","responseType","decodeAudioData","response","buff","msg","statusText","message","send","reader","readAsArrayBuffer","lengthComputable","percentComplete","loaded","isLoaded","rate","_cueStart","cueStart","cueEnd","setVolume","isPlaying","_initSourceNode","_initCounterNode","_arrayIndex","loopStart","loopEnd","playMode","str","pTime","setLoop","bool","isLooping","isPaused","stopAll","_time","_rampTime","_tFromNow","getVolume","reverseBuffer","setPitch","newPlaybackRate","getPlaybackRate","jump","cueTime","cTime","dur","channels","frames","getPeaks","width","sampleSize","sampleStep","peaks","chan","currentPos","curVol","onended","getLevel","setPath","setBuffer","buf","size","newBuffer","channelNum","_this","cNode","workletBufferSize","processorOptions","onmessage","data","_onTimeUpdate","audioBuf","arrayBuffer","_createCounterBuffer","processPeaks","_initThreshold","_minThreshold","_minPeaks","bufLen","allPeaks","minThreshold","minPeaks","offlineContext","startRendering","oncomplete","filteredBuffer","renderedBuffer","bufferData","getPeaksAtThreshold","topTempos","intervalCounts","tempoCounts","intervalCount","theoreticalTempo","mapTempo","some","tempoCount","tempo","count","groupNeighborsByTempo","peaksObj","peaksArray","sort","startPeak","endPeak","startPos","sampleIndex","intervals","countIntervalsBetweenNearbyPeaks","intA","intB","tempoPeaks","bpmVariance","peaksAtTopTempo","peak","intervalBPM","peakTime","getPeaksAtTopTempo","Peak","amplitude","tempos","Cue","id","addCue","cue","removeCue","cueLength","clearCues","playbackTime","callbackTime","_prevUpdateTime","save","fileName","saveSound","getBlob","dataView","Amplitude","smoothing","parameterData","normalize","volume","volNorm","stereoVol","stereoVolNorm","channel","toggleNormalize","smooth","FFT","bins","analyser","createAnalyser","fftSize","configurable","smoothingTimeConstant","freqDomain","Uint8Array","frequencyBinCount","timeDomain","bass","lowMid","mid","highMid","treble","waveform","_isSafari","timeToFloat","getFloatTimeDomainData","timeToInt","getByteTimeDomainData","normalArray","scaled","analyze","freqToFloat","getFloatFrequencyData","freqToInt","getByteFrequencyData","getEnergy","frequency1","frequency2","nyquist","swap","lowIndex","highIndex","numFrequencies","freq1","freq2","getCentroid","cumulative_sum","centroid_normalization","mean_freq_index","linAverages","N","spectrum","spectrumLength","spectrumStep","linearAverages","groupIndex","specIndex","logAverages","octaveBands","octaveIndex","hi","getOctaveBands","fCtr0","lastFrequencyBand","lo","ctr","newFrequencyBand","fft","_input","midi","midiToFrequency","pitch","octave","noteNumber","noteToScaleIndex","transpose","harmonize","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","l1","t2","l2","t3","l3","aLevel","dLevel","rLevel","_rampHighPercentage","_rampLowPercentage","control","_init","isExponential","sourceToClear","wasTriggered","_setRampAD","_rampAttackTime","checkExpInput","_rampDecayTime","TCDenominator","_rampAttackTC","_rampDecayTC","setRampPercentages","p1","p2","isExp","lastAttack","valToSet","v2","destination1","destination2","AudioIn","Reverb","Noise","Delay","Env","createDCOffset","bufferSource","Pulse","w","dcOffset","dcGain","mW","sig","SignalAdd","mods","currentFreq","freqMod","assignType","_brownNoise","_pinkNoise","_whiteNoise","whiteBuffer","noiseData","random","b0","b1","b2","b3","b4","b5","b6","pinkBuffer","white","brownBuffer","lastOut","noise","inputSources","stream","mediaStream","currentSource","enabled","MediaStreamTrack","mediaDevices","successCallback","audioSource","constraints","audio","echoCancellation","deviceId","createMediaStreamSource","getTracks","track","getSources","onSuccess","onError","resolve","reject","enumerateDevices","devices","device","kind","error","setSource","active","initialFade","_equalPowerA","EqualPowerGain","_equalPowerB","_invert","Expr","applyBinary","Constructor","_eval","applyUnary","getNumber","literalNumber","_replacements","inputCount","_parseInputs","_nodes","tree","_parseTree","_disposeNodes","_Expressions","signal","glue",",","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","EQFilter","EQ","_eqsize","factor","bands","_newBand","Panner3D","createPanner","panningModel","distanceModel","xVal","yVal","zVal","positionX","positionY","positionZ","orient","orientX","orientY","orientZ","orientationX","orientationY","orientationZ","setFalloff","maxDistance","rolloffFactor","maxDist","rolloff","Listener3D","listener","xValF","yValF","zValF","xValU","yValU","zValU","orientForward","orientUp","forwardX","forwardY","forwardZ","upX","upY","upZ","_split","_merge","_leftGain","_rightGain","leftDelay","rightDelay","_leftFilter","_rightFilter","_maxDelay","maxValue","feedback","_delayTime","_feedback","_filter","_initConvolverNode","_seconds","_decay","_reverse","_buildImpulse","convolverNode","createConvolver","_teardownConvolverNode","_setBuffer","decayRate","rebuild","impulse","impulseL","impulseR","Convolver","impulses","_loadBuffer","cReverb","chunks","addImpulse","resetImpulse","toggleImpulse","Metro","clock","ontick","syncedParts","prevTick","tatumTime","tickCallback","elapsedTime","thisPart","incrementStep","phrases","thisPhrase","phraseArray","sequence","bNum","metroTicks","looping","setBPM","beatTime","tatums","getBPM","getRate","resetSync","part","pushSync","beatLength","initial","playNextPart","aScore","currentPart","scoreStep","Phrase","phraseStep","Part","steps","bLength","partStep","noLoop","metro","addPhrase","array","removePhrase","getPhrase","replaceSequence","onStep","Score","thisScore","nextPart","resetPart","resetParts","SoundLoop","musicalTimeMode","_interval","_bpm","maxIterations","iterations","_calcFreq","syncedStart","otherLoop","_update","_convertNotation","Number","_measure","timeSig","Compressor","compressor","number","SoundRecorder","_inputChannels","_outputChannels","buffers","leftBuffer","rightBuffer","_callback","record","sFile","writeFile","PeakDetect","_framesPerPeak","framesPerPeak","framesSinceLastPeak","cutoff","cutoffMult","energy","penergy","currentValue","isDetected","f1","f2","_onPeak","update","fftObject","nrg","onPeak","makeDistortionCurve","amount","k","deg","Distortion","curveAmount","waveShaperNode","getAmount","getOversample"],"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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s6C,eAAiBt6C,KAAK0J,GAAGc,mBAE9BxK,KAAKi6C,OAASI,EACdr6C,KAAKs6C,eAAe5vC,MAAQsvC,EAAoBK,GAChDr6C,KAAKs6C,eAAetvC,WAAaA,EAEjChL,KAAKE,MAAMiD,QAAQnD,KAAKs6C,gBAExBt6C,KAAKs6C,eAAen3C,QAAQnD,KAAK4J,MAGnC5B,GAAGoyC,WAAW56C,UAAYlB,OAAOY,OAAOuK,EAAOjK,WAY/CwI,GAAGoyC,WAAW56C,UAAUsa,QAAU,SAASC,EAAKkgC,EAAQjvC,GACtD+O,EAAI5W,QAAQnD,KAAKE,OACjBF,KAAKQ,IAAIy5C,EAAQjvC,IAYnBhD,GAAGoyC,WAAW56C,UAAUgB,IAAM,SAASy5C,EAAQjvC,GAC7C,GAAIivC,EAAQ,CACV,IAAII,EAAcryC,GAAGxI,UAAU0b,IAAI++B,EAAQ,EAAK,EAAK,EAAG,KACxDj6C,KAAKi6C,OAASI,EACdr6C,KAAKs6C,eAAe5vC,MAAQsvC,EAAoBK,GAE9CrvC,IACFhL,KAAKs6C,eAAetvC,WAAaA,IAYrChD,GAAGoyC,WAAW56C,UAAU+6C,UAAY,WAClC,OAAOv6C,KAAKi6C,QAUdjyC,GAAGoyC,WAAW56C,UAAUg7C,cAAgB,WACtC,OAAOx6C,KAAKs6C,eAAetvC,YAI7BhD,GAAGoyC,WAAW56C,UAAUwD,QAAU,WAChCyG,EAAOjK,UAAUwD,QAAQU,MAAM1D,MAC3BA,KAAKs6C,iBACPt6C,KAAKs6C,eAAep3C,aACpBlD,KAAKs6C,eAAiB,QAzItBv8C,KAAAL,EAAAF,EAAAE,EAAAC,QAAAD,QAAAwJ","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 = 31);\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","'use strict';\r\n\r\n\r\ndefine(['audiocontext'], function (audiocontext) {\r\n // Master contains the master sound output.\r\n var Master = function() {\r\n this.input = audiocontext.createGain();\r\n this.output = audiocontext.createGain();\r\n\r\n //put a hard limiter on the output\r\n this.limiter = audiocontext.createDynamicsCompressor();\r\n this.limiter.threshold.value = -3;\r\n this.limiter.ratio.value = 20;\r\n this.limiter.knee.value = 1;\r\n\r\n this.audiocontext = audiocontext;\r\n\r\n this.output.disconnect();\r\n\r\n // connect input to limiter\r\n this.input.connect(this.limiter);\r\n\r\n // connect limiter to output\r\n this.limiter.connect(this.output);\r\n\r\n // meter is just for global Amplitude / FFT analysis\r\n this.meter = audiocontext.createGain();\r\n this.fftMeter = audiocontext.createGain();\r\n this.output.connect(this.meter);\r\n this.output.connect(this.fftMeter);\r\n\r\n // connect output to destination\r\n this.output.connect(this.audiocontext.destination);\r\n\r\n // an array of all sounds in the sketch\r\n this.soundArray = [];\r\n // an array of all musical parts in the sketch\r\n this.parts = [];\r\n\r\n // file extensions to search for\r\n this.extensions = [];\r\n };\r\n\r\n // create a single instance of the p5Sound / master output for use within this sketch\r\n var p5sound = new Master();\r\n\r\n /**\r\n * Returns a number representing the master amplitude (volume) for sound\r\n * in this sketch.\r\n *\r\n * @method getMasterVolume\r\n * @return {Number} Master amplitude (volume) for sound in this sketch.\r\n * Should be between 0.0 (silence) and 1.0.\r\n */\r\n p5.prototype.getMasterVolume = function() {\r\n return p5sound.output.gain.value;\r\n };\r\n\r\n /**\r\n *

Scale the output of all sound in this sketch

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

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

\r\n *\r\n *

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

\r\n *\r\n * @method masterVolume\r\n * @param {Number|Object} volume Volume (amplitude) between 0.0\r\n * and 1.0 or modulating signal/oscillator\r\n * @param {Number} [rampTime] Fade for t seconds\r\n * @param {Number} [timeFromNow] Schedule this event to happen at\r\n * t seconds in the future\r\n */\r\n p5.prototype.masterVolume = function(vol, rampTime, tFromNow) {\r\n if (typeof vol === 'number') {\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n var currentVol = p5sound.output.gain.value;\r\n p5sound.output.gain.cancelScheduledValues(now + tFromNow);\r\n p5sound.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\r\n p5sound.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\r\n }\r\n else if (vol) {\r\n vol.connect(p5sound.output.gain);\r\n } else {\r\n // return the Gain Node\r\n return p5sound.output.gain;\r\n }\r\n };\r\n\r\n /**\r\n * `p5.soundOut` is the p5.sound master output. It sends output to\r\n * the destination of this window's web audio context. It contains\r\n * Web Audio API nodes including a dyanmicsCompressor (.limiter),\r\n * and Gain Nodes for .input and .output.\r\n *\r\n * @property {Object} soundOut\r\n */\r\n p5.prototype.soundOut = p5.soundOut = p5sound;\r\n\r\n // a silent connection to the DesinationNode\r\n // which will ensure that anything connected to it\r\n // will not be garbage collected\r\n p5.soundOut._silentNode = p5sound.audiocontext.createGain();\r\n p5.soundOut._silentNode.gain.value = 0;\r\n p5.soundOut._silentNode.connect(p5sound.audiocontext.destination);\r\n\r\n\r\n return p5sound;\r\n});\r\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});","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","'use strict';\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var CrossFade = require('Tone/component/CrossFade');\r\n\r\n /**\r\n * Effect is a base class for audio effects in p5.
\r\n * This module handles the nodes and methods that are\r\n * common and useful for current and future effects.\r\n *\r\n *\r\n * This class is extended by p5.Distortion,\r\n * p5.Compressor,\r\n * p5.Delay,\r\n * p5.Filter,\r\n * p5.Reverb.\r\n *\r\n * @class p5.Effect\r\n * @constructor\r\n *\r\n * @param {Object} [ac] Reference to the audio context of the p5 object\r\n * @param {AudioNode} [input] Gain Node effect wrapper\r\n * @param {AudioNode} [output] Gain Node effect wrapper\r\n * @param {Object} [_drywet] Tone.JS CrossFade node (defaults to value: 1)\r\n * @param {AudioNode} [wet] Effects that extend this class should connect\r\n * to the wet signal to this gain node, so that dry and wet\r\n * signals are mixed properly.\r\n */\r\n p5.Effect = function() {\r\n this.ac = p5sound.audiocontext;\r\n\r\n this.input = this.ac.createGain();\r\n this.output = this.ac.createGain();\r\n\r\n /**\r\n *\tThe p5.Effect class is built\r\n * \tusing Tone.js CrossFade\r\n * \t@private\r\n */\r\n\r\n this._drywet = new CrossFade(1);\r\n\r\n /**\r\n *\tIn classes that extend\r\n *\tp5.Effect, connect effect nodes\r\n *\tto the wet parameter\r\n */\r\n this.wet = this.ac.createGain();\r\n\r\n this.input.connect(this._drywet.a);\r\n this.wet.connect(this._drywet.b);\r\n this._drywet.connect(this.output);\r\n\r\n this.connect();\r\n\r\n //Add to the soundArray\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Set the output volume of the filter.\r\n *\r\n * @method amp\r\n * @for p5.Effect\r\n * @param {Number} [vol] amplitude between 0 and 1.0\r\n * @param {Number} [rampTime] create a fade that lasts until rampTime\r\n * @param {Number} [tFromNow] schedule this event to happen in tFromNow seconds\r\n */\r\n p5.Effect.prototype.amp = function(vol, rampTime, tFromNow){\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n var currentVol = this.output.gain.value;\r\n this.output.gain.cancelScheduledValues(now);\r\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow + .001);\r\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime + .001);\r\n };\r\n\r\n /**\r\n * Link effects together in a chain\r\n * Example usage: filter.chain(reverb, delay, panner);\r\n * May be used with an open-ended number of arguments\r\n *\r\n * @method chain\r\n * @for p5.Effect\r\n * @param {Object} [arguments] Chain together multiple sound objects\r\n */\r\n p5.Effect.prototype.chain = function(){\r\n if (arguments.length>0){\r\n this.connect(arguments[0]);\r\n for(var i=1;i\r\n * let midiNotes = [60, 64, 67, 72];\r\n * let noteIndex = 0;\r\n * let midiVal, freq;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(startSound);\r\n * osc = new p5.TriOsc();\r\n * env = new p5.Envelope();\r\n * }\r\n *\r\n * function draw() {\r\n * background(220);\r\n * text('tap to play', 10, 20);\r\n * if (midiVal) {\r\n * text('MIDI: ' + midiVal, 10, 40);\r\n * text('Freq: ' + freq, 10, 60);\r\n * }\r\n * }\r\n *\r\n * function startSound() {\r\n * // see also: userStartAudio();\r\n * osc.start();\r\n *\r\n * midiVal = midiNotes[noteIndex % midiNotes.length];\r\n * freq = midiToFreq(midiVal);\r\n * osc.freq(freq);\r\n * env.ramp(osc, 0, 1.0, 0);\r\n *\r\n * noteIndex++;\r\n * }\r\n * \r\n */\r\n var midiToFreq = p5.prototype.midiToFreq = function(m) {\r\n return 440 * Math.pow(2, (m-69)/12.0);\r\n };\r\n\r\n // This method converts ANSI notes specified as a string \"C4\", \"Eb3\" to a frequency\r\n var noteToFreq = function(note) {\r\n if (typeof note !== 'string') {\r\n return note;\r\n }\r\n var wholeNotes = {A:21, B:23, C:24, D:26, E:28, F:29, G:31};\r\n var value = wholeNotes[ note[0].toUpperCase() ];\r\n var octave = ~~note.slice(-1);\r\n value += 12 * (octave -1);\r\n\r\n switch(note[1]) {\r\n case '#':\r\n value += 1;\r\n break;\r\n case 'b':\r\n value -= 1;\r\n break;\r\n default:\r\n break;\r\n }\r\n return midiToFreq(value);\r\n };\r\n\r\n /**\r\n * List the SoundFile formats that you will include. LoadSound\r\n * will search your directory for these extensions, and will pick\r\n * a format that is compatable with the client's web browser.\r\n * Here is a free online file\r\n * converter.\r\n *\r\n * @method soundFormats\r\n * @param {String} [...formats] i.e. 'mp3', 'wav', 'ogg'\r\n * @example\r\n *
\r\n * function preload() {\r\n * // set the global sound formats\r\n * soundFormats('mp3', 'ogg');\r\n *\r\n * // load either beatbox.mp3, or .ogg, depending on browser\r\n * mySound = loadSound('assets/beatbox.mp3');\r\n * }\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * background(220);\r\n * text('sound loaded! tap to play', 10, 20, width - 20);\r\n * cnv.mousePressed(function() {\r\n * mySound.play();\r\n * });\r\n * }\r\n *
\r\n */\r\n p5.prototype.soundFormats = function() {\r\n // reset extensions array\r\n p5sound.extensions = [];\r\n // add extensions\r\n for (var i = 0; i < arguments.length; i++) {\r\n arguments[i] = arguments[i].toLowerCase();\r\n if (['mp3','wav','ogg', 'm4a', 'aac'].indexOf(arguments[i]) > -1) {\r\n p5sound.extensions.push(arguments[i]);\r\n } else {\r\n throw arguments[i] + ' is not a valid sound format!';\r\n }\r\n }\r\n };\r\n\r\n p5.prototype.disposeSound = function() {\r\n for (var i = 0; i < p5sound.soundArray.length; i++) {\r\n p5sound.soundArray[i].dispose();\r\n }\r\n };\r\n\r\n // register removeSound to dispose of p5sound SoundFiles, Convolvers,\r\n // Oscillators etc when sketch ends\r\n p5.prototype.registerMethod('remove', p5.prototype.disposeSound);\r\n\r\n p5.prototype._checkFileFormats = function(paths) {\r\n var path;\r\n // if path is a single string, check to see if extension is provided\r\n if (typeof paths === 'string') {\r\n path = paths;\r\n // see if extension is provided\r\n var extTest = path.split('.').pop();\r\n // if an extension is provided...\r\n if (['mp3','wav','ogg', 'm4a', 'aac'].indexOf(extTest) > -1) {\r\n if (p5.prototype.isFileSupported(extTest)) {\r\n path = path;\r\n }\r\n else {\r\n var pathSplit = path.split('.');\r\n var pathCore = pathSplit[pathSplit.length - 1];\r\n for (var i = 0; i 1) {\r\n rightChannel = audioBuffer.getChannelData(1);\r\n } else {\r\n rightChannel = leftChannel;\r\n }\r\n\r\n var interleaved = interleave(leftChannel, rightChannel);\r\n\r\n // create the buffer and view to create the .WAV file\r\n var buffer = new window.ArrayBuffer(44 + interleaved.length * 2);\r\n var view = new window.DataView(buffer);\r\n\r\n // write the WAV container,\r\n // check spec at: https://web.archive.org/web/20171215131933/http://tiny.systems/software/soundProgrammer/WavFormatDocs.pdf\r\n\r\n // RIFF chunk descriptor\r\n writeUTFBytes(view, 0, 'RIFF');\r\n view.setUint32(4, 36 + interleaved.length * 2, true);\r\n writeUTFBytes(view, 8, 'WAVE');\r\n // FMT sub-chunk\r\n writeUTFBytes(view, 12, 'fmt ');\r\n view.setUint32(16, 16, true);\r\n view.setUint16(20, 1, true);\r\n // stereo (2 channels)\r\n view.setUint16(22, 2, true);\r\n view.setUint32(24, p5sound.audiocontext.sampleRate, true);\r\n view.setUint32(28, p5sound.audiocontext.sampleRate * 4, true);\r\n view.setUint16(32, 4, true);\r\n view.setUint16(34, 16, true);\r\n // data sub-chunk\r\n writeUTFBytes(view, 36, 'data');\r\n view.setUint32(40, interleaved.length * 2, true);\r\n\r\n // write the PCM samples\r\n var lng = interleaved.length;\r\n var index = 44;\r\n var volume = 1;\r\n for (var i = 0; i < lng; i++) {\r\n view.setInt16(index, interleaved[i] * (0x7FFF * volume), true);\r\n index += 2;\r\n }\r\n\r\n return view;\r\n }\r\n\r\n // helper methods to save waves\r\n function interleave(leftChannel, rightChannel) {\r\n var length = leftChannel.length + rightChannel.length;\r\n var result = new Float32Array(length);\r\n\r\n var inputIndex = 0;\r\n\r\n for (var index = 0; index < length;) {\r\n result[index++] = leftChannel[inputIndex];\r\n result[index++] = rightChannel[inputIndex];\r\n inputIndex++;\r\n }\r\n return result;\r\n }\r\n\r\n function writeUTFBytes(view, offset, string) {\r\n var lng = string.length;\r\n for (var i = 0; i < lng; i++) {\r\n view.setUint8(offset + i, string.charCodeAt(i));\r\n }\r\n }\r\n\r\n function safeBufferSize(idealBufferSize) {\r\n let bufferSize = idealBufferSize;\r\n\r\n // if the AudioWorkletNode is actually a ScriptProcessorNode created via polyfill,\r\n // make sure that our chosen buffer size isn't smaller than the buffer size automatically\r\n // selected by the polyfill\r\n // reference: https://github.com/GoogleChromeLabs/audioworklet-polyfill/issues/13#issuecomment-425014930\r\n let tempAudioWorkletNode = new AudioWorkletNode(p5sound.audiocontext, processorNames.soundFileProcessor);\r\n if (tempAudioWorkletNode instanceof ScriptProcessorNode) {\r\n bufferSize = tempAudioWorkletNode.bufferSize;\r\n }\r\n tempAudioWorkletNode.disconnect();\r\n tempAudioWorkletNode = null;\r\n\r\n return bufferSize;\r\n }\r\n\r\n return {\r\n convertToWav: convertToWav,\r\n midiToFreq: midiToFreq,\r\n noteToFreq: noteToFreq,\r\n safeBufferSize: safeBufferSize\r\n };\r\n\r\n});\r\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});","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});","module.exports = {\r\n recorderProcessor: 'recorder-processor',\r\n soundFileProcessor: 'sound-file-processor',\r\n amplitudeProcessor: 'amplitude-processor'\r\n};\r\n","'use strict';\r\n\r\ndefine(function () {\r\n /*\r\n Helper function to generate an error\r\n with a custom stack trace that points to the sketch\r\n and removes other parts of the stack trace.\r\n\r\n @private\r\n @class customError\r\n @constructor\r\n @param {String} name custom error name\r\n @param {String} errorTrace custom error trace\r\n @param {String} failedPath path to the file that failed to load\r\n @property {String} name custom error name\r\n @property {String} message custom error message\r\n @property {String} stack trace the error back to a line in the user's sketch.\r\n Note: this edits out stack trace within p5.js and p5.sound.\r\n @property {String} originalStack unedited, original stack trace\r\n @property {String} failedPath path to the file that failed to load\r\n @return {Error} returns a custom Error object\r\n */\r\n var CustomError = function(name, errorTrace, failedPath) {\r\n var err = new Error();\r\n var tempStack, splitStack;\r\n\r\n err.name = name;\r\n err.originalStack = err.stack + errorTrace;\r\n tempStack = err.stack + errorTrace;\r\n err.failedPath = failedPath;\r\n\r\n // only print the part of the stack trace that refers to the user code:\r\n var splitStack = tempStack.split('\\n');\r\n splitStack = splitStack.filter(function(ln) {\r\n return !ln.match(/(p5.|native code|globalInit)/g);\r\n });\r\n err.stack = splitStack.join('\\n');\r\n\r\n return err; // TODO: is this really a constructor?\r\n };\r\n\r\n return CustomError;\r\n});\r\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/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/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});","'use strict';\r\n\r\ndefine(function (require) {\r\n var Effect = require('effect');\r\n\r\n /**\r\n *

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

\r\n * p5.LowPass:\r\n * Allows frequencies below the cutoff frequency to pass through,\r\n * and attenuates frequencies above the cutoff.
\r\n * p5.HighPass:\r\n * The opposite of a lowpass filter.
\r\n * p5.BandPass:\r\n * Allows a range of frequencies to pass through and attenuates\r\n * the frequencies below and above this frequency range.
\r\n *\r\n * The .res() method controls either width of the\r\n * bandpass, or resonance of the low/highpass cutoff frequency.\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.Filter\r\n * @extends p5.Effect\r\n * @constructor\r\n * @param {String} [type] 'lowpass' (default), 'highpass', 'bandpass'\r\n * @example\r\n *
\r\n * let fft, noise, filter;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100,100);\r\n * cnv.mousePressed(makeNoise);\r\n * fill(255, 0, 255);\r\n *\r\n * filter = new p5.BandPass();\r\n * noise = new p5.Noise();\r\n * noise.disconnect();\r\n * noise.connect(filter);\r\n *\r\n * fft = new p5.FFT();\r\n * }\r\n *\r\n * function draw() {\r\n * background(220);\r\n *\r\n * // set the BandPass frequency based on mouseX\r\n * let freq = map(mouseX, 0, width, 20, 10000);\r\n * freq = constrain(freq, 0, 22050);\r\n * filter.freq(freq);\r\n * // give the filter a narrow band (lower res = wider bandpass)\r\n * filter.res(50);\r\n *\r\n * // draw filtered spectrum\r\n * let spectrum = fft.analyze();\r\n * noStroke();\r\n * for (let i = 0; i < spectrum.length; i++) {\r\n * let x = map(i, 0, spectrum.length, 0, width);\r\n * let h = -height + map(spectrum[i], 0, 255, height, 0);\r\n * rect(x, height, width/spectrum.length, h);\r\n * }\r\n * if (!noise.started) {\r\n * text('tap here and drag to change frequency', 10, 20, width - 20);\r\n * } else {\r\n * text('Frequency: ' + round(freq)+'Hz', 20, 20, width - 20);\r\n * }\r\n * }\r\n *\r\n * function makeNoise() {\r\n * // see also: `userStartAudio()`\r\n * noise.start();\r\n * noise.amp(0.5, 0.2);\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * noise.amp(0, 0.2);\r\n * }\r\n *\r\n *
\r\n */\r\n p5.Filter = function (type) {\r\n\r\n Effect.call(this);\r\n //add extend Effect by adding a Biquad Filter\r\n\r\n /**\r\n * The p5.Filter is built with a\r\n * \r\n * Web Audio BiquadFilter Node.\r\n *\r\n * @property {DelayNode} biquadFilter\r\n\t */\r\n\r\n this.biquad = this.ac.createBiquadFilter();\r\n\r\n this.input.connect(this.biquad);\r\n\r\n this.biquad.connect(this.wet);\r\n\r\n if (type) {\r\n this.setType(type);\r\n }\r\n\r\n //Properties useful for the toggle method.\r\n this._on = true;\r\n this._untoggledType = this.biquad.type;\r\n };\r\n p5.Filter.prototype = Object.create(Effect.prototype);\r\n\r\n\r\n /**\r\n * Filter an audio signal according to a set\r\n * of filter parameters.\r\n *\r\n * @method process\r\n * @param {Object} Signal An object that outputs audio\r\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\r\n * @param {Number} [res] Resonance/Width of the filter frequency\r\n * from 0.001 to 1000\r\n */\r\n p5.Filter.prototype.process = function(src, freq, res, time) {\r\n src.connect(this.input);\r\n this.set(freq, res, time);\r\n };\r\n\r\n\r\n /**\r\n * Set the frequency and the resonance of the filter.\r\n *\r\n * @method set\r\n * @param {Number} [freq] Frequency in Hz, from 10 to 22050\r\n * @param {Number} [res] Resonance (Q) from 0.001 to 1000\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n */\r\n p5.Filter.prototype.set = function(freq, res, time) {\r\n if (freq) {\r\n this.freq(freq, time);\r\n }\r\n if (res) {\r\n this.res(res, time);\r\n }\r\n };\r\n\r\n /**\r\n * Set the filter frequency, in Hz, from 10 to 22050 (the range of\r\n * human hearing, although in reality most people hear in a narrower\r\n * range).\r\n *\r\n * @method freq\r\n * @param {Number} freq Filter Frequency\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n * @return {Number} value Returns the current frequency value\r\n */\r\n p5.Filter.prototype.freq = function(freq, time) {\r\n var t = time || 0;\r\n if (freq <= 0) {\r\n freq = 1;\r\n }\r\n if (typeof freq === 'number') {\r\n this.biquad.frequency.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.biquad.frequency.exponentialRampToValueAtTime(freq, this.ac.currentTime + 0.02 + t);\r\n } else if (freq) {\r\n freq.connect(this.biquad.frequency);\r\n }\r\n return this.biquad.frequency.value;\r\n };\r\n\r\n /**\r\n * Controls either width of a bandpass frequency,\r\n * or the resonance of a low/highpass cutoff frequency.\r\n *\r\n * @method res\r\n * @param {Number} res Resonance/Width of filter freq\r\n * from 0.001 to 1000\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n * @return {Number} value Returns the current res value\r\n */\r\n p5.Filter.prototype.res = function(res, time) {\r\n var t = time || 0;\r\n if (typeof res === 'number') {\r\n this.biquad.Q.value = res;\r\n this.biquad.Q.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.biquad.Q.linearRampToValueAtTime(res, this.ac.currentTime + 0.02 + t);\r\n } else if (res) {\r\n res.connect(this.biquad.Q);\r\n }\r\n return this.biquad.Q.value;\r\n };\r\n\r\n /**\r\n * Controls the gain attribute of a Biquad Filter.\r\n * This is distinctly different from .amp() which is inherited from p5.Effect\r\n * .amp() controls the volume via the output gain node\r\n * p5.Filter.gain() controls the gain parameter of a Biquad Filter node.\r\n *\r\n * @method gain\r\n * @param {Number} gain\r\n * @return {Number} Returns the current or updated gain value\r\n */\r\n p5.Filter.prototype.gain = function(gain, time) {\r\n var t = time || 0;\r\n if (typeof gain === 'number') {\r\n this.biquad.gain.value = gain;\r\n this.biquad.gain.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.biquad.gain.linearRampToValueAtTime(gain, this.ac.currentTime + 0.02 + t);\r\n } else if (gain) {\r\n gain.connect(this.biquad.gain);\r\n }\r\n return this.biquad.gain.value;\r\n };\r\n\r\n\r\n /**\r\n * Toggle function. Switches between the specified type and allpass\r\n *\r\n * @method toggle\r\n * @return {boolean} [Toggle value]\r\n */\r\n p5.Filter.prototype.toggle = function() {\r\n this._on = !this._on;\r\n\r\n if (this._on === true) {\r\n this.biquad.type = this._untoggledType;\r\n } else if (this._on === false) {\r\n this.biquad.type = 'allpass';\r\n }\r\n\r\n return this._on;\r\n };\r\n\r\n /**\r\n * Set the type of a p5.Filter. Possible types include:\r\n * \"lowpass\" (default), \"highpass\", \"bandpass\",\r\n * \"lowshelf\", \"highshelf\", \"peaking\", \"notch\",\r\n * \"allpass\".\r\n *\r\n * @method setType\r\n * @param {String} t\r\n */\r\n p5.Filter.prototype.setType = function(t) {\r\n this.biquad.type = t;\r\n this._untoggledType = this.biquad.type;\r\n };\r\n\r\n p5.Filter.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n Effect.prototype.dispose.apply(this);\r\n if (this.biquad) {\r\n this.biquad.disconnect();\r\n delete this.biquad;\r\n }\r\n };\r\n\r\n /**\r\n * Constructor: new p5.LowPass() Filter.\r\n * This is the same as creating a p5.Filter and then calling\r\n * its method setType('lowpass').\r\n * See p5.Filter for methods.\r\n *\r\n * @class p5.LowPass\r\n * @constructor\r\n * @extends p5.Filter\r\n */\r\n p5.LowPass = function() {\r\n p5.Filter.call(this, 'lowpass');\r\n };\r\n p5.LowPass.prototype = Object.create(p5.Filter.prototype);\r\n\r\n /**\r\n * Constructor: new p5.HighPass() Filter.\r\n * This is the same as creating a p5.Filter and then calling\r\n * its method setType('highpass').\r\n * See p5.Filter for methods.\r\n *\r\n * @class p5.HighPass\r\n * @constructor\r\n * @extends p5.Filter\r\n */\r\n p5.HighPass = function() {\r\n p5.Filter.call(this, 'highpass');\r\n };\r\n p5.HighPass.prototype = Object.create(p5.Filter.prototype);\r\n\r\n /**\r\n * Constructor: new p5.BandPass() Filter.\r\n * This is the same as creating a p5.Filter and then calling\r\n * its method setType('bandpass').\r\n * See p5.Filter for methods.\r\n *\r\n * @class p5.BandPass\r\n * @constructor\r\n * @extends p5.Filter\r\n */\r\n p5.BandPass = function() {\r\n p5.Filter.call(this, 'bandpass');\r\n };\r\n p5.BandPass.prototype = Object.create(p5.Filter.prototype);\r\n\r\n return p5.Filter;\r\n});\r\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});","'use strict';\r\n\r\nglobal.TONE_SILENCE_VERSION_LOGGING = true;\r\n\r\ndefine(['startaudiocontext', 'Tone/core/Context', 'Tone/core/Tone'], function (StartAudioContext, Context, Tone) {\r\n // Create the Audio Context\r\n const audiocontext = new window.AudioContext();\r\n\r\n // Tone and p5.sound share the same audio context\r\n Tone.context.dispose();\r\n Tone.setContext(audiocontext);\r\n\r\n /**\r\n *

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

\r\n *\r\n *

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

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

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n * @param {Element|Array} [element(s)] This argument can be an Element,\r\n * Selector String, NodeList, p5.Element,\r\n * jQuery Element, or an Array of any of those.\r\n * @param {Function} [callback] Callback to invoke when the AudioContext\r\n * has started\r\n * @return {Promise} Returns a Promise that resolves when\r\n * the AudioContext state is 'running'\r\n * @method userStartAudio\r\n * @for p5\r\n * @example\r\n *
\r\n * function setup() {\r\n * // mimics the autoplay policy\r\n * getAudioContext().suspend();\r\n *\r\n * let mySynth = new p5.MonoSynth();\r\n *\r\n * // This won't play until the context has resumed\r\n * mySynth.play('A6');\r\n * }\r\n * function draw() {\r\n * background(220);\r\n * textAlign(CENTER, CENTER);\r\n * text(getAudioContext().state, width/2, height/2);\r\n * }\r\n * function mousePressed() {\r\n * userStartAudio();\r\n * }\r\n *
\r\n */\r\n p5.prototype.userStartAudio = function(elements, callback) {\r\n var elt = elements;\r\n if (elements instanceof p5.Element) {\r\n elt = elements.elt;\r\n } else if (elements instanceof Array && elements[0] instanceof p5.Element ) {\r\n elt = elements.map(function(e) { return e.elt});\r\n }\r\n return StartAudioContext(audiocontext, elt, callback);\r\n };\r\n\r\n return audiocontext;\r\n});\r\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});","'use strict';\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n\r\n var Add = require('Tone/signal/Add');\r\n var Mult = require('Tone/signal/Multiply');\r\n var Scale = require('Tone/signal/Scale');\r\n\r\n /**\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n * @class p5.Oscillator\r\n * @constructor\r\n * @param {Number} [freq] frequency defaults to 440Hz\r\n * @param {String} [type] type of oscillator. Options:\r\n * 'sine' (default), 'triangle',\r\n * 'sawtooth', 'square'\r\n * @example\r\n *
\r\n * let osc, playing, freq, amp;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playOscillator);\r\n * osc = new p5.Oscillator('sine');\r\n * }\r\n *\r\n * function draw() {\r\n * background(220)\r\n * freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\r\n * amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\r\n *\r\n * text('tap to play', 20, 20);\r\n * text('freq: ' + freq, 20, 40);\r\n * text('amp: ' + amp, 20, 60);\r\n *\r\n * if (playing) {\r\n * // smooth the transitions by 0.1 seconds\r\n * osc.freq(freq, 0.1);\r\n * osc.amp(amp, 0.1);\r\n * }\r\n * }\r\n *\r\n * function playOscillator() {\r\n * // starting an oscillator on a user gesture will enable audio\r\n * // in browsers that have a strict autoplay policy.\r\n * // See also: userStartAudio();\r\n * osc.start();\r\n * playing = true;\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * // ramp amplitude to 0 over 0.5 seconds\r\n * osc.amp(0, 0.5);\r\n * playing = false;\r\n * }\r\n *
\r\n */\r\n p5.Oscillator = function(freq, type) {\r\n if (typeof freq === 'string') {\r\n var f = type;\r\n type = freq;\r\n freq = f;\r\n } if (typeof type === 'number') {\r\n var f = type;\r\n type = freq;\r\n freq = f;\r\n }\r\n this.started = false;\r\n\r\n // components\r\n this.phaseAmount = undefined;\r\n this.oscillator = p5sound.audiocontext.createOscillator();\r\n this.f = freq || 440.0; // frequency\r\n this.oscillator.type = type || 'sine';\r\n this.oscillator.frequency.setValueAtTime(this.f, p5sound.audiocontext.currentTime);\r\n\r\n // connections\r\n this.output = p5sound.audiocontext.createGain();\r\n\r\n this._freqMods = []; // modulators connected to this oscillator's frequency\r\n\r\n // set default output gain to 0.5\r\n this.output.gain.value = 0.5;\r\n this.output.gain.setValueAtTime(0.5, p5sound.audiocontext.currentTime);\r\n\r\n this.oscillator.connect(this.output);\r\n // stereo panning\r\n this.panPosition = 0.0;\r\n this.connection = p5sound.input; // connect to p5sound by default\r\n this.panner = new p5.Panner(this.output, this.connection, 1);\r\n\r\n //array of math operation signal chaining\r\n this.mathOps = [this.output];\r\n\r\n // add to the soundArray so we can dispose of the osc later\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Start an oscillator.\r\n *\r\n * Starting an oscillator on a user gesture will enable audio in browsers\r\n * that have a strict autoplay policy, including Chrome and most mobile\r\n * devices. See also: `userStartAudio()`.\r\n *\r\n * @method start\r\n * @for p5.Oscillator\r\n * @param {Number} [time] startTime in seconds from now.\r\n * @param {Number} [frequency] frequency in Hz.\r\n */\r\n p5.Oscillator.prototype.start = function(time, f) {\r\n if (this.started) {\r\n var now = p5sound.audiocontext.currentTime;\r\n this.stop(now);\r\n }\r\n if (!this.started) {\r\n var freq = f || this.f;\r\n var type = this.oscillator.type;\r\n\r\n // set old osc free to be garbage collected (memory)\r\n if (this.oscillator) {\r\n this.oscillator.disconnect();\r\n delete this.oscillator;\r\n }\r\n\r\n // var detune = this.oscillator.frequency.value;\r\n this.oscillator = p5sound.audiocontext.createOscillator();\r\n this.oscillator.frequency.value = Math.abs(freq);\r\n this.oscillator.type = type;\r\n // this.oscillator.detune.value = detune;\r\n this.oscillator.connect(this.output);\r\n time = time || 0;\r\n this.oscillator.start(time + p5sound.audiocontext.currentTime);\r\n this.freqNode = this.oscillator.frequency;\r\n\r\n // if other oscillators are already connected to this osc's freq\r\n for (var i in this._freqMods) {\r\n if (typeof this._freqMods[i].connect !== 'undefined') {\r\n this._freqMods[i].connect(this.oscillator.frequency);\r\n }\r\n }\r\n\r\n this.started = true;\r\n }\r\n };\r\n\r\n /**\r\n * Stop an oscillator. Accepts an optional parameter\r\n * to determine how long (in seconds from now) until the\r\n * oscillator stops.\r\n *\r\n * @method stop\r\n * @for p5.Oscillator\r\n * @param {Number} secondsFromNow Time, in seconds from now.\r\n */\r\n p5.Oscillator.prototype.stop = function(time) {\r\n if (this.started) {\r\n var t = time || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n this.oscillator.stop(t + now);\r\n this.started = false;\r\n }\r\n };\r\n\r\n /**\r\n * Set the amplitude between 0 and 1.0. Or, pass in an object\r\n * such as an oscillator to modulate amplitude with an audio signal.\r\n *\r\n * @method amp\r\n * @for p5.Oscillator\r\n * @param {Number|Object} vol between 0 and 1.0\r\n * or a modulating signal/oscillator\r\n * @param {Number} [rampTime] create a fade that lasts rampTime\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n * @return {AudioParam} gain If no value is provided,\r\n * returns the Web Audio API\r\n * AudioParam that controls\r\n * this oscillator's\r\n * gain/amplitude/volume)\r\n */\r\n p5.Oscillator.prototype.amp = function(vol, rampTime, tFromNow) {\r\n var self = this;\r\n if (typeof vol === 'number') {\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\r\n }\r\n\r\n else if (vol) {\r\n vol.connect(self.output.gain);\r\n } else {\r\n // return the Gain Node\r\n return this.output.gain;\r\n }\r\n };\r\n\r\n // these are now the same thing\r\n p5.Oscillator.prototype.fade = p5.Oscillator.prototype.amp;\r\n\r\n p5.Oscillator.prototype.getAmp = function() {\r\n return this.output.gain.value;\r\n };\r\n\r\n /**\r\n * Set frequency of an oscillator to a value. Or, pass in an object\r\n * such as an oscillator to modulate the frequency with an audio signal.\r\n *\r\n * @method freq\r\n * @for p5.Oscillator\r\n * @param {Number|Object} Frequency Frequency in Hz\r\n * or modulating signal/oscillator\r\n * @param {Number} [rampTime] Ramp time (in seconds)\r\n * @param {Number} [timeFromNow] Schedule this event to happen\r\n * at x seconds from now\r\n * @return {AudioParam} Frequency If no value is provided,\r\n * returns the Web Audio API\r\n * AudioParam that controls\r\n * this oscillator's frequency\r\n * @example\r\n *
\r\n * let osc;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playOscillator);\r\n * osc = new p5.Oscillator(300);\r\n * background(220);\r\n * text('tap to play', 20, 20);\r\n * }\r\n *\r\n * function playOscillator() {\r\n * osc.start();\r\n * osc.amp(0.5);\r\n * // start at 700Hz\r\n * osc.freq(700);\r\n * // ramp to 60Hz over 0.7 seconds\r\n * osc.freq(60, 0.7);\r\n * osc.amp(0, 0.1, 0.7);\r\n * }\r\n *
\r\n */\r\n p5.Oscillator.prototype.freq = function(val, rampTime, tFromNow) {\r\n if (typeof val === 'number' && !isNaN(val)) {\r\n this.f = val;\r\n var now = p5sound.audiocontext.currentTime;\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var t = now + tFromNow + rampTime;\r\n // var currentFreq = this.oscillator.frequency.value;\r\n // this.oscillator.frequency.cancelScheduledValues(now);\r\n\r\n if (rampTime === 0) {\r\n this.oscillator.frequency.setValueAtTime(val, tFromNow + now);\r\n } else {\r\n if (val > 0 ) {\r\n this.oscillator.frequency.exponentialRampToValueAtTime(val, tFromNow + rampTime + now);\r\n } else {\r\n this.oscillator.frequency.linearRampToValueAtTime(val, tFromNow + rampTime + now);\r\n }\r\n }\r\n\r\n // reset phase if oscillator has a phase\r\n if (this.phaseAmount) {\r\n this.phase(this.phaseAmount);\r\n }\r\n\r\n } else if (val) {\r\n if (val.output) {\r\n val = val.output;\r\n }\r\n val.connect(this.oscillator.frequency);\r\n\r\n // keep track of what is modulating this param\r\n // so it can be re-connected if\r\n this._freqMods.push( val );\r\n } else {\r\n // return the Frequency Node\r\n return this.oscillator.frequency;\r\n }\r\n };\r\n\r\n p5.Oscillator.prototype.getFreq = function() {\r\n return this.oscillator.frequency.value;\r\n };\r\n\r\n /**\r\n * Set type to 'sine', 'triangle', 'sawtooth' or 'square'.\r\n *\r\n * @method setType\r\n * @for p5.Oscillator\r\n * @param {String} type 'sine', 'triangle', 'sawtooth' or 'square'.\r\n */\r\n p5.Oscillator.prototype.setType = function(type) {\r\n this.oscillator.type = type;\r\n };\r\n\r\n p5.Oscillator.prototype.getType = function() {\r\n return this.oscillator.type;\r\n };\r\n\r\n /**\r\n * Connect to a p5.sound / Web Audio object.\r\n *\r\n * @method connect\r\n * @for p5.Oscillator\r\n * @param {Object} unit A p5.sound or Web Audio object\r\n */\r\n p5.Oscillator.prototype.connect = function(unit) {\r\n if (!unit) {\r\n this.panner.connect(p5sound.input);\r\n }\r\n else if (unit.hasOwnProperty('input')) {\r\n this.panner.connect(unit.input);\r\n this.connection = unit.input;\r\n }\r\n else {\r\n this.panner.connect(unit);\r\n this.connection = unit;\r\n }\r\n };\r\n\r\n /**\r\n * Disconnect all outputs\r\n *\r\n * @method disconnect\r\n * @for p5.Oscillator\r\n */\r\n p5.Oscillator.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n if (this.panner) {\r\n this.panner.disconnect();\r\n if (this.output) {\r\n this.output.connect(this.panner);\r\n }\r\n }\r\n this.oscMods = [];\r\n };\r\n\r\n /**\r\n * Pan between Left (-1) and Right (1)\r\n *\r\n * @method pan\r\n * @for p5.Oscillator\r\n * @param {Number} panning Number between -1 and 1\r\n * @param {Number} timeFromNow schedule this event to happen\r\n * seconds from now\r\n */\r\n p5.Oscillator.prototype.pan = function(pval, tFromNow) {\r\n this.panPosition = pval;\r\n this.panner.pan(pval, tFromNow);\r\n };\r\n\r\n p5.Oscillator.prototype.getPan = function() {\r\n return this.panPosition;\r\n };\r\n\r\n // get rid of the oscillator\r\n p5.Oscillator.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n\r\n if (this.oscillator) {\r\n var now = p5sound.audiocontext.currentTime;\r\n this.stop(now);\r\n this.disconnect();\r\n this.panner = null;\r\n this.oscillator = null;\r\n }\r\n // if it is a Pulse\r\n if (this.osc2) {\r\n this.osc2.dispose();\r\n }\r\n };\r\n\r\n /**\r\n * Set the phase of an oscillator between 0.0 and 1.0.\r\n * In this implementation, phase is a delay time\r\n * based on the oscillator's current frequency.\r\n *\r\n * @method phase\r\n * @for p5.Oscillator\r\n * @param {Number} phase float between 0.0 and 1.0\r\n */\r\n p5.Oscillator.prototype.phase = function(p) {\r\n var delayAmt = p5.prototype.map(p, 0, 1.0, 0, 1/this.f);\r\n var now = p5sound.audiocontext.currentTime;\r\n\r\n this.phaseAmount = p;\r\n\r\n if (!this.dNode) {\r\n // create a delay node\r\n this.dNode = p5sound.audiocontext.createDelay();\r\n // put the delay node in between output and panner\r\n this.oscillator.disconnect();\r\n this.oscillator.connect(this.dNode);\r\n this.dNode.connect(this.output);\r\n }\r\n\r\n // set delay time to match phase:\r\n this.dNode.delayTime.setValueAtTime(delayAmt, now);\r\n };\r\n\r\n // ========================== //\r\n // SIGNAL MATH FOR MODULATION //\r\n // ========================== //\r\n\r\n // return sigChain(this, scale, thisChain, nextChain, Scale);\r\n var sigChain = function(o, mathObj, thisChain, nextChain, type) {\r\n var chainSource = o.oscillator;\r\n // if this type of math already exists in the chain, replace it\r\n for (var i in o.mathOps) {\r\n if (o.mathOps[i] instanceof type) {\r\n chainSource.disconnect();\r\n o.mathOps[i].dispose();\r\n thisChain = i;\r\n // assume nextChain is output gain node unless...\r\n if (thisChain < o.mathOps.length - 2) {\r\n nextChain = o.mathOps[i+1];\r\n }\r\n }\r\n }\r\n if (thisChain === o.mathOps.length - 1) {\r\n o.mathOps.push(nextChain);\r\n }\r\n // assume source is the oscillator unless i > 0\r\n if (i > 0) {\r\n chainSource = o.mathOps[i-1];\r\n }\r\n chainSource.disconnect();\r\n chainSource.connect(mathObj);\r\n mathObj.connect(nextChain);\r\n o.mathOps[thisChain] = mathObj;\r\n return o;\r\n };\r\n\r\n /**\r\n * Add a value to the p5.Oscillator's output amplitude,\r\n * and return the oscillator. Calling this method again\r\n * will override the initial add() with a new value.\r\n *\r\n * @method add\r\n * @for p5.Oscillator\r\n * @param {Number} number Constant number to add\r\n * @return {p5.Oscillator} Oscillator Returns this oscillator\r\n * with scaled output\r\n *\r\n */\r\n p5.Oscillator.prototype.add = function(num) {\r\n var add = new Add(num);\r\n var thisChain = this.mathOps.length-1;\r\n var nextChain = this.output;\r\n return sigChain(this, add, thisChain, nextChain, Add);\r\n };\r\n\r\n /**\r\n * Multiply the p5.Oscillator's output amplitude\r\n * by a fixed value (i.e. turn it up!). Calling this method\r\n * again will override the initial mult() with a new value.\r\n *\r\n * @method mult\r\n * @for p5.Oscillator\r\n * @param {Number} number Constant number to multiply\r\n * @return {p5.Oscillator} Oscillator Returns this oscillator\r\n * with multiplied output\r\n */\r\n p5.Oscillator.prototype.mult = function(num) {\r\n var mult = new Mult(num);\r\n var thisChain = this.mathOps.length-1;\r\n var nextChain = this.output;\r\n return sigChain(this, mult, thisChain, nextChain, Mult);\r\n };\r\n\r\n /**\r\n * Scale this oscillator's amplitude values to a given\r\n * range, and return the oscillator. Calling this method\r\n * again will override the initial scale() with new values.\r\n *\r\n * @method scale\r\n * @for p5.Oscillator\r\n * @param {Number} inMin input range minumum\r\n * @param {Number} inMax input range maximum\r\n * @param {Number} outMin input range minumum\r\n * @param {Number} outMax input range maximum\r\n * @return {p5.Oscillator} Oscillator Returns this oscillator\r\n * with scaled output\r\n */\r\n p5.Oscillator.prototype.scale = function(inMin, inMax, outMin, outMax) {\r\n var mapOutMin, mapOutMax;\r\n if (arguments.length === 4) {\r\n mapOutMin = p5.prototype.map(outMin, inMin, inMax, 0, 1) - 0.5;\r\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5;\r\n }\r\n else {\r\n mapOutMin = arguments[0];\r\n mapOutMax = arguments[1];\r\n }\r\n var scale = new Scale(mapOutMin, mapOutMax);\r\n var thisChain = this.mathOps.length-1;\r\n var nextChain = this.output;\r\n return sigChain(this, scale, thisChain, nextChain, Scale);\r\n\r\n // this.output.disconnect();\r\n // this.output.connect(scale)\r\n };\r\n\r\n // ============================== //\r\n // SinOsc, TriOsc, SqrOsc, SawOsc //\r\n // ============================== //\r\n\r\n /**\r\n * Constructor: new p5.SinOsc().\r\n * This creates a Sine Wave Oscillator and is\r\n * equivalent to new p5.Oscillator('sine')\r\n * or creating a p5.Oscillator and then calling\r\n * its method setType('sine').\r\n * See p5.Oscillator for methods.\r\n *\r\n * @class p5.SinOsc\r\n * @constructor\r\n * @extends p5.Oscillator\r\n * @param {Number} [freq] Set the frequency\r\n */\r\n p5.SinOsc = function(freq) {\r\n p5.Oscillator.call(this, freq, 'sine');\r\n };\r\n\r\n p5.SinOsc.prototype = Object.create(p5.Oscillator.prototype);\r\n\r\n /**\r\n * Constructor: new p5.TriOsc().\r\n * This creates a Triangle Wave Oscillator and is\r\n * equivalent to new p5.Oscillator('triangle')\r\n * or creating a p5.Oscillator and then calling\r\n * its method setType('triangle').\r\n * See p5.Oscillator for methods.\r\n *\r\n * @class p5.TriOsc\r\n * @constructor\r\n * @extends p5.Oscillator\r\n * @param {Number} [freq] Set the frequency\r\n */\r\n p5.TriOsc = function(freq) {\r\n p5.Oscillator.call(this, freq, 'triangle');\r\n };\r\n\r\n p5.TriOsc.prototype = Object.create(p5.Oscillator.prototype);\r\n\r\n /**\r\n * Constructor: new p5.SawOsc().\r\n * This creates a SawTooth Wave Oscillator and is\r\n * equivalent to new p5.Oscillator('sawtooth')\r\n * or creating a p5.Oscillator and then calling\r\n * its method setType('sawtooth').\r\n * See p5.Oscillator for methods.\r\n *\r\n * @class p5.SawOsc\r\n * @constructor\r\n * @extends p5.Oscillator\r\n * @param {Number} [freq] Set the frequency\r\n */\r\n p5.SawOsc = function(freq) {\r\n p5.Oscillator.call(this, freq, 'sawtooth');\r\n };\r\n\r\n p5.SawOsc.prototype = Object.create(p5.Oscillator.prototype);\r\n\r\n /**\r\n * Constructor: new p5.SqrOsc().\r\n * This creates a Square Wave Oscillator and is\r\n * equivalent to new p5.Oscillator('square')\r\n * or creating a p5.Oscillator and then calling\r\n * its method setType('square').\r\n * See p5.Oscillator for methods.\r\n *\r\n * @class p5.SqrOsc\r\n * @constructor\r\n * @extends p5.Oscillator\r\n * @param {Number} [freq] Set the frequency\r\n */\r\n p5.SqrOsc = function(freq) {\r\n p5.Oscillator.call(this, freq, 'square');\r\n };\r\n\r\n p5.SqrOsc.prototype = Object.create(p5.Oscillator.prototype);\r\n\r\n});\r\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});","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});","'use strict';\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var AudioVoice = require('audioVoice');\r\n var noteToFreq = require('helpers').noteToFreq;\r\n\r\n var DEFAULT_SUSTAIN = 0.15;\r\n\r\n /**\r\n * A MonoSynth is used as a single voice for sound synthesis.\r\n * This is a class to be used in conjunction with the PolySynth\r\n * class. Custom synthetisers should be built inheriting from\r\n * this class.\r\n *\r\n * @class p5.MonoSynth\r\n * @constructor\r\n * @example\r\n *
\r\n * let monoSynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSynth);\r\n * background(220);\r\n * textAlign(CENTER);\r\n * text('tap to play', width/2, height/2);\r\n *\r\n * monoSynth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function playSynth() {\r\n * userStartAudio();\r\n *\r\n * let note = random(['Fb4', 'G4']);\r\n * // note velocity (volume, from 0 to 1)\r\n * let velocity = random();\r\n * // time from now (in seconds)\r\n * let time = 0;\r\n * // note duration (in seconds)\r\n * let dur = 1/6;\r\n *\r\n * monoSynth.play(note, velocity, time, dur);\r\n * }\r\n *
\r\n **/\r\n\r\n p5.MonoSynth = function () {\r\n AudioVoice.call(this);\r\n\r\n this.oscillator = new p5.Oscillator();\r\n\r\n this.env = new p5.Envelope();\r\n this.env.setRange(1, 0);\r\n this.env.setExp(true);\r\n\r\n //set params\r\n this.setADSR(0.02, 0.25, 0.05, 0.35);\r\n\r\n // oscillator --> env --> this.output (gain) --> p5.soundOut\r\n this.oscillator.disconnect();\r\n this.oscillator.connect(this.output);\r\n\r\n this.env.disconnect();\r\n this.env.setInput(this.output.gain);\r\n\r\n // reset oscillator gain to 1.0\r\n this.oscillator.output.gain.value = 1.0;\r\n\r\n this.oscillator.start();\r\n this.connect();\r\n\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n p5.MonoSynth.prototype = Object.create(p5.AudioVoice.prototype);\r\n\r\n /**\r\n * Play tells the MonoSynth to start playing a note. This method schedules\r\n * the calling of .triggerAttack and .triggerRelease.\r\n *\r\n * @method play\r\n * @for p5.MonoSynth\r\n * @param {String | Number} note the note you want to play, specified as a\r\n * frequency in Hertz (Number) or as a midi\r\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\r\n * See \r\n * Tone. Defaults to 440 hz.\r\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\r\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\r\n * @param {Number} [sustainTime] time to sustain before releasing the envelope. Defaults to 0.15 seconds.\r\n * @example\r\n *
\r\n * let monoSynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSynth);\r\n * background(220);\r\n * textAlign(CENTER);\r\n * text('tap to play', width/2, height/2);\r\n *\r\n * monoSynth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function playSynth() {\r\n * userStartAudio();\r\n *\r\n * let note = random(['Fb4', 'G4']);\r\n * // note velocity (volume, from 0 to 1)\r\n * let velocity = random();\r\n * // time from now (in seconds)\r\n * let time = 0;\r\n * // note duration (in seconds)\r\n * let dur = 1/6;\r\n *\r\n * monoSynth.play(note, velocity, time, dur);\r\n * }\r\n *
\r\n *\r\n */\r\n p5.MonoSynth.prototype.play = function (note, velocity, secondsFromNow, susTime) {\r\n this.triggerAttack(note, velocity, ~~secondsFromNow);\r\n this.triggerRelease(~~secondsFromNow + (susTime || DEFAULT_SUSTAIN));\r\n };\r\n\r\n /**\r\n * Trigger the Attack, and Decay portion of the Envelope.\r\n * Similar to holding down a key on a piano, but it will\r\n * hold the sustain level until you let go.\r\n *\r\n * @param {String | Number} note the note you want to play, specified as a\r\n * frequency in Hertz (Number) or as a midi\r\n * value in Note/Octave format (\"C4\", \"Eb3\"...etc\")\r\n * See \r\n * Tone. Defaults to 440 hz\r\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\r\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\r\n * @method triggerAttack\r\n * @for p5.MonoSynth\r\n * @example\r\n *
\r\n * let monoSynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(triggerAttack);\r\n * background(220);\r\n * text('tap here for attack, let go to release', 5, 20, width - 20);\r\n * monoSynth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function triggerAttack() {\r\n * userStartAudio();\r\n *\r\n * monoSynth.triggerAttack(\"E3\");\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * monoSynth.triggerRelease();\r\n * }\r\n *
\r\n */\r\n p5.MonoSynth.prototype.triggerAttack = function (note, velocity, secondsFromNow) {\r\n var secondsFromNow = ~~secondsFromNow;\r\n var freq = noteToFreq(note);\r\n var vel = velocity || 0.1;\r\n this.oscillator.freq(freq, 0, secondsFromNow);\r\n this.env.ramp(this.output.gain, secondsFromNow, vel);\r\n };\r\n\r\n /**\r\n * Trigger the release of the Envelope. This is similar to releasing\r\n * the key on a piano and letting the sound fade according to the\r\n * release level and release time.\r\n *\r\n * @param {Number} secondsFromNow time to trigger the release\r\n * @method triggerRelease\r\n * @for p5.MonoSynth\r\n * @example\r\n *
\r\n * let monoSynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(triggerAttack);\r\n * background(220);\r\n * text('tap here for attack, let go to release', 5, 20, width - 20);\r\n * monoSynth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function triggerAttack() {\r\n * userStartAudio();\r\n *\r\n * monoSynth.triggerAttack(\"E3\");\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * monoSynth.triggerRelease();\r\n * }\r\n *
\r\n */\r\n p5.MonoSynth.prototype.triggerRelease = function (secondsFromNow) {\r\n var secondsFromNow = secondsFromNow || 0;\r\n this.env.ramp(this.output.gain, secondsFromNow, 0);\r\n };\r\n\r\n /**\r\n * Set values like a traditional\r\n * \r\n * ADSR envelope\r\n * .\r\n *\r\n * @method setADSR\r\n * @for p5.MonoSynth\r\n * @param {Number} attackTime Time (in seconds before envelope\r\n * reaches Attack Level\r\n * @param {Number} [decayTime] Time (in seconds) before envelope\r\n * reaches Decay/Sustain Level\r\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\r\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\r\n * The susRatio determines the decayLevel and the level at which the\r\n * sustain portion of the envelope will sustain.\r\n * For example, if attackLevel is 0.4, releaseLevel is 0,\r\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\r\n * increased to 1.0 (using setRange),\r\n * then decayLevel would increase proportionally, to become 0.5.\r\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\r\n */\r\n p5.MonoSynth.prototype.setADSR = function (attack,decay,sustain,release) {\r\n this.env.setADSR(attack, decay, sustain, release);\r\n };\r\n\r\n\r\n /**\r\n * Getters and Setters\r\n * @property {Number} attack\r\n * @for p5.MonoSynth\r\n */\r\n /**\r\n * @property {Number} decay\r\n * @for p5.MonoSynth\r\n */\r\n /**\r\n * @property {Number} sustain\r\n * @for p5.MonoSynth\r\n */\r\n /**\r\n * @property {Number} release\r\n * @for p5.MonoSynth\r\n */\r\n Object.defineProperties(p5.MonoSynth.prototype, {\r\n 'attack': {\r\n get : function() {\r\n return this.env.aTime;\r\n },\r\n set : function(attack) {\r\n this.env.setADSR(attack, this.env.dTime,\r\n this.env.sPercent, this.env.rTime);\r\n }\r\n },\r\n 'decay': {\r\n get : function() {\r\n return this.env.dTime;\r\n },\r\n set : function(decay) {\r\n this.env.setADSR(this.env.aTime, decay,\r\n this.env.sPercent, this.env.rTime);\r\n }\r\n },\r\n 'sustain': {\r\n get : function() {\r\n return this.env.sPercent;\r\n },\r\n set : function(sustain) {\r\n this.env.setADSR(this.env.aTime, this.env.dTime,\r\n sustain, this.env.rTime);\r\n }\r\n },\r\n 'release': {\r\n get : function() {\r\n return this.env.rTime;\r\n },\r\n set : function(release) {\r\n this.env.setADSR(this.env.aTime, this.env.dTime,\r\n this.env.sPercent, release);\r\n }\r\n },\r\n });\r\n\r\n\r\n /**\r\n * MonoSynth amp\r\n * @method amp\r\n * @for p5.MonoSynth\r\n * @param {Number} vol desired volume\r\n * @param {Number} [rampTime] Time to reach new volume\r\n * @return {Number} new volume value\r\n */\r\n p5.MonoSynth.prototype.amp = function(vol, rampTime) {\r\n var t = rampTime || 0;\r\n if (typeof vol !== 'undefined') {\r\n this.oscillator.amp(vol, t);\r\n }\r\n return this.oscillator.amp().value;\r\n };\r\n\r\n /**\r\n * Connect to a p5.sound / Web Audio object.\r\n *\r\n * @method connect\r\n * @for p5.MonoSynth\r\n * @param {Object} unit A p5.sound or Web Audio object\r\n */\r\n\r\n p5.MonoSynth.prototype.connect = function(unit) {\r\n var u = unit || p5sound.input;\r\n this.output.connect(u.input ? u.input : u);\r\n };\r\n\r\n /**\r\n * Disconnect all outputs\r\n *\r\n * @method disconnect\r\n * @for p5.MonoSynth\r\n */\r\n p5.MonoSynth.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n };\r\n\r\n\r\n /**\r\n * Get rid of the MonoSynth and free up its resources / memory.\r\n *\r\n * @method dispose\r\n * @for p5.MonoSynth\r\n */\r\n p5.MonoSynth.prototype.dispose = function() {\r\n AudioVoice.prototype.dispose.apply(this);\r\n\r\n if (this.env) {\r\n this.env.dispose();\r\n }\r\n if (this.oscillator) {\r\n this.oscillator.dispose();\r\n }\r\n };\r\n\r\n});\r\n","'use strict';\r\ndefine(function() {\r\n var p5sound = require('master');\r\n\r\n /**\r\n * Base class for monophonic synthesizers. Any extensions of this class\r\n * should follow the API and implement the methods below in order to\r\n * remain compatible with p5.PolySynth();\r\n *\r\n * @class p5.AudioVoice\r\n * @constructor\r\n */\r\n p5.AudioVoice = function () {\r\n\t this.ac = p5sound.audiocontext;\r\n\t this.output = this.ac.createGain();\r\n\t this.connect();\r\n\t p5sound.soundArray.push(this);\r\n };\r\n\r\n p5.AudioVoice.prototype.play = function (note, velocity, secondsFromNow, sustime) {\r\n };\r\n\r\n p5.AudioVoice.prototype.triggerAttack = function (note, velocity, secondsFromNow) {\r\n };\r\n\r\n p5.AudioVoice.prototype.triggerRelease = function (secondsFromNow) {\r\n };\r\n\r\n p5.AudioVoice.prototype.amp = function(vol, rampTime) {\r\n };\r\n\r\n /**\r\n * Connect to p5 objects or Web Audio Nodes\r\n * @method connect\r\n * @for p5.AudioVoice\r\n * @param {Object} unit\r\n */\r\n p5.AudioVoice.prototype.connect = function(unit) {\r\n var u = unit || p5sound.input;\r\n this.output.connect(u.input ? u.input : u);\r\n };\r\n\r\n /**\r\n * Disconnect from soundOut\r\n * @method disconnect\r\n * @for p5.AudioVoice\r\n */\r\n p5.AudioVoice.prototype.disconnect = function() {\r\n this.output.disconnect();\r\n };\r\n\r\n p5.AudioVoice.prototype.dispose = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n delete this.output;\r\n }\r\n };\r\n\r\n return p5.AudioVoice;\r\n});\r\n","'use strict';\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var TimelineSignal = require('Tone/signal/TimelineSignal');\r\n var noteToFreq = require('helpers').noteToFreq;\r\n\r\n /**\r\n * An AudioVoice is used as a single voice for sound synthesis.\r\n * The PolySynth class holds an array of AudioVoice, and deals\r\n * with voices allocations, with setting notes to be played, and\r\n * parameters to be set.\r\n *\r\n * @class p5.PolySynth\r\n * @constructor\r\n *\r\n * @param {Number} [synthVoice] A monophonic synth voice inheriting\r\n * the AudioVoice class. Defaults to p5.MonoSynth\r\n * @param {Number} [maxVoices] Number of voices, defaults to 8;\r\n * @example\r\n *
\r\n * let polySynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSynth);\r\n * background(220);\r\n * text('click to play', 20, 20);\r\n *\r\n * polySynth = new p5.PolySynth();\r\n * }\r\n *\r\n * function playSynth() {\r\n * userStartAudio();\r\n *\r\n * // note duration (in seconds)\r\n * let dur = 1.5;\r\n *\r\n * // time from now (in seconds)\r\n * let time = 0;\r\n *\r\n * // velocity (volume, from 0 to 1)\r\n * let vel = 0.1;\r\n *\r\n * // notes can overlap with each other\r\n * polySynth.play('G2', vel, 0, dur);\r\n * polySynth.play('C3', vel, time += 1/3, dur);\r\n * polySynth.play('G3', vel, time += 1/3, dur);\r\n * }\r\n *
\r\n **/\r\n p5.PolySynth = function(audioVoice, maxVoices) {\r\n //audiovoices will contain maxVoices many monophonic synths\r\n this.audiovoices = [];\r\n\r\n /**\r\n * An object that holds information about which notes have been played and\r\n * which notes are currently being played. New notes are added as keys\r\n * on the fly. While a note has been attacked, but not released, the value of the\r\n * key is the audiovoice which is generating that note. When notes are released,\r\n * the value of the key becomes undefined.\r\n * @property notes\r\n */\r\n this.notes = {};\r\n\r\n //indices of the most recently used, and least recently used audiovoice\r\n this._newest = 0;\r\n this._oldest = 0;\r\n\r\n /**\r\n * A PolySynth must have at least 1 voice, defaults to 8\r\n * @property polyvalue\r\n */\r\n this.maxVoices = maxVoices || 8;\r\n\r\n /**\r\n * Monosynth that generates the sound for each note that is triggered. The\r\n * p5.PolySynth defaults to using the p5.MonoSynth as its voice.\r\n * @property AudioVoice\r\n */\r\n this.AudioVoice = audioVoice === undefined ? p5.MonoSynth : audioVoice;\r\n\r\n /**\r\n * This value must only change as a note is attacked or released. Due to delay\r\n * and sustain times, Tone.TimelineSignal is required to schedule the change in value.\r\n\t * @private\r\n * @property {Tone.TimelineSignal} _voicesInUse\r\n */\r\n this._voicesInUse = new TimelineSignal(0);\r\n\r\n this.output = p5sound.audiocontext.createGain();\r\n this.connect();\r\n\r\n //Construct the appropriate number of audiovoices\r\n this._allocateVoices();\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Construct the appropriate number of audiovoices\r\n * @private\r\n * @for p5.PolySynth\r\n * @method _allocateVoices\r\n */\r\n p5.PolySynth.prototype._allocateVoices = function() {\r\n for(var i = 0; i< this.maxVoices; i++) {\r\n this.audiovoices.push(new this.AudioVoice());\r\n this.audiovoices[i].disconnect();\r\n this.audiovoices[i].connect(this.output);\r\n }\r\n };\r\n\r\n /**\r\n * Play a note by triggering noteAttack and noteRelease with sustain time\r\n *\r\n * @method play\r\n * @for p5.PolySynth\r\n * @param {Number} [note] midi note to play (ranging from 0 to 127 - 60 being a middle C)\r\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)\r\n * @param {Number} [secondsFromNow] time from now (in seconds) at which to play\r\n * @param {Number} [sustainTime] time to sustain before releasing the envelope\r\n * @example\r\n *
\r\n * let polySynth;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSynth);\r\n * background(220);\r\n * text('click to play', 20, 20);\r\n *\r\n * polySynth = new p5.PolySynth();\r\n * }\r\n *\r\n * function playSynth() {\r\n * userStartAudio();\r\n *\r\n * // note duration (in seconds)\r\n * let dur = 1.5;\r\n *\r\n * // time from now (in seconds)\r\n * let time = 0;\r\n *\r\n * // velocity (volume, from 0 to 1)\r\n * let vel = 0.1;\r\n *\r\n * // notes can overlap with each other\r\n * polySynth.play('G2', vel, 0, dur);\r\n * polySynth.play('C3', vel, time += 1/3, dur);\r\n * polySynth.play('G3', vel, time += 1/3, dur);\r\n * }\r\n *
\r\n */\r\n p5.PolySynth.prototype.play = function (note,velocity, secondsFromNow, susTime) {\r\n var susTime = susTime || 1;\r\n this.noteAttack(note, velocity, secondsFromNow);\r\n this.noteRelease(note, secondsFromNow + susTime);\r\n };\r\n\r\n\r\n /**\r\n * noteADSR sets the envelope for a specific note that has just been triggered.\r\n * Using this method modifies the envelope of whichever audiovoice is being used\r\n * to play the desired note. The envelope should be reset before noteRelease is called\r\n * in order to prevent the modified envelope from being used on other notes.\r\n *\r\n * @method noteADSR\r\n * @for p5.PolySynth\r\n * @param {Number} [note] Midi note on which ADSR should be set.\r\n * @param {Number} [attackTime] Time (in seconds before envelope\r\n * reaches Attack Level\r\n * @param {Number} [decayTime] Time (in seconds) before envelope\r\n * reaches Decay/Sustain Level\r\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\r\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\r\n * The susRatio determines the decayLevel and the level at which the\r\n * sustain portion of the envelope will sustain.\r\n * For example, if attackLevel is 0.4, releaseLevel is 0,\r\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\r\n * increased to 1.0 (using setRange),\r\n * then decayLevel would increase proportionally, to become 0.5.\r\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\r\n **/\r\n\r\n p5.PolySynth.prototype.noteADSR = function (note,a,d,s,r,timeFromNow) {\r\n var now = p5sound.audiocontext.currentTime;\r\n var timeFromNow = timeFromNow || 0;\r\n var t = now + timeFromNow\r\n this.audiovoices[ this.notes[note].getValueAtTime(t) ].setADSR(a,d,s,r);\r\n };\r\n\r\n\r\n /**\r\n * Set the PolySynths global envelope. This method modifies the envelopes of each\r\n * monosynth so that all notes are played with this envelope.\r\n *\r\n * @method setADSR\r\n * @for p5.PolySynth\r\n * @param {Number} [attackTime] Time (in seconds before envelope\r\n * reaches Attack Level\r\n * @param {Number} [decayTime] Time (in seconds) before envelope\r\n * reaches Decay/Sustain Level\r\n * @param {Number} [susRatio] Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,\r\n * where 1.0 = attackLevel, 0.0 = releaseLevel.\r\n * The susRatio determines the decayLevel and the level at which the\r\n * sustain portion of the envelope will sustain.\r\n * For example, if attackLevel is 0.4, releaseLevel is 0,\r\n * and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is\r\n * increased to 1.0 (using setRange),\r\n * then decayLevel would increase proportionally, to become 0.5.\r\n * @param {Number} [releaseTime] Time in seconds from now (defaults to 0)\r\n **/\r\n p5.PolySynth.prototype.setADSR = function(a,d,s,r) {\r\n this.audiovoices.forEach(function(voice) {\r\n voice.setADSR(a,d,s,r);\r\n });\r\n };\r\n\r\n /**\r\n * Trigger the Attack, and Decay portion of a MonoSynth.\r\n * Similar to holding down a key on a piano, but it will\r\n * hold the sustain level until you let go.\r\n *\r\n * @method noteAttack\r\n * @for p5.PolySynth\r\n * @param {Number} [note] midi note on which attack should be triggered.\r\n * @param {Number} [velocity] velocity of the note to play (ranging from 0 to 1)/\r\n * @param {Number} [secondsFromNow] time from now (in seconds)\r\n * @example\r\n *
\r\n * let polySynth = new p5.PolySynth();\r\n * let pitches = ['G', 'D', 'G', 'C'];\r\n * let octaves = [2, 3, 4];\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playChord);\r\n * background(220);\r\n * text('tap to play', 20, 20);\r\n * }\r\n *\r\n * function playChord() {\r\n * userStartAudio();\r\n *\r\n * // play a chord: multiple notes at the same time\r\n * for (let i = 0; i < 4; i++) {\r\n * let note = random(pitches) + random(octaves);\r\n * polySynth.noteAttack(note, 0.1);\r\n * }\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * // release all voices\r\n * polySynth.noteRelease();\r\n * }\r\n *
\r\n */\r\n p5.PolySynth.prototype.noteAttack = function (_note, _velocity, secondsFromNow) {\r\n //this value goes to the audiovoices which handle their own scheduling\r\n var secondsFromNow = ~~secondsFromNow;\r\n\r\n //this value is used by this._voicesInUse\r\n var acTime = p5sound.audiocontext.currentTime + secondsFromNow;\r\n\r\n //Convert note to frequency if necessary. This is because entries into this.notes\r\n //should be based on frequency for the sake of consistency.\r\n var note = noteToFreq(_note);\r\n var velocity = _velocity || 0.1;\r\n\r\n var currentVoice;\r\n\r\n //Release the note if it is already playing\r\n if (this.notes[note] && this.notes[note].getValueAtTime(acTime) !== null) {\r\n this.noteRelease(note, 0);\r\n }\r\n\r\n //Check to see how many voices are in use at the time the note will start\r\n if (this._voicesInUse.getValueAtTime(acTime) < this.maxVoices) {\r\n currentVoice = Math.max(~~this._voicesInUse.getValueAtTime(acTime), 0);\r\n }\r\n //If we are exceeding the polyvalue, bump off the oldest notes and replace\r\n //with a new note\r\n else {\r\n currentVoice = this._oldest;\r\n\r\n var oldestNote = p5.prototype.freqToMidi(this.audiovoices[this._oldest].oscillator.freq().value);\r\n this.noteRelease(oldestNote);\r\n this._oldest = ( this._oldest + 1 ) % (this.maxVoices - 1);\r\n }\r\n\r\n //Overrite the entry in the notes object. A note (frequency value)\r\n //corresponds to the index of the audiovoice that is playing it\r\n this.notes[note] = new TimelineSignal();\r\n this.notes[note].setValueAtTime(currentVoice, acTime);\r\n\r\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\r\n //Add 1 and schedule this value at time 't', when this note will start playing\r\n var previousVal = this._voicesInUse._searchBefore(acTime) === null ? 0 : this._voicesInUse._searchBefore(acTime).value;\r\n this._voicesInUse.setValueAtTime(previousVal + 1, acTime);\r\n\r\n //Then update all scheduled values that follow to increase by 1\r\n this._updateAfter(acTime, 1);\r\n\r\n this._newest = currentVoice;\r\n //The audiovoice handles the actual scheduling of the note\r\n if (typeof velocity === 'number') {\r\n var maxRange = 1 / this._voicesInUse.getValueAtTime(acTime) * 2;\r\n velocity = velocity > maxRange ? maxRange : velocity;\r\n }\r\n this.audiovoices[currentVoice].triggerAttack(note, velocity, secondsFromNow);\r\n };\r\n\r\n /**\r\n * Private method to ensure accurate values of this._voicesInUse\r\n * Any time a new value is scheduled, it is necessary to increment all subsequent\r\n * scheduledValues after attack, and decrement all subsequent\r\n * scheduledValues after release\r\n *\r\n * @private\r\n * @for p5.PolySynth\r\n * @param {[type]} time [description]\r\n * @param {[type]} value [description]\r\n * @return {[type]} [description]\r\n */\r\n p5.PolySynth.prototype._updateAfter = function(time, value) {\r\n if(this._voicesInUse._searchAfter(time) === null) {\r\n return;\r\n } else{\r\n this._voicesInUse._searchAfter(time).value += value;\r\n var nextTime = this._voicesInUse._searchAfter(time).time;\r\n this._updateAfter(nextTime, value);\r\n }\r\n };\r\n\r\n\r\n /**\r\n * Trigger the Release of an AudioVoice note. This is similar to releasing\r\n * the key on a piano and letting the sound fade according to the\r\n * release level and release time.\r\n *\r\n * @method noteRelease\r\n * @for p5.PolySynth\r\n * @param {Number} [note] midi note on which attack should be triggered.\r\n * If no value is provided, all notes will be released.\r\n * @param {Number} [secondsFromNow] time to trigger the release\r\n * @example\r\n *
\r\n * let polySynth = new p5.PolySynth();\r\n * let pitches = ['G', 'D', 'G', 'C'];\r\n * let octaves = [2, 3, 4];\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playChord);\r\n * background(220);\r\n * text('tap to play', 20, 20);\r\n * }\r\n *\r\n * function playChord() {\r\n * userStartAudio();\r\n *\r\n * // play a chord: multiple notes at the same time\r\n * for (let i = 0; i < 4; i++) {\r\n * let note = random(pitches) + random(octaves);\r\n * polySynth.noteAttack(note, 0.1);\r\n * }\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * // release all voices\r\n * polySynth.noteRelease();\r\n * }\r\n *
\r\n *\r\n */\r\n p5.PolySynth.prototype.noteRelease = function (_note,secondsFromNow) {\r\n var now = p5sound.audiocontext.currentTime;\r\n var tFromNow = secondsFromNow || 0;\r\n var t = now + tFromNow;\r\n\r\n // if a note value is not provided, release all voices\r\n if (!_note) {\r\n this.audiovoices.forEach(function(voice) {\r\n voice.triggerRelease(tFromNow)\r\n });\r\n this._voicesInUse.setValueAtTime(0, t);\r\n for (var n in this.notes) {\r\n this.notes[n].dispose();\r\n delete this.notes[n];\r\n }\r\n return;\r\n }\r\n\r\n //Make sure note is in frequency inorder to query the this.notes object\r\n var note = noteToFreq(_note);\r\n\r\n if (!this.notes[note] || this.notes[note].getValueAtTime(t) === null) {\r\n console.warn('Cannot release a note that is not already playing');\r\n } else {\r\n //Find the scheduled change in this._voicesInUse that will be previous to this new note\r\n //subtract 1 and schedule this value at time 't', when this note will stop playing\r\n var previousVal = Math.max(~~this._voicesInUse.getValueAtTime(t).value, 1);\r\n this._voicesInUse.setValueAtTime(previousVal - 1, t);\r\n //Then update all scheduled values that follow to decrease by 1 but never go below 0\r\n if (previousVal > 0) {\r\n this._updateAfter(t, -1);\r\n }\r\n\r\n this.audiovoices[ this.notes[note].getValueAtTime(t) ].triggerRelease(tFromNow);\r\n this.notes[note].dispose();\r\n delete this.notes[note];\r\n\r\n this._newest = this._newest === 0 ? 0 : (this._newest - 1) % (this.maxVoices - 1);\r\n }\r\n\r\n };\r\n\r\n /**\r\n * Connect to a p5.sound / Web Audio object.\r\n *\r\n * @method connect\r\n * @for p5.PolySynth\r\n * @param {Object} unit A p5.sound or Web Audio object\r\n */\r\n p5.PolySynth.prototype.connect = function (unit) {\r\n var u = unit || p5sound.input;\r\n this.output.connect(u.input ? u.input : u);\r\n };\r\n\r\n /**\r\n * Disconnect all outputs\r\n *\r\n * @method disconnect\r\n * @for p5.PolySynth\r\n */\r\n p5.PolySynth.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n };\r\n\r\n /**\r\n * Get rid of the MonoSynth and free up its resources / memory.\r\n *\r\n * @method dispose\r\n * @for p5.PolySynth\r\n */\r\n p5.PolySynth.prototype.dispose = function() {\r\n this.audiovoices.forEach(function(voice) {\r\n voice.dispose();\r\n });\r\n\r\n if (this.output) {\r\n this.output.disconnect();\r\n delete this.output;\r\n }\r\n };\r\n\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n require('audioworklet-polyfill');\r\n require('shims');\r\n require('audiocontext');\r\n var p5SOUND = require('master');\r\n require('helpers');\r\n require('errorHandler');\r\n require('audioWorklet');\r\n require('panner');\r\n require('soundfile');\r\n require('amplitude');\r\n require('fft');\r\n require('signal');\r\n require('oscillator');\r\n require('envelope');\r\n require('pulse');\r\n require('noise');\r\n require('audioin');\r\n require('filter');\r\n require('eq');\r\n require('panner3d');\r\n require('listener3d');\r\n require('delay');\r\n require('reverb');\r\n require('metro');\r\n require('looper');\r\n require('soundLoop');\r\n require('compressor');\r\n require('soundRecorder');\r\n require('peakDetect');\r\n require('gain');\r\n require('monosynth');\r\n require('polysynth');\r\n require('distortion');\r\n require('audioVoice');\r\n require('monosynth');\r\n require('polysynth');\r\n\r\n return p5SOUND;\r\n\r\n});\r\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].length;\\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].length;\\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);\"","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var ac = p5sound.audiocontext;\r\n\r\n // Stereo panner\r\n // if there is a stereo panner node use it\r\n if(typeof ac.createStereoPanner !== 'undefined') {\r\n p5.Panner = function (input, output) {\r\n this.stereoPanner = this.input = ac.createStereoPanner();\r\n input.connect(this.stereoPanner);\r\n this.stereoPanner.connect(output);\r\n };\r\n\r\n p5.Panner.prototype.pan = function(val, tFromNow) {\r\n var time = tFromNow || 0;\r\n var t = ac.currentTime + time;\r\n\r\n this.stereoPanner.pan.linearRampToValueAtTime(val, t);\r\n };\r\n\r\n //not implemented because stereopanner\r\n //node does not require this and will automatically\r\n //convert single channel or multichannel to stereo.\r\n //tested with single and stereo, not with (>2) multichannel\r\n p5.Panner.prototype.inputChannels = function() {};\r\n\r\n p5.Panner.prototype.connect = function(obj) {\r\n this.stereoPanner.connect(obj);\r\n };\r\n\r\n p5.Panner.prototype.disconnect = function() {\r\n if (this.stereoPanner) {\r\n this.stereoPanner.disconnect();\r\n }\r\n };\r\n\r\n } else {\r\n // if there is no createStereoPanner object\r\n // such as in safari 7.1.7 at the time of writing this\r\n // use this method to create the effect\r\n p5.Panner = function(input, output, numInputChannels) {\r\n this.input = ac.createGain();\r\n input.connect(this.input);\r\n\r\n this.left = ac.createGain();\r\n this.right = ac.createGain();\r\n this.left.channelInterpretation = 'discrete';\r\n this.right.channelInterpretation = 'discrete';\r\n\r\n // if input is stereo\r\n if (numInputChannels > 1) {\r\n this.splitter = ac.createChannelSplitter(2);\r\n this.input.connect(this.splitter);\r\n\r\n this.splitter.connect(this.left, 1);\r\n this.splitter.connect(this.right, 0);\r\n }\r\n else {\r\n this.input.connect(this.left);\r\n this.input.connect(this.right);\r\n }\r\n\r\n this.output = ac.createChannelMerger(2);\r\n this.left.connect(this.output, 0, 1);\r\n this.right.connect(this.output, 0, 0);\r\n this.output.connect(output);\r\n };\r\n\r\n // -1 is left, +1 is right\r\n p5.Panner.prototype.pan = function(val, tFromNow) {\r\n var time = tFromNow || 0;\r\n var t = ac.currentTime + time;\r\n var v = (val + 1) / 2;\r\n var rightVal = Math.cos(v*Math.PI/2);\r\n var leftVal = Math.sin(v * Math.PI/2);\r\n this.left.gain.linearRampToValueAtTime(leftVal, t);\r\n this.right.gain.linearRampToValueAtTime(rightVal, t);\r\n };\r\n\r\n p5.Panner.prototype.inputChannels = function(numChannels) {\r\n if (numChannels === 1) {\r\n this.input.disconnect();\r\n this.input.connect(this.left);\r\n this.input.connect(this.right);\r\n } else if (numChannels === 2) {\r\n if (typeof(this.splitter === 'undefined')) {\r\n this.splitter = ac.createChannelSplitter(2);\r\n }\r\n this.input.disconnect();\r\n this.input.connect(this.splitter);\r\n this.splitter.connect(this.left, 1);\r\n this.splitter.connect(this.right, 0);\r\n }\r\n };\r\n\r\n p5.Panner.prototype.connect = function(obj) {\r\n this.output.connect(obj);\r\n };\r\n\r\n p5.Panner.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n };\r\n }\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n const CustomError = require('errorHandler');\r\n const p5sound = require('master');\r\n const ac = p5sound.audiocontext;\r\n const { midiToFreq, convertToWav, safeBufferSize } = require('helpers');\r\n var processorNames = require('./audioWorklet/processorNames');\r\n\r\n /**\r\n *

SoundFile object with a path to a file.

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

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

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

\r\n *\r\n *

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

\r\n *\r\n *

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

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

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

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

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

\r\n *\r\n * @method logAverages\r\n * @for p5.FFT\r\n * @param {Array} octaveBands Array of Octave Bands objects for grouping\r\n * @return {Array} logAverages Array of average amplitude values for each group\r\n */\r\n p5.FFT.prototype.logAverages = function(octaveBands) {\r\n var nyquist = p5sound.audiocontext.sampleRate / 2;\r\n var spectrum = this.freqDomain;\r\n var spectrumLength = spectrum.length;\r\n\r\n var logAverages = new Array(octaveBands.length);\r\n // Keep a second index for the current average group and place the values accordingly\r\n // With only one loop in the spectrum data\r\n var octaveIndex = 0;\r\n\r\n for (var specIndex = 0; specIndex < spectrumLength; specIndex++) {\r\n var specIndexFrequency = Math.round(\r\n specIndex * nyquist / this.freqDomain.length\r\n );\r\n\r\n // Increase the group index if the current frequency exceeds the limits of the band\r\n if (specIndexFrequency > octaveBands[octaveIndex].hi) {\r\n octaveIndex++;\r\n }\r\n\r\n logAverages[octaveIndex] =\r\n logAverages[octaveIndex] !== undefined\r\n ? (logAverages[octaveIndex] + spectrum[specIndex]) / 2\r\n : spectrum[specIndex];\r\n }\r\n\r\n return logAverages;\r\n };\r\n\r\n /**\r\n * Calculates and Returns the 1/N\r\n * Octave Bands\r\n * N defaults to 3 and minimum central frequency to 15.625Hz.\r\n * (1/3 Octave Bands ~= 31 Frequency Bands)\r\n * Setting fCtr0 to a central value of a higher octave will ignore the lower bands\r\n * and produce less frequency groups.\r\n *\r\n * @method getOctaveBands\r\n * @for p5.FFT\r\n * @param {Number} N Specifies the 1/N type of generated octave bands\r\n * @param {Number} fCtr0 Minimum central frequency for the lowest band\r\n * @return {Array} octaveBands Array of octave band objects with their bounds\r\n */\r\n p5.FFT.prototype.getOctaveBands = function(N, fCtr0) {\r\n var N = N || 3; // Default to 1/3 Octave Bands\r\n var fCtr0 = fCtr0 || 15.625; // Minimum central frequency, defaults to 15.625Hz\r\n\r\n var octaveBands = [];\r\n var lastFrequencyBand = {\r\n lo: fCtr0 / Math.pow(2, 1 / (2 * N)),\r\n ctr: fCtr0,\r\n hi: fCtr0 * Math.pow(2, 1 / (2 * N))\r\n };\r\n octaveBands.push(lastFrequencyBand);\r\n\r\n var nyquist = p5sound.audiocontext.sampleRate / 2;\r\n while (lastFrequencyBand.hi < nyquist) {\r\n var newFrequencyBand = {};\r\n newFrequencyBand.lo = lastFrequencyBand.hi;\r\n newFrequencyBand.ctr = lastFrequencyBand.ctr * Math.pow(2, 1 / N);\r\n newFrequencyBand.hi = newFrequencyBand.ctr * Math.pow(2, 1 / (2 * N));\r\n\r\n octaveBands.push(newFrequencyBand);\r\n lastFrequencyBand = newFrequencyBand;\r\n }\r\n\r\n return octaveBands;\r\n };\r\n\r\n // helper methods to convert type from float (dB) to int (0-255)\r\n var freqToFloat = function(fft) {\r\n if (fft.freqDomain instanceof Float32Array === false) {\r\n fft.freqDomain = new Float32Array(fft.analyser.frequencyBinCount);\r\n }\r\n };\r\n var freqToInt = function(fft) {\r\n if (fft.freqDomain instanceof Uint8Array === false) {\r\n fft.freqDomain = new Uint8Array(fft.analyser.frequencyBinCount);\r\n }\r\n };\r\n var timeToFloat = function(fft) {\r\n if (fft.timeDomain instanceof Float32Array === false) {\r\n fft.timeDomain = new Float32Array(fft.analyser.frequencyBinCount);\r\n }\r\n };\r\n var timeToInt = function(fft) {\r\n if (fft.timeDomain instanceof Uint8Array === false) {\r\n fft.timeDomain = new Uint8Array(fft.analyser.frequencyBinCount);\r\n }\r\n };\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n // Signal is built with the Tone.js signal by Yotam Mann\r\n // https://github.com/TONEnoTONE/Tone.js/\r\n var Signal = require('Tone/signal/Signal');\r\n var Add = require('Tone/signal/Add');\r\n var Mult = require('Tone/signal/Multiply');\r\n var Scale = require('Tone/signal/Scale');\r\n\r\n /**\r\n *

p5.Signal is a constant audio-rate signal used by p5.Oscillator\r\n * and p5.Envelope for modulation math.

\r\n *\r\n *

This is necessary because Web Audio is processed on a seprate clock.\r\n * For example, the p5 draw loop runs about 60 times per second. But\r\n * the audio clock must process samples 44100 times per second. If we\r\n * want to add a value to each of those samples, we can't do it in the\r\n * draw loop, but we can do it by adding a constant-rate audio signal.This class mostly functions behind the scenes in p5.sound, and returns\r\n * a Tone.Signal from the Tone.js library by Yotam Mann.\r\n * If you want to work directly with audio signals for modular\r\n * synthesis, check out\r\n * tone.js.

\r\n *\r\n * @class p5.Signal\r\n * @constructor\r\n * @return {Tone.Signal} A Signal object from the Tone.js library\r\n * @example\r\n *
\r\n * let carrier, modulator;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(canvasPressed);\r\n * background(220);\r\n * text('tap to play', 20, 20);\r\n *\r\n * carrier = new p5.Oscillator('sine');\r\n * carrier.start();\r\n * carrier.amp(1); // set amplitude\r\n * carrier.freq(220); // set frequency\r\n *\r\n * modulator = new p5.Oscillator('sawtooth');\r\n * modulator.disconnect();\r\n * modulator.start();\r\n * modulator.amp(1);\r\n * modulator.freq(4);\r\n *\r\n * // Modulator's default amplitude range is -1 to 1.\r\n * // Multiply it by -200, so the range is -200 to 200\r\n * // then add 220 so the range is 20 to 420\r\n * carrier.freq( modulator.mult(-400).add(220) );\r\n * }\r\n *\r\n * function canvasPressed() {\r\n * userStartAudio();\r\n * carrier.amp(1.0);\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * carrier.amp(0);\r\n * }\r\n *
\r\n */\r\n p5.Signal = function(value) {\r\n var s = new Signal(value);\r\n // p5sound.soundArray.push(s);\r\n return s; // TODO: is this really a constructor?\r\n };\r\n\r\n /**\r\n * Fade to value, for smooth transitions\r\n *\r\n * @method fade\r\n * @for p5.Signal\r\n * @param {Number} value Value to set this signal\r\n * @param {Number} [secondsFromNow] Length of fade, in seconds from now\r\n */\r\n Signal.prototype.fade = Signal.prototype.linearRampToValueAtTime;\r\n Mult.prototype.fade = Signal.prototype.fade;\r\n Add.prototype.fade = Signal.prototype.fade;\r\n Scale.prototype.fade = Signal.prototype.fade;\r\n\r\n\r\n /**\r\n * Connect a p5.sound object or Web Audio node to this\r\n * p5.Signal so that its amplitude values can be scaled.\r\n *\r\n * @method setInput\r\n * @for p5.Signal\r\n * @param {Object} input\r\n */\r\n Signal.prototype.setInput = function(_input) {\r\n _input.connect(this);\r\n };\r\n Mult.prototype.setInput = Signal.prototype.setInput;\r\n Add.prototype.setInput = Signal.prototype.setInput;\r\n Scale.prototype.setInput = Signal.prototype.setInput;\r\n\r\n\r\n // signals can add / mult / scale themselves\r\n\r\n /**\r\n * Add a constant value to this audio signal,\r\n * and return the resulting audio signal. Does\r\n * not change the value of the original signal,\r\n * instead it returns a new p5.SignalAdd.\r\n *\r\n * @method add\r\n * @for p5.Signal\r\n * @param {Number} number\r\n * @return {p5.Signal} object\r\n */\r\n Signal.prototype.add = function(num) {\r\n var add = new Add(num);\r\n // add.setInput(this);\r\n this.connect(add);\r\n return add;\r\n };\r\n Mult.prototype.add = Signal.prototype.add;\r\n Add.prototype.add = Signal.prototype.add;\r\n Scale.prototype.add = Signal.prototype.add;\r\n\r\n /**\r\n * Multiply this signal by a constant value,\r\n * and return the resulting audio signal. Does\r\n * not change the value of the original signal,\r\n * instead it returns a new p5.SignalMult.\r\n *\r\n * @method mult\r\n * @for p5.Signal\r\n * @param {Number} number to multiply\r\n * @return {p5.Signal} object\r\n */\r\n Signal.prototype.mult = function(num) {\r\n var mult = new Mult(num);\r\n // mult.setInput(this);\r\n this.connect(mult);\r\n return mult;\r\n };\r\n Mult.prototype.mult = Signal.prototype.mult;\r\n Add.prototype.mult = Signal.prototype.mult;\r\n Scale.prototype.mult = Signal.prototype.mult;\r\n\r\n /**\r\n * Scale this signal value to a given range,\r\n * and return the result as an audio signal. Does\r\n * not change the value of the original signal,\r\n * instead it returns a new p5.SignalScale.\r\n *\r\n * @method scale\r\n * @for p5.Signal\r\n * @param {Number} number to multiply\r\n * @param {Number} inMin input range minumum\r\n * @param {Number} inMax input range maximum\r\n * @param {Number} outMin input range minumum\r\n * @param {Number} outMax input range maximum\r\n * @return {p5.Signal} object\r\n */\r\n Signal.prototype.scale = function(inMin, inMax, outMin, outMax) {\r\n var mapOutMin, mapOutMax;\r\n if (arguments.length === 4) {\r\n mapOutMin = p5.prototype.map(outMin, inMin, inMax, 0, 1) - 0.5;\r\n mapOutMax = p5.prototype.map(outMax, inMin, inMax, 0, 1) - 0.5;\r\n }\r\n else {\r\n mapOutMin = arguments[0];\r\n mapOutMax = arguments[1];\r\n }\r\n var scale = new Scale(mapOutMin, mapOutMax);\r\n this.connect(scale);\r\n return scale;\r\n };\r\n Mult.prototype.scale = Signal.prototype.scale;\r\n Add.prototype.scale = Signal.prototype.scale;\r\n Scale.prototype.scale = Signal.prototype.scale;\r\n\r\n});\r\n\r\n\r\n","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});","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n var p5sound = require('master');\r\n var Add = require('Tone/signal/Add');\r\n var Mult = require('Tone/signal/Multiply');\r\n var Scale = require('Tone/signal/Scale');\r\n var TimelineSignal = require('Tone/signal/TimelineSignal');\r\n\r\n /**\r\n *

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

\r\n *

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

\r\n *

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

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

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

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n * @class p5.AudioIn\r\n * @constructor\r\n * @param {Function} [errorCallback] A function to call if there is an error\r\n * accessing the AudioIn. For example,\r\n * Safari and iOS devices do not\r\n * currently allow microphone access.\r\n * @example\r\n *
\r\n * let mic;\r\n *\r\n * function setup(){\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(userStartAudio);\r\n * textAlign(CENTER);\r\n * mic = new p5.AudioIn();\r\n * mic.start();\r\n * }\r\n *\r\n * function draw(){\r\n * background(0);\r\n * fill(255);\r\n * text('tap to start', width/2, 20);\r\n *\r\n * micLevel = mic.getLevel();\r\n * let y = height - micLevel * height;\r\n * ellipse(width/2, y, 10, 10);\r\n * }\r\n *
\r\n */\r\n p5.AudioIn = function(errorCallback) {\r\n // set up audio input\r\n /**\r\n * @property {GainNode} input\r\n */\r\n this.input = p5sound.audiocontext.createGain();\r\n /**\r\n * @property {GainNode} output\r\n */\r\n this.output = p5sound.audiocontext.createGain();\r\n\r\n /**\r\n * @property {MediaStream|null} stream\r\n */\r\n this.stream = null;\r\n /**\r\n * @property {MediaStreamAudioSourceNode|null} mediaStream\r\n */\r\n this.mediaStream = null;\r\n /**\r\n * @property {Number|null} currentSource\r\n */\r\n this.currentSource = null;\r\n\r\n /**\r\n * Client must allow browser to access their microphone / audioin source.\r\n * Default: false. Will become true when the client enables access.\r\n *\r\n * @property {Boolean} enabled\r\n */\r\n this.enabled = false;\r\n\r\n /**\r\n * Input amplitude, connect to it by default but not to master out\r\n *\r\n * @property {p5.Amplitude} amplitude\r\n */\r\n this.amplitude = new p5.Amplitude();\r\n this.output.connect(this.amplitude.input);\r\n\r\n if (!window.MediaStreamTrack || !window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia) {\r\n errorCallback ? errorCallback() : window.alert('This browser does not support MediaStreamTrack and mediaDevices');\r\n }\r\n\r\n // add to soundArray so we can dispose on close\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Start processing audio input. This enables the use of other\r\n * AudioIn methods like getLevel(). Note that by default, AudioIn\r\n * is not connected to p5.sound's output. So you won't hear\r\n * anything unless you use the connect() method.
\r\n *\r\n * Certain browsers limit access to the user's microphone. For example,\r\n * Chrome only allows access from localhost and over https. For this reason,\r\n * you may want to include an errorCallback—a function that is called in case\r\n * the browser won't provide mic access.\r\n *\r\n * @method start\r\n * @for p5.AudioIn\r\n * @param {Function} [successCallback] Name of a function to call on\r\n * success.\r\n * @param {Function} [errorCallback] Name of a function to call if\r\n * there was an error. For example,\r\n * some browsers do not support\r\n * getUserMedia.\r\n */\r\n p5.AudioIn.prototype.start = function(successCallback, errorCallback) {\r\n var self = this;\r\n\r\n if (this.stream) {\r\n this.stop();\r\n }\r\n\r\n // set the audio source\r\n var audioSource = p5sound.inputSources[self.currentSource];\r\n var constraints = {\r\n audio: {\r\n sampleRate: p5sound.audiocontext.sampleRate,\r\n echoCancellation: false\r\n }\r\n };\r\n\r\n // if developers determine which source to use\r\n if (p5sound.inputSources[this.currentSource]) {\r\n constraints.audio.deviceId = audioSource.deviceId;\r\n }\r\n\r\n window.navigator.mediaDevices.getUserMedia( constraints )\r\n .then( function(stream) {\r\n self.stream = stream;\r\n self.enabled = true;\r\n // Wrap a MediaStreamSourceNode around the live input\r\n self.mediaStream = p5sound.audiocontext.createMediaStreamSource(stream);\r\n self.mediaStream.connect(self.output);\r\n // only send to the Amplitude reader, so we can see it but not hear it.\r\n self.amplitude.setInput(self.output);\r\n if (successCallback) successCallback();\r\n })\r\n .catch( function(err) {\r\n if (errorCallback) errorCallback(err);\r\n else console.error(err);\r\n });\r\n };\r\n\r\n /**\r\n * Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().\r\n * If re-starting, the user may be prompted for permission access.\r\n *\r\n * @method stop\r\n * @for p5.AudioIn\r\n */\r\n p5.AudioIn.prototype.stop = function() {\r\n if (this.stream) {\r\n this.stream.getTracks().forEach(function(track) {\r\n track.stop();\r\n });\r\n\r\n this.mediaStream.disconnect();\r\n\r\n delete this.mediaStream;\r\n delete this.stream;\r\n }\r\n };\r\n\r\n /**\r\n * Connect to an audio unit. If no parameter is provided, will\r\n * connect to the master output (i.e. your speakers).
\r\n *\r\n * @method connect\r\n * @for p5.AudioIn\r\n * @param {Object} [unit] An object that accepts audio input,\r\n * such as an FFT\r\n */\r\n p5.AudioIn.prototype.connect = function(unit) {\r\n if (unit) {\r\n if (unit.hasOwnProperty('input')) {\r\n this.output.connect(unit.input);\r\n }\r\n else if (unit.hasOwnProperty('analyser')) {\r\n this.output.connect(unit.analyser);\r\n }\r\n else {\r\n this.output.connect(unit);\r\n }\r\n }\r\n else {\r\n this.output.connect(p5sound.input);\r\n }\r\n };\r\n\r\n /**\r\n * Disconnect the AudioIn from all audio units. For example, if\r\n * connect() had been called, disconnect() will stop sending\r\n * signal to your speakers.
\r\n *\r\n * @method disconnect\r\n * @for p5.AudioIn\r\n */\r\n p5.AudioIn.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n // stay connected to amplitude even if not outputting to p5\r\n this.output.connect(this.amplitude.input);\r\n }\r\n };\r\n\r\n /**\r\n * Read the Amplitude (volume level) of an AudioIn. The AudioIn\r\n * class contains its own instance of the Amplitude class to help\r\n * make it easy to get a microphone's volume level. Accepts an\r\n * optional smoothing value (0.0 < 1.0). NOTE: AudioIn must\r\n * .start() before using .getLevel().
\r\n *\r\n * @method getLevel\r\n * @for p5.AudioIn\r\n * @param {Number} [smoothing] Smoothing is 0.0 by default.\r\n * Smooths values based on previous values.\r\n * @return {Number} Volume level (between 0.0 and 1.0)\r\n */\r\n p5.AudioIn.prototype.getLevel = function(smoothing) {\r\n if (smoothing) {\r\n this.amplitude.smoothing = smoothing;\r\n }\r\n return this.amplitude.getLevel();\r\n };\r\n\r\n /**\r\n * Set amplitude (volume) of a mic input between 0 and 1.0.
\r\n *\r\n * @method amp\r\n * @for p5.AudioIn\r\n * @param {Number} vol between 0 and 1.0\r\n * @param {Number} [time] ramp time (optional)\r\n */\r\n p5.AudioIn.prototype.amp = function(vol, t) {\r\n if (t) {\r\n var rampTime = t || 0;\r\n var currentVol = this.output.gain.value;\r\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\r\n this.output.gain.setValueAtTime(currentVol, p5sound.audiocontext.currentTime);\r\n this.output.gain.linearRampToValueAtTime(vol, rampTime + p5sound.audiocontext.currentTime);\r\n } else {\r\n this.output.gain.cancelScheduledValues(p5sound.audiocontext.currentTime);\r\n this.output.gain.setValueAtTime(vol, p5sound.audiocontext.currentTime);\r\n }\r\n };\r\n\r\n /**\r\n * Returns a list of available input sources. This is a wrapper\r\n * for and it returns a Promise.\r\n *\r\n * @method getSources\r\n * @for p5.AudioIn\r\n * @param {Function} [successCallback] This callback function handles the sources when they\r\n * have been enumerated. The callback function\r\n * receives the deviceList array as its only argument\r\n * @param {Function} [errorCallback] This optional callback receives the error\r\n * message as its argument.\r\n * @returns {Promise} Returns a Promise that can be used in place of the callbacks, similar\r\n * to the enumerateDevices() method\r\n * @example\r\n *
\r\n * let audioIn;\r\n *\r\n * function setup(){\r\n * text('getting sources...', 0, 20);\r\n * audioIn = new p5.AudioIn();\r\n * audioIn.getSources(gotSources);\r\n * }\r\n *\r\n * function gotSources(deviceList) {\r\n * if (deviceList.length > 0) {\r\n * //set the source to the first item in the deviceList array\r\n * audioIn.setSource(0);\r\n * let currentSource = deviceList[audioIn.currentSource];\r\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\r\n * }\r\n * }\r\n *
\r\n */\r\n p5.AudioIn.prototype.getSources = function (onSuccess, onError) {\r\n return new Promise( function(resolve, reject) {\r\n window.navigator.mediaDevices.enumerateDevices()\r\n .then( function(devices) {\r\n p5sound.inputSources = devices.filter(function(device) {\r\n return device.kind === 'audioinput';\r\n });\r\n resolve(p5sound.inputSources);\r\n if (onSuccess) {\r\n onSuccess(p5sound.inputSources);\r\n }\r\n })\r\n .catch( function(error) {\r\n reject(error);\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error('This browser does not support MediaStreamTrack.getSources()');\r\n }\r\n });\r\n });\r\n };\r\n\r\n /**\r\n * Set the input source. Accepts a number representing a\r\n * position in the array returned by getSources().\r\n * This is only available in browsers that support\r\n *
navigator.mediaDevices.enumerateDevices().
\r\n *\r\n * @method setSource\r\n * @for p5.AudioIn\r\n * @param {number} num position of input source in the array\r\n * @example\r\n *
\r\n * let audioIn;\r\n *\r\n * function setup(){\r\n * text('getting sources...', 0, 20);\r\n * audioIn = new p5.AudioIn();\r\n * audioIn.getSources(gotSources);\r\n * }\r\n *\r\n * function gotSources(deviceList) {\r\n * if (deviceList.length > 0) {\r\n * //set the source to the first item in the deviceList array\r\n * audioIn.setSource(0);\r\n * let currentSource = deviceList[audioIn.currentSource];\r\n * text('set source to: ' + currentSource.deviceId, 5, 20, width);\r\n * }\r\n * }\r\n *
\r\n */\r\n p5.AudioIn.prototype.setSource = function(num) {\r\n if (p5sound.inputSources.length > 0 && num < p5sound.inputSources.length) {\r\n // set the current source\r\n this.currentSource = num;\r\n console.log('set source to ', p5sound.inputSources[this.currentSource]);\r\n } else {\r\n console.log('unable to set input source');\r\n }\r\n\r\n // restart stream if currently active\r\n if (this.stream && this.stream.active) {\r\n this.start();\r\n }\r\n };\r\n\r\n // private method\r\n p5.AudioIn.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n\r\n this.stop();\r\n\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n if (this.amplitude) {\r\n this.amplitude.disconnect();\r\n }\r\n delete this.amplitude;\r\n delete this.output;\r\n };\r\n\r\n});\r\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","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});","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n var Effect = require('effect');\r\n var EQFilter = require('eqFilter');\r\n\r\n /**\r\n * p5.EQ is an audio effect that performs the function of a multiband\r\n * audio equalizer. Equalization is used to adjust the balance of\r\n * frequency compoenents of an audio signal. This process is commonly used\r\n * in sound production and recording to change the waveform before it reaches\r\n * a sound output device. EQ can also be used as an audio effect to create\r\n * interesting distortions by filtering out parts of the spectrum. p5.EQ is\r\n * built using a chain of Web Audio Biquad Filter Nodes and can be\r\n * instantiated with 3 or 8 bands. Bands can be added or removed from\r\n * the EQ by directly modifying p5.EQ.bands (the array that stores filters).\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.EQ\r\n * @constructor\r\n * @extends p5.Effect\r\n * @param {Number} [_eqsize] Constructor will accept 3 or 8, defaults to 3\r\n * @return {Object} p5.EQ object\r\n *\r\n * @example\r\n *
\r\n * let eq, soundFile\r\n * let eqBandIndex = 0;\r\n * let eqBandNames = ['lows', 'mids', 'highs'];\r\n *\r\n * function preload() {\r\n * soundFormats('mp3', 'ogg');\r\n * soundFile = loadSound('assets/beat');\r\n * }\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(toggleSound);\r\n *\r\n * eq = new p5.EQ(eqBandNames.length);\r\n * soundFile.disconnect();\r\n * eq.process(soundFile);\r\n * }\r\n *\r\n * function draw() {\r\n * background(30);\r\n * noStroke();\r\n * fill(255);\r\n * textAlign(CENTER);\r\n * text('filtering ', 50, 25);\r\n *\r\n * fill(255, 40, 255);\r\n * textSize(26);\r\n * text(eqBandNames[eqBandIndex], 50, 55);\r\n *\r\n * fill(255);\r\n * textSize(9);\r\n *\r\n * if (!soundFile.isPlaying()) {\r\n * text('tap to play', 50, 80);\r\n * } else {\r\n * text('tap to filter next band', 50, 80)\r\n * }\r\n * }\r\n *\r\n * function toggleSound() {\r\n * if (!soundFile.isPlaying()) {\r\n * soundFile.play();\r\n * } else {\r\n * eqBandIndex = (eqBandIndex + 1) % eq.bands.length;\r\n * }\r\n *\r\n * for (let i = 0; i < eq.bands.length; i++) {\r\n * eq.bands[i].gain(0);\r\n * }\r\n * // filter the band we want to filter\r\n * eq.bands[eqBandIndex].gain(-40);\r\n * }\r\n *
\r\n */\r\n p5.EQ = function(_eqsize) {\r\n Effect.call(this);\r\n\r\n //p5.EQ can be of size (3) or (8), defaults to 3\r\n _eqsize = _eqsize === 3 || _eqsize === 8 ? _eqsize : 3;\r\n\r\n var factor;\r\n _eqsize === 3 ? factor = Math.pow(2,3) : factor = 2;\r\n\r\n /**\r\n * The p5.EQ is built with abstracted p5.Filter objects.\r\n * To modify any bands, use methods of the \r\n * p5.Filter API, especially `gain` and `freq`.\r\n * Bands are stored in an array, with indices 0 - 3, or 0 - 7\r\n * @property {Array} bands\r\n *\r\n */\r\n this.bands = [];\r\n\r\n\r\n var freq, res;\r\n for (var i = 0; i < _eqsize; i++) {\r\n if (i === _eqsize - 1) {\r\n freq = 21000;\r\n res = .01;\r\n } else if (i === 0) {\r\n freq = 100;\r\n res = .1;\r\n }\r\n else if (i===1) {\r\n freq = _eqsize === 3 ? 360 * factor : 360;\r\n res = 1;\r\n }else {\r\n freq = this.bands[i-1].freq() * factor;\r\n res = 1;\r\n }\r\n this.bands[i] = this._newBand(freq, res);\r\n\r\n if (i>0) {\r\n this.bands[i-1].connect(this.bands[i].biquad);\r\n } else {\r\n this.input.connect(this.bands[i].biquad);\r\n }\r\n }\r\n this.bands[_eqsize-1].connect(this.output);\r\n };\r\n p5.EQ.prototype = Object.create(Effect.prototype);\r\n\r\n /**\r\n * Process an input by connecting it to the EQ\r\n * @method process\r\n * @param {Object} src Audio source\r\n */\r\n p5.EQ.prototype.process = function (src) {\r\n src.connect(this.input);\r\n };\r\n\r\n // /**\r\n // * Set the frequency and gain of each band in the EQ. This method should be\r\n // * called with 3 or 8 frequency and gain pairs, depending on the size of the EQ.\r\n // * ex. eq.set(freq0, gain0, freq1, gain1, freq2, gain2);\r\n // *\r\n // * @method set\r\n // * @for p5.EQ\r\n // * @param {Number} [freq0] Frequency value for band with index 0\r\n // * @param {Number} [gain0] Gain value for band with index 0\r\n // * @param {Number} [freq1] Frequency value for band with index 1\r\n // * @param {Number} [gain1] Gain value for band with index 1\r\n // * @param {Number} [freq2] Frequency value for band with index 2\r\n // * @param {Number} [gain2] Gain value for band with index 2\r\n // * @param {Number} [freq3] Frequency value for band with index 3\r\n // * @param {Number} [gain3] Gain value for band with index 3\r\n // * @param {Number} [freq4] Frequency value for band with index 4\r\n // * @param {Number} [gain4] Gain value for band with index 4\r\n // * @param {Number} [freq5] Frequency value for band with index 5\r\n // * @param {Number} [gain5] Gain value for band with index 5\r\n // * @param {Number} [freq6] Frequency value for band with index 6\r\n // * @param {Number} [gain6] Gain value for band with index 6\r\n // * @param {Number} [freq7] Frequency value for band with index 7\r\n // * @param {Number} [gain7] Gain value for band with index 7\r\n // */\r\n p5.EQ.prototype.set = function() {\r\n if (arguments.length === this.bands.length * 2) {\r\n for (var i = 0; i < arguments.length; i+=2) {\r\n this.bands[i/2].freq(arguments[i]);\r\n this.bands[i/2].gain(arguments[i+1]);\r\n }\r\n }\r\n else {\r\n console.error('Argument mismatch. .set() should be called with ' + this.bands.length*2 +\r\n ' arguments. (one frequency and gain value pair for each band of the eq)');\r\n }\r\n };\r\n\r\n /**\r\n * Add a new band. Creates a p5.Filter and strips away everything but\r\n * the raw biquad filter. This method returns an abstracted p5.Filter,\r\n * which can be added to p5.EQ.bands, in order to create new EQ bands.\r\n * @private\r\n * @for p5.EQ\r\n * @method _newBand\r\n * @param {Number} freq\r\n * @param {Number} res\r\n * @return {Object} Abstracted Filter\r\n */\r\n p5.EQ.prototype._newBand = function(freq, res) {\r\n return new EQFilter(freq, res);\r\n };\r\n\r\n p5.EQ.prototype.dispose = function () {\r\n Effect.prototype.dispose.apply(this);\r\n\r\n if (this.bands) {\r\n while (this.bands.length > 0) {\r\n delete this.bands.pop().dispose();\r\n }\r\n delete this.bands;\r\n }\r\n };\r\n\r\n return p5.EQ;\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n var Filter = require('filter');\r\n var p5sound = require('master');\r\n\r\n /**\r\n * EQFilter extends p5.Filter with constraints\r\n * necessary for the p5.EQ\r\n *\r\n * @private\r\n */\r\n var EQFilter = function(freq, res) {\r\n Filter.call(this, 'peaking');\r\n this.disconnect();\r\n this.set(freq, res);\r\n this.biquad.gain.value = 0;\r\n delete this.input;\r\n delete this.output;\r\n delete this._drywet;\r\n delete this.wet;\r\n\r\n };\r\n EQFilter.prototype = Object.create(Filter.prototype);\r\n\r\n EQFilter.prototype.amp = function() {\r\n console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');\r\n };\r\n EQFilter.prototype.drywet = function() {\r\n console.warn('`drywet()` is not available for p5.EQ bands.');\r\n };\r\n EQFilter.prototype.connect = function(unit) {\r\n var u = unit || p5.soundOut.input;\r\n if (this.biquad) {\r\n this.biquad.connect(u.input ? u.input : u);\r\n } else {\r\n this.output.connect(u.input ? u.input : u);\r\n }\r\n };\r\n\r\n EQFilter.prototype.disconnect = function() {\r\n if (this.biquad) {\r\n this.biquad.disconnect();\r\n }\r\n };\r\n EQFilter.prototype.dispose = function() {\r\n // remove reference form soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n this.disconnect();\r\n delete this.biquad;\r\n };\r\n\r\n return EQFilter;\r\n});\r\n","'use strict'\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n var Effect = require('effect');\r\n\r\n /**\r\n * Panner3D is based on the \r\n * Web Audio Spatial Panner Node.\r\n * This panner is a spatial processing node that allows audio to be positioned\r\n * and oriented in 3D space.\r\n *\r\n * The position is relative to an \r\n * Audio Context Listener, which can be accessed\r\n * by p5.soundOut.audiocontext.listener\r\n *\r\n *\r\n * @class p5.Panner3D\r\n * @constructor\r\n */\r\n\tp5.Panner3D = function() {\r\n Effect.call(this);\r\n\r\n /**\r\n * \r\n * Web Audio Spatial Panner Node\r\n *\r\n * Properties include\r\n * - panningModel: \"equal power\" or \"HRTF\"\r\n * - distanceModel: \"linear\", \"inverse\", or \"exponential\"\r\n *\r\n * @property {AudioNode} panner\r\n *\r\n */\r\n this.panner = this.ac.createPanner();\r\n this.panner.panningModel = 'HRTF';\r\n this.panner.distanceModel = 'linear';\r\n this.panner.connect(this.output);\r\n this.input.connect(this.panner);\r\n\t};\r\n\r\n p5.Panner3D.prototype = Object.create(Effect.prototype);\r\n\r\n\r\n /**\r\n * Connect an audio sorce\r\n *\r\n * @method process\r\n * @for p5.Panner3D\r\n * @param {Object} src Input source\r\n */\r\n p5.Panner3D.prototype.process = function(src) {\r\n src.connect(this.input);\r\n }\r\n /**\r\n * Set the X,Y,Z position of the Panner\r\n * @method set\r\n * @for p5.Panner3D\r\n * @param {Number} xVal\r\n * @param {Number} yVal\r\n * @param {Number} zVal\r\n * @param {Number} time\r\n * @return {Array} Updated x, y, z values as an array\r\n */\r\n p5.Panner3D.prototype.set = function(xVal, yVal, zVal, time) {\r\n this.positionX(xVal,time);\r\n this.positionY(yVal,time);\r\n this.positionZ(zVal,time);\r\n return [this.panner.positionX.value,\r\n this.panner.positionY.value,\r\n this.panner.positionZ.value];\r\n };\r\n\r\n /**\r\n * Getter and setter methods for position coordinates\r\n * @method positionX\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n /**\r\n * Getter and setter methods for position coordinates\r\n * @method positionY\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n /**\r\n * Getter and setter methods for position coordinates\r\n * @method positionZ\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n p5.Panner3D.prototype.positionX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.panner.positionX.value = xVal;\r\n this.panner.positionX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.positionX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.panner.positionX);\r\n }\r\n return this.panner.positionX.value;\r\n };\r\n p5.Panner3D.prototype.positionY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.panner.positionY.value = yVal;\r\n this.panner.positionY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.positionY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.panner.positionY);\r\n }\r\n return this.panner.positionY.value;\r\n };\r\n p5.Panner3D.prototype.positionZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.panner.positionZ.value = zVal;\r\n this.panner.positionZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.positionZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.panner.positionZ);\r\n }\r\n return this.panner.positionZ.value;\r\n };\r\n\r\n /**\r\n * Set the X,Y,Z position of the Panner\r\n * @method orient\r\n * @for p5.Panner3D\r\n * @param {Number} xVal\r\n * @param {Number} yVal\r\n * @param {Number} zVal\r\n * @param {Number} time\r\n * @return {Array} Updated x, y, z values as an array\r\n */\r\n p5.Panner3D.prototype.orient = function(xVal, yVal, zVal, time) {\r\n this.orientX(xVal,time);\r\n this.orientY(yVal,time);\r\n this.orientZ(zVal,time);\r\n return [this.panner.orientationX.value,\r\n this.panner.orientationY.value,\r\n this.panner.orientationZ.value];\r\n };\r\n\r\n /**\r\n * Getter and setter methods for orient coordinates\r\n * @method orientX\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n /**\r\n * Getter and setter methods for orient coordinates\r\n * @method orientY\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n /**\r\n * Getter and setter methods for orient coordinates\r\n * @method orientZ\r\n * @for p5.Panner3D\r\n * @return {Number} updated coordinate value\r\n */\r\n p5.Panner3D.prototype.orientX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.panner.orientationX.value = xVal;\r\n this.panner.orientationX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.orientationX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.panner.orientationX);\r\n }\r\n return this.panner.orientationX.value;\r\n };\r\n p5.Panner3D.prototype.orientY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.panner.orientationY.value = yVal;\r\n this.panner.orientationY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.orientationY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.panner.orientationY);\r\n }\r\n return this.panner.orientationY.value;\r\n };\r\n p5.Panner3D.prototype.orientZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.panner.orientationZ.value = zVal;\r\n this.panner.orientationZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.panner.orientationZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.panner.orientationZ);\r\n }\r\n return this.panner.orientationZ.value;\r\n };\r\n\r\n /**\r\n * Set the rolloff factor and max distance\r\n * @method setFalloff\r\n * @for p5.Panner3D\r\n * @param {Number} [maxDistance]\r\n * @param {Number} [rolloffFactor]\r\n */\r\n p5.Panner3D.prototype.setFalloff = function(maxDistance, rolloffFactor) {\r\n this.maxDist(maxDistance);\r\n this.rolloff(rolloffFactor);\r\n };\r\n /**\r\n * Maxium distance between the source and the listener\r\n * @method maxDist\r\n * @for p5.Panner3D\r\n * @param {Number} maxDistance\r\n * @return {Number} updated value\r\n */\r\n p5.Panner3D.prototype.maxDist = function(maxDistance){\r\n if (typeof maxDistance === 'number') {\r\n this.panner.maxDistance = maxDistance;\r\n }\r\n return this.panner.maxDistance;\r\n };\r\n\r\n /**\r\n * How quickly the volume is reduced as the source moves away from the listener\r\n * @method rollof\r\n * @for p5.Panner3D\r\n * @param {Number} rolloffFactor\r\n * @return {Number} updated value\r\n */\r\n p5.Panner3D.prototype.rolloff = function(rolloffFactor){\r\n if (typeof rolloffFactor === 'number') {\r\n this.panner.rolloffFactor = rolloffFactor;\r\n }\r\n return this.panner.rolloffFactor;\r\n };\r\n\r\n p5.Panner3D.dispose = function() {\r\n Effect.prototype.dispose.apply(this);\r\n if (this.panner) {\r\n this.panner.disconnect();\r\n delete this.panner;\r\n }\r\n };\r\n\r\n return p5.Panner3D;\r\n\r\n});\r\n","'use strict'\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n var Effect = require('effect');\r\n\r\n// /**\r\n// * listener is a class that can construct both a Spatial Panner\r\n// * and a Spatial Listener. The panner is based on the \r\n// * Web Audio Spatial Panner Node\r\n// * https://www.w3.org/TR/webaudio/#the-listenernode-interface\r\n// * This panner is a spatial processing node that allows audio to be positioned\r\n// * and oriented in 3D space. \r\n// *\r\n// * The Listener modifies the properties of the Audio Context Listener. \r\n// * Both objects types use the same methods. The default is a spatial panner.\r\n// *\r\n// * p5.Panner3D - Constructs a Spatial Panner
\r\n// * p5.Listener3D - Constructs a Spatial Listener
\r\n// *\r\n// * @class listener\r\n// * @constructor\r\n// * @return {Object} p5.Listener3D Object\r\n// *\r\n// * @param {Web Audio Node} listener Web Audio Spatial Panning Node\r\n// * @param {AudioParam} listener.panningModel \"equal power\" or \"HRTF\"\r\n// * @param {AudioParam} listener.distanceModel \"linear\", \"inverse\", or \"exponential\"\r\n// * @param {String} [type] [Specify construction of a spatial panner or listener]\r\n// */\r\n \r\n\tp5.Listener3D = function(type) {\r\n this.ac = p5sound.audiocontext;\r\n this.listener = this.ac.listener;\r\n\t}; \r\n\r\n// /**\r\n// * Connect an audio sorce\r\n// * @param {Object} src Input source\r\n// */\r\n p5.Listener3D.prototype.process = function(src) {\r\n src.connect(this.input);\r\n }\r\n// /**\r\n// * Set the X,Y,Z position of the Panner\r\n// * @param {[Number]} xVal\r\n// * @param {[Number]} yVal\r\n// * @param {[Number]} zVal\r\n// * @param {[Number]} time\r\n// * @return {[Array]} [Updated x, y, z values as an array]\r\n// */\r\n p5.Listener3D.prototype.position = function(xVal, yVal, zVal, time) {\r\n this.positionX(xVal,time);\r\n this.positionY(yVal,time);\r\n this.positionZ(zVal,time);\r\n return [this.listener.positionX.value, \r\n this.listener.positionY.value,\r\n this.listener.positionZ.value];\r\n };\r\n\r\n// /**\r\n// * Getter and setter methods for position coordinates\r\n// * @return {Number} [updated coordinate value]\r\n// */\r\n p5.Listener3D.prototype.positionX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.listener.positionX.value = xVal;\r\n this.listener.positionX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.positionX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.listener.positionX);\r\n }\r\n return this.listener.positionX.value;\r\n };\r\n p5.Listener3D.prototype.positionY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.listener.positionY.value = yVal;\r\n this.listener.positionY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.positionY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.listener.positionY);\r\n }\r\n return this.listener.positionY.value;\r\n };\r\n p5.Listener3D.prototype.positionZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.listener.positionZ.value = zVal;\r\n this.listener.positionZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.positionZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.listener.positionZ);\r\n }\r\n return this.listener.positionZ.value;\r\n };\r\n\r\n// cannot define method when class definition is commented\r\n// /**\r\n// * Overrides the listener orient() method because Listener has slightly\r\n// * different params. In human terms, Forward vectors are the direction the \r\n// * nose is pointing. Up vectors are the direction of the top of the head.\r\n// *\r\n// * @method orient\r\n// * @param {Number} xValF Forward vector X direction\r\n// * @param {Number} yValF Forward vector Y direction\r\n// * @param {Number} zValF Forward vector Z direction\r\n// * @param {Number} xValU Up vector X direction\r\n// * @param {Number} yValU Up vector Y direction\r\n// * @param {Number} zValU Up vector Z direction\r\n// * @param {Number} time \r\n// * @return {Array} All orienation params\r\n// */\r\n p5.Listener3D.prototype.orient = function(xValF, yValF, zValF, \r\n xValU, yValU, zValU, time) {\r\n\r\n if (arguments.length === 3 || arguments.length === 4) {\r\n time = arguments[3];\r\n this.orientForward(xValF, yValF, zValF, time);\r\n } else if (arguments.length === 6 || arguments === 7) {\r\n this.orientForward(xValF, yValF, zValF);\r\n this.orientUp(xValU, yValU, zValU, time);\r\n }\r\n \r\n return [this.listener.forwardX.value, \r\n this.listener.forwardY.value,\r\n this.listener.forwardZ.value,\r\n this.listener.upX.value,\r\n this.listener.upY.value,\r\n this.listener.upZ.value];\r\n };\r\n\r\n\r\n p5.Listener3D.prototype.orientForward = function(xValF, yValF, zValF, time) {\r\n this.forwardX(xValF,time);\r\n this.forwardY(yValF,time);\r\n this.forwardZ(zValF,time);\r\n\r\n return [this.listener.forwardX, \r\n this.listener.forwardY,\r\n this.listener.forwardZ];\r\n };\r\n\r\n p5.Listener3D.prototype.orientUp = function(xValU, yValU, zValU, time) {\r\n this.upX(xValU,time);\r\n this.upY(yValU,time);\r\n this.upZ(zValU,time);\r\n\r\n return [this.listener.upX, \r\n this.listener.upY,\r\n this.listener.upZ];\r\n };\r\n// /**\r\n// * Getter and setter methods for orient coordinates\r\n// * @return {Number} [updated coordinate value]\r\n// */\r\n p5.Listener3D.prototype.forwardX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.listener.forwardX.value = xVal;\r\n this.listener.forwardX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.forwardX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.listener.forwardX);\r\n }\r\n return this.listener.forwardX.value;\r\n };\r\n p5.Listener3D.prototype.forwardY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.listener.forwardY.value = yVal;\r\n this.listener.forwardY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.forwardY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.listener.forwardY);\r\n }\r\n return this.listener.forwardY.value;\r\n };\r\n p5.Listener3D.prototype.forwardZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.listener.forwardZ.value = zVal;\r\n this.listener.forwardZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.forwardZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.listener.forwardZ);\r\n }\r\n return this.listener.forwardZ.value;\r\n };\r\n p5.Listener3D.prototype.upX = function(xVal, time) {\r\n var t = time || 0;\r\n if (typeof xVal === 'number') {\r\n this.listener.upX.value = xVal;\r\n this.listener.upX.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.upX.linearRampToValueAtTime(xVal, this.ac.currentTime + 0.02 + t);\r\n } else if (xVal) {\r\n xVal.connect(this.listener.upX);\r\n }\r\n return this.listener.upX.value;\r\n };\r\n p5.Listener3D.prototype.upY = function(yVal, time) {\r\n var t = time || 0;\r\n if (typeof yVal === 'number') {\r\n this.listener.upY.value = yVal;\r\n this.listener.upY.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.upY.linearRampToValueAtTime(yVal, this.ac.currentTime + 0.02 + t);\r\n } else if (yVal) {\r\n yVal.connect(this.listener.upY);\r\n }\r\n return this.listener.upY.value;\r\n };\r\n p5.Listener3D.prototype.upZ = function(zVal, time) {\r\n var t = time || 0;\r\n if (typeof zVal === 'number') {\r\n this.listener.upZ.value = zVal;\r\n this.listener.upZ.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.listener.upZ.linearRampToValueAtTime(zVal, this.ac.currentTime + 0.02 + t);\r\n } else if (zVal) {\r\n zVal.connect(this.listener.upZ);\r\n }\r\n return this.listener.upZ.value;\r\n };\r\n \r\n return p5.Listener3D;\r\n\r\n});","'use strict';\r\n\r\ndefine(function (require) {\r\n var Filter = require('filter');\r\n var Effect = require('effect');\r\n\r\n /**\r\n * Delay is an echo effect. It processes an existing sound source,\r\n * and outputs a delayed version of that sound. The p5.Delay can\r\n * produce different effects depending on the delayTime, feedback,\r\n * filter, and type. In the example below, a feedback of 0.5 (the\r\n * default value) will produce a looping delay that decreases in\r\n * volume by 50% each repeat. A filter will cut out the high\r\n * frequencies so that the delay does not sound as piercing as the\r\n * original source.\r\n *\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n * @class p5.Delay\r\n * @extends p5.Effect\r\n * @constructor\r\n * @example\r\n *
\r\n * let osc;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * background(220);\r\n * textAlign(CENTER);\r\n * text('tap to play', width/2, height/2);\r\n *\r\n * osc = new p5.Oscillator('square');\r\n * osc.amp(0.5);\r\n * delay = new p5.Delay();\r\n *\r\n * // delay.process() accepts 4 parameters:\r\n * // source, delayTime (in seconds), feedback, filter frequency\r\n * delay.process(osc, 0.12, .7, 2300);\r\n *\r\n * cnv.mousePressed(oscStart);\r\n * }\r\n *\r\n * function oscStart() {\r\n * osc.start();\r\n * }\r\n *\r\n * function mouseReleased() {\r\n * osc.stop();\r\n * }\r\n *
\r\n */\r\n p5.Delay = function() {\r\n \tEffect.call(this);\r\n\r\n this._split = this.ac.createChannelSplitter(2);\r\n this._merge = this.ac.createChannelMerger(2);\r\n\r\n this._leftGain = this.ac.createGain();\r\n this._rightGain = this.ac.createGain();\r\n\r\n /**\r\n * The p5.Delay is built with two\r\n * \r\n * Web Audio Delay Nodes, one for each stereo channel.\r\n *\r\n * @for p5.Delay\r\n * @property {DelayNode} leftDelay\r\n */\r\n this.leftDelay = this.ac.createDelay();\r\n /**\r\n * The p5.Delay is built with two\r\n * \r\n * Web Audio Delay Nodes, one for each stereo channel.\r\n * @for p5.Delay\r\n * @property {DelayNode} rightDelay\r\n */\r\n this.rightDelay = this.ac.createDelay();\r\n\r\n this._leftFilter = new Filter();\r\n this._rightFilter = new Filter();\r\n this._leftFilter.disconnect();\r\n this._rightFilter.disconnect();\r\n\r\n this._leftFilter.biquad.frequency.setValueAtTime(1200, this.ac.currentTime);\r\n this._rightFilter.biquad.frequency.setValueAtTime(1200, this.ac.currentTime);\r\n this._leftFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\r\n this._rightFilter.biquad.Q.setValueAtTime(0.3, this.ac.currentTime);\r\n\r\n // graph routing\r\n this.input.connect(this._split);\r\n this.leftDelay.connect(this._leftGain);\r\n this.rightDelay.connect(this._rightGain);\r\n this._leftGain.connect(this._leftFilter.input);\r\n this._rightGain.connect(this._rightFilter.input);\r\n this._merge.connect(this.wet);\r\n\r\n\r\n this._leftFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\r\n this._rightFilter.biquad.gain.setValueAtTime(1, this.ac.currentTime);\r\n\r\n // default routing\r\n this.setType(0);\r\n\r\n this._maxDelay = this.leftDelay.delayTime.maxValue;\r\n\r\n // set initial feedback to 0.5\r\n this.feedback(0.5);\r\n\r\n\r\n };\r\n\r\n p5.Delay.prototype = Object.create(Effect.prototype);\r\n /**\r\n * Add delay to an audio signal according to a set\r\n * of delay parameters.\r\n *\r\n * @method process\r\n * @for p5.Delay\r\n * @param {Object} Signal An object that outputs audio\r\n * @param {Number} [delayTime] Time (in seconds) of the delay/echo.\r\n * Some browsers limit delayTime to\r\n * 1 second.\r\n * @param {Number} [feedback] sends the delay back through itself\r\n * in a loop that decreases in volume\r\n * each time.\r\n * @param {Number} [lowPass] Cutoff frequency. Only frequencies\r\n * below the lowPass will be part of the\r\n * delay.\r\n */\r\n p5.Delay.prototype.process = function(src, _delayTime, _feedback, _filter) {\r\n var feedback = _feedback || 0;\r\n var delayTime = _delayTime || 0;\r\n if (feedback >= 1.0) {\r\n throw new Error('Feedback value will force a positive feedback loop.');\r\n }\r\n if (delayTime >= this._maxDelay) {\r\n throw new Error('Delay Time exceeds maximum delay time of ' + this._maxDelay + ' second.');\r\n }\r\n\r\n src.connect(this.input);\r\n this.leftDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\r\n this.rightDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);\r\n this._leftGain.gain.value = feedback;\r\n this._rightGain.gain.value = feedback;\r\n\r\n if (_filter) {\r\n this._leftFilter.freq(_filter);\r\n this._rightFilter.freq(_filter);\r\n }\r\n };\r\n\r\n /**\r\n * Set the delay (echo) time, in seconds. Usually this value will be\r\n * a floating point number between 0.0 and 1.0.\r\n *\r\n * @method delayTime\r\n * @for p5.Delay\r\n * @param {Number} delayTime Time (in seconds) of the delay\r\n */\r\n p5.Delay.prototype.delayTime = function(t) {\r\n // if t is an audio node...\r\n if (typeof t !== 'number') {\r\n t.connect(this.leftDelay.delayTime);\r\n t.connect(this.rightDelay.delayTime);\r\n }\r\n\r\n else {\r\n this.leftDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\r\n this.rightDelay.delayTime.cancelScheduledValues(this.ac.currentTime);\r\n this.leftDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\r\n this.rightDelay.delayTime.linearRampToValueAtTime(t, this.ac.currentTime);\r\n }\r\n };\r\n\r\n /**\r\n * Feedback occurs when Delay sends its signal back through its input\r\n * in a loop. The feedback amount determines how much signal to send each\r\n * time through the loop. A feedback greater than 1.0 is not desirable because\r\n * it will increase the overall output each time through the loop,\r\n * creating an infinite feedback loop. The default value is 0.5\r\n *\r\n * @method feedback\r\n * @for p5.Delay\r\n * @param {Number|Object} feedback 0.0 to 1.0, or an object such as an\r\n * Oscillator that can be used to\r\n * modulate this param\r\n * @returns {Number} Feedback value\r\n *\r\n */\r\n p5.Delay.prototype.feedback = function(f) {\r\n // if f is an audio node...\r\n if (f && typeof f !== 'number') {\r\n f.connect(this._leftGain.gain);\r\n f.connect(this._rightGain.gain);\r\n }\r\n else if (f >= 1.0) {\r\n throw new Error('Feedback value will force a positive feedback loop.');\r\n }\r\n else if (typeof f === 'number') {\r\n this._leftGain.gain.value = f;\r\n this._rightGain.gain.value = f;\r\n }\r\n\r\n // return value of feedback\r\n return this._leftGain.gain.value;\r\n };\r\n\r\n /**\r\n * Set a lowpass filter frequency for the delay. A lowpass filter\r\n * will cut off any frequencies higher than the filter frequency.\r\n *\r\n * @method filter\r\n * @for p5.Delay\r\n * @param {Number|Object} cutoffFreq A lowpass filter will cut off any\r\n * frequencies higher than the filter frequency.\r\n * @param {Number|Object} res Resonance of the filter frequency\r\n * cutoff, or an object (i.e. a p5.Oscillator)\r\n * that can be used to modulate this parameter.\r\n * High numbers (i.e. 15) will produce a resonance,\r\n * low numbers (i.e. .2) will produce a slope.\r\n */\r\n p5.Delay.prototype.filter = function(freq, q) {\r\n this._leftFilter.set(freq, q);\r\n this._rightFilter.set(freq, q);\r\n };\r\n\r\n\r\n /**\r\n * Choose a preset type of delay. 'pingPong' bounces the signal\r\n * from the left to the right channel to produce a stereo effect.\r\n * Any other parameter will revert to the default delay setting.\r\n *\r\n * @method setType\r\n * @for p5.Delay\r\n * @param {String|Number} type 'pingPong' (1) or 'default' (0)\r\n */\r\n p5.Delay.prototype.setType = function(t) {\r\n if (t === 1) {\r\n t = 'pingPong';\r\n }\r\n this._split.disconnect();\r\n this._leftFilter.disconnect();\r\n this._rightFilter.disconnect();\r\n this._split.connect(this.leftDelay, 0);\r\n this._split.connect(this.rightDelay, 1);\r\n switch(t) {\r\n case 'pingPong':\r\n this._rightFilter.setType( this._leftFilter.biquad.type );\r\n this._leftFilter.output.connect(this._merge, 0, 0);\r\n this._rightFilter.output.connect(this._merge, 0, 1);\r\n this._leftFilter.output.connect(this.rightDelay);\r\n this._rightFilter.output.connect(this.leftDelay);\r\n break;\r\n default:\r\n this._leftFilter.output.connect(this._merge, 0, 0);\r\n this._rightFilter.output.connect(this._merge, 0, 1);\r\n this._leftFilter.output.connect(this.leftDelay);\r\n this._rightFilter.output.connect(this.rightDelay);\r\n }\r\n };\r\n\r\n // DocBlocks for methods inherited from p5.Effect\r\n /**\r\n * Set the output level of the delay effect.\r\n *\r\n * @method amp\r\n * @for p5.Delay\r\n * @param {Number} volume amplitude between 0 and 1.0\r\n * @param {Number} [rampTime] create a fade that lasts rampTime\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n */\r\n /**\r\n * Send output to a p5.sound or web audio object\r\n *\r\n * @method connect\r\n * @for p5.Delay\r\n * @param {Object} unit\r\n */\r\n /**\r\n * Disconnect all output.\r\n *\r\n * @method disconnect\r\n * @for p5.Delay\r\n */\r\n\r\n p5.Delay.prototype.dispose = function() {\r\n\r\n Effect.prototype.dispose.apply(this);\r\n\r\n this._split.disconnect();\r\n this._leftFilter.dispose();\r\n this._rightFilter.dispose();\r\n this._merge.disconnect();\r\n this._leftGain.disconnect();\r\n this._rightGain.disconnect();\r\n this.leftDelay.disconnect();\r\n this.rightDelay.disconnect();\r\n\r\n this._split = undefined;\r\n this._leftFilter = undefined;\r\n this._rightFilter = undefined;\r\n this._merge = undefined;\r\n this._leftGain = undefined;\r\n this._rightGain = undefined;\r\n this.leftDelay = undefined;\r\n this.rightDelay = undefined;\r\n };\r\n\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n var CustomError = require('errorHandler');\r\n var Effect = require('effect');\r\n\r\n /**\r\n * Reverb adds depth to a sound through a large number of decaying\r\n * echoes. It creates the perception that sound is occurring in a\r\n * physical space. The p5.Reverb has paramters for Time (how long does the\r\n * reverb last) and decayRate (how much the sound decays with each echo)\r\n * that can be set with the .set() or .process() methods. The p5.Convolver\r\n * extends p5.Reverb allowing you to recreate the sound of actual physical\r\n * spaces through convolution.\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.Reverb\r\n * @extends p5.Effect\r\n * @constructor\r\n * @example\r\n *
\r\n * let soundFile, reverb;\r\n * function preload() {\r\n * soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\r\n * }\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(playSound);\r\n *\r\n * reverb = new p5.Reverb();\r\n * soundFile.disconnect(); // so we'll only hear reverb...\r\n *\r\n * // connect soundFile to reverb, process w/\r\n * // 3 second reverbTime, decayRate of 2%\r\n * reverb.process(soundFile, 3, 2);\r\n * }\r\n *\r\n * function draw() {\r\n * let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);\r\n * // 1 = all reverb, 0 = no reverb\r\n * reverb.drywet(dryWet);\r\n *\r\n * background(220);\r\n * text('tap to play', 10, 20);\r\n * text('dry/wet: ' + round(dryWet * 100) + '%', 10, height - 20);\r\n * }\r\n *\r\n * function playSound() {\r\n * soundFile.play();\r\n * }\r\n *
\r\n */\r\n\r\n\r\n p5.Reverb = function() {\r\n Effect.call(this);\r\n\r\n this._initConvolverNode();\r\n\r\n // otherwise, Safari distorts\r\n this.input.gain.value = 0.5;\r\n\r\n // default params\r\n this._seconds = 3;\r\n this._decay = 2;\r\n this._reverse = false;\r\n\r\n this._buildImpulse();\r\n\r\n };\r\n\r\n p5.Reverb.prototype = Object.create(Effect.prototype);\r\n\r\n p5.Reverb.prototype._initConvolverNode = function() {\r\n this.convolverNode = this.ac.createConvolver();\r\n this.input.connect(this.convolverNode);\r\n this.convolverNode.connect(this.wet);\r\n };\r\n\r\n p5.Reverb.prototype._teardownConvolverNode = function() {\r\n if (this.convolverNode) {\r\n this.convolverNode.disconnect();\r\n delete this.convolverNode;\r\n }\r\n };\r\n\r\n p5.Reverb.prototype._setBuffer = function(audioBuffer) {\r\n this._teardownConvolverNode();\r\n this._initConvolverNode();\r\n this.convolverNode.buffer = audioBuffer;\r\n };\r\n /**\r\n * Connect a source to the reverb, and assign reverb parameters.\r\n *\r\n * @method process\r\n * @for p5.Reverb\r\n * @param {Object} src p5.sound / Web Audio object with a sound\r\n * output.\r\n * @param {Number} [seconds] Duration of the reverb, in seconds.\r\n * Min: 0, Max: 10. Defaults to 3.\r\n * @param {Number} [decayRate] Percentage of decay with each echo.\r\n * Min: 0, Max: 100. Defaults to 2.\r\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\r\n */\r\n p5.Reverb.prototype.process = function(src, seconds, decayRate, reverse) {\r\n src.connect(this.input);\r\n var rebuild = false;\r\n if (seconds) {\r\n this._seconds = seconds;\r\n rebuild = true;\r\n }\r\n if (decayRate) {\r\n this._decay = decayRate;\r\n }\r\n if (reverse) {\r\n this._reverse = reverse;\r\n }\r\n if (rebuild) {\r\n this._buildImpulse();\r\n }\r\n };\r\n\r\n /**\r\n * Set the reverb settings. Similar to .process(), but without\r\n * assigning a new input.\r\n *\r\n * @method set\r\n * @for p5.Reverb\r\n * @param {Number} [seconds] Duration of the reverb, in seconds.\r\n * Min: 0, Max: 10. Defaults to 3.\r\n * @param {Number} [decayRate] Percentage of decay with each echo.\r\n * Min: 0, Max: 100. Defaults to 2.\r\n * @param {Boolean} [reverse] Play the reverb backwards or forwards.\r\n */\r\n p5.Reverb.prototype.set = function(seconds, decayRate, reverse) {\r\n var rebuild = false;\r\n if (seconds) {\r\n this._seconds = seconds;\r\n rebuild = true;\r\n }\r\n if (decayRate) {\r\n this._decay = decayRate;\r\n }\r\n if (reverse) {\r\n this._reverse = reverse;\r\n }\r\n if (rebuild) {\r\n this._buildImpulse();\r\n }\r\n };\r\n\r\n // DocBlocks for methods inherited from p5.Effect\r\n /**\r\n * Set the output level of the reverb effect.\r\n *\r\n * @method amp\r\n * @for p5.Reverb\r\n * @param {Number} volume amplitude between 0 and 1.0\r\n * @param {Number} [rampTime] create a fade that lasts rampTime\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n */\r\n /**\r\n * Send output to a p5.sound or web audio object\r\n *\r\n * @method connect\r\n * @for p5.Reverb\r\n * @param {Object} unit\r\n */\r\n /**\r\n * Disconnect all output.\r\n *\r\n * @method disconnect\r\n * @for p5.Reverb\r\n */\r\n\r\n /**\r\n * Inspired by Simple Reverb by Jordan Santell\r\n * https://github.com/web-audio-components/simple-reverb/blob/master/index.js\r\n *\r\n * Utility function for building an impulse response\r\n * based on the module parameters.\r\n *\r\n * @private\r\n */\r\n p5.Reverb.prototype._buildImpulse = function() {\r\n var rate = this.ac.sampleRate;\r\n var length = rate*this._seconds;\r\n var decay = this._decay;\r\n var impulse = this.ac.createBuffer(2, length, rate);\r\n var impulseL = impulse.getChannelData(0);\r\n var impulseR = impulse.getChannelData(1);\r\n var n, i;\r\n for (i = 0; i < length; i++) {\r\n n = this._reverse ? length - i : i;\r\n impulseL[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\r\n impulseR[i] = (Math.random() * 2 - 1) * Math.pow(1 - n / length, decay);\r\n }\r\n this._setBuffer(impulse);\r\n };\r\n\r\n p5.Reverb.prototype.dispose = function() {\r\n Effect.prototype.dispose.apply(this);\r\n this._teardownConvolverNode();\r\n };\r\n\r\n // =======================================================================\r\n // *** p5.Convolver ***\r\n // =======================================================================\r\n\r\n /**\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

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

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 */\n p5.Part = function(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 p5.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 p5.Part.prototype.setBPM = function(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 p5.Part.prototype.getBPM = function() {\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 p5.Part.prototype.start = function(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 p5.Part.prototype.loop = function(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 p5.Part.prototype.noLoop = function() {\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 p5.Part.prototype.stop = function(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 p5.Part.prototype.pause = function(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 p5.Part.prototype.addPhrase = function(name, callback, array) {\n var p;\n if (arguments.length === 3) {\n p = new p5.Phrase(name, callback, array);\n } else if (arguments[0] instanceof p5.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 p5.Part.prototype.removePhrase = function(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 p5.Part.prototype.getPhrase = function(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 p5.Part.prototype.replaceSequence = function(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 p5.Part.prototype.incrementStep = function(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 p5.Part.prototype.onStep = function(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 */\n p5.Score = function() {\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]) {\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 p5.Score.prototype.onended = function() {\n if (this.looping) {\n // this.resetParts();\n this.parts[0].start();\n }\n this.currentPart = 0;\n };\n\n /**\n * Start playback of the score.\n *\n * @method start\n * @for p5.Score\n */\n p5.Score.prototype.start = function() {\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 p5.Score.prototype.stop = function() {\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 p5.Score.prototype.pause = function() {\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 p5.Score.prototype.loop = function() {\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 p5.Score.prototype.noLoop = function() {\n this.looping = false;\n };\n\n p5.Score.prototype.resetParts = function() {\n var self = this;\n this.parts.forEach(function(part) {\n self.resetParts[part];\n });\n };\n\n p5.Score.prototype.resetPart = function(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 p5.Score.prototype.setBPM = function(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 function 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\n});\n","'use strict';\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n var Clock = require('Tone/core/Clock');\r\n\r\n /**\r\n * SoundLoop\r\n *\r\n * @class p5.SoundLoop\r\n * @constructor\r\n *\r\n * @param {Function} callback this function will be called on each iteration of theloop\r\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.\r\n *\r\n * @example\r\n *
\r\n * let synth, soundLoop;\r\n * let notePattern = [60, 62, 64, 67, 69, 72];\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(canvasPressed);\r\n * colorMode(HSB);\r\n * background(0, 0, 86);\r\n * text('tap to start/stop', 10, 20);\r\n *\r\n * //the looper's callback is passed the timeFromNow\r\n * //this value should be used as a reference point from\r\n * //which to schedule sounds\r\n * let intervalInSeconds = 0.2;\r\n * soundLoop = new p5.SoundLoop(onSoundLoop, intervalInSeconds);\r\n *\r\n * synth = new p5.MonoSynth();\r\n * }\r\n *\r\n * function canvasPressed() {\r\n * // ensure audio is enabled\r\n * userStartAudio();\r\n *\r\n * if (soundLoop.isPlaying) {\r\n * soundLoop.stop();\r\n * } else {\r\n * // start the loop\r\n * soundLoop.start();\r\n * }\r\n * }\r\n *\r\n * function onSoundLoop(timeFromNow) {\r\n * let noteIndex = (soundLoop.iterations - 1) % notePattern.length;\r\n * let note = midiToFreq(notePattern[noteIndex]);\r\n * synth.play(note, 0.5, timeFromNow);\r\n * background(noteIndex * 360 / notePattern.length, 50, 100);\r\n * }\r\n *
\r\n */\r\n p5.SoundLoop = function(callback, interval) {\r\n this.callback = callback;\r\n /**\r\n * musicalTimeMode uses Tone.Time convention\r\n * true if string, false if number\r\n * @property {Boolean} musicalTimeMode\r\n */\r\n this.musicalTimeMode = typeof this._interval === 'number' ? false : true;\r\n\r\n this._interval = interval || 1;\r\n\r\n /**\r\n * musicalTimeMode variables\r\n * modify these only when the interval is specified in musicalTime format as a string\r\n */\r\n this._timeSignature = 4;\r\n this._bpm = 60;\r\n\r\n this.isPlaying = false;\r\n\r\n /**\r\n * Set a limit to the number of loops to play. defaults to Infinity\r\n * @property {Number} maxIterations\r\n */\r\n this.maxIterations = Infinity;\r\n var self = this;\r\n\r\n this.clock = new Clock({\r\n 'callback' : function(time) {\r\n var timeFromNow = time - p5sound.audiocontext.currentTime;\r\n /**\r\n * Do not initiate the callback if timeFromNow is < 0\r\n * This ususually occurs for a few milliseconds when the page\r\n * is not fully loaded\r\n *\r\n * The callback should only be called until maxIterations is reached\r\n */\r\n if (timeFromNow > 0 && self.iterations <= self.maxIterations) {\r\n self.callback(timeFromNow);}\r\n },\r\n 'frequency' : this._calcFreq()\r\n });\r\n };\r\n\r\n /**\r\n * Start the loop\r\n * @method start\r\n * @for p5.SoundLoop\r\n * @param {Number} [timeFromNow] schedule a starting time\r\n */\r\n p5.SoundLoop.prototype.start = function(timeFromNow) {\r\n var t = timeFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n if (!this.isPlaying) {\r\n this.clock.start(now + t);\r\n this.isPlaying = true;\r\n }\r\n };\r\n\r\n /**\r\n * Stop the loop\r\n * @method stop\r\n * @for p5.SoundLoop\r\n * @param {Number} [timeFromNow] schedule a stopping time\r\n */\r\n p5.SoundLoop.prototype.stop = function(timeFromNow) {\r\n var t = timeFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n if (this.isPlaying) {\r\n this.clock.stop(now + t);\r\n this.isPlaying = false;\r\n }\r\n };\r\n /**\r\n * Pause the loop\r\n * @method pause\r\n * @for p5.SoundLoop\r\n * @param {Number} [timeFromNow] schedule a pausing time\r\n */\r\n p5.SoundLoop.prototype.pause = function(timeFromNow) {\r\n var t = timeFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n if (this.isPlaying) {\r\n this.clock.pause(now + t);\r\n this.isPlaying = false;\r\n }\r\n };\r\n\r\n\r\n /**\r\n * Synchronize loops. Use this method to start two or more loops in synchronization\r\n * or to start a loop in synchronization with a loop that is already playing\r\n * This method will schedule the implicit loop in sync with the explicit master loop\r\n * i.e. loopToStart.syncedStart(loopToSyncWith)\r\n *\r\n * @method syncedStart\r\n * @for p5.SoundLoop\r\n * @param {Object} otherLoop a p5.SoundLoop to sync with\r\n * @param {Number} [timeFromNow] Start the loops in sync after timeFromNow seconds\r\n */\r\n p5.SoundLoop.prototype.syncedStart = function(otherLoop, timeFromNow) {\r\n var t = timeFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n\r\n if (!otherLoop.isPlaying) {\r\n otherLoop.clock.start(now + t);\r\n otherLoop.isPlaying = true;\r\n this.clock.start(now + t);\r\n this.isPlaying = true;\r\n } else if (otherLoop.isPlaying) {\r\n var time = otherLoop.clock._nextTick - p5sound.audiocontext.currentTime;\r\n this.clock.start(now + time);\r\n this.isPlaying = true;\r\n }\r\n };\r\n\r\n\r\n /**\r\n * Updates frequency value, reflected in next callback\r\n * @private\r\n * @for p5.SoundLoop\r\n * @method _update\r\n */\r\n p5.SoundLoop.prototype._update = function() {\r\n this.clock.frequency.value = this._calcFreq();\r\n };\r\n\r\n /**\r\n * Calculate the frequency of the clock's callback based on bpm, interval, and timesignature\r\n * @private\r\n * @for p5.SoundLoop\r\n * @method _calcFreq\r\n * @return {Number} new clock frequency value\r\n */\r\n p5.SoundLoop.prototype._calcFreq = function() {\r\n //Seconds mode, bpm / timesignature has no effect\r\n if (typeof this._interval === 'number') {\r\n this.musicalTimeMode = false;\r\n return 1 / this._interval;\r\n }\r\n //Musical timing mode, calculate interval based bpm, interval,and time signature\r\n else if (typeof this._interval === 'string') {\r\n this.musicalTimeMode = true;\r\n return this._bpm / 60 / this._convertNotation(this._interval) * (this._timeSignature / 4);\r\n }\r\n };\r\n\r\n /**\r\n * Convert notation from musical time format to seconds\r\n * Uses Tone.Time convention\r\n * @private\r\n * @for p5.SoundLoop\r\n * @method _convertNotation\r\n * @param {String} value value to be converted\r\n * @return {Number} converted value in seconds\r\n */\r\n p5.SoundLoop.prototype._convertNotation = function(value) {\r\n var type = value.slice(-1);\r\n value = Number(value.slice(0,-1));\r\n switch (type) {\r\n case 'm':\r\n return this._measure(value);\r\n case 'n':\r\n return this._note(value);\r\n default:\r\n console.warn('Specified interval is not formatted correctly. See Tone.js '+\r\n 'timing reference for more info: https://github.com/Tonejs/Tone.js/wiki/Time');\r\n }\r\n };\r\n\r\n /**\r\n * Helper conversion methods of measure and note\r\n * @private\r\n * @for p5.SoundLoop\r\n * @method _measure\r\n */\r\n p5.SoundLoop.prototype._measure = function(value) {\r\n return value * this._timeSignature;\r\n };\r\n\r\n /**\r\n * @private\r\n * @method _note\r\n * @for p5.SoundLoop\r\n */\r\n p5.SoundLoop.prototype._note = function(value) {\r\n return this._timeSignature / value ;\r\n };\r\n\r\n\r\n /**\r\n * Getters and Setters, setting any paramter will result in a change in the clock's\r\n * frequency, that will be reflected after the next callback\r\n * beats per minute (defaults to 60)\r\n * @property {Number} bpm\r\n * @for p5.SoundLoop\r\n */\r\n Object.defineProperty(p5.SoundLoop.prototype, 'bpm', {\r\n get : function() {\r\n return this._bpm;\r\n },\r\n set : function(bpm) {\r\n if (!this.musicalTimeMode) {\r\n console.warn('Changing the BPM in \"seconds\" mode has no effect. '+\r\n 'BPM is only relevant in musicalTimeMode '+\r\n 'when the interval is specified as a string '+\r\n '(\"2n\", \"4n\", \"1m\"...etc)');\r\n }\r\n this._bpm = bpm;\r\n this._update();\r\n }\r\n });\r\n\r\n /**\r\n * number of quarter notes in a measure (defaults to 4)\r\n * @property {Number} timeSignature\r\n * @for p5.SoundLoop\r\n */\r\n Object.defineProperty(p5.SoundLoop.prototype, 'timeSignature', {\r\n get : function() {\r\n return this._timeSignature;\r\n },\r\n set : function(timeSig) {\r\n if (!this.musicalTimeMode) {\r\n console.warn('Changing the timeSignature in \"seconds\" mode has no effect. '+\r\n 'BPM is only relevant in musicalTimeMode '+\r\n 'when the interval is specified as a string '+\r\n '(\"2n\", \"4n\", \"1m\"...etc)');\r\n }\r\n this._timeSignature = timeSig;\r\n this._update();\r\n }\r\n });\r\n\r\n /**\r\n * length of the loops interval\r\n * @property {Number|String} interval\r\n * @for p5.SoundLoop\r\n */\r\n Object.defineProperty(p5.SoundLoop.prototype, 'interval', {\r\n get : function() {\r\n return this._interval;\r\n },\r\n set : function(interval) {\r\n this.musicalTimeMode = typeof interval === 'Number'? false : true;\r\n this._interval = interval;\r\n this._update();\r\n }\r\n });\r\n\r\n /**\r\n * how many times the callback has been called so far\r\n * @property {Number} iterations\r\n * @for p5.SoundLoop\r\n * @readonly\r\n */\r\n Object.defineProperty(p5.SoundLoop.prototype, 'iterations', {\r\n get : function() {\r\n return this.clock.ticks;\r\n }\r\n });\r\n\r\n return p5.SoundLoop;\r\n});\r\n","define(function (require) {\r\n\t'use strict';\r\n\r\n\tvar p5sound = require('master');\r\n\tvar Effect = require('effect');\r\n var CustomError = require('errorHandler');\r\n\r\n /**\r\n * Compressor is an audio effect class that performs dynamics compression\r\n * on an audio input source. This is a very commonly used technique in music\r\n * and sound production. Compression creates an overall louder, richer,\r\n * and fuller sound by lowering the volume of louds and raising that of softs.\r\n * Compression can be used to avoid clipping (sound distortion due to\r\n * peaks in volume) and is especially useful when many sounds are played\r\n * at once. Compression can be used on indivudal sound sources in addition\r\n * to the master output.\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.Compressor\r\n * @constructor\r\n * @extends p5.Effect\r\n *\r\n *\r\n */\r\n\tp5.Compressor = function() {\r\n\t\tEffect.call(this);\r\n\r\n /**\r\n * The p5.Compressor is built with a Web Audio Dynamics Compressor Node\r\n * \r\n * @property {AudioNode} compressor\r\n */\r\n\r\n\r\n\t\tthis.compressor = this.ac.createDynamicsCompressor();\r\n\r\n this.input.connect(this.compressor);\r\n this.compressor.connect(this.wet);\r\n\t};\r\n\r\n\tp5.Compressor.prototype = Object.create(Effect.prototype);\r\n\r\n /**\r\n * Performs the same function as .connect, but also accepts\r\n * optional parameters to set compressor's audioParams\r\n * @method process\r\n * @for p5.Compressor\r\n *\r\n * @param {Object} src Sound source to be connected\r\n *\r\n * @param {Number} [attack] The amount of time (in seconds) to reduce the gain by 10dB,\r\n * default = .003, range 0 - 1\r\n * @param {Number} [knee] A decibel value representing the range above the\r\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\r\n * default = 30, range 0 - 40\r\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\r\n * default = 12, range 1 - 20\r\n * @param {Number} [threshold] The decibel value above which the compression will start taking effect\r\n * default = -24, range -100 - 0\r\n * @param {Number} [release] The amount of time (in seconds) to increase the gain by 10dB\r\n * default = .25, range 0 - 1\r\n */\r\n\tp5.Compressor.prototype.process = function(src, attack, knee,\r\n ratio, threshold, release) {\r\n\t\tsrc.connect(this.input);\r\n\t\tthis.set(attack, knee, ratio, threshold, release);\r\n\t};\r\n\r\n /**\r\n * Set the paramters of a compressor.\r\n * @method set\r\n * @for p5.Compressor\r\n * @param {Number} attack The amount of time (in seconds) to reduce the gain by 10dB,\r\n * default = .003, range 0 - 1\r\n * @param {Number} knee A decibel value representing the range above the\r\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\r\n * default = 30, range 0 - 40\r\n * @param {Number} ratio The amount of dB change in input for a 1 dB change in output\r\n * default = 12, range 1 - 20\r\n * @param {Number} threshold The decibel value above which the compression will start taking effect\r\n * default = -24, range -100 - 0\r\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\r\n * default = .25, range 0 - 1\r\n */\r\n p5.Compressor.prototype.set = function (attack, knee,\r\n ratio, threshold, release) {\r\n\r\n if (typeof attack !== 'undefined') {this.attack(attack);}\r\n if (typeof knee !== 'undefined') {this.knee(knee);}\r\n if (typeof ratio !== 'undefined') {this.ratio(ratio);}\r\n if (typeof threshold !== 'undefined') {this.threshold(threshold);}\r\n if (typeof release !== 'undefined') {this.release(release);}\r\n };\r\n\r\n\r\n /**\r\n * Get current attack or set value w/ time ramp\r\n *\r\n *\r\n * @method attack\r\n * @for p5.Compressor\r\n * @param {Number} [attack] Attack is the amount of time (in seconds) to reduce the gain by 10dB,\r\n * default = .003, range 0 - 1\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.attack = function (attack, time){\r\n var t = time || 0;\r\n if (typeof attack == 'number'){\r\n this.compressor.attack.value = attack;\r\n this.compressor.attack.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.attack.linearRampToValueAtTime(attack, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof attack !== 'undefined') {\r\n attack.connect(this.compressor.attack);\r\n }\r\n return this.compressor.attack.value;\r\n };\r\n\r\n\r\n /**\r\n * Get current knee or set value w/ time ramp\r\n *\r\n * @method knee\r\n * @for p5.Compressor\r\n * @param {Number} [knee] A decibel value representing the range above the\r\n * threshold where the curve smoothly transitions to the \"ratio\" portion.\r\n * default = 30, range 0 - 40\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.knee = function (knee, time){\r\n var t = time || 0;\r\n if (typeof knee == 'number'){\r\n this.compressor.knee.value = knee;\r\n this.compressor.knee.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.knee.linearRampToValueAtTime(knee, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof knee !== 'undefined') {\r\n knee.connect(this.compressor.knee);\r\n }\r\n return this.compressor.knee.value;\r\n };\r\n\r\n\r\n /**\r\n * Get current ratio or set value w/ time ramp\r\n * @method ratio\r\n * @for p5.Compressor\r\n * @param {Number} [ratio] The amount of dB change in input for a 1 dB change in output\r\n * default = 12, range 1 - 20\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.ratio = function (ratio, time){\r\n var t = time || 0;\r\n if (typeof ratio == 'number'){\r\n this.compressor.ratio.value = ratio;\r\n this.compressor.ratio.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.ratio.linearRampToValueAtTime(ratio, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof ratio !== 'undefined') {\r\n ratio.connect(this.compressor.ratio);\r\n }\r\n return this.compressor.ratio.value;\r\n };\r\n\r\n\r\n /**\r\n * Get current threshold or set value w/ time ramp\r\n * @method threshold\r\n * @for p5.Compressor\r\n * @param {Number} threshold The decibel value above which the compression will start taking effect\r\n * default = -24, range -100 - 0\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.threshold = function (threshold, time){\r\n var t = time || 0;\r\n if (typeof threshold == 'number'){\r\n this.compressor.threshold.value = threshold;\r\n this.compressor.threshold.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.threshold.linearRampToValueAtTime(threshold, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof threshold !== 'undefined') {\r\n threshold.connect(this.compressor.threshold);\r\n }\r\n return this.compressor.threshold.value;\r\n };\r\n\r\n\r\n /**\r\n * Get current release or set value w/ time ramp\r\n * @method release\r\n * @for p5.Compressor\r\n * @param {Number} release The amount of time (in seconds) to increase the gain by 10dB\r\n * default = .25, range 0 - 1\r\n *\r\n * @param {Number} [time] Assign time value to schedule the change in value\r\n */\r\n p5.Compressor.prototype.release = function (release, time){\r\n var t = time || 0;\r\n if (typeof release == 'number'){\r\n this.compressor.release.value = release;\r\n this.compressor.release.cancelScheduledValues(this.ac.currentTime + 0.01 + t);\r\n this.compressor.release.linearRampToValueAtTime(release, this.ac.currentTime + 0.02 + t);\r\n } else if (typeof number !== 'undefined') {\r\n release.connect(this.compressor.release);\r\n }\r\n return this.compressor.release.value;\r\n };\r\n\r\n /**\r\n * Return the current reduction value\r\n *\r\n * @method reduction\r\n * @for p5.Compressor\r\n * @return {Number} Value of the amount of gain reduction that is applied to the signal\r\n */\r\n p5.Compressor.prototype.reduction =function() {\r\n return this.compressor.reduction.value;\r\n };\r\n\r\n\r\n\tp5.Compressor.prototype.dispose = function() {\r\n Effect.prototype.dispose.apply(this);\r\n if (this.compressor) {\r\n this.compressor.disconnect();\r\n delete this.compressor;\r\n }\r\n\t};\r\n\r\n return p5.Compressor;\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n // inspiration: recorder.js, Tone.js & typedarray.org\r\n\r\n const p5sound = require('master');\r\n const { convertToWav, safeBufferSize } = require('helpers');\r\n const processorNames = require('./audioWorklet/processorNames');\r\n const ac = p5sound.audiocontext;\r\n\r\n /**\r\n *

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

\r\n *

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

\r\n *\r\n * @class p5.SoundRecorder\r\n * @constructor\r\n * @example\r\n *
\r\n * let mic, recorder, soundFile;\r\n * let state = 0;\r\n *\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(canvasPressed);\r\n * background(220);\r\n * textAlign(CENTER, CENTER);\r\n *\r\n * // create an audio in\r\n * mic = new p5.AudioIn();\r\n *\r\n * // prompts user to enable their browser mic\r\n * mic.start();\r\n *\r\n * // create a sound recorder\r\n * recorder = new p5.SoundRecorder();\r\n *\r\n * // connect the mic to the recorder\r\n * recorder.setInput(mic);\r\n *\r\n * // this sound file will be used to\r\n * // playback & save the recording\r\n * soundFile = new p5.SoundFile();\r\n *\r\n * text('tap to record', width/2, height/2);\r\n * }\r\n *\r\n * function canvasPressed() {\r\n * // ensure audio is enabled\r\n * userStartAudio();\r\n *\r\n * // make sure user enabled the mic\r\n * if (state === 0 && mic.enabled) {\r\n *\r\n * // record to our p5.SoundFile\r\n * recorder.record(soundFile);\r\n *\r\n * background(255,0,0);\r\n * text('Recording!', width/2, height/2);\r\n * state++;\r\n * }\r\n * else if (state === 1) {\r\n * background(0,255,0);\r\n *\r\n * // stop recorder and\r\n * // send result to soundFile\r\n * recorder.stop();\r\n *\r\n * text('Done! Tap to play and download', width/2, height/2, width - 20);\r\n * state++;\r\n * }\r\n *\r\n * else if (state === 2) {\r\n * soundFile.play(); // play the result!\r\n * save(soundFile, 'mySound.wav');\r\n * state++;\r\n * }\r\n * }\r\n *
\r\n */\r\n p5.SoundRecorder = function() {\r\n this.input = ac.createGain();\r\n this.output = ac.createGain();\r\n\r\n this._inputChannels = 2;\r\n this._outputChannels = 2; // stereo output, even if input is mono\r\n\r\n const workletBufferSize = safeBufferSize(1024);\r\n\r\n this._workletNode = new AudioWorkletNode(ac, processorNames.recorderProcessor, {\r\n outputChannelCount: [this._outputChannels],\r\n processorOptions: {\r\n numInputChannels: this._inputChannels,\r\n bufferSize: workletBufferSize\r\n }\r\n });\r\n\r\n this._workletNode.port.onmessage = function(event) {\r\n if (event.data.name === 'buffers') {\r\n const buffers = [\r\n new Float32Array(event.data.leftBuffer),\r\n new Float32Array(event.data.rightBuffer)\r\n ];\r\n this._callback(buffers);\r\n }\r\n }.bind(this);\r\n\r\n /**\r\n * callback invoked when the recording is over\r\n * @private\r\n * @type Function(Float32Array)\r\n */\r\n this._callback = function() {};\r\n\r\n // connections\r\n this._workletNode.connect(p5.soundOut._silentNode);\r\n this.setInput();\r\n\r\n // add this p5.SoundFile to the soundArray\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Connect a specific device to the p5.SoundRecorder.\r\n * If no parameter is given, p5.SoundRecorer will record\r\n * all audible p5.sound from your sketch.\r\n *\r\n * @method setInput\r\n * @for p5.SoundRecorder\r\n * @param {Object} [unit] p5.sound object or a web audio unit\r\n * that outputs sound\r\n */\r\n p5.SoundRecorder.prototype.setInput = function(unit) {\r\n this.input.disconnect();\r\n this.input = null;\r\n this.input = ac.createGain();\r\n this.input.connect(this._workletNode);\r\n this.input.connect(this.output);\r\n if (unit) {\r\n unit.connect(this.input);\r\n } else {\r\n p5.soundOut.output.connect(this.input);\r\n }\r\n };\r\n\r\n /**\r\n * Start recording. To access the recording, provide\r\n * a p5.SoundFile as the first parameter. The p5.SoundRecorder\r\n * will send its recording to that p5.SoundFile for playback once\r\n * recording is complete. Optional parameters include duration\r\n * (in seconds) of the recording, and a callback function that\r\n * will be called once the complete recording has been\r\n * transfered to the p5.SoundFile.\r\n *\r\n * @method record\r\n * @for p5.SoundRecorder\r\n * @param {p5.SoundFile} soundFile p5.SoundFile\r\n * @param {Number} [duration] Time (in seconds)\r\n * @param {Function} [callback] The name of a function that will be\r\n * called once the recording completes\r\n */\r\n p5.SoundRecorder.prototype.record = function(sFile, duration, callback) {\r\n this._workletNode.port.postMessage({ name: 'start', duration: duration });\r\n\r\n if (sFile && callback) {\r\n this._callback = function(buffer) {\r\n sFile.setBuffer(buffer);\r\n callback();\r\n };\r\n }\r\n else if (sFile) {\r\n this._callback = function(buffer) {\r\n sFile.setBuffer(buffer);\r\n };\r\n }\r\n };\r\n\r\n /**\r\n * Stop the recording. Once the recording is stopped,\r\n * the results will be sent to the p5.SoundFile that\r\n * was given on .record(), and if a callback function\r\n * was provided on record, that function will be called.\r\n *\r\n * @method stop\r\n * @for p5.SoundRecorder\r\n */\r\n p5.SoundRecorder.prototype.stop = function() {\r\n this._workletNode.port.postMessage({ name: 'stop' });\r\n };\r\n\r\n p5.SoundRecorder.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n\r\n this._callback = function() {};\r\n if (this.input) {\r\n this.input.disconnect();\r\n }\r\n this.input = null;\r\n this._workletNode = null;\r\n };\r\n\r\n\r\n /**\r\n * Save a p5.SoundFile as a .wav file. The browser will prompt the user\r\n * to download the file to their device.\r\n * For uploading audio to a server, use\r\n * `p5.SoundFile.saveBlob`.\r\n *\r\n * @for p5\r\n * @method saveSound\r\n * @param {p5.SoundFile} soundFile p5.SoundFile that you wish to save\r\n * @param {String} fileName name of the resulting .wav file.\r\n */\r\n // add to p5.prototype as this is used by the p5 `save()` method.\r\n p5.prototype.saveSound = function (soundFile, fileName) {\r\n const dataView = convertToWav(soundFile.buffer);\r\n p5.prototype.writeFile([dataView], fileName, 'wav');\r\n };\r\n});\r\n","'use strict';\r\n\r\ndefine(function () {\r\n /**\r\n *

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

\r\n *

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

\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n *

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

\r\n *\r\n * @class p5.PeakDetect\r\n * @constructor\r\n * @param {Number} [freq1] lowFrequency - defaults to 20Hz\r\n * @param {Number} [freq2] highFrequency - defaults to 20000 Hz\r\n * @param {Number} [threshold] Threshold for detecting a beat between 0 and 1\r\n * scaled logarithmically where 0.1 is 1/2 the loudness\r\n * of 1.0. Defaults to 0.35.\r\n * @param {Number} [framesPerPeak] Defaults to 20.\r\n * @example\r\n *
\r\n *\r\n * var cnv, soundFile, fft, peakDetect;\r\n * var ellipseWidth = 10;\r\n *\r\n * function preload() {\r\n * soundFile = loadSound('assets/beat.mp3');\r\n * }\r\n *\r\n * function setup() {\r\n * background(0);\r\n * noStroke();\r\n * fill(255);\r\n * textAlign(CENTER);\r\n *\r\n * // p5.PeakDetect requires a p5.FFT\r\n * fft = new p5.FFT();\r\n * peakDetect = new p5.PeakDetect();\r\n * }\r\n *\r\n * function draw() {\r\n * background(0);\r\n * text('click to play/pause', width/2, height/2);\r\n *\r\n * // peakDetect accepts an fft post-analysis\r\n * fft.analyze();\r\n * peakDetect.update(fft);\r\n *\r\n * if ( peakDetect.isDetected ) {\r\n * ellipseWidth = 50;\r\n * } else {\r\n * ellipseWidth *= 0.95;\r\n * }\r\n *\r\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\r\n * }\r\n *\r\n * // toggle play/stop when canvas is clicked\r\n * function mouseClicked() {\r\n * if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {\r\n * if (soundFile.isPlaying() ) {\r\n * soundFile.stop();\r\n * } else {\r\n * soundFile.play();\r\n * }\r\n * }\r\n * }\r\n *
\r\n */\r\n p5.PeakDetect = function(freq1, freq2, threshold, _framesPerPeak) {\r\n // framesPerPeak determines how often to look for a beat.\r\n // If a beat is provided, try to look for a beat based on bpm\r\n this.framesPerPeak = _framesPerPeak || 20;\r\n this.framesSinceLastPeak = 0;\r\n this.decayRate = 0.95;\r\n\r\n this.threshold = threshold || 0.35;\r\n this.cutoff = 0;\r\n\r\n // how much to increase the cutoff\r\n // TO DO: document this / figure out how to make it accessible\r\n this.cutoffMult = 1.5;\r\n\r\n this.energy = 0;\r\n this.penergy = 0;\r\n\r\n // TO DO: document this property / figure out how to make it accessible\r\n this.currentValue = 0;\r\n\r\n /**\r\n * isDetected is set to true when a peak is detected.\r\n *\r\n * @attribute isDetected {Boolean}\r\n * @default false\r\n */\r\n this.isDetected = false;\r\n\r\n this.f1 = freq1 || 40;\r\n this.f2 = freq2 || 20000;\r\n\r\n // function to call when a peak is detected\r\n this._onPeak = function() {};\r\n };\r\n\r\n\r\n /**\r\n * The update method is run in the draw loop.\r\n *\r\n * Accepts an FFT object. You must call .analyze()\r\n * on the FFT object prior to updating the peakDetect\r\n * because it relies on a completed FFT analysis.\r\n *\r\n * @method update\r\n * @param {p5.FFT} fftObject A p5.FFT object\r\n */\r\n p5.PeakDetect.prototype.update = function(fftObject) {\r\n var nrg = this.energy = fftObject.getEnergy(this.f1,this.f2)/255;\r\n if (nrg > this.cutoff && nrg > this.threshold && nrg-this.penergy > 0) {\r\n\r\n // trigger callback\r\n this._onPeak();\r\n this.isDetected = true;\r\n\r\n // debounce\r\n this.cutoff = nrg * this.cutoffMult;\r\n this.framesSinceLastPeak = 0;\r\n } else {\r\n this.isDetected = false;\r\n if (this.framesSinceLastPeak <= this.framesPerPeak) {\r\n this.framesSinceLastPeak++;\r\n } else {\r\n this.cutoff *= this.decayRate;\r\n this.cutoff = Math.max(this.cutoff, this.threshold);\r\n }\r\n }\r\n\r\n this.currentValue = nrg;\r\n this.penergy = nrg;\r\n };\r\n\r\n /**\r\n * onPeak accepts two arguments: a function to call when\r\n * a peak is detected. The value of the peak,\r\n * between 0.0 and 1.0, is passed to the callback.\r\n *\r\n * @method onPeak\r\n * @param {Function} callback Name of a function that will\r\n * be called when a peak is\r\n * detected.\r\n * @param {Object} [val] Optional value to pass\r\n * into the function when\r\n * a peak is detected.\r\n * @example\r\n *
\r\n * var cnv, soundFile, fft, peakDetect;\r\n * var ellipseWidth = 0;\r\n *\r\n * function preload() {\r\n * soundFile = loadSound('assets/beat.mp3');\r\n * }\r\n *\r\n * function setup() {\r\n * cnv = createCanvas(100,100);\r\n * textAlign(CENTER);\r\n *\r\n * fft = new p5.FFT();\r\n * peakDetect = new p5.PeakDetect();\r\n *\r\n * setupSound();\r\n *\r\n * // when a beat is detected, call triggerBeat()\r\n * peakDetect.onPeak(triggerBeat);\r\n * }\r\n *\r\n * function draw() {\r\n * background(0);\r\n * fill(255);\r\n * text('click to play', width/2, height/2);\r\n *\r\n * fft.analyze();\r\n * peakDetect.update(fft);\r\n *\r\n * ellipseWidth *= 0.95;\r\n * ellipse(width/2, height/2, ellipseWidth, ellipseWidth);\r\n * }\r\n *\r\n * // this function is called by peakDetect.onPeak\r\n * function triggerBeat() {\r\n * ellipseWidth = 50;\r\n * }\r\n *\r\n * // mouseclick starts/stops sound\r\n * function setupSound() {\r\n * cnv.mouseClicked( function() {\r\n * if (soundFile.isPlaying() ) {\r\n * soundFile.stop();\r\n * } else {\r\n * soundFile.play();\r\n * }\r\n * });\r\n * }\r\n *
\r\n */\r\n p5.PeakDetect.prototype.onPeak = function(callback, val) {\r\n var self = this;\r\n\r\n self._onPeak = function() {\r\n callback(self.energy, val);\r\n };\r\n };\r\n\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n var p5sound = require('master');\r\n\r\n /**\r\n * A gain node is usefull to set the relative volume of sound.\r\n * It's typically used to build mixers.\r\n *\r\n * @class p5.Gain\r\n * @constructor\r\n * @example\r\n *
\r\n *\r\n * // load two soundfile and crossfade beetween them\r\n * let sound1,sound2;\r\n * let sound1Gain, sound2Gain, masterGain;\r\n * function preload(){\r\n * soundFormats('ogg', 'mp3');\r\n * sound1 = loadSound('assets/Damscray_-_Dancing_Tiger_01');\r\n * sound2 = loadSound('assets/beat');\r\n * }\r\n * function setup() {\r\n * let cnv = createCanvas(100, 100);\r\n * cnv.mousePressed(startSound);\r\n * // create a 'master' gain to which we will connect both soundfiles\r\n * masterGain = new p5.Gain();\r\n * masterGain.connect();\r\n * sound1.disconnect(); // diconnect from p5 output\r\n * sound1Gain = new p5.Gain(); // setup a gain node\r\n * sound1Gain.setInput(sound1); // connect the first sound to its input\r\n * sound1Gain.connect(masterGain); // connect its output to the 'master'\r\n * sound2.disconnect();\r\n * sound2Gain = new p5.Gain();\r\n * sound2Gain.setInput(sound2);\r\n * sound2Gain.connect(masterGain);\r\n * }\r\n * function startSound() {\r\n * sound1.loop();\r\n * sound2.loop();\r\n * loop();\r\n * }\r\n * function mouseReleased() {\r\n * sound1.stop();\r\n * sound2.stop();\r\n * }\r\n * function draw(){\r\n * background(220);\r\n * textAlign(CENTER);\r\n * textSize(11);\r\n * fill(0);\r\n * if (!sound1.isPlaying()) {\r\n * text('tap and drag to play', width/2, height/2);\r\n * return;\r\n * }\r\n * // map the horizontal position of the mouse to values useable for volume * control of sound1\r\n * var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);\r\n * var sound2Volume = 1-sound1Volume;\r\n * sound1Gain.amp(sound1Volume);\r\n * sound2Gain.amp(sound2Volume);\r\n * // map the vertical position of the mouse to values useable for 'master * volume control'\r\n * var masterVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\r\n * masterGain.amp(masterVolume);\r\n * text('master', width/2, height - masterVolume * height * 0.9)\r\n * fill(255, 0, 255);\r\n * textAlign(LEFT);\r\n * text('sound1', 5, height - sound1Volume * height * 0.9);\r\n * textAlign(RIGHT);\r\n * text('sound2', width - 5, height - sound2Volume * height * 0.9);\r\n * }\r\n *
\r\n */\r\n\r\n p5.Gain = function() {\r\n this.ac = p5sound.audiocontext;\r\n\r\n this.input = this.ac.createGain();\r\n this.output = this.ac.createGain();\r\n\r\n // otherwise, Safari distorts\r\n this.input.gain.value = 0.5;\r\n this.input.connect(this.output);\r\n\r\n // add to the soundArray\r\n p5sound.soundArray.push(this);\r\n };\r\n\r\n /**\r\n * Connect a source to the gain node.\r\n *\r\n * @method setInput\r\n * @for p5.Gain\r\n * @param {Object} src p5.sound / Web Audio object with a sound\r\n * output.\r\n */\r\n\r\n\r\n p5.Gain.prototype.setInput = function(src) {\r\n src.connect(this.input);\r\n };\r\n\r\n /**\r\n * Send output to a p5.sound or web audio object\r\n *\r\n * @method connect\r\n * @for p5.Gain\r\n * @param {Object} unit\r\n */\r\n p5.Gain.prototype.connect = function(unit) {\r\n var u = unit || p5.soundOut.input;\r\n this.output.connect(u.input ? u.input : u);\r\n };\r\n\r\n /**\r\n * Disconnect all output.\r\n *\r\n * @method disconnect\r\n * @for p5.Gain\r\n */\r\n p5.Gain.prototype.disconnect = function() {\r\n if (this.output) {\r\n this.output.disconnect();\r\n }\r\n };\r\n\r\n /**\r\n * Set the output level of the gain node.\r\n *\r\n * @method amp\r\n * @for p5.Gain\r\n * @param {Number} volume amplitude between 0 and 1.0\r\n * @param {Number} [rampTime] create a fade that lasts rampTime\r\n * @param {Number} [timeFromNow] schedule this event to happen\r\n * seconds from now\r\n */\r\n p5.Gain.prototype.amp = function(vol, rampTime, tFromNow) {\r\n var rampTime = rampTime || 0;\r\n var tFromNow = tFromNow || 0;\r\n var now = p5sound.audiocontext.currentTime;\r\n var currentVol = this.output.gain.value;\r\n this.output.gain.cancelScheduledValues(now);\r\n this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);\r\n this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);\r\n };\r\n\r\n p5.Gain.prototype.dispose = function() {\r\n // remove reference from soundArray\r\n var index = p5sound.soundArray.indexOf(this);\r\n p5sound.soundArray.splice(index, 1);\r\n if (this.output) {\r\n this.output.disconnect();\r\n delete this.output;\r\n }\r\n if (this.input) {\r\n this.input.disconnect();\r\n delete this.input;\r\n }\r\n };\r\n\r\n});\r\n","'use strict';\r\n\r\ndefine(function (require) {\r\n\r\n var Effect = require('effect');\r\n\r\n /*\r\n * Adapted from [Kevin Ennis on StackOverflow](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\r\n */\r\n function makeDistortionCurve(amount) {\r\n var k = typeof amount === 'number' ? amount : 50;\r\n var numSamples = 44100;\r\n var curve = new Float32Array(numSamples);\r\n var deg = Math.PI / 180;\r\n var i = 0;\r\n var x;\r\n for ( ; i < numSamples; ++i ) {\r\n x = i * 2 / numSamples - 1;\r\n curve[i] = ( 3 + k ) * x * 20 * deg / ( Math.PI + k * Math.abs(x) );\r\n }\r\n return curve;\r\n }\r\n\r\n /**\r\n * A Distortion effect created with a Waveshaper Node,\r\n * with an approach adapted from\r\n * [Kevin Ennis](http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion)\r\n *\r\n * This class extends p5.Effect.\r\n * Methods amp(), chain(),\r\n * drywet(), connect(), and\r\n * disconnect() are available.\r\n *\r\n * @class p5.Distortion\r\n * @extends p5.Effect\r\n * @constructor\r\n * @param {Number} [amount=0.25] Unbounded distortion amount.\r\n * Normal values range from 0-1.\r\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\r\n *\r\n */\r\n p5.Distortion = function(amount, oversample) {\r\n Effect.call(this);\r\n\r\n if (typeof amount === 'undefined') {\r\n amount = 0.25;\r\n } if (typeof amount !== 'number') {\r\n throw new Error('amount must be a number');\r\n } if (typeof oversample === 'undefined') {\r\n oversample = '2x';\r\n } if (typeof oversample !== 'string') {\r\n throw new Error('oversample must be a String');\r\n }\r\n\r\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\r\n\r\n /**\r\n * The p5.Distortion is built with a\r\n * \r\n * Web Audio WaveShaper Node.\r\n *\r\n * @property {AudioNode} WaveShaperNode\r\n */\r\n this.waveShaperNode = this.ac.createWaveShaper();\r\n\r\n this.amount = curveAmount;\r\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\r\n this.waveShaperNode.oversample = oversample;\r\n\r\n this.input.connect(this.waveShaperNode);\r\n\r\n this.waveShaperNode.connect(this.wet);\r\n };\r\n\r\n p5.Distortion.prototype = Object.create(Effect.prototype);\r\n\r\n\r\n /**\r\n * Process a sound source, optionally specify amount and oversample values.\r\n *\r\n * @method process\r\n * @for p5.Distortion\r\n * @param {Number} [amount=0.25] Unbounded distortion amount.\r\n * Normal values range from 0-1.\r\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\r\n */\r\n p5.Distortion.prototype.process = function(src, amount, oversample) {\r\n src.connect(this.input);\r\n this.set(amount, oversample);\r\n };\r\n\r\n /**\r\n * Set the amount and oversample of the waveshaper distortion.\r\n *\r\n * @method set\r\n * @for p5.Distortion\r\n * @param {Number} [amount=0.25] Unbounded distortion amount.\r\n * Normal values range from 0-1.\r\n * @param {String} [oversample='none'] 'none', '2x', or '4x'.\r\n */\r\n p5.Distortion.prototype.set = function(amount, oversample) {\r\n if (amount) {\r\n var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);\r\n this.amount = curveAmount;\r\n this.waveShaperNode.curve = makeDistortionCurve(curveAmount);\r\n }\r\n if (oversample) {\r\n this.waveShaperNode.oversample = oversample;\r\n }\r\n };\r\n\r\n /**\r\n * Return the distortion amount, typically between 0-1.\r\n *\r\n * @method getAmount\r\n * @for p5.Distortion\r\n * @return {Number} Unbounded distortion amount.\r\n * Normal values range from 0-1.\r\n */\r\n p5.Distortion.prototype.getAmount = function() {\r\n return this.amount;\r\n };\r\n\r\n /**\r\n * Return the oversampling.\r\n *\r\n * @method getOversample\r\n * @for p5.Distortion\r\n * @return {String} Oversample can either be 'none', '2x', or '4x'.\r\n */\r\n p5.Distortion.prototype.getOversample = function() {\r\n return this.waveShaperNode.oversample;\r\n };\r\n\r\n\r\n p5.Distortion.prototype.dispose = function() {\r\n Effect.prototype.dispose.apply(this);\r\n if (this.waveShaperNode) {\r\n this.waveShaperNode.disconnect();\r\n this.waveShaperNode = null;\r\n }\r\n };\r\n});\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index ed1554ac..fcf15aaa 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "git", "url": "https://github.com/processing/p5.js-sound.git" }, - "version": "0.3.12", + "version": "0.3.13", "license": "MIT", "devDependencies": { "@babel/core": "^7.4.5", diff --git a/src/looper.js b/src/looper.js index 4e0ca755..b3d74e54 100644 --- a/src/looper.js +++ b/src/looper.js @@ -405,11 +405,6 @@ define(function(require) { if (this.looping) { // this.resetParts(); this.parts[0].start(); - } else { - this.parts[this.parts.length - 1].onended = function() { - this.stop(); - this.resetParts(); - }; } this.currentPart = 0; }; From b05331add62ed389cc2504f3c4bc51f8564826b5 Mon Sep 17 00:00:00 2001 From: dori Date: Sat, 11 Apr 2020 15:32:53 -0400 Subject: [PATCH 3/3] score with two args failed on last version --- examples/files/tick.mp3 | Bin 0 -> 11284 bytes examples/playScore/index.html | 10 +++++++ examples/playScore/sketch.js | 51 ++++++++++++++++++++++++++++++++++ index.html | 1 + 4 files changed, 62 insertions(+) create mode 100644 examples/files/tick.mp3 create mode 100644 examples/playScore/index.html create mode 100644 examples/playScore/sketch.js diff --git a/examples/files/tick.mp3 b/examples/files/tick.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..fa11e926f3211b95910e2ce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mz! zW6j)2F7-CI#g7`*oCcfIbdRfsRj{kPx>7_Gr%9&a9h%KBDlqQW({5L041>qUhQdZF z%d8`bNmIs}3+sgrqUW)AieeYApF&s6H5Ig!g!u#o1gieOFx20H#!~?LzA9wIhN{od zCF}2vbp_a7ijEcmAI%cplqV)c`+wyZ$f@QN-H)tTut81Q!RE6Ttch*ri|RMFDxa~5 zvcX&I;8Pt##nx3zFmw;_cRK@k3xU(}AFCUx{)f7iRDG+JR8rVuj!^2m7CTN?*JC2l z)To*t(|=O+L_U9=f5iacN~KDBkuAzFQ{U7VIm59sw3wMHHHgWcP3E)a%k!g}bRpph;05@}YyqcOr*bt_B^O?n z`+NqOUi$wNeZ&7t_E$pCLZXWk7wJ%IaEkRrW+ad~;wu0R`F9B9Z)p$-{X5tBe`#y~ KzuW&s;Qs*q+QnP| literal 0 HcmV?d00001 diff --git a/examples/playScore/index.html b/examples/playScore/index.html new file mode 100644 index 00000000..6ec1957c --- /dev/null +++ b/examples/playScore/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/examples/playScore/sketch.js b/examples/playScore/sketch.js new file mode 100644 index 00000000..4e1edbb6 --- /dev/null +++ b/examples/playScore/sketch.js @@ -0,0 +1,51 @@ +/* eslint-disable strict */ +let mypart, score, cnv, tick; + +function preload() { + tick = loadSound('../files/tick.mp3'); +} + +function setup() { + cnv = createCanvas(400, 400); + textAlign(CENTER); + cnv.mousePressed(playOneTime); + cnv.doubleClicked(playMeTwice); + + mypart = new p5.Part(4, 1/4); + + tick.pattern = [1, 2, 3, 4]; + tick.phrase = new p5.Phrase('metro', playTick, tick.pattern ); + mypart.addPhrase(tick.phrase); +} + +function playMeTwice() { + userStartAudio(); + score = new p5.Score(mypart, mypart); + score.setBPM(55); + score.start(); +} + +function playOneTime() { + userStartAudio(); + score = new p5.Score(mypart); + score.setBPM(55); + score.start(); +} + +function draw() { + background(33); + textSize(32); + fill(255); + text('click to play once', width/2, height/2-25); + text('double-click to play twice', width/2, height/2+25); +} + +function playMyPart() { + userStartAudio(); + score.start(); +} + +function playTick(time) { + tick.play(time); +} + diff --git a/index.html b/index.html index c2ec3ff3..e7c6dc9d 100644 --- a/index.html +++ b/index.html @@ -69,6 +69,7 @@

p5.sound +