New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

audio-feeder

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-feeder - npm Package Compare versions

Comparing version 0.4.20 to 0.4.21

2

dist/AudioFeeder.min.js

@@ -1,1 +0,1 @@

!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?exports.AudioFeeder=b():a.AudioFeeder=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){!function(){function b(a){this._options=a||{},this._backend=null,this._resampleFractional=0,this._resampleLastSampleData=void 0}var d=(c(1),c(2)),e=c(4);b.prototype.rate=0,b.prototype.targetRate=0,b.prototype.channels=0,b.prototype.bufferSize=0,Object.defineProperty(b.prototype,"bufferDuration",{get:function(){return this.targetRate?this.bufferSize/this.targetRate:0}}),Object.defineProperty(b.prototype,"bufferThreshold",{get:function(){return this._backend?this._backend.bufferThreshold/this.targetRate:0},set:function(a){if(!this._backend)throw"Invalid state: AudioFeeder cannot set bufferThreshold before init";this._backend.bufferThreshold=Math.round(a*this.targetRate)}}),Object.defineProperty(b.prototype,"playbackPosition",{get:function(){if(this._backend){var a=this.getPlaybackState();return a.playbackPosition}return 0}}),Object.defineProperty(b.prototype,"durationBuffered",{get:function(){if(this._backend){var a=this.getPlaybackState();return a.samplesQueued/this.targetRate}return 0}}),Object.defineProperty(b.prototype,"muted",{get:function(){if(this._backend)return this._backend.muted;throw"Invalid state: cannot get mute before init"},set:function(a){if(!this._backend)throw"Invalid state: cannot set mute before init";this._backend.muted=a}}),b.prototype.mute=function(){this.muted=!0},b.prototype.unmute=function(){this.muted=!1},Object.defineProperty(b.prototype,"volume",{get:function(){if(this._backend)return this._backend.volume;throw"Invalid state: cannot get volume before init"},set:function(a){if(!this._backend)throw"Invalid state: cannot set volume before init";this._backend.volume=a}}),b.prototype.init=function(a,b){if(this.channels=a,this.rate=b,d.isSupported())this._backend=new d(a,b,this._options);else{if(!e.isSupported())throw"No supported backend";this._backend=new e(a,b,this._options)}this.targetRate=this._backend.rate,this.bufferSize=this._backend.bufferSize,this._backend.onstarved=function(){this.onstarved&&this.onstarved()}.bind(this),this._backend.onbufferlow=function(){this.onbufferlow&&this.onbufferlow()}.bind(this)},b.prototype._resample=function(a){var b=this.rate,c=this.channels,d=this._backend.rate,e=this._backend.channels;if(b==d&&c==e)return a;var f,g=[],h=a[0].length,i=this._resampleFractional,j=h*d/b+i,k=Math.trunc(j),l=j-k;f=b<d?function(a,c,e,f){for(var g=function(b){return b<0?e&&e.length+b>0?e[e.length+b]:a[0]:a[b]},h=0;h<c.length;h++){var j,k=(h+1-i)*b/d-1,l=Math.floor(k),m=Math.ceil(k);j=l==m?g(l):g(l)*(m-k)+g(m)*(k-l),c[h]=f*j}}:function(a,b,c,d){for(var e=0;e<b.length;e++)b[e]=d*a[e*a.length/b.length|0]};var m=1;e>c&&(m=Math.SQRT1_2);for(var n=0;n<e;n++){var o=n;n>=c&&(o=0);var p=a[o],q=new Float32Array(k),r=this._resampleLastSampleData?this._resampleLastSampleData[o]:void 0;f(p,q,r,m),g.push(q)}return this._resampleFractional=l,this._resampleLastSampleData=a,g},b.prototype.bufferData=function(a){if(!this._backend)throw"Invalid state: AudioFeeder cannot bufferData before init";var b=this._resample(a);this._backend.appendBuffer(b)},b.prototype.getPlaybackState=function(){if(this._backend)return this._backend.getPlaybackState();throw"Invalid state: AudioFeeder cannot getPlaybackState before init"},b.prototype.waitUntilReady=function(a){if(!this._backend)throw"Invalid state: AudioFeeder cannot waitUntilReady before init";this._backend.waitUntilReady(a)},b.prototype.start=function(){if(!this._backend)throw"Invalid state: AudioFeeder cannot start before init";this._backend.start()},b.prototype.stop=function(){if(!this._backend)throw"Invalid state: AudioFeeder cannot stop before init";this._backend.stop()},b.prototype.flush=function(){if(this._resampleFractional=0,this._resampleLastSampleData=void 0,!this._backend)throw"Invalid state: AudioFeeder cannot flush before init";this._backend.flush()},b.prototype.close=function(){this._backend&&(this._backend.close(),this._backend=null)},b.prototype.onstarved=null,b.prototype.onbufferlow=null,b.isSupported=function(){return!!Float32Array&&(d.isSupported()||e.isSupported())},b.initSharedAudioContext=function(){return d.isSupported()?d.initSharedAudioContext():null},a.exports=b}()},function(a,b){function c(a,b){if(a<1||a!==Math.round(a))throw"Invalid channel count for BufferQueue";this.channels=a,this.bufferSize=b,this.flush()}c.prototype.flush=function(){this._buffers=[],this._pendingBuffer=this.createBuffer(this.bufferSize),this._pendingPos=0},c.prototype.sampleCount=function(){var a=0;return this._buffers.forEach(function(b){a+=b[0].length}),a},c.prototype.createBuffer=function(a){for(var b=[],c=0;c<this.channels;c++)b[c]=new Float32Array(a);return b},c.prototype.validate=function(a){if(a.length!==this.channels)return!1;for(var b,c=0;c<a.length;c++){var d=a[c];if(!(d instanceof Float32Array))return!1;if(0==c)b=d.length;else if(d.length!==b)return!1}return!0},c.prototype.appendBuffer=function(a){if(!this.validate(a))throw"Invalid audio buffer passed to BufferQueue.appendBuffer";for(var b=a[0],c=b.length,d=this.channels,e=this._pendingPos,f=this._pendingBuffer,g=this.bufferSize,h=0;h<c;h++){for(var i=0;i<d;i++)f[i][e]=a[i][h];++e==g&&(this._buffers.push(f),e=this._pendingPos=0,f=this._pendingBuffer=this.createBuffer(g))}this._pendingPos=e},c.prototype.prependBuffer=function(a){if(!this.validate(a))throw"Invalid audio buffer passed to BufferQueue.prependBuffer";var b=this._buffers.slice(0);b.push(this.trimBuffer(this._pendingBuffer,0,this._pendingPos)),this.flush(),this.appendBuffer(a);for(var c=0;c<b.length;c++)this.appendBuffer(b[c])},c.prototype.nextBuffer=function(){if(this._buffers.length)return this._buffers.shift();var a=this.trimBuffer(this._pendingBuffer,0,this._pendingPos);return this._pendingBuffer=this.createBuffer(this.bufferSize),this._pendingPos=0,a},c.prototype.trimBuffer=function(a,b,c){var d=a[0].length,e=b+Math.min(c,d);if(0==b&&e>=d)return a;for(var f=[],g=0;g<this.channels;g++)f[g]=a[g].subarray(b,e);return f},a.exports=c},function(a,b,c){!function(){function b(a,c,d){var f=d.audioContext||b.initSharedAudioContext();if(this._context=f,this.output=d.output||f.destination,this.rate=f.sampleRate,this.channels=2,d.bufferSize&&(this.bufferSize=0|d.bufferSize),this.bufferThreshold=2*this.bufferSize,this._bufferQueue=new e(this.channels,this.bufferSize),this._playbackTimeAtBufferTail=f.currentTime,this._queuedTime=0,this._delayedTime=0,this._dropped=0,this._liveBuffer=this._bufferQueue.createBuffer(this.bufferSize),f.createScriptProcessor)this._node=f.createScriptProcessor(this.bufferSize,0,this.channels);else{if(!f.createJavaScriptNode)throw new Error("Bad version of web audio API?");this._node=f.createJavaScriptNode(this.bufferSize,0,this.channels)}}var d=window.AudioContext||window.webkitAudioContext,e=c(1),f=c(3);b.prototype.bufferSize=4096,b.prototype.bufferThreshold=8192,b.prototype._volume=1,Object.defineProperty(b.prototype,"volume",{get:function(){return this._volume},set:function(a){this._volume=+a}}),b.prototype._muted=!1,Object.defineProperty(b.prototype,"muted",{get:function(){return this._muted},set:function(a){this._muted=!!a}}),b.prototype._audioProcess=function(a){var b,c,d,e,g;g="number"==typeof a.playbackTime?a.playbackTime:this._context.currentTime+this.bufferSize/this.rate;var h=this._playbackTimeAtBufferTail;if(h<g&&(this._delayedTime+=g-h),this._bufferQueue.sampleCount()<this.bufferSize&&this.onstarved&&this.onstarved(),this._bufferQueue.sampleCount()<this.bufferSize){for(b=0;b<this.channels;b++)for(d=a.outputBuffer.getChannelData(b),e=0;e<this.bufferSize;e++)d[e]=0;return void this._dropped++}var i=this.muted?0:this.volume,j=this._bufferQueue.nextBuffer();if(j[0].length<this.bufferSize)throw"Audio buffer not expected length.";for(b=0;b<this.channels;b++)for(c=j[b],this._liveBuffer[b].set(j[b]),d=a.outputBuffer.getChannelData(b),e=0;e<c.length;e++)d[e]=c[e]*i;this._queuedTime+=this.bufferSize/this.rate,this._playbackTimeAtBufferTail=g+this.bufferSize/this.rate,this._bufferQueue.sampleCount()<Math.max(this.bufferSize,this.bufferThreshold)&&this.onbufferlow&&f(this.onbufferlow.bind(this))},b.prototype._samplesQueued=function(){var a=this._bufferQueue.sampleCount(),b=Math.floor(this._timeAwaitingPlayback()*this.rate);return a+b},b.prototype._timeAwaitingPlayback=function(){return Math.max(0,this._playbackTimeAtBufferTail-this._context.currentTime)},b.prototype.getPlaybackState=function(){return{playbackPosition:this._queuedTime-this._timeAwaitingPlayback(),samplesQueued:this._samplesQueued(),dropped:this._dropped,delayed:this._delayedTime}},b.prototype.waitUntilReady=function(a){a()},b.prototype.appendBuffer=function(a){this._bufferQueue.appendBuffer(a)},b.prototype.start=function(){this._node.onaudioprocess=this._audioProcess.bind(this),this._node.connect(this.output),this._playbackTimeAtBufferTail=this._context.currentTime},b.prototype.stop=function(){if(this._node){var a=this._timeAwaitingPlayback();if(a>0){var b=Math.round(a*this.rate),c=this._liveBuffer?this._liveBuffer[0].length:0;b>c?(this._bufferQueue.prependBuffer(this._liveBuffer),this._bufferQueue.prependBuffer(this._bufferQueue.createBuffer(b-c))):this._bufferQueue.prependBuffer(this._bufferQueue.trimBuffer(this._liveBuffer,c-b,b)),this._playbackTimeAtBufferTail-=a}this._node.onaudioprocess=null,this._node.disconnect()}},b.prototype.flush=function(){this._bufferQueue.flush()},b.prototype.close=function(){this.stop(),this._context=null},b.prototype.onstarved=null,b.prototype.onbufferlow=null,b.isSupported=function(){return!!d},b.sharedAudioContext=null,b.initSharedAudioContext=function(){if(!b.sharedAudioContext&&b.isSupported()){var a,c=new d;if(c.createScriptProcessor)a=c.createScriptProcessor(1024,0,2);else{if(!c.createJavaScriptNode)throw new Error("Bad version of web audio API?");a=c.createJavaScriptNode(1024,0,2)}a.connect(c.destination),a.disconnect(),b.sharedAudioContext=c}return b.sharedAudioContext},a.exports=b}()},function(a,b){a.exports=function(){if("undefined"!=typeof window.setImmediate)return window.setImmediate;if(window&&window.postMessage){var a=[];return window.addEventListener("message",function(b){if(b.source===window){var c=b.data;if("object"==typeof c&&c.nextTickBrowserPingMessage){var d=a.pop();d&&d()}}}),function(b){a.push(b),window.postMessage({nextTickBrowserPingMessage:!0},document.location.toString())}}return function(a){setTimeout(a,0)}}()},function(a,b,c){!function(){function b(a){for(var b=new Uint8Array(a),c=b.length,d="",e=0;e<c;e+=8)d+=h[b[e]],d+=h[b[e+1]],d+=h[b[e+2]],d+=h[b[e+3]],d+=h[b[e+4]],d+=h[b[e+5]],d+=h[b[e+6]],d+=h[b[e+7]];return d}function d(a){this.init(a)}var e=c(5),f=c(3),g=function(a,b,c){c=c||{};var g={};"string"==typeof c.base&&(g.swf=c.base+"/"+e),c.bufferSize&&(this.bufferSize=0|c.bufferSize),this._flashaudio=new d(g),this._flashBuffer="",this._cachedFlashState=null,this._cachedFlashTime=0,this._cachedFlashInterval=185,this._waitUntilReadyQueue=[],this.onready=function(){for(this._flashaudio.flashElement.setBufferSize(this.bufferSize),this._flashaudio.flashElement.setBufferThreshold(this.bufferThreshold);this._waitUntilReadyQueue.length;){var a=this._waitUntilReadyQueue.shift();a.apply(this)}},this.onlog=function(a){console.log("AudioFeeder FlashBackend: "+a)},this.bufferThreshold=2*this.bufferSize;var h={ready:"sync",log:"sync",starved:"sync",bufferlow:"async"};this._callbackName="AudioFeederFlashBackendCallback"+this._flashaudio.id;window[this._callbackName]=function(a){var b=h[a],c=this["on"+a];b&&c&&("async"===b?f(c.bind(this)):(c.apply(this,Array.prototype.slice.call(arguments,1)),this._flushFlashBuffer()))}.bind(this)};g.prototype.rate=44100,g.prototype.channels=2,g.prototype.bufferSize=4096,g.prototype._bufferThreshold=8192,Object.defineProperty(g.prototype,"bufferThreshold",{get:function(){return this._bufferThreshold},set:function(a){this._bufferThreshold=0|a,this.waitUntilReady(function(){this._flashaudio.flashElement.setBufferThreshold(this._bufferThreshold)}.bind(this))}}),g.prototype._volume=1,Object.defineProperty(g.prototype,"volume",{get:function(){return this._volume},set:function(a){this._volume=+a,this.waitUntilReady(this._flashVolumeUpdate.bind(this))}}),g.prototype._muted=!1,Object.defineProperty(g.prototype,"muted",{get:function(){return this._muted},set:function(a){this._muted=!!a,this.waitUntilReady(this._flashVolumeUpdate.bind(this))}}),g.prototype._paused=!0,g.prototype._flashVolumeUpdate=function(){this._flashaudio&&this._flashaudio.flashElement&&this._flashaudio.flashElement.setVolume&&this._flashaudio.flashElement.setVolume(this.muted?0:this.volume)},g.prototype._resampleFlash=function(a){for(var b=a[0].length,c=new Float32Array(2*b),d=a[0],e=this.channels>1?a[1]:d,f=0;f<b;f++){var g=f,h=2*f;c[h]=d[g],c[h+1]=e[g]}return c};for(var h=[],i=0;i<256;i++)h[i]=String.fromCharCode(i+57344);g.prototype._flushFlashBuffer=function(){var a=this._flashBuffer,b=this._flashaudio.flashElement;this._flashBuffer="",a.length>0&&(this._cachedFlashState=b.write(a),this._cachedFlashTime=Date.now())},g.prototype.appendBuffer=function(a){var c=this._resampleFlash(a);if(c.length>0){var d=b(c.buffer);this._flashBuffer+=d,this._flashBuffer.length>=8*this.bufferSize&&this._flushFlashBuffer()}},g.prototype.getPlaybackState=function(){if(this._flashaudio&&this._flashaudio.flashElement&&this._flashaudio.flashElement.write){var a,b=Date.now(),c=this._paused?0:b-this._cachedFlashTime;if(this._cachedFlashState&&c<this._cachedFlashInterval){var d=this._cachedFlashState;a={playbackPosition:d.playbackPosition+c/1e3,samplesQueued:d.samplesQueued-Math.max(0,Math.round(c*this.rate/1e3)),dropped:d.dropped,delayed:d.delayed}}else a=this._flashaudio.flashElement.getPlaybackState(),this._cachedFlashState=a,this._cachedFlashTime=b;return a.samplesQueued+=this._flashBuffer.length/8,a}return{playbackPosition:0,samplesQueued:0,dropped:0,delayed:0}},g.prototype.waitUntilReady=function(a){this._flashaudio&&this._flashaudio.flashElement.write?a.apply(this):this._waitUntilReadyQueue.push(a)},g.prototype.start=function(){this._flushFlashBuffer(),this._flashaudio.flashElement.start(),this._paused=!1,this._cachedFlashState=null},g.prototype.stop=function(){this._flashaudio.flashElement.stop(),this._paused=!0,this._cachedFlashState=null},g.prototype.flush=function(){this._flashBuffer="",this._flashaudio.flashElement.flush(),this._cachedFlashState=null},g.prototype.close=function(){this.stop();var a=this._flashaudio.flashWrapper;a.parentNode.removeChild(a),this._flashaudio=null,delete window[this._callbackName]},g.prototype.onstarved=null,g.prototype.onbufferlow=null,g.isSupported=function(){if(navigator.userAgent.indexOf("Trident")!==-1)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash");return!0}catch(a){return!1}return!1},d.nextId=1,d.prototype={nextId:null,swf:e,flashWrapper:null,flashElement:null,init:function(a){var b=this;b.id=d.nextId++,a&&"undefined"!=typeof a.swf&&(b.swf=a.swf),b.flashWrapper=document.createElement("div"),b.flashWrapper.id="dynamicaudio-flashwrapper-"+b.id;var c=b.flashWrapper.style;c.position="fixed",c.width="11px",c.height="11px",c.bottom=c.left="0px",c.overflow="hidden",b.flashElement=document.createElement("div"),b.flashElement.id="dynamicaudio-flashelement-"+b.id,b.flashWrapper.appendChild(b.flashElement),document.body.appendChild(b.flashWrapper);var e=b.flashElement.id,f='<param name="FlashVars" value="objectId='+b.id+'">';b.flashWrapper.innerHTML="<object id='"+e+"' width='10' height='10' type='application/x-shockwave-flash' data='"+b.swf+"' style='visibility: visible;'><param name='allowscriptaccess' value='always'>"+f+"</object>",b.flashElement=document.getElementById(e)}},a.exports=g}()},function(a,b,c){a.exports=c.p+"dynamicaudio.swf?version=2c1ce3bfb7e6fa65c26d726a00017a94"}])});
!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?exports.AudioFeeder=b():a.AudioFeeder=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){!function(){function b(a){this._options=a||{},this._backend=null,this._resampleFractional=0,this._resampleLastSampleData=void 0,this._tempoChanger=null}var d=(c(1),c(2)),e=c(4),f=c(6);b.prototype.rate=0,b.prototype.targetRate=0,b.prototype.channels=0,b.prototype.bufferSize=0,Object.defineProperty(b.prototype,"bufferDuration",{get:function(){return this.targetRate?this.bufferSize/this.targetRate:0}}),Object.defineProperty(b.prototype,"bufferThreshold",{get:function(){return this._backend?this._backend.bufferThreshold/this.targetRate:0},set:function(a){if(!this._backend)throw"Invalid state: AudioFeeder cannot set bufferThreshold before init";this._backend.bufferThreshold=Math.round(a*this.targetRate)}}),Object.defineProperty(b.prototype,"playbackPosition",{get:function(){if(this._backend){var a=this.getPlaybackState();return a.playbackPosition}return 0}}),Object.defineProperty(b.prototype,"outputPlaybackPosition",{get:function(){if(this._backend){var a=this.getPlaybackState();return a.outputPlaybackPosition}return 0}}),Object.defineProperty(b.prototype,"durationBuffered",{get:function(){if(this._backend){var a=this.getPlaybackState();return a.samplesQueued/this.targetRate}return 0}}),Object.defineProperty(b.prototype,"muted",{get:function(){if(this._backend)return this._backend.muted;throw"Invalid state: cannot get mute before init"},set:function(a){if(!this._backend)throw"Invalid state: cannot set mute before init";this._backend.muted=a}}),b.prototype.mute=function(){this.muted=!0},b.prototype.unmute=function(){this.muted=!1},Object.defineProperty(b.prototype,"volume",{get:function(){if(this._backend)return this._backend.volume;throw"Invalid state: cannot get volume before init"},set:function(a){if(!this._backend)throw"Invalid state: cannot set volume before init";this._backend.volume=a}}),Object.defineProperty(b.prototype,"tempo",{get:function(){if(this._tempoChanger)return this._tempoChanger.getTempo();throw"Invalid state: cannot get tempo before init"},set:function(a){if(!this._tempoChanger)throw"Invalid state: cannot set tempo before init";this._tempoChanger.setTempo(a)}}),b.prototype.init=function(a,b){if(this.channels=a,this.rate=b,d.isSupported())this._backend=new d(a,b,this._options);else{if(!e.isSupported())throw"No supported backend";this._backend=new e(a,b,this._options)}this.targetRate=this._backend.rate,this.bufferSize=this._backend.bufferSize,this._tempoChanger=f({sampleRate:this.targetRate,numChannels:a,tempo:1}),this._backend.onstarved=function(){this.onstarved&&this.onstarved()}.bind(this),this._backend.onbufferlow=function(){this.onbufferlow&&this.onbufferlow()}.bind(this)},b.prototype._resample=function(a){var b=this.rate,c=this.channels,d=this._backend.rate,e=this._backend.channels;if(b==d&&c==e)return a;var f,g=[],h=a[0].length,i=this._resampleFractional,j=h*d/b+i,k=Math.floor(j),l=j-k;f=b<d?function(a,c,e,f){for(var g=function(b){return b<0?e&&e.length+b>0?e[e.length+b]:a[0]:a[b]},h=0;h<c.length;h++){var j,k=(h+1-i)*b/d-1,l=Math.floor(k),m=Math.ceil(k);j=l==m?g(l):g(l)*(m-k)+g(m)*(k-l),c[h]=f*j}}:function(a,b,c,d){for(var e=0;e<b.length;e++)b[e]=d*a[e*a.length/b.length|0]};var m=1;e>c&&(m=Math.SQRT1_2);for(var n=0;n<e;n++){var o=n;n>=c&&(o=0);var p=a[o],q=new Float32Array(k),r=this._resampleLastSampleData?this._resampleLastSampleData[o]:void 0;f(p,q,r,m),g.push(q)}return this._resampleFractional=l,this._resampleLastSampleData=a,g},b.prototype.bufferData=function(a){if(!this._backend)throw"Invalid state: AudioFeeder cannot bufferData before init";var b=this._resample(a);b=this._tempoChanger.process(b),this._backend.appendBuffer(b)},b.prototype.getPlaybackState=function(){if(this._backend){var a=this._backend.getPlaybackState();return a.outputPlaybackPosition=a.playbackPosition,a.playbackPosition=this._tempoChanger.mapOutputToInputTime(a.outputPlaybackPosition),a}throw"Invalid state: AudioFeeder cannot getPlaybackState before init"},b.prototype.waitUntilReady=function(a){if(!this._backend)throw"Invalid state: AudioFeeder cannot waitUntilReady before init";this._backend.waitUntilReady(a)},b.prototype.start=function(){if(!this._backend)throw"Invalid state: AudioFeeder cannot start before init";this._backend.start()},b.prototype.stop=function(){if(!this._backend)throw"Invalid state: AudioFeeder cannot stop before init";this._backend.stop()},b.prototype.flush=function(){if(this._resampleFractional=0,this._resampleLastSampleData=void 0,!this._backend)throw"Invalid state: AudioFeeder cannot flush before init";this._tempoChanger.flush(this.durationBuffered),this._backend.flush()},b.prototype.close=function(){this._backend&&(this._backend.close(),this._backend=null)},b.prototype.onstarved=null,b.prototype.onbufferlow=null,b.isSupported=function(){return!!Float32Array&&(d.isSupported()||e.isSupported())},b.initSharedAudioContext=function(){return d.isSupported()?d.initSharedAudioContext():null},a.exports=b}()},function(a,b){function c(a,b){if(a<1||a!==Math.round(a))throw"Invalid channel count for BufferQueue";this.channels=a,this.bufferSize=b,this.flush()}c.prototype.flush=function(){this._buffers=[],this._pendingBuffer=this.createBuffer(this.bufferSize),this._pendingPos=0},c.prototype.sampleCount=function(){var a=0;return this._buffers.forEach(function(b){a+=b[0].length}),a},c.prototype.createBuffer=function(a){for(var b=[],c=0;c<this.channels;c++)b[c]=new Float32Array(a);return b},c.prototype.validate=function(a){if(a.length!==this.channels)return!1;for(var b,c=0;c<a.length;c++){var d=a[c];if(!(d instanceof Float32Array))return!1;if(0==c)b=d.length;else if(d.length!==b)return!1}return!0},c.prototype.appendBuffer=function(a){if(!this.validate(a))throw"Invalid audio buffer passed to BufferQueue.appendBuffer";for(var b=a[0],c=b.length,d=this.channels,e=this._pendingPos,f=this._pendingBuffer,g=this.bufferSize,h=0;h<c;h++){for(var i=0;i<d;i++)f[i][e]=a[i][h];++e==g&&(this._buffers.push(f),e=this._pendingPos=0,f=this._pendingBuffer=this.createBuffer(g))}this._pendingPos=e},c.prototype.prependBuffer=function(a){if(!this.validate(a))throw"Invalid audio buffer passed to BufferQueue.prependBuffer";var b=this._buffers.slice(0);b.push(this.trimBuffer(this._pendingBuffer,0,this._pendingPos)),this.flush(),this.appendBuffer(a);for(var c=0;c<b.length;c++)this.appendBuffer(b[c])},c.prototype.nextBuffer=function(){if(this._buffers.length)return this._buffers.shift();var a=this.trimBuffer(this._pendingBuffer,0,this._pendingPos);return this._pendingBuffer=this.createBuffer(this.bufferSize),this._pendingPos=0,a},c.prototype.trimBuffer=function(a,b,c){var d=a[0].length,e=b+Math.min(c,d);if(0==b&&e>=d)return a;for(var f=[],g=0;g<this.channels;g++)f[g]=a[g].subarray(b,e);return f},a.exports=c},function(a,b,c){!function(){function b(a,c,d){var f=d.audioContext||b.initSharedAudioContext();if(this._context=f,this.output=d.output||f.destination,this.rate=f.sampleRate,this.channels=2,d.bufferSize&&(this.bufferSize=0|d.bufferSize),this.bufferThreshold=2*this.bufferSize,this._bufferQueue=new e(this.channels,this.bufferSize),this._playbackTimeAtBufferTail=f.currentTime,this._queuedTime=0,this._delayedTime=0,this._dropped=0,this._liveBuffer=this._bufferQueue.createBuffer(this.bufferSize),f.createScriptProcessor)this._node=f.createScriptProcessor(this.bufferSize,0,this.channels);else{if(!f.createJavaScriptNode)throw new Error("Bad version of web audio API?");this._node=f.createJavaScriptNode(this.bufferSize,0,this.channels)}}var d=window.AudioContext||window.webkitAudioContext,e=c(1),f=c(3);b.prototype.bufferSize=4096,b.prototype.bufferThreshold=8192,b.prototype._volume=1,Object.defineProperty(b.prototype,"volume",{get:function(){return this._volume},set:function(a){this._volume=+a}}),b.prototype._muted=!1,Object.defineProperty(b.prototype,"muted",{get:function(){return this._muted},set:function(a){this._muted=!!a}}),b.prototype._audioProcess=function(a){var b,c,d,e,g;g="number"==typeof a.playbackTime?a.playbackTime:this._context.currentTime+this.bufferSize/this.rate;var h=this._playbackTimeAtBufferTail;if(h<g&&(this._delayedTime+=g-h),this._bufferQueue.sampleCount()<this.bufferSize&&this.onstarved&&this.onstarved(),this._bufferQueue.sampleCount()<this.bufferSize){for(b=0;b<this.channels;b++)for(d=a.outputBuffer.getChannelData(b),e=0;e<this.bufferSize;e++)d[e]=0;return void this._dropped++}var i=this.muted?0:this.volume,j=this._bufferQueue.nextBuffer();if(j[0].length<this.bufferSize)throw"Audio buffer not expected length.";for(b=0;b<this.channels;b++)for(c=j[b],this._liveBuffer[b].set(j[b]),d=a.outputBuffer.getChannelData(b),e=0;e<c.length;e++)d[e]=c[e]*i;this._queuedTime+=this.bufferSize/this.rate,this._playbackTimeAtBufferTail=g+this.bufferSize/this.rate,this._bufferQueue.sampleCount()<Math.max(this.bufferSize,this.bufferThreshold)&&this.onbufferlow&&f(this.onbufferlow.bind(this))},b.prototype._samplesQueued=function(){var a=this._bufferQueue.sampleCount(),b=Math.floor(this._timeAwaitingPlayback()*this.rate);return a+b},b.prototype._timeAwaitingPlayback=function(){return Math.max(0,this._playbackTimeAtBufferTail-this._context.currentTime)},b.prototype.getPlaybackState=function(){return{playbackPosition:this._queuedTime-this._timeAwaitingPlayback(),samplesQueued:this._samplesQueued(),dropped:this._dropped,delayed:this._delayedTime}},b.prototype.waitUntilReady=function(a){a()},b.prototype.appendBuffer=function(a){this._bufferQueue.appendBuffer(a)},b.prototype.start=function(){this._node.onaudioprocess=this._audioProcess.bind(this),this._node.connect(this.output),this._playbackTimeAtBufferTail=this._context.currentTime},b.prototype.stop=function(){if(this._node){var a=this._timeAwaitingPlayback();if(a>0){var b=Math.round(a*this.rate),c=this._liveBuffer?this._liveBuffer[0].length:0;b>c?(this._bufferQueue.prependBuffer(this._liveBuffer),this._bufferQueue.prependBuffer(this._bufferQueue.createBuffer(b-c))):this._bufferQueue.prependBuffer(this._bufferQueue.trimBuffer(this._liveBuffer,c-b,b)),this._playbackTimeAtBufferTail-=a}this._node.onaudioprocess=null,this._node.disconnect()}},b.prototype.flush=function(){this._bufferQueue.flush()},b.prototype.close=function(){this.stop(),this._context=null},b.prototype.onstarved=null,b.prototype.onbufferlow=null,b.isSupported=function(){return!!d},b.sharedAudioContext=null,b.initSharedAudioContext=function(){if(!b.sharedAudioContext&&b.isSupported()){var a,c=new d;if(c.createScriptProcessor)a=c.createScriptProcessor(1024,0,2);else{if(!c.createJavaScriptNode)throw new Error("Bad version of web audio API?");a=c.createJavaScriptNode(1024,0,2)}a.connect(c.destination),a.disconnect(),b.sharedAudioContext=c}return b.sharedAudioContext},a.exports=b}()},function(a,b){a.exports=function(){if("undefined"!=typeof window.setImmediate)return window.setImmediate;if(window&&window.postMessage){var a=[];return window.addEventListener("message",function(b){if(b.source===window){var c=b.data;if("object"==typeof c&&c.nextTickBrowserPingMessage){var d=a.pop();d&&d()}}}),function(b){a.push(b),window.postMessage({nextTickBrowserPingMessage:!0},document.location.toString())}}return function(a){setTimeout(a,0)}}()},function(a,b,c){!function(){function b(a){for(var b=new Uint8Array(a),c=b.length,d="",e=0;e<c;e+=8)d+=h[b[e]],d+=h[b[e+1]],d+=h[b[e+2]],d+=h[b[e+3]],d+=h[b[e+4]],d+=h[b[e+5]],d+=h[b[e+6]],d+=h[b[e+7]];return d}function d(a){this.init(a)}var e=c(5),f=c(3),g=function(a,b,c){c=c||{};var g={};"string"==typeof c.base&&(g.swf=c.base+"/"+e),c.bufferSize&&(this.bufferSize=0|c.bufferSize),this._flashaudio=new d(g),this._flashBuffer="",this._cachedFlashState=null,this._cachedFlashTime=0,this._cachedFlashInterval=185,this._waitUntilReadyQueue=[],this.onready=function(){for(this._flashaudio.flashElement.setBufferSize(this.bufferSize),this._flashaudio.flashElement.setBufferThreshold(this.bufferThreshold);this._waitUntilReadyQueue.length;){var a=this._waitUntilReadyQueue.shift();a.apply(this)}},this.onlog=function(a){console.log("AudioFeeder FlashBackend: "+a)},this.bufferThreshold=2*this.bufferSize;var h={ready:"sync",log:"sync",starved:"sync",bufferlow:"async"};this._callbackName="AudioFeederFlashBackendCallback"+this._flashaudio.id;window[this._callbackName]=function(a){var b=h[a],c=this["on"+a];b&&c&&("async"===b?f(c.bind(this)):(c.apply(this,Array.prototype.slice.call(arguments,1)),this._flushFlashBuffer()))}.bind(this)};g.prototype.rate=44100,g.prototype.channels=2,g.prototype.bufferSize=4096,g.prototype._bufferThreshold=8192,Object.defineProperty(g.prototype,"bufferThreshold",{get:function(){return this._bufferThreshold},set:function(a){this._bufferThreshold=0|a,this.waitUntilReady(function(){this._flashaudio.flashElement.setBufferThreshold(this._bufferThreshold)}.bind(this))}}),g.prototype._volume=1,Object.defineProperty(g.prototype,"volume",{get:function(){return this._volume},set:function(a){this._volume=+a,this.waitUntilReady(this._flashVolumeUpdate.bind(this))}}),g.prototype._muted=!1,Object.defineProperty(g.prototype,"muted",{get:function(){return this._muted},set:function(a){this._muted=!!a,this.waitUntilReady(this._flashVolumeUpdate.bind(this))}}),g.prototype._paused=!0,g.prototype._flashVolumeUpdate=function(){this._flashaudio&&this._flashaudio.flashElement&&this._flashaudio.flashElement.setVolume&&this._flashaudio.flashElement.setVolume(this.muted?0:this.volume)},g.prototype._resampleFlash=function(a){for(var b=a[0].length,c=new Float32Array(2*b),d=a[0],e=this.channels>1?a[1]:d,f=0;f<b;f++){var g=f,h=2*f;c[h]=d[g],c[h+1]=e[g]}return c};for(var h=[],i=0;i<256;i++)h[i]=String.fromCharCode(i+57344);g.prototype._flushFlashBuffer=function(){var a=this._flashBuffer,b=this._flashaudio.flashElement;this._flashBuffer="",a.length>0&&(this._cachedFlashState=b.write(a),this._cachedFlashTime=Date.now())},g.prototype.appendBuffer=function(a){var c=this._resampleFlash(a);if(c.length>0){var d=b(c.buffer);this._flashBuffer+=d,this._flashBuffer.length>=8*this.bufferSize&&this._flushFlashBuffer()}},g.prototype.getPlaybackState=function(){if(this._flashaudio&&this._flashaudio.flashElement&&this._flashaudio.flashElement.write){var a,b=Date.now(),c=this._paused?0:b-this._cachedFlashTime;if(this._cachedFlashState&&c<this._cachedFlashInterval){var d=this._cachedFlashState;a={playbackPosition:d.playbackPosition+c/1e3,samplesQueued:d.samplesQueued-Math.max(0,Math.round(c*this.rate/1e3)),dropped:d.dropped,delayed:d.delayed}}else a=this._flashaudio.flashElement.getPlaybackState(),this._cachedFlashState=a,this._cachedFlashTime=b;return a.samplesQueued+=this._flashBuffer.length/8,a}return{playbackPosition:0,samplesQueued:0,dropped:0,delayed:0}},g.prototype.waitUntilReady=function(a){this._flashaudio&&this._flashaudio.flashElement.write?a.apply(this):this._waitUntilReadyQueue.push(a)},g.prototype.start=function(){this._flushFlashBuffer(),this._flashaudio.flashElement.start(),this._paused=!1,this._cachedFlashState=null},g.prototype.stop=function(){this._flashaudio.flashElement.stop(),this._paused=!0,this._cachedFlashState=null},g.prototype.flush=function(){this._flashBuffer="",this._flashaudio.flashElement.flush(),this._cachedFlashState=null},g.prototype.close=function(){this.stop();var a=this._flashaudio.flashWrapper;a.parentNode.removeChild(a),this._flashaudio=null,delete window[this._callbackName]},g.prototype.onstarved=null,g.prototype.onbufferlow=null,g.isSupported=function(){if(navigator.userAgent.indexOf("Trident")!==-1)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash");return!0}catch(a){return!1}return!1},d.nextId=1,d.prototype={nextId:null,swf:e,flashWrapper:null,flashElement:null,init:function(a){var b=this;b.id=d.nextId++,a&&"undefined"!=typeof a.swf&&(b.swf=a.swf),b.flashWrapper=document.createElement("div"),b.flashWrapper.id="dynamicaudio-flashwrapper-"+b.id;var c=b.flashWrapper.style;c.position="fixed",c.width="11px",c.height="11px",c.bottom=c.left="0px",c.overflow="hidden",b.flashElement=document.createElement("div"),b.flashElement.id="dynamicaudio-flashelement-"+b.id,b.flashWrapper.appendChild(b.flashElement),document.body.appendChild(b.flashWrapper);var e=b.flashElement.id,f='<param name="FlashVars" value="objectId='+b.id+'">';b.flashWrapper.innerHTML="<object id='"+e+"' width='10' height='10' type='application/x-shockwave-flash' data='"+b.swf+"' style='visibility: visible;'><param name='allowscriptaccess' value='always'>"+f+"</object>",b.flashElement=document.getElementById(e)}},a.exports=g}()},function(a,b,c){a.exports=c.p+"dynamicaudio.swf?version=2c1ce3bfb7e6fa65c26d726a00017a94"},function(a,b,c){!function(b,c){a.exports=c()}(window,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{enumerable:!0,get:d})},b.r=function(a){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},b.t=function(a,c){if(1&c&&(a=b(a)),8&c)return a;if(4&c&&"object"==typeof a&&a&&a.__esModule)return a;var d=Object.create(null);if(b.r(d),Object.defineProperty(d,"default",{enumerable:!0,value:a}),2&c&&"string"!=typeof a)for(var e in a)b.d(d,e,function(b){return a[b]}.bind(null,e));return d},b.n=function(a){var c=a&&a.__esModule?function(){return a["default"]}:function(){return a};return b.d(c,"a",c),c},b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},b.p="",b(b.s=1)}([function(a,b){var c={float_array:function(a){return new Float32Array(a)},blit:function(a,b,c,d,e){c.set(a.subarray(b,b+e),d)}};a.exports=c},function(a,b,c){!function(){var b=c(0),d=c(2),e=function(a){a=a||{};var c=a.sampleRate||44100,e=a.wsizeLog||11,f=a.tempo||1,g=(a.numChannels||2,.9),h=1e-8,i=Math.pow(2,50/1200)-1,j=.1,k=1<<e,l=d(e),m=1<<e-2;m-=m%100;for(var n=b.float_array(k+m+5),o=b.float_array(k+m+5),p=m,q=m,r=b.float_array(k),s=0;s<k;s++)r[s]=.5*(1-Math.cos(2*Math.PI*s/k));for(var t=(k>>1)+1,u=b.float_array(t),v=b.float_array(t),w=b.float_array(t),x=b.float_array(t),y=b.float_array(t),z=b.float_array(t),A=(t>>1)+1,B=[0,0],C=[],D=[],E=[],F=[],s=0;s<2;s++)C.push(b.float_array(A)),D.push(b.float_array(A)),E.push(b.float_array(A)),F.push(b.float_array(t));var G=b.float_array(A),H=b.float_array(A),I=0,J=0,K=[{in_time:0,out_time:0,tempo:f}],L=0,M=0,N=1,O=0,P=0,Q=0,R=0,S={};S.mapOutputToInputTime=function(a){for(var b=K.length-1;a<K[b].out_time&&b>0;)b--;var c=K[b];return c.in_time+c.tempo*(a-c.out_time)},S.flush=function(a){O=0,B=[0,0],M=0,R=0,Q=0;for(var b=0;b<2;b++)for(var c=0;c<t;c++)F[b][c]=0;for(var b=0;b<n.length;b++)n[b]=0;for(var b=0;b<o.length;b++)o[b]=0;if(a){J=Math.max(0,J-a),I=S.mapOutputToInputTime(J);for(var d=K.length-1;J<=K[d].out_time&&d>=0;)K.pop(),d--;K.push({in_time:I,out_time:J,tempo:f})}};var T=function(a,b){for(var c=a.length/b|0,d=0,e=0;e<c;e++)d+=a[e*b];return g/d};S.getTempo=function(){return f},S.setTempo=function(a){p=q=m,a>=1?q=Math.round(p/a):p=Math.round(q*a),P=(1/a-1*q/p)*p,N=T(r,q),f=a;var b=K[K.length-1];b.out_time==J?b.tempo=a:K.push({in_time:I,out_time:J,tempo:a})},S.flush(0),S.setTempo(f);var U=function(a,b,c){var d=Math.floor(c),e=d%2==1?-1:1;return Math.atan2(e*(b[d]-b[d+1]),e*(a[d]-a[d+1]))},V=function(a){return a-2*Math.PI*Math.round(a/(2*Math.PI))},W=function(a,b,c,d,e){var f=2*Math.PI/k*.5*(d+b)*p,g=V(a-c-f);return(g+f)*e},X=function(a,b){for(var c=0,d=0;d<a.length;d++)a[d]>c&&(c=a[d]);var e=h*c,f=1,g=1;b[0]=1;for(var d=2;d<a.length;d++){var j=d*i;if(a[d]>e&&a[d]>a[d-1]&&a[d]>=a[d+1]){var k=d+(a[d-1]-a[d+1])/(2*(a[d-1]-2*a[d]+a[d+1]));k-b[f-1]>j?(b[f++]=k,g=d):a[d]>a[g]&&(b[f-1]=k,g=d)}}return f},Y=function(a,b,c,d,e,f){for(var g=a%2,h=1-g,l=F[h],m=B[h],n=C[h],o=D[h],p=E[h],q=F[g],r=1;r<q.length;r++)q[r]=b[r]*b[r]+c[r]*c[r];var s=C[g],t=B[g]=X(q,s),u=D[g],v=E[g];if(0!=a&&0!=t){for(var w=0,x=0;x<t;x++){for(var y=s[x];s[x]>n[w]&&w!=m;)++w;var z=w;w>0&&y-n[w-1]<n[w]-y&&(z=w-1);var A=y*i;if(Math.abs(n[z]-y)<A&&l[Math.round(n[z])]>j*q[Math.round(y)]){var I=U(b,c,y),J=o[z]+p[z]+W(I,y,o[z],n[z],f),K=J-I;u[x]=I,v[x]=K,G[x]=Math.cos(K),H[x]=Math.sin(K)}else u[x]=U(b,c,y),v[x]=0,G[x]=1,H[x]=0}s[t]=2*k;for(var z=0,L=s[z],M=s[z+1],N=G[z],O=H[z],r=1;r<b.length-1;r++){r>=L&&r-L>M-r&&(++z,L=s[z],M=s[z+1],N=G[z],O=H[z]);var P=b[r]*N-c[r]*O,Q=b[r]*O+c[r]*N;b[r]=P,c[r]=Q}}else for(var x=0;x<t;x++){var y=s[x];o[x]=p[x]=U(b,c,y)}},Z=function(){O+=2*P;var a=0|O;O-=a;for(var c=0;c<k;c++)l.m_re[c]=r[c]*n[c],l.m_im[c]=r[c]*n[p+c];b.blit(n,2*p,n,0,k-p),l.inplace(!1),l.unpack(u,v,w,x);var d=1*q/p;Y(L,u,v,y,z,d);var e=1*(q+a)/p;Y(L+1,w,x,u,v,e),b.blit(w,0,y,0,t),b.blit(x,0,z,0,t),l.repack(u,v,w,x),l.inplace(!0);var f=o.length;b.blit(o,M,o,0,f-M);for(var c=f-M;c<f;c++)o[c]=0;for(var g=0,h=N,c=0;c<q;c++)Math.abs(2*l.m_re[c])>g&&(g=Math.abs(2*l.m_re[c]));for(var c=0;c<k-q;c++)Math.abs(l.m_re[c+q+a]+l.m_im[c])>g&&(g=Math.abs(l.m_re[c+q+a]+l.m_im[c]));for(var c=k-q;c<k;c++)Math.abs(2*l.m_im[c])>g&&(g=Math.abs(2*l.m_im[c]));var i=1/Math.floor(1*k/(2*q));h*g>i&&(h=i/g);for(var c=0;c<k;c++)o[c]+=h*l.m_re[c],o[c+q+a]+=h*l.m_im[c];return L+=2,M=2*q+a};return S.process=function(a){var d=a[0].length,e=a[0];if(a.length>1){e=b.float_array(a[0].length);for(var g=1/a.length,h=0;h<a.length;h++)for(var i=0;i<d;i++)e[i]+=g*a[h][i]}if(1==f){if(R+Q>0){for(var j=R+Q+d,l=[],h=0;h<a.length;h++){var m=b.float_array(j);b.blit(o,0,m,0,R),b.blit(n,0,m,R,Q),b.blit(a[h],0,m,R+Q,d),l.push(m)}S.flush(0),d=j,a=l}return I+=d/c,J+=d/c,a}var r=Q+d-(k-p),s=2*Math.floor(Math.max(0,r)/(2*p)),t=R+q*s+Math.floor(O+P*s);R>t&&(t=R);var u=b.float_array(t);b.blit(o,0,u,0,R);for(var v=0,w=R,x=0,y=0;;){var z=k+p-Q;if(v+z>d){b.blit(e,v,n,Q,d-v),Q+=d-v,v=d;break}z<=0?Q-=2*p:(b.blit(e,v,n,Q,z),v+=z,Q=k-p),y=Z(),I+=2*p/c,J+=y/c,x=w+y-t,x<0&&(x=0),b.blit(o,0,u,w,y-x),w+=y}b.blit(o,y-x,o,0,x),R=x;for(var A=[],h=0;h<a.length;h++)A.push(u);return A},S};a.exports=e}()},function(a,b,c){"use strict";var d=c(0),e=function(a){for(var b=1<<a,c={m_logN:a,m_N:b,m_invN:1/b,m_re:d.float_array(b),m_im:d.float_array(b),m_revTgt:new Array(b)},e=0;e<b;e++){for(var f=e,g=0,h=0;h<a;h++)g<<=1,g|=1&f,f>>=1;c.m_revTgt[e]=g}c.twiddleRe=d.float_array(c.m_logN),c.twiddleIm=d.float_array(c.m_logN);for(var i=1,j=0;j<c.m_logN;j++){var k=2*i*Math.PI*c.m_invN;c.twiddleRe[j]=Math.cos(k),c.twiddleIm[j]=Math.sin(k),i<<=1}c.inplace=function(a){var b=c.m_re,d=c.m_im,e=c.m_N,f=c.m_logN,g=e>>1,h=e>>1,i=e;if(a)for(var j=1/e,k=0;k<e;k++)b[k]*=j,d[k]*=j;for(var l=0;l<f;l++){var m=c.twiddleRe[l],n=c.twiddleIm[l];a||(n*=-1);for(var o=0;o<e;){for(var p=o,q=o+h,r=1,s=0,t=0;t<g;t++){var u=b[p],v=d[p],w=b[q],x=d[q];b[p]=u+w,d[p]=v+x,w=u-w,x=v-x,b[q]=w*r-x*s,d[q]=w*s+x*r,p++,q++;var y=r;r=r*m-s*n,s=y*n+s*m}o+=i}g>>=1,h>>=1,i>>=1}for(var z,A,B=c.m_revTgt,C=0;C<e;C++)B[C]>C&&(z=B[C],A=b[z],b[z]=b[C],b[C]=A,A=d[z],d[z]=d[C],d[C]=A)};var l=b>>1;return c.unpack=function(a,d,e,f){a[0]=c.m_re[0],e[0]=c.m_im[0],d[0]=f[0]=0,a[l]=c.m_re[l],e[l]=c.m_im[l],d[l]=f[l]=0;for(var g=1;g<l;g++)a[g]=(c.m_re[g]+c.m_re[b-g])/2,d[g]=(c.m_im[g]-c.m_im[b-g])/2,e[g]=(c.m_im[g]+c.m_im[b-g])/2,f[g]=(-c.m_re[g]+c.m_re[b-g])/2},c.repack=function(a,d,e,f){c.m_re[0]=a[0],c.m_im[0]=e[0],c.m_re[l]=a[l],c.m_im[l]=e[l];for(var g=1;g<l;g++)c.m_re[g]=a[g]-f[g],c.m_im[g]=d[g]+e[g],c.m_re[b-g]=a[g]+f[g],c.m_im[b-g]=-d[g]+e[g]},c};a.exports=e}])})}])});

@@ -61,12 +61,8 @@ var demo =

sampleCounter = 0,
feeder = new AudioFeeder();
feeder = new AudioFeeder(),
initialized = false;
start.disabled = true;
feeder.init(channels, rate);
feeder.waitUntilReady(function() {
start.disabled = false;
});
function bufferSineWave(time) {
var freq = 261, // middle C
shellFreq = 0.5, // fade in/out over 2 seconds
chunkSamples = Math.round(time * rate), // buffer 1s at a time

@@ -78,3 +74,4 @@ samples = Math.ceil(chunkSamples / freq) * freq,

for (var i = 0; i < samples; i++) {
buffer[i] = Math.sin((sampleCounter / rate) * freq * 2 * Math.PI);
buffer[i] = Math.sin((sampleCounter / rate) * freq * 2 * Math.PI)
* Math.sin((sampleCounter / rate) * shellFreq * 2 * Math.PI);
sampleCounter++;

@@ -90,4 +87,14 @@ }

bufferSineWave(1); // pre-buffer 1s
feeder.start();
var startFn = function() {
feeder.tempo = document.querySelector('#tempo').value / 100;
bufferSineWave(1); // pre-buffer 1s
feeder.start();
};
if (!initialized) {
feeder.init(channels, rate);
feeder.waitUntilReady(startFn);
initialized = true;
} else startFn();
});

@@ -103,3 +110,3 @@

console.log('buffer low');
while (feeder.durationBuffered < feeder.bufferThreshold * 2) {
while (feeder.durationBuffered * feeder.tempo < feeder.bufferThreshold * 2) {
bufferSineWave(1);

@@ -126,2 +133,7 @@ }

var tempo = document.querySelector('#tempo');
tempo.addEventListener('change', function() {
feeder.tempo = this.value / 100;
});
start.disabled = false;

@@ -128,0 +140,0 @@ };

{
"name": "audio-feeder",
"version": "0.4.20",
"version": "0.4.21",
"description": "Abstraction for streaming raw PCM audio in browser via Web Audio API.",

@@ -32,2 +32,3 @@ "main": "dist/AudioFeeder.js",

"devDependencies": {
"audio-tempo-changer.js": "^0.2.0",
"eslint": "^5.13.0",

@@ -40,2 +41,3 @@ "file-loader": "^0.8.5",

"webpack": "^1.12.2",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.1.14"

@@ -42,0 +44,0 @@ },

@@ -17,2 +17,4 @@ audio-feeder

## Updates
* 0.4.21 - 2019-05-28
* Included audio-tempo-changer to allow changing tempo of audio via .tempo attribute
* 0.4.20 - 2019-05-17

@@ -19,0 +21,0 @@ * Fix for running Flash path when embedded into strict mode

@@ -14,12 +14,8 @@ module.exports = function demo() {

sampleCounter = 0,
feeder = new AudioFeeder();
feeder = new AudioFeeder(),
initialized = false;
start.disabled = true;
feeder.init(channels, rate);
feeder.waitUntilReady(function() {
start.disabled = false;
});
function bufferSineWave(time) {
var freq = 261, // middle C
shellFreq = 0.5, // fade in/out over 2 seconds
chunkSamples = Math.round(time * rate), // buffer 1s at a time

@@ -31,3 +27,4 @@ samples = Math.ceil(chunkSamples / freq) * freq,

for (var i = 0; i < samples; i++) {
buffer[i] = Math.sin((sampleCounter / rate) * freq * 2 * Math.PI);
buffer[i] = Math.sin((sampleCounter / rate) * freq * 2 * Math.PI)
* Math.sin((sampleCounter / rate) * shellFreq * 2 * Math.PI);
sampleCounter++;

@@ -43,4 +40,14 @@ }

bufferSineWave(1); // pre-buffer 1s
feeder.start();
var startFn = function() {
feeder.tempo = document.querySelector('#tempo').value / 100;
bufferSineWave(1); // pre-buffer 1s
feeder.start();
};
if (!initialized) {
feeder.init(channels, rate);
feeder.waitUntilReady(startFn);
initialized = true;
} else startFn();
});

@@ -56,3 +63,3 @@

console.log('buffer low');
while (feeder.durationBuffered < feeder.bufferThreshold * 2) {
while (feeder.durationBuffered * feeder.tempo < feeder.bufferThreshold * 2) {
bufferSineWave(1);

@@ -79,3 +86,8 @@ }

var tempo = document.querySelector('#tempo');
tempo.addEventListener('change', function() {
feeder.tempo = this.value / 100;
});
start.disabled = false;
};

@@ -5,3 +5,4 @@ (function() {

WebAudioBackend = require('./web-audio-backend.js'),
FlashBackend = require('./flash-backend.js');
FlashBackend = require('./flash-backend.js'),
AudioTempoChanger = require('audio-tempo-changer.js');

@@ -38,3 +39,4 @@

* @typedef {Object} PlaybackState
* @property {number} playbackPosition - total seconds so far of audio data that have played
* @property {number} playbackPosition - total seconds so far of input audio data that have played (pre tempo change)
* @property {number} outputPlaybackPosition - total seconds so far of audio that has been played (post tempo change)
* @property {number} samplesQueued - number of samples at target rate that are queued up for playback

@@ -60,2 +62,3 @@ * @property {number} dropped - number of underrun events, when we had to play silence due to data starvation

this._resampleLastSampleData = undefined;
this._tempoChanger = null; // Initialized at init
};

@@ -151,4 +154,5 @@

/**
* Current playback position, in seconds.
* Current playback position, in seconds, in input time (i.e. pre tempo change)
* This compensates for drops and underruns, and is suitable for a/v sync.

@@ -171,2 +175,20 @@ *

/**
* Current playback position, in seconds, in output time (i.e. post tempo change)
* Also compensates for drops and underruns, and is suitable for a/v sync.
*
* @type {number}
* @readonly
*/
Object.defineProperty(AudioFeeder.prototype, 'outputPlaybackPosition', {
get: function getOutputPlaybackPosition() {
if (this._backend) {
var playbackState = this.getPlaybackState();
return playbackState.outputPlaybackPosition;
} else {
return 0;
}
}
});
/**
* Duration of remaining queued data, in seconds.

@@ -247,2 +269,25 @@ *

/**
* Tempo multiplier, defaults to 1.0.
* @name volume
* @type {number}
*/
Object.defineProperty(AudioFeeder.prototype, 'tempo', {
get: function getTempo() {
if (this._tempoChanger) {
return this._tempoChanger.getTempo();
} else {
throw 'Invalid state: cannot get tempo before init';
}
},
set: function setTempo(val) {
if (this._tempoChanger) {
this._tempoChanger.setTempo(val);
} else {
throw 'Invalid state: cannot set tempo before init';
}
}
});
/**
* Start setting up for output with the given channel count and sample rate.

@@ -272,2 +317,5 @@ * Audio data you provide will be resampled if necessary to whatever the

// Initialize tempo changer (NB! no "new")
this._tempoChanger = AudioTempoChanger({ sampleRate: this.targetRate, numChannels: numChannels, tempo: 1.0 });
// Pass through the starved event

@@ -314,3 +362,3 @@ this._backend.onstarved = (function() {

outputLen = inputLen * targetRate / rate + previousFractional,
outputSamples = Math.trunc(outputLen),
outputSamples = Math.floor(outputLen),
remainingFractional = (outputLen - outputSamples);

@@ -404,2 +452,9 @@

var samples = this._resample(sampleData);
// NB! it is important all samples go through tempoChanger
// it is built to switch to just copying if tempo = 1.0
// but it still needs the samples to transition smoothly
// and keep an accurate time map
samples = this._tempoChanger.process(samples);
this._backend.appendBuffer(samples);

@@ -418,3 +473,6 @@ } else {

if (this._backend) {
return this._backend.getPlaybackState();
var state = this._backend.getPlaybackState();
state.outputPlaybackPosition = state.playbackPosition; // as _backend works only in output time
state.playbackPosition = this._tempoChanger.mapOutputToInputTime(state.outputPlaybackPosition);
return state;
} else {

@@ -478,2 +536,3 @@ throw 'Invalid state: AudioFeeder cannot getPlaybackState before init';

if (this._backend) {
this._tempoChanger.flush(this.durationBuffered);
this._backend.flush();

@@ -480,0 +539,0 @@ } else {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc