22 lines
375 KiB
JavaScript
22 lines
375 KiB
JavaScript
|
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Tone=e():t.Tone=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function n(s){if(e[s])return e[s].exports;var i=e[s]={i:s,l:!1,exports:{}};return t[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(s,i,function(e){return t[e]}.bind(null,i));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=684)}([function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return o})),n.d(e,"d",(function(){return r})),n.d(e,"e",(function(){return a})),n.d(e,"f",(function(){return c})),n.d(e,"g",(function(){return u})),n.d(e,"i",(function(){return h})),n.d(e,"h",(function(){return l})),n.d(e,"j",(function(){return d})),n.d(e,"k",(function(){return p}));const s=new WeakSet,i=new WeakMap,o=new WeakMap,r=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakMap,h=new WeakMap,l=new WeakMap,d=new WeakMap,p=new WeakMap},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var s=n(4);const i=(t,e)=>{Object(s.a)(t,e,"channelCount"),Object(s.a)(t,e,"channelCountMode"),Object(s.a)(t,e,"channelInterpretation")}},function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return i}));const s=-34028234663852886e22,i=-s},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));const s=(t,e)=>t.context===e},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));const s=(t,e,n)=>{const s=e[n];void 0!==s&&s!==t[n]&&(t[n]=s)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));const s=(t,e,n)=>{const s=e[n];void 0!==s&&s!==t[n].value&&(t[n].value=s)}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var s=n(0),i=n(9);const o=t=>Object(i.a)(s.c,t)},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));const s=()=>{try{return new DOMException("","InvalidStateError")}catch(t){return t.code=11,t.name="InvalidStateError",t}}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var s=n(0),i=n(9);const o=t=>Object(i.a)(s.b,t)},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));const s=(t,e)=>{const n=t.get(e);if(void 0===n)throw new Error("A value with the given key could not be found.");return n}},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));const s=()=>{try{return new DOMException("","NotSupportedError")}catch(t){return t.code=9,t.name="NotSupportedError",t}}},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));const s=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t)},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));const s=t=>"inputs"in t},function(t,e,n){"use strict";n.d(e,"AudioContext",(function(){return Oi})),n.d(e,"AudioWorkletNode",(function(){return qi})),n.d(e,"OfflineAudioContext",(function(){return Vi})),n.d(e,"isAnyAudioContext",(function(){return Ni})),n.d(e,"isAnyAudioNode",(function(){return Pi})),n.d(e,"isAnyAudioParam",(function(){return Li})),n.d(e,"isAnyOfflineAudioContext",(function(){return zi})),n.d(e,"isSupported",(function(){return Bi}));var s=n(18),i=n(516),o=n(517),r=n(518),a=n(667),c=n(519),u=n(520),h=n(521),l=n(522),d=n(523),p=n(524),f=n(525),_=n(526),m=n(527),g=n(528),v=n(529),y=n(665),b=n(530),x=n(531),w=n(532),T=n(670),O=n(533),S=n(534),C=n(535),k=n(536),A=n
|
||
|
/**
|
||
|
* Tone.js
|
||
|
* @author Yotam Mann
|
||
|
* @license http://opensource.org/licenses/MIT MIT License
|
||
|
* @copyright 2014-2019 Yotam Mann
|
||
|
*/class V{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||w&&this.toString()===w.TONE_DEBUG_CLASS)&&l(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}V.version=i;function N(t,e){return t>e+1e-6}function P(t,e){return N(t,e)||z(t,e)}function L(t,e){return t+1e-6<e}function z(t,e){return Math.abs(t-e)<1e-6}function B(t,e,n){return Math.max(Math.min(t,n),e)}class W extends V{constructor(){super(),this.name="Timeline",this._timeline=[];const t=q(W.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(r(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){const e=this._timeline[this.length-1];r(P(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{const e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(t){const e=this._timeline.indexOf(t);return-1!==e&&this._timeline.splice(e,1),this}get(t,e="time"){const n=this._search(t,e);return-1!==n?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const n=this._search(t,e);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(t){const e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];const n=this._search(t);return n-1>=0?this._timeline[n-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(z(this._timeline[e].time,t)){for(let n=e;n>=0&&z(this._timeline[n].time,t);n--)e=n;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&P(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){const e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){const e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(0===this._timeline.length)return-1;let n=0;const s=this._timeline.length;let i=s;if(s>0&&this._timeline[s-1][e]<=t)return s-1;for(;n<i;){let s=Math.floor(n+(i-n)/2);const o=this._timeline[s],r=this._timeline[s+1];if(z(o[e],t)){for(let n=s;n<this._timeline.length;n++){if(!z(this._timeline[n][e],t))break;s=n}return s}if(L(o[e],t)&&N(r[e],t))return s;N(o[e],t)?i=s:n=s+1}return-1}_iterate(t,e=0,n=this._timeline.length-1){this._timeline.slice(e,n+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){const n=this._search(t);return-1!==n&&this._iterate(e,0,n),this}forEachAfter(t,e){const n=this._search(t);return this._iterate(e,n+1),this}forEachBetween(t,e,n){let s=this._search(t),i=this._search(e);return-1!==s&&-1!==i?(this._timeline[s].time!==t&&(s+=1),this._timeline[i].time===e&&(i-=1),this._iterate(n,s,i)):-1===s&&this._iterate(n,0,i),this}forEachFrom(t,e){let n=this._search(t);for(;n>=0&&this._timeline[n].time>=t;)n--;return this._iterate(e,n+1),this}forEachAtTime(t,e){const n=this._search(t);if(-1!==n&&z(this._timeline[n].time,t)){let s=n;for(let e=n;e>=0&&z(this._timeline[e].time,t);e--)s=e;this._iterate(t=>{e(t)},s,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const U=[];function G(t){U.push(t)}const Y=[];function Q(t){Y.push(t)}class Z extends V{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(t=>{p(this._events)&&(this._events={}),this._events.hasOwnProperty(t)||(this._events[t]=[]),this._events[t].push(e)}),this}once(t,e){const n=(...s)=>{e(...s),this.off(t,n)};return this.on(t,n),this}off(t,e){return t.split(/\W+/).forEach(n=>{if(p(this._events)&&(this._events={}),this._events.hasOwnProperty(t))if(p(e))this._events[t]=[];else{const n=this._events[t];for(let t=0;t<n.length;t++)n[t]===e
|
||
|
/*! *****************************************************************************
|
||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||
|
this file except in compliance with the License. You may obtain a copy of the
|
||
|
License at http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
||
|
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||
|
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||
|
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||
|
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||
|
|
||
|
See the Apache Version 2.0 License for specific language governing permissions
|
||
|
and limitations under the License.
|
||
|
***************************************************************************** */(this.rawContext,t,e)}addAudioWorkletModule(t,e){return S(this,void 0,void 0,(function*(){r(f(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletModules.has(e)||this._workletModules.set(e,this.rawContext.audioWorklet.addModule(t)),yield this._workletModules.get(e)}))}workletsAreReady(){return S(this,void 0,void 0,(function*(){const t=[];this._workletModules.forEach(e=>t.push(e)),yield Promise.all(t)}))}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get latencyHint(){return this._latencyHint}_setLatencyHint(t){let e=0;if(this._latencyHint=t,b(t))switch(t){case"interactive":e=.1;break;case"playback":e=.5;break;case"balanced":e=.25}this.lookAhead=e,this.updateInterval=e/2}get rawContext(){return this._context}now(){return this._context.currentTime+this.lookAhead}immediate(){return this._context.currentTime}resume(){return"suspended"===this._context.state&&M(this._context)?this._context.resume():Promise.resolve()}close(){return S(this,void 0,void 0,(function*(){var t;M(this._context)&&(yield this._context.close()),this._initialized&&(t=this,Y.forEach(e=>e(t)))}))}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{const e=this._context.createBuffer(1,128,this._context.sampleRate),n=e.getChannelData(0);for(let e=0;e<n.length;e++)n[e]=t;const s=this._context.createBufferSource();return s.channelCount=1,s.channelCountMode="explicit",s.buffer=e,s.loop=!0,s.start(0),this._constants.set(t,s),s}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this}_timeoutLoop(){const t=this.now();let e=this._timeouts.peek();for(;this._timeouts.length&&e&&e.time<=t;)e.callback(),this._timeouts.shift(),e=this._timeouts.peek()}setTimeout(t,e){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:n+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){const n=++this._timeoutIds,s=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),s()},id:n,time:i+e})};return s(),n}}function $(t,e){y(e)?e.forEach(e=>$(t,e)):Object.defineProperty(t,e,{enumerable:!0,writable:!1})}function J(t,e){y(e)?e.forEach(e=>J(t,e)):Object.defineProperty(t,e,{writable:!0})}const K=()=>{};class tt extends V{constructor(){super(),this.name="ToneAudioBuffer",this.onload=K;const t=q(tt.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,t.url&&j(t.url)||t.url instanceof tt?this.set(t.url):b(t.url)&&this.load(t.url).catch(t.onerror)}static getDefaults(){return{onerror:K,onload:K,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:it().sampleRate}set(t){return t instanceof tt?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return S(this,void 0,void 0,(function*(){const e=tt.load(t).then(t=>{this.set(t),this.onload(this)});tt.downloads.push(e);try{yield e}finally{const t=tt.downloads.indexOf(e);tt.downloads.splice(t,1)}return this}))}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){const e=y(t)&&t[0].length>0,n=e?t.length:1,s=e?t[0].length:t.length,i=it(),o=i.createBuffer(n,s,i.sampleRate),r=e||1!==n?t:[t];for(let t=0;t<n;t++)o.copyToChannel(r[t],t);return this._buffer=o,this}toMono(t){if(m(t))this.fromArray(this.toArray(t));else{let t=new Float32Array(this.length);const e=this.numberOfChannels;for(let n=0;n<e;n++){const e=this.toArray(n);for(let n=0;n<e.length;n++)t[n]+=e[n]}t=t.map(t=>t/e),this.fromArray(t)}return this}toArray(t){if(m(t))return this.getChannelData(t);if(1===this.numberOfChannels)return this
|
||
|
//# sourceMappingURL=Tone.js.map
|