/*! p5.sound.min.js v0.3.10 2019-01-10 */
/ * *
* p5 . sound
* https : //p5js.org/reference/#/libraries/p5.sound
*
* From the Processing Foundation and contributors
* https : //github.com/processing/p5.js-sound/graphs/contributors
*
* MIT License ( MIT )
* https : //github.com/processing/p5.js-sound/blob/master/LICENSE
*
* Some of the many audio libraries & resources that inspire p5 . sound :
* - TONE . js ( c ) Yotam Mann . Licensed under The MIT License ( MIT ) . https : //github.com/TONEnoTONE/Tone.js
* - buzz . js ( c ) Jay Salvat . Licensed under The MIT License ( MIT ) . http : //buzz.jaysalvat.com/
* - Boris Smus Web Audio API book , 2013. Licensed under the Apache License http : //www.apache.org/licenses/LICENSE-2.0
* - wavesurfer . js https : //github.com/katspaugh/wavesurfer.js
* - Web Audio Components by Jordan Santell https : //github.com/web-audio-components
* - Wilm Thoben ' s Sound library for Processing https : //github.com/processing/processing/tree/master/java/libraries/sound
*
* Web Audio API : http : //w3.org/TR/webaudio/
* /
! function ( t , e ) { "function" == typeof define && define . amd ? define ( "p5.sound" , [ "p5" ] , function ( t ) { e ( t ) } ) : e ( "object" == typeof exports ? require ( "../p5" ) : t . p5 ) } ( this , function ( t ) { var e ; e = function ( ) { ! function ( ) { function t ( t ) { t && ( t . setTargetAtTime || ( t . setTargetAtTime = t . setTargetValueAtTime ) ) } window . hasOwnProperty ( "webkitAudioContext" ) && ! window . hasOwnProperty ( "AudioContext" ) && ( window . AudioContext = window . webkitAudioContext , "function" != typeof AudioContext . prototype . createGain && ( AudioContext . prototype . createGain = AudioContext . prototype . createGainNode ) , "function" != typeof AudioContext . prototype . createDelay && ( AudioContext . prototype . createDelay = AudioContext . prototype . createDelayNode ) , "function" != typeof AudioContext . prototype . createScriptProcessor && ( AudioContext . prototype . createScriptProcessor = AudioContext . prototype . createJavaScriptNode ) , "function" != typeof AudioContext . prototype . createPeriodicWave && ( AudioContext . prototype . createPeriodicWave = AudioContext . prototype . createWaveTable ) , AudioContext . prototype . internal_createGain = AudioContext . prototype . createGain , AudioContext . prototype . createGain = function ( ) { var e = this . internal_createGain ( ) ; return t ( e . gain ) , e } , AudioContext . prototype . internal_createDelay = AudioContext . prototype . createDelay , AudioContext . prototype . createDelay = function ( e ) { var i = e ? this . internal_createDelay ( e ) : this . internal_createDelay ( ) ; return t ( i . delayTime ) , i } , AudioContext . prototype . internal_createBufferSource = AudioContext . prototype . createBufferSource , AudioContext . prototype . createBufferSource = function ( ) { var e = this . internal_createBufferSource ( ) ; return e . start ? ( e . internal_start = e . start , e . start = function ( t , i , n ) { "undefined" != typeof n ? e . internal_start ( t || 0 , i , n ) : e . internal_start ( t || 0 , i || 0 ) } ) : e . start = function ( t , e , i ) { e || i ? this . noteGrainOn ( t || 0 , e , i ) : this . noteOn ( t || 0 ) } , e . stop ? ( e . internal_stop = e . stop , e . stop = function ( t ) { e . internal_stop ( t || 0 ) } ) : e . stop = function ( t ) { this . noteOff ( t || 0 ) } , t ( e . playbackRate ) , e } , AudioContext . prototype . internal_createDynamicsCompressor = AudioContext . prototype . createDynamicsCompressor , AudioContext . prototype . createDynamicsCompressor = function ( ) { var e = this . internal_createDynamicsCompressor ( ) ; return t ( e . threshold ) , t ( e . knee ) , t ( e . ratio ) , t ( e . reduction ) , t ( e . attack ) , t ( e . release ) , e } , AudioContext . prototype . internal_createBiquadFilter = AudioContext . prototype . createBiquadFilter , AudioContext . prototype . createBiquadFilter = function ( ) { var e = this . internal_createBiquadFilter ( ) ; return t ( e . frequency ) , t ( e . detune ) , t ( e . Q ) , t ( e . gain ) , e } , "function" != typeof AudioContext . prototype . createOscillator && ( AudioContext . prototype . internal_createOscillator = AudioContext . prototype . createOscillator , AudioContext . prototype . createOscillator = function ( ) { var e = this . internal_createOscillator ( ) ; return e . start ? ( e . internal_start = e . start , e . start = function ( t ) { e . internal_start ( t || 0 ) } ) : e . start = function ( t ) { this . noteOn ( t || 0 ) } , e . stop ? ( e . internal_stop = e . stop , e . stop = function ( t ) { e . internal_stop ( t || 0 ) } ) : e . stop = function ( t ) { this . noteOff ( t || 0 ) } , e . setPeriodicWave || ( e . setPeriodicWave = e . setWaveTable ) , t ( e . frequency ) , t ( e . detune ) , e } ) ) , window . hasOwnProperty ( "webkitOfflineAudioContext" ) && ! window . hasOwnProperty ( "OfflineAudioContext" ) && ( window . OfflineAudioContext = window . webkitOfflineAudioContext ) } ( window ) , navigator . getUserMedia = navigator . getUserMedia || navigator . webkitGetUserMedia || navigator . mozGetUserMedia || navigator . msGetUserMedia ; var e = document . createElement ( "audio" ) ; t . prototype . isSupported = function ( ) { return ! ! e . canPlayType } ; var i = function ( ) { return ! ! e . canPlayType && e . canPlayType ( 'audio/ogg; codecs="vorbis"' ) } , n = function ( ) { return ! ! e . canPlayType && e . canPlayType ( "audio/mpeg;" ) } , o = function ( ) { return ! ! e . canPlayType && e . canPlayType ( 'audio/wav; codecs="1"' ) } , r = function ( ) { return ! ! e . canPlayType && ( e . canPlayType ( "audio/x-m4a;" ) || e . canPlayType ( "audio/aac;" ) ) } , s = function ( ) { return ! ! e . canPlayType && e . canPlayType ( "audio/x-aiff;" ) } ; t . prototype . isFileSupported = function ( t ) { switch ( t . toLowerCase ( ) ) { case "mp3" : return n ( ) ; case "wav" : return o ( ) ; case "ogg" : return i ( ) ; case "aac" : case "m4a" : case "mp4" : return r ( ) ; case "aif" : case "aiff" : return s ( ) ; default : return ! 1 } } } ( ) ; var i ; ! function ( t , e ) { i = function ( ) { return e ( ) } ( ) } ( this , function ( ) { function t ( t ) { var
n += this . freqDomain [ o ] ; var r = 0 ; 0 !== n && ( r = i / n ) ; var s = r * ( t / this . freqDomain . length ) ; return s } , t . FFT . prototype . smooth = function ( t ) { return "undefined" != typeof t && ( this . smoothing = t ) , this . smoothing } , t . FFT . prototype . dispose = function ( ) { var t = e . soundArray . indexOf ( this ) ; e . soundArray . splice ( t , 1 ) , this . analyser && ( this . analyser . disconnect ( ) , delete this . analyser ) } , t . FFT . prototype . linAverages = function ( t ) { for ( var t = t || 16 , e = this . freqDomain , i = e . length , n = Math . floor ( i / t ) , o = new Array ( t ) , r = 0 , s = 0 ; i > s ; s ++ ) o [ r ] = void 0 !== o [ r ] ? ( o [ r ] + e [ s ] ) / 2 : e [ s ] , s % n === n - 1 && r ++ ; return o } , t . FFT . prototype . logAverages = function ( t ) { for ( var i = e . audiocontext . sampleRate / 2 , n = this . freqDomain , o = n . length , r = new Array ( t . length ) , s = 0 , a = 0 ; o > a ; a ++ ) { var u = Math . round ( a * i / this . freqDomain . length ) ; u > t [ s ] . hi && s ++ , r [ s ] = void 0 !== r [ s ] ? ( r [ s ] + n [ a ] ) / 2 : n [ a ] } return r } , t . FFT . prototype . getOctaveBands = function ( t , i ) { var t = t || 3 , i = i || 15.625 , n = [ ] , o = { lo : i / Math . pow ( 2 , 1 / ( 2 * t ) ) , ctr : i , hi : i * Math . pow ( 2 , 1 / ( 2 * t ) ) } ; n . push ( o ) ; for ( var r = e . audiocontext . sampleRate / 2 ; o . hi < r ; ) { var s = { } ; s . lo = o . hi , s . ctr = o . ctr * Math . pow ( 2 , 1 / t ) , s . hi = s . ctr * Math . pow ( 2 , 1 / ( 2 * t ) ) , n . push ( s ) , o = s } return n } ; var i = function ( t ) { t . freqDomain instanceof Float32Array == ! 1 && ( t . freqDomain = new Float32Array ( t . analyser . frequencyBinCount ) ) } , n = function ( t ) { t . freqDomain instanceof Uint8Array == ! 1 && ( t . freqDomain = new Uint8Array ( t . analyser . frequencyBinCount ) ) } , r = function ( t ) { t . timeDomain instanceof Float32Array == ! 1 && ( t . timeDomain = new Float32Array ( t . analyser . frequencyBinCount ) ) } , s = function ( t ) { t . timeDomain instanceof Uint8Array == ! 1 && ( t . timeDomain = new Uint8Array ( t . analyser . frequencyBinCount ) ) } } ( o ) ; var h ; h = function ( ) { "use strict" ; var t = function ( t , e ) { this . isUndef ( t ) || 1 === t ? this . input = this . context . createGain ( ) : t > 1 && ( this . input = new Array ( t ) ) , this . isUndef ( e ) || 1 === e ? this . output = this . context . createGain ( ) : e > 1 && ( this . output = new Array ( t ) ) } ; t . prototype . set = function ( e , i , n ) { if ( this . isObject ( e ) ) n = i ; else if ( this . isString ( e ) ) { var o = { } ; o [ e ] = i , e = o } t : for ( var r in e ) { i = e [ r ] ; var s = this ; if ( - 1 !== r . indexOf ( "." ) ) { for ( var a = r . split ( "." ) , u = 0 ; u < a . length - 1 ; u ++ ) if ( s = s [ a [ u ] ] , s instanceof t ) { a . splice ( 0 , u + 1 ) ; var c = a . join ( "." ) ; s . set ( c , i ) ; continue t } r = a [ a . length - 1 ] } var p = s [ r ] ; this . isUndef ( p ) || ( t . Signal && p instanceof t . Signal || t . Param && p instanceof t . Param ? p . value !== i && ( this . isUndef ( n ) ? p . value = i : p . rampTo ( i , n ) ) : p instanceof AudioParam ? p . value !== i && ( p . value = i ) : p instanceof t ? p . set ( i ) : p !== i && ( s [ r ] = i ) ) } return this } , t . prototype . get = function ( e ) { this . isUndef ( e ) ? e = this . _ collectDefaults ( this . constructor ) : this . isString ( e ) && ( e = [ e ] ) ; for ( var i = { } , n = 0 ; n < e . length ; n ++ ) { var o = e [ n ] , r = this , s = i ; if ( - 1 !== o . indexOf ( "." ) ) { for ( var a = o . split ( "." ) , u = 0 ; u < a . length - 1 ; u ++ ) { var c = a [ u ] ; s [ c ] = s [ c ] || { } , s = s [ c ] , r = r [ c ] } o = a [ a . length - 1 ] } var p = r [ o ] ; this . isObject ( e [ o ] ) ? s [ o ] = p . get ( ) : t . Signal && p instanceof t . Signal ? s [ o ] = p . value : t . Param && p instanceof t . Param ? s [ o ] = p . value : p instanceof AudioParam ? s [ o ] = p . value : p instanceof t ? s [ o ] = p . get ( ) : this . isFunction ( p ) || this . isUndef ( p ) || ( s [ o ] = p ) } return i } , t . prototype . _ collectDefaults = function ( t ) { var e = [ ] ; if ( this . isUndef ( t . defaults ) || ( e = Object . keys ( t . defaults ) ) , ! this . isUndef ( t . _ super ) ) for ( var i = this . _ collectDefaults ( t . _ super ) , n = 0 ; n < i . length ; n ++ ) - 1 === e . indexOf ( i [ n ] ) && e . push ( i [ n ] ) ; return e } , t . prototype . toString = function ( ) { for ( var e in t ) { var i = e [ 0 ] . match ( /^[A-Z]$/ ) , n = t [ e ] === this . constructor ; if ( this . isFunction ( t [ e ] ) && i && n ) return e } return "Tone" } , Object . defineProperty ( t . prototype , "numberOfInputs" , { get : function ( ) { return this . input ? this . isArray ( this . input ) ? this . input . length : 1 : 0 } } ) , Object . defineProperty ( t . prototype , "numberOfOutputs" , { get : function ( ) { return this . output ? this . isArray ( this . output ) ? this . output . length : 1 : 0 } } ) , t . prototype . dispose = function ( ) { return this . isUndef ( this . input ) || ( this . input instanceof AudioNode && this . input . disconnect ( ) , this . input = null ) , this . isUndef ( this . output ) || ( this . output instanceof AudioNode && this . output . disconnect ( ) , this . output = null ) , this } , t . prototype . connect = function ( t , e , i ) { return Array . isArray ( this . output ) ? ( e = this . defaultArg ( e , 0 ) , this . output [ e ] . connect ( t , 0 , i ) ) : this . output . connect ( t , e , i ) , this } , t . prototype . disconnect = function ( t , e , i ) { this . isArray ( this . output ) ? this . isNumber ( t ) ? this . output [ t ] . disconnect ( ) : ( e = th
t . extend ( t . Scale , t . SignalBase ) , Object . defineProperty ( t . Scale . prototype , "min" , { get : function ( ) { return this . _ outputMin } , set : function ( t ) { this . _ outputMin = t , this . _ setRange ( ) } } ) , Object . defineProperty ( t . Scale . prototype , "max" , { get : function ( ) { return this . _ outputMax } , set : function ( t ) { this . _ outputMax = t , this . _ setRange ( ) } } ) , t . Scale . prototype . _ setRange = function ( ) { this . _ add . value = this . _ outputMin , this . _ scale . value = this . _ outputMax - this . _ outputMin } , t . Scale . prototype . dispose = function ( ) { return t . prototype . dispose . call ( this ) , this . _ add . dispose ( ) , this . _ add = null , this . _ scale . dispose ( ) , this . _ scale = null , this } , t . Scale } ( h , w , A ) ; var k ; k = function ( ) { var e = S , i = w , n = A , r = P , s = h , a = o ; s . setContext ( a . audiocontext ) , t . Signal = function ( t ) { var i = new e ( t ) ; return i } , e . prototype . fade = e . prototype . linearRampToValueAtTime , n . prototype . fade = e . prototype . fade , i . prototype . fade = e . prototype . fade , r . prototype . fade = e . prototype . fade , e . prototype . setInput = function ( t ) { t . connect ( this ) } , n . prototype . setInput = e . prototype . setInput , i . prototype . setInput = e . prototype . setInput , r . prototype . setInput = e . prototype . setInput , e . prototype . add = function ( t ) { var e = new i ( t ) ; return this . connect ( e ) , e } , n . prototype . add = e . prototype . add , i . prototype . add = e . prototype . add , r . prototype . add = e . prototype . add , e . prototype . mult = function ( t ) { var e = new n ( t ) ; return this . connect ( e ) , e } , n . prototype . mult = e . prototype . mult , i . prototype . mult = e . prototype . mult , r . prototype . mult = e . prototype . mult , e . prototype . scale = function ( e , i , n , o ) { var s , a ; 4 === arguments . length ? ( s = t . prototype . map ( n , e , i , 0 , 1 ) - . 5 , a = t . prototype . map ( o , e , i , 0 , 1 ) - . 5 ) : ( s = arguments [ 0 ] , a = arguments [ 1 ] ) ; var u = new r ( s , a ) ; return this . connect ( u ) , u } , n . prototype . scale = e . prototype . scale , i . prototype . scale = e . prototype . scale , r . prototype . scale = e . prototype . scale } ( S , w , A , P , h , o ) ; var O ; O = function ( ) { var e = o , i = w , n = A , r = P ; t . Oscillator = function ( i , n ) { if ( "string" == typeof i ) { var o = n ; n = i , i = o } if ( "number" == typeof n ) { var o = n ; n = i , i = o } this . started = ! 1 , this . phaseAmount = void 0 , this . oscillator = e . audiocontext . createOscillator ( ) , this . f = i || 440 , this . oscillator . type = n || "sine" , this . oscillator . frequency . setValueAtTime ( this . f , e . audiocontext . currentTime ) , this . output = e . audiocontext . createGain ( ) , this . _ freqMods = [ ] , this . output . gain . value = . 5 , this . output . gain . setValueAtTime ( . 5 , e . audiocontext . currentTime ) , this . oscillator . connect ( this . output ) , this . panPosition = 0 , this . connection = e . input , this . panner = new t . Panner ( this . output , this . connection , 1 ) , this . mathOps = [ this . output ] , e . soundArray . push ( this ) } , t . Oscillator . prototype . start = function ( t , i ) { if ( this . started ) { var n = e . audiocontext . currentTime ; this . stop ( n ) } if ( ! this . started ) { var o = i || this . f , r = this . oscillator . type ; this . oscillator && ( this . oscillator . disconnect ( ) , delete this . oscillator ) , this . oscillator = e . audiocontext . createOscillator ( ) , this . oscillator . frequency . value = Math . abs ( o ) , this . oscillator . type = r , this . oscillator . connect ( this . output ) , t = t || 0 , this . oscillator . start ( t + e . audiocontext . currentTime ) , this . freqNode = this . oscillator . frequency ; for ( var s in this . _ freqMods ) "undefined" != typeof this . _ freqMods [ s ] . connect && this . _ freqMods [ s ] . connect ( this . oscillator . frequency ) ; this . started = ! 0 } } , t . Oscillator . prototype . stop = function ( t ) { if ( this . started ) { var i = t || 0 , n = e . audiocontext . currentTime ; this . oscillator . stop ( i + n ) , this . started = ! 1 } } , t . Oscillator . prototype . amp = function ( t , i , n ) { var o = this ; if ( "number" == typeof t ) { var i = i || 0 , n = n || 0 , r = e . audiocontext . currentTime ; this . output . gain . linearRampToValueAtTime ( t , r + n + i ) } else { if ( ! t ) return this . output . gain ; t . connect ( o . output . gain ) } } , t . Oscillator . prototype . fade = t . Oscillator . prototype . amp , t . Oscillator . prototype . getAmp = function ( ) { return this . output . gain . value } , t . Oscillator . prototype . freq = function ( t , i , n ) { if ( "number" != typeof t || isNaN ( t ) ) { if ( ! t ) return this . oscillator . frequency ; t . output && ( t = t . output ) , t . connect ( this . oscillator . frequency ) , this . _ freqMods . push ( t ) } else { this . f = t ; var o = e . audiocontext . currentTime , i = i || 0 , n = n || 0 ; 0 === i ? this . oscillator . frequency . setValueAtTime ( t , n + o ) : t > 0 ? this . oscillator . frequency . exponentialRampToValueAtTime ( t , n + i + o ) : this . oscillator . frequency . linearRampToValueAtTime ( t , n + i + o ) , this . phaseAmount && this . phase ( this . phaseAmount ) } } , t . Oscillator . prototype . getFreq = function ( ) { return this . os
this . _ shaper . dispose ( ) , this . _ shaper = null , this . _ multiply . dispose ( ) , this . _ multiply = null , this . _ subtract . dispose ( ) , this . _ subtract = null , this . _ modSignal . dispose ( ) , this . _ modSignal = null , this } , t . Modulo } ( h , f , A ) ; var G ; G = function ( t ) { "use strict" ; return t . Pow = function ( e ) { this . _ exp = this . defaultArg ( e , 1 ) , this . _ expScaler = this . input = this . output = new t . WaveShaper ( this . _ expFunc ( this . _ exp ) , 8192 ) } , t . extend ( t . Pow , t . SignalBase ) , Object . defineProperty ( t . Pow . prototype , "value" , { get : function ( ) { return this . _ exp } , set : function ( t ) { this . _ exp = t , this . _ expScaler . setMap ( this . _ expFunc ( this . _ exp ) ) } } ) , t . Pow . prototype . _ expFunc = function ( t ) { return function ( e ) { return Math . pow ( Math . abs ( e ) , t ) } } , t . Pow . prototype . dispose = function ( ) { return t . prototype . dispose . call ( this ) , this . _ expScaler . dispose ( ) , this . _ expScaler = null , this } , t . Pow } ( h ) ; var L ; L = function ( t ) { "use strict" ; return t . AudioToGain = function ( ) { this . _ norm = this . input = this . output = new t . WaveShaper ( function ( t ) { return ( t + 1 ) / 2 } ) } , t . extend ( t . AudioToGain , t . SignalBase ) , t . AudioToGain . prototype . dispose = function ( ) { return t . prototype . dispose . call ( this ) , this . _ norm . dispose ( ) , this . _ norm = null , this } , t . AudioToGain } ( h , f ) ; var j ; j = function ( t ) { "use strict" ; function e ( t , e , i ) { var n = new t ; return i . _ eval ( e [ 0 ] ) . connect ( n , 0 , 0 ) , i . _ eval ( e [ 1 ] ) . connect ( n , 0 , 1 ) , n } function i ( t , e , i ) { var n = new t ; return i . _ eval ( e [ 0 ] ) . connect ( n , 0 , 0 ) , n } function n ( t ) { return t ? parseFloat ( t ) : void 0 } function o ( t ) { return t && t . args ? parseFloat ( t . args ) : void 0 } return t . Expr = function ( ) { var t = this . _ replacements ( Array . prototype . slice . call ( arguments ) ) , e = this . _ parseInputs ( t ) ; this . _ nodes = [ ] , this . input = new Array ( e ) ; for ( var i = 0 ; e > i ; i ++ ) this . input [ i ] = this . context . createGain ( ) ; var n , o = this . _ parseTree ( t ) ; try { n = this . _ eval ( o ) } catch ( r ) { throw this . _ disposeNodes ( ) , new Error ( "Tone.Expr: Could evaluate expression: " + t ) } this . output = n } , t . extend ( t . Expr , t . SignalBase ) , t . Expr . _ Expressions = { value : { signal : { regexp : /^\d+\.\d+|^\d+/ , method : function ( e ) { var i = new t . Signal ( n ( e ) ) ; return i } } , input : { regexp : /^\$\d/ , method : function ( t , e ) { return e . input [ n ( t . substr ( 1 ) ) ] } } } , glue : { "(" : { regexp : /^\(/ } , ")" : { regexp : /^\)/ } , "," : { regexp : /^,/ } } , func : { abs : { regexp : /^abs/ , method : i . bind ( this , t . Abs ) } , mod : { regexp : /^mod/ , method : function ( e , i ) { var n = o ( e [ 1 ] ) , r = new t . Modulo ( n ) ; return i . _ eval ( e [ 0 ] ) . connect ( r ) , r } } , pow : { regexp : /^pow/ , method : function ( e , i ) { var n = o ( e [ 1 ] ) , r = new t . Pow ( n ) ; return i . _ eval ( e [ 0 ] ) . connect ( r ) , r } } , a2g : { regexp : /^a2g/ , method : function ( e , i ) { var n = new t . AudioToGain ; return i . _ eval ( e [ 0 ] ) . connect ( n ) , n } } } , binary : { "+" : { regexp : /^\+/ , precedence : 1 , method : e . bind ( this , t . Add ) } , "-" : { regexp : /^\-/ , precedence : 1 , method : function ( n , o ) { return 1 === n . length ? i ( t . Negate , n , o ) : e ( t . Subtract , n , o ) } } , "*" : { regexp : /^\*/ , precedence : 0 , method : e . bind ( this , t . Multiply ) } } , unary : { "-" : { regexp : /^\-/ , method : i . bind ( this , t . Negate ) } , "!" : { regexp : /^\!/ , method : i . bind ( this , t . NOT ) } } } , t . Expr . prototype . _ parseInputs = function ( t ) { var e = t . match ( /\$\d/g ) , i = 0 ; if ( null !== e ) for ( var n = 0 ; n < e . length ; n ++ ) { var o = parseInt ( e [ n ] . substr ( 1 ) ) + 1 ; i = Math . max ( i , o ) } return i } , t . Expr . prototype . _ replacements = function ( t ) { for ( var e = t . shift ( ) , i = 0 ; i < t . length ; i ++ ) e = e . replace ( /\%/i , t [ i ] ) ; return e } , t . Expr . prototype . _ tokenize = function ( e ) { function i ( e ) { for ( var i in t . Expr . _ Expressions ) { var n = t . Expr . _ Expressions [ i ] ; for ( var o in n ) { var r = n [ o ] , s = r . regexp , a = e . match ( s ) ; if ( null !== a ) return { type : i , value : a [ 0 ] , method : r . method } } } throw new SyntaxError ( "Tone.Expr: Unexpected token " + e ) } for ( var n = - 1 , o = [ ] ; e . length > 0 ; ) { e = e . trim ( ) ; var r = i ( e ) ; o . push ( r ) , e = e . substr ( r . value . length ) } return { next : function ( ) { return o [ ++ n ] } , peek : function ( ) { return o [ n + 1 ] } } } , t . Expr . prototype . _ parseTree = function ( e ) { function i ( t , e ) { return ! p ( t ) && "glue" === t . type && t . value === e } function n ( e , i , n ) { var o = ! 1 , r = t . Expr . _ Expressions [ i ] ; if ( ! p ( e ) ) for ( var s in r ) { var a = r [ s ] ; if ( a . regexp . test ( e . value ) ) { if ( p ( n ) ) return ! 0 ; if ( a . precedence === n ) return ! 0 } } return o } function o ( t ) { p ( t ) && ( t = 5 ) ; var e ; e = 0 > t ? r ( ) : o ( t - 1 ) ; for ( var i = c . peek ( ) ; n ( i , "binary" , t ) ; ) i = c . next ( ) , e = { operator : i . value , method : i . method , args : [ e , o ( t - 1 ) ] } , i = c . peek ( ) ; return e } function r ( ) { var t , e ; return t = c . peek ( ) , n ( t , "unary" ) ? ( t = c . next ( ) , e = r ( ) , { operator : t . value , method : t . method , args : [ e ] } ) : s ( ) } function s ( ) { var t , e ; if ( t = c . peek ( ) , p ( t ) ) thro
this . metro . setBPM ( t , e ) } , t . Part . prototype . getBPM = function ( ) { return this . metro . getBPM ( ) } , t . Part . prototype . start = function ( t ) { if ( ! this . isPlaying ) { this . isPlaying = ! 0 , this . metro . resetSync ( this ) ; var e = t || 0 ; this . metro . start ( e ) } } , t . Part . prototype . loop = function ( t ) { this . looping = ! 0 , this . onended = function ( ) { this . partStep = 0 } ; var e = t || 0 ; this . start ( e ) } , t . Part . prototype . noLoop = function ( ) { this . looping = ! 1 , this . onended = function ( ) { this . stop ( ) } } , t . Part . prototype . stop = function ( t ) { this . partStep = 0 , this . pause ( t ) } , t . Part . prototype . pause = function ( t ) { this . isPlaying = ! 1 ; var e = t || 0 ; this . metro . stop ( e ) } , t . Part . prototype . addPhrase = function ( e , i , n ) { var o ; if ( 3 === arguments . length ) o = new t . Phrase ( e , i , n ) ; else { if ( ! ( arguments [ 0 ] instanceof t . Phrase ) ) throw "invalid input. addPhrase accepts name, callback, array or a p5.Phrase" ; o = arguments [ 0 ] } this . phrases . push ( o ) , o . sequence . length > this . length && ( this . length = o . sequence . length ) } , t . Part . prototype . removePhrase = function ( t ) { for ( var e in this . phrases ) this . phrases [ e ] . name === t && this . phrases . splice ( e , 1 ) } , t . Part . prototype . getPhrase = function ( t ) { for ( var e in this . phrases ) if ( this . phrases [ e ] . name === t ) return this . phrases [ e ] } , t . Part . prototype . replaceSequence = function ( t , e ) { for ( var i in this . phrases ) this . phrases [ i ] . name === t && ( this . phrases [ i ] . sequence = e ) } , t . Part . prototype . incrementStep = function ( t ) { this . partStep < this . length - 1 ? ( this . callback ( t ) , this . partStep += 1 ) : this . looping || this . partStep !== this . length - 1 || ( console . log ( "done" ) , this . onended ( ) ) } , t . Part . prototype . onStep = function ( t ) { this . callback = t } , t . Score = function ( ) { this . parts = [ ] , this . currentPart = 0 ; var t = this ; for ( var i in arguments ) arguments [ i ] && this . parts [ i ] && ( this . parts [ i ] = arguments [ i ] , this . parts [ i ] . nextPart = this . parts [ i + 1 ] , this . parts [ i ] . onended = function ( ) { t . resetPart ( i ) , e ( t ) } ) ; this . looping = ! 1 } , t . Score . prototype . onended = function ( ) { this . looping ? this . parts [ 0 ] . start ( ) : this . parts [ this . parts . length - 1 ] . onended = function ( ) { this . stop ( ) , this . resetParts ( ) } , this . currentPart = 0 } , t . Score . prototype . start = function ( ) { this . parts [ this . currentPart ] . start ( ) , this . scoreStep = 0 } , t . Score . prototype . stop = function ( ) { this . parts [ this . currentPart ] . stop ( ) , this . currentPart = 0 , this . scoreStep = 0 } , t . Score . prototype . pause = function ( ) { this . parts [ this . currentPart ] . stop ( ) } , t . Score . prototype . loop = function ( ) { this . looping = ! 0 , this . start ( ) } , t . Score . prototype . noLoop = function ( ) { this . looping = ! 1 } , t . Score . prototype . resetParts = function ( ) { var t = this ; this . parts . forEach ( function ( e ) { t . resetParts [ e ] } ) } , t . Score . prototype . resetPart = function ( t ) { this . parts [ t ] . stop ( ) , this . parts [ t ] . partStep = 0 ; for ( var e in this . parts [ t ] . phrases ) this . parts [ t ] && ( this . parts [ t ] . phrases [ e ] . phraseStep = 0 ) } , t . Score . prototype . setBPM = function ( t , e ) { for ( var i in this . parts ) this . parts [ i ] && this . parts [ i ] . setBPM ( t , e ) } } ( o ) ; var ot ; ot = function ( ) { var e = o , i = et ; return t . SoundLoop = function ( t , n ) { this . callback = t , this . musicalTimeMode = "number" == typeof this . _ interval ? ! 1 : ! 0 , this . _ interval = n || 1 , this . _ timeSignature = 4 , this . _ bpm = 60 , this . isPlaying = ! 1 , this . maxIterations = 1 / 0 ; var o = this ; this . clock = new i ( { callback : function ( t ) { var i = t - e . audiocontext . currentTime ; i > 0 && o . iterations <= o . maxIterations && o . callback ( i ) } , frequency : this . _ calcFreq ( ) } ) } , t . SoundLoop . prototype . start = function ( t ) { var i = t || 0 , n = e . audiocontext . currentTime ; this . isPlaying || ( this . clock . start ( n + i ) , this . isPlaying = ! 0 ) } , t . SoundLoop . prototype . stop = function ( t ) { var i = t || 0 , n = e . audiocontext . currentTime ; this . isPlaying && ( this . clock . stop ( n + i ) , this . isPlaying = ! 1 ) } , t . SoundLoop . prototype . pause = function ( t ) { var i = t || 0 , n = e . audiocontext . currentTime ; this . isPlaying && ( this . clock . pause ( n + i ) , this . isPlaying = ! 1 ) } , t . SoundLoop . prototype . syncedStart = function ( t , i ) { var n = i || 0 , o = e . audiocontext . currentTime ; if ( t . isPlaying ) { if ( t . isPlaying ) { var r = t . clock . _ nextTick - e . audiocontext . currentTime ; this . clock . start ( o + r ) , this . isPlaying = ! 0 } } else t . clock . start ( o + n ) , t . isPlaying = ! 0 , this . clock . start ( o + n ) , this . isPlaying = ! 0 } , t . SoundLoop . prototype . _ update = function ( ) { this . clock . frequency . value = this . _ calcFreq ( ) } , t . SoundLoop . prototype . _ calcFreq = function ( ) { return "number" == typeof this . _ interval ? ( this . musicalTimeMode = ! 1 , 1 / this . _ interval ) : "string" == typeof this . _ interval ? ( this . musicalTimeMode = ! 0 , this . _ bpm / 60 / this