forked from xiangyuecn/Recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecorder.wav.min.js
6 lines (6 loc) · 17 KB
/
recorder.wav.min.js
1
2
3
4
5
6
/*
录音
https://github.com/xiangyuecn/Recorder
src: recorder-core.js,engine/wav.js
*/
!function(I){"use strict";var d=function(){},U=function(e){return new t(e)};U.LM="2023-02-01 18:05";var A="Recorder",C="getUserMedia",P="srcSampleRate",W="sampleRate",L="catch";U.IsOpen=function(){var e=U.Stream;if(e){var t=e.getTracks&&e.getTracks()||e.audioTracks||[],n=t[0];if(n){var r=n.readyState;return"live"==r||r==n.LIVE}}return!1},U.BufferSize=4096,U.Destroy=function(){for(var e in O(A+" Destroy"),S(),n)n[e]()};var n={};U.BindDestroy=function(e,t){n[e]=t},U.Support=function(){var e=navigator.mediaDevices||{};return e[C]||(e=navigator)[C]||(e[C]=e.webkitGetUserMedia||e.mozGetUserMedia||e.msGetUserMedia),!!e[C]&&(U.Scope=e,!!U.GetContext())},U.GetContext=function(){var e=I.AudioContext;return e||(e=I.webkitAudioContext),e?(U.Ctx&&"closed"!=U.Ctx.state||(U.Ctx=new e,U.BindDestroy("Ctx",function(){var e=U.Ctx;e&&e.close&&(e.close(),U.Ctx=0)})),U.Ctx):null};var T="ConnectEnableWebM";U[T]=!0;var D="ConnectEnableWorklet";U[D]=!1;var y=function(e,c){var f,i,u,l=e.BufferSize||U.BufferSize,v=U.Ctx,p=e.Stream,s=function(e){var t=p._m=v.createMediaStreamSource(p),n=v.destination,r="createMediaStreamDestination";v[r]&&(n=v[r]()),t.connect(e),e.connect(n)},h="",g=p._call,m=function(e){for(var t in g){for(var n=e.length,r=new Int16Array(n),a=0,o=0;o<n;o++){var i=Math.max(-1,Math.min(1,e[o]));i=i<0?32768*i:32767*i,r[o]=i,a+=Math.abs(i)}for(var s in g)g[s](r,a);return}},d="ScriptProcessor",C="audioWorklet",y=A+" "+C,S="RecProc",_="MediaRecorder",b=_+".WebM.PCM",k=v.createScriptProcessor||v.createJavaScriptNode,M="。由于"+C+"内部1秒375次回调,在移动端可能会有性能问题导致回调丢失录音变短,PC端无影响,暂不建议开启"+C+"。",w=function(){i=p.isWorklet=!1,R(p),O("Connect采用老的"+d+","+(U[D]?"但已":"可")+"设置"+A+"."+D+"=true尝试启用"+C+h+M,3);var e=p._p=k.call(v,l,1,1);s(e);var t="_D220626",n=U[t];n&&O("Use "+A+"."+t,3),e.onaudioprocess=function(e){var t=e.inputBuffer.getChannelData(0);n?(t=new Float32Array(t),setTimeout(function(){m(t)})):m(t)}},x=function(){f=p.isWebM=!1,F(p),i=p.isWorklet=!k||U[D];var t=I.AudioWorkletNode;if(i&&v[C]&&t){var r=function(){return i&&p._na},a=p._na=function(){""!==u&&(clearTimeout(u),u=setTimeout(function(){u=0,r()&&(O(C+"未返回任何音频,恢复使用"+d,3),k&&w())},500))},o=function(){if(r()){var e=p._n=new t(v,S,{processorOptions:{bufferSize:l}});s(e),e.port.onmessage=function(e){u&&(clearTimeout(u),u=""),r()?m(e.data.val):i||O(C+"多余回调",3)},O("Connect采用"+C+",设置"+A+"."+D+"=false可恢复老式"+d+h+M,3)}};v.resume()[g&&"finally"](function(){if(r())if(v[S])o();else{var e,t,n=(t="class "+S+" extends AudioWorkletProcessor{",t+="constructor "+(e=function(e){return e.toString().replace(/^function|DEL_/g,"").replace(/\$RA/g,y)})(function(e){DEL_super(e);var t=this,n=e.processorOptions.bufferSize;t.bufferSize=n,t.buffer=new Float32Array(2*n),t.pos=0,t.port.onmessage=function(e){e.data.kill&&(t.kill=!0,console.log("$RA kill call"))},console.log("$RA .ctor call",e)}),t+="process "+e(function(e,t,n){var r=this,a=r.bufferSize,o=r.buffer,i=r.pos;if((e=(e[0]||[])[0]||[]).length){o.set(e,i);var s=~~((i+=e.length)/a)*a;if(s){this.port.postMessage({val:o.slice(0,s)});var c=o.subarray(s,i);(o=new Float32Array(2*a)).set(c),i=c.length,r.buffer=o}r.pos=i}return!r.kill}),t+='}try{registerProcessor("'+S+'", '+S+')}catch(e){console.error("'+y+'注册失败",e)}',"data:text/javascript;base64,"+btoa(unescape(encodeURIComponent(t))));v[C].addModule(n).then(function(e){r()&&(v[S]=1,o(),u&&a())})[L](function(e){O(C+".addModule失败",1,e),r()&&w()})}})}else w()};!function(){var e=I[_],t="ondataavailable",n="audio/webm; codecs=pcm";f=p.isWebM=U[T];var r=e&&t in e.prototype&&e.isTypeSupported(n);if(h=r?"":"(此浏览器不支持"+b+")",!c||!f||!r)return x();var a=function(){return f&&p._ra},o=(p._ra=function(){""!==u&&(clearTimeout(u),u=setTimeout(function(){a()&&(O(_+"未返回任何音频,降级使用"+C,3),x())},500))},Object.assign({mimeType:n},U.ConnectWebMOptions)),i=p._r=new e(p,o),s=p._rd={sampleRate:v[W]};i[t]=function(e){var t=new FileReader;t.onloadend=function(){if(a()){var e=z(new Uint8Array(t.result),s);if(!e)return;if(-1==e)return void x();u&&(clearTimeout(u),u=""),m(e)}else f||O(_+"多余回调",3)},t.readAsArrayBuffer(e.data)},i.start(~~(l/48)),O("Connect采用"+b+",设置"+A+"."+T+"=false可恢复使用"+C+"或老式"+d)}()},R=function(e){e._na=null,e._n&&(e._n.port.postMessage({kill:!0}),e._n.disconnect(),e._n=null)},F=function(e){e._ra=null,e._r&&(e._r.stop(),e._r=null)},S=function(e){var t=(e=e||U)==U,n=e.Stream;if(n&&(n._m&&(n._m.disconnect(),n._m=null),n._p&&(n._p.disconnect(),n._p.onaudioprocess=n._p=null),R(n),F(n),t)){for(var r=n.getTracks&&n.getTracks()||n.audioTracks||[],a=0;a<r.length;a++){var o=r[a];o.stop&&o.stop()}n.stop&&n.stop()}e.Stream=0};U.SampleData=function(e,t,n,r,a){r||(r={});var o=r.index||0,i=r.offset||0,s=r.frameNext||[];a||(a={});var c=a.frameSize||1;a.frameType&&(c="mp3"==a.frameType?1152:1);var f=e.length;f+1<o&&O("SampleData似乎传入了未重置chunk "+o+">"+f,3);for(var u=0,l=o;l<f;l++)u+=e[l].length;u=Math.max(0,u-Math.floor(i));var v=t/n;1<v?u=Math.floor(u/v):(v=1,n=t),u+=s.length;for(var p=new Int16Array(u),h=0,l=0;l<s.length;l++)p[h]=s[l],h++;for(;o<f;o++){for(var g=e[o],l=i,m=g.length;l<m;){var d=Math.floor(l),C=Math.ceil(l),y=l-d,S=g[d],_=C<m?g[C]:(e[o+1]||[S])[0]||0;p[h]=S+(_-S)*y,h++,l+=v}i=l-m}s=null;var b=p.length%c;if(0<b){var k=2*(p.length-b);s=new Int16Array(p.buffer.slice(k)),p=new Int16Array(p.buffer.slice(0,k))}return{index:o,offset:i,frameNext:s,sampleRate:n,data:p}},U.PowerLevel=function(e,t){var n=e/t||0;return n<1251?Math.round(n/1250*10):Math.round(Math.min(100,Math.max(0,100*(1+Math.log(n/1e4)/Math.log(10)))))},U.PowerDBFS=function(e){var t=Math.max(.1,e||0);return t=Math.min(t,32767),t=20*Math.log(t/32767)/Math.log(10),Math.max(-100,Math.round(t))},U.CLog=function(e,t){var n=new Date,r=("0"+n.getMinutes()).substr(-2)+":"+("0"+n.getSeconds()).substr(-2)+"."+("00"+n.getMilliseconds()).substr(-3),a=this&&this.envIn&&this.envCheck&&this.id,o=["["+r+" "+A+(a?":"+a:"")+"]"+e],i=arguments,s=I.console||{},c=2,f=s.log;for("number"==typeof t?f=1==t?s.error:3==t?s.warn:f:c=1;c<i.length;c++)o.push(i[c]);u?f&&f("[IsLoser]"+o[0],1<o.length?o:""):f.apply(s,o)};var O=function(){U.CLog.apply(this,arguments)},u=!0;try{u=!console.log.apply}catch(e){}var r=0;function t(e){this.id=++r,o();var t={type:"mp3",bitRate:16,sampleRate:16e3,onProcess:d};for(var n in e)t[n]=e[n];this.set=t,this._S=9,this.Sync={O:9,C:9}}U.Sync={O:9,C:9},U.prototype=t.prototype={CLog:O,_streamStore:function(){return this.set.sourceStream?this:U},open:function(e,n){var r=this,a=r._streamStore();e=e||d;var o=function(e,t){t=!!t,r.CLog("录音open失败:"+e+",isUserNotAllow:"+t,1),n&&n(e,t)},i=function(){r.CLog("open ok id:"+r.id),e(),r._SO=0},s=a.Sync,c=++s.O,f=s.C;r._O=r._O_=c,r._SO=r._S;var t=r.envCheck({envName:"H5",canProcess:!0});if(t)o("不能录音:"+t);else if(r.set.sourceStream){if(!U.GetContext())return void o("不支持此浏览器从流中获取录音");S(a),r.Stream=r.set.sourceStream,r.Stream._call={};try{y(a)}catch(e){return void o("从流中打开录音失败:"+e.message)}i()}else{var u=function(e,t){try{I.top.a}catch(e){return void o('无权录音(跨域,请尝试给iframe添加麦克风访问策略,如allow="camera;microphone")')}/Permission|Allow/i.test(e)?o("用户拒绝了录音权限",!0):!1===I.isSecureContext?o("浏览器禁止不安全页面录音,可开启https解决"):/Found/i.test(e)?o(t+",无可用麦克风"):o(t)};if(U.IsOpen())i();else if(U.Support()){var l=function(t){setTimeout(function(){t._call={};var e=U.Stream;e&&(S(),t._call=e._call),U.Stream=t,function(){if(f!=s.C||!r._O){var e="open被取消";return c==s.O?r.close():e="open被中断",o(e),!0}}()||(U.IsOpen()?(e&&r.CLog("发现同时多次调用open",1),y(a,1),i()):o("录音功能无效:无音频流"))},100)},v=function(e){var t=e.name||e.message||e.code+":"+e;r.CLog("请求录音权限错误",1,e),u(t,"无法录音:"+t)},p={noiseSuppression:!1,echoCancellation:!1},h=r.set.audioTrackSet;for(var g in h)p[g]=h[g];p.sampleRate=U.Ctx.sampleRate;try{var m=U.Scope[C]({audio:p},l,v)}catch(e){r.CLog(C,3,e),m=U.Scope[C]({audio:!0},l,v)}m&&m.then&&m.then(l)[L](v)}else u("","此浏览器不支持录音")}},close:function(e){e=e||d;var t=this,n=t._streamStore();t._stop();var r=n.Sync;if(t._O=0,t._O_!=r.O)return t.CLog("close被忽略(因为同时open了多个rec,只有最后一个会真正close)",3),void e();r.C++,S(n),t.CLog("close"),e()},mock:function(e,t){var n=this;return n._stop(),n.isMock=1,n.mockEnvInfo=null,n.buffers=[e],n.recSize=e.length,n[P]=t,n},envCheck:function(e){var t,n=this.set,r="CPU_BE";if(t||U[r]||!I.Int8Array||new Int8Array(new Int32Array([1]).buffer)[0]||(o(r),t="不支持CPU_BE架构"),!t){var a=n.type;this[a+"_envCheck"]?t=this[a+"_envCheck"](e,n):n.takeoffEncodeChunk&&(t=a+"类型"+(this[a]?"":"(未加载编码器)")+"不支持设置takeoffEncodeChunk")}return t||""},envStart:function(e,t){var n=this,r=n.set;n.isMock=e?1:0,n.mockEnvInfo=e,n.buffers=[],n.recSize=0,n.envInLast=0,n.envInFirst=0,n.envInFix=0,n.envInFixTs=[];var a=r[W];if(t<a?r[W]=t:a=0,n[P]=t,n.CLog(P+": "+t+" set."+W+": "+r[W]+(a?" 忽略"+a:""),a?3:0),n.engineCtx=0,n[r.type+"_start"]){var o=n.engineCtx=n[r.type+"_start"](r);o&&(o.pcmDatas=[],o.pcmSize=0)}},envResume:function(){this.envInFixTs=[]},envIn:function(e,t){var a=this,o=a.set,i=a.engineCtx,n=a[P],r=e.length,s=U.PowerLevel(t,r),c=a.buffers,f=c.length;c.push(e);var u=c,l=f,v=Date.now(),p=Math.round(r/n*1e3);a.envInLast=v,1==a.buffers.length&&(a.envInFirst=v-p);var h=a.envInFixTs;h.splice(0,0,{t:v,d:p});for(var g=v,m=0,d=0;d<h.length;d++){var C=h[d];if(3e3<v-C.t){h.length=d;break}g=C.t,m+=C.d}var y=h[1],S=v-g;if(S/3<S-m&&(y&&1e3<S||6<=h.length)){var _=v-y.t-p;if(p/5<_){var b=!o.disableEnvInFix;if(a.CLog("["+v+"]"+(b?"":"未")+"补偿"+_+"ms",3),a.envInFix+=_,b){var k=new Int16Array(_*n/1e3);r+=k.length,c.push(k)}}}var M=a.recSize,w=r,x=M+w;if(a.recSize=x,i){var I=U.SampleData(c,n,o[W],i.chunkInfo);i.chunkInfo=I,x=(M=i.pcmSize)+(w=I.data.length),i.pcmSize=x,c=i.pcmDatas,f=c.length,c.push(I.data),n=I[W]}var A=Math.round(x/n*1e3),L=c.length,T=u.length,D=function(){for(var e=R?0:-w,t=null==c[0],n=f;n<L;n++){var r=c[n];null==r?t=1:(e+=r.length,i&&r.length&&a[o.type+"_encode"](i,r))}if(t&&i)for(n=l,u[0]&&(n=0);n<T;n++)u[n]=null;t&&(e=R?w:0,c[0]=null),i?i.pcmSize+=e:a.recSize+=e},R=0,F="rec.set.onProcess";try{R=o.onProcess(c,s,A,n,f,D)}catch(e){console.error(F+"回调出错是不允许的,需保证不会抛异常",e)}var O=Date.now()-v;if(10<O&&1e3<a.envInFirst-v&&a.CLog(F+"低性能,耗时"+O+"ms",3),!0===R){var z=0;for(d=f;d<L;d++)null==c[d]?z=1:c[d]=new Int16Array(0);z?a.CLog("未进入异步前不能清除buffers",3):i?i.pcmSize-=w:a.recSize-=w}else D()},start:function(){var t=this,n=U.Ctx,e=1;if(t.set.sourceStream?t.Stream||(e=0):U.IsOpen()||(e=0),e)if(t.CLog("开始录音"),t._stop(),t.state=3,t.envStart(null,n[W]),t._SO&&t._SO+1!=t._S)t.CLog("start被中断",3);else{t._SO=0;var r=function(){3==t.state&&(t.state=1,t.resume())};if("suspended"==n.state){var a="AudioContext resume: ";t.CLog(a+"wait..."),n.resume().then(function(){t.CLog(a+n.state),r()})[L](function(e){t.CLog(a+n.state+" 可能无法录音:"+e.message,1,e),r()})}else r()}else t.CLog("未open",1)},pause:function(){var e=this;e.state&&(e.state=2,e.CLog("pause"),delete e._streamStore().Stream._call[e.id])},resume:function(){var e,n=this;if(n.state){n.state=1,n.CLog("resume"),n.envResume();var t=n._streamStore().Stream;t._call[n.id]=function(e,t){1==n.state&&n.envIn(e,t)},(e=t)._na&&e._na(),e._ra&&e._ra()}},_stop:function(e){var t=this,n=t.set;t.isMock||t._S++,t.state&&(t.pause(),t.state=0),!e&&t[n.type+"_stop"]&&(t[n.type+"_stop"](t.engineCtx),t.engineCtx=0)},stop:function(n,t,e){var r,a=this,o=a.set,i=a.envInLast-a.envInFirst,s=i&&a.buffers.length;a.CLog("stop 和start时差"+(i?i+"ms 补偿"+a.envInFix+"ms envIn:"+s+" fps:"+(s/i*1e3).toFixed(1):"-"));var c=function(){a._stop(),e&&a.close()},f=function(e){a.CLog("结束录音失败:"+e,1),t&&t(e),c()},u=function(e,t){if(a.CLog("结束录音 编码花"+(Date.now()-r)+"ms 音频时长"+t+"ms 文件大小"+e.size+"b"),o.takeoffEncodeChunk)a.CLog("启用takeoffEncodeChunk后stop返回的blob长度为0不提供音频数据",3);else if(e.size<Math.max(100,t/2))return void f("生成的"+o.type+"无效");n&&n(e,t),c()};if(!a.isMock){var l=3==a.state;if(!a.state||l)return void f("未开始录音"+(l?",开始录音前无用户交互导致AudioContext未运行":""));a._stop(!0)}var v=a.recSize;if(v)if(a.buffers[0])if(a[o.type]){if(a.isMock){var p=a.envCheck(a.mockEnvInfo||{envName:"mock",canProcess:!1});if(p)return void f("录音错误:"+p)}var h=a.engineCtx;if(a[o.type+"_complete"]&&h){var g=Math.round(h.pcmSize/o[W]*1e3);return r=Date.now(),void a[o.type+"_complete"](h,function(e){u(e,g)},f)}r=Date.now();var m=U.SampleData(a.buffers,a[P],o[W]);o[W]=m[W];var d=m.data;g=Math.round(d.length/o[W]*1e3),a.CLog("采样"+v+"->"+d.length+" 花:"+(Date.now()-r)+"ms"),setTimeout(function(){r=Date.now(),a[o.type](d,function(e){u(e,g)},function(e){f(e)})})}else f("未加载"+o.type+"编码器");else f("音频buffers被释放");else f("未采集到录音")}},I[A]&&(O("重复引入"+A,3),I[A].Destroy()),I[A]=U;var z=function(e,t){t.pos||(t.pos=[0],t.tracks={},t.bytes=[]);var n=t.tracks,r=[t.pos[0]],a=function(){t.pos[0]=r[0]},o=t.bytes.length,i=new Uint8Array(o+e.length);if(i.set(t.bytes),i.set(e,o),t.bytes=i,!t._ht){if(N(i,r),G(i,r),!E(N(i,r),[24,83,128,103]))return;for(N(i,r);r[0]<i.length;){var s=N(i,r),c=G(i,r),f=[0],u=0;if(!c)return;if(E(s,[22,84,174,107])){for(;f[0]<c.length;){var l=N(c,f),v=G(c,f),p=[0],h={channels:0,sampleRate:0};if(E(l,[174]))for(;p[0]<v.length;){var g=N(v,p),m=G(v,p),d=[0];if(E(g,[215])){var C=B(m);h.number=C,n[C]=h}else if(E(g,[131])){var C=B(m);1==C?h.type="video":2==C?(h.type="audio",u||(t.track0=h),h.idx=u++):h.type="Type-"+C}else if(E(g,[134])){for(var y="",S=0;S<m.length;S++)y+=String.fromCharCode(m[S]);h.codec=y}else if(E(g,[225]))for(;d[0]<m.length;){var _=N(m,d),b=G(m,d);if(E(_,[181])){var C=0,k=new Uint8Array(b.reverse()).buffer;4==b.length?C=new Float32Array(k)[0]:8==b.length?C=new Float64Array(k)[0]:O("WebM Track !Float",1,b),h[W]=Math.round(C)}else E(_,[98,100])?h.bitDepth=B(b):E(_,[159])&&(h.channels=B(b))}}}t._ht=1,O("WebM Tracks",n),a();break}}}var M=t.track0;if(M){if(16==M.bitDepth&&/FLOAT/i.test(M.codec)&&(M.bitDepth=32,O("WebM 16改32位",3)),M[W]!=t[W]||32!=M.bitDepth||M.channels<1||!/(\b|_)PCM\b/i.test(M.codec))return t.bytes=[],t.bad||O("WebM Track非预期",3,t),-(t.bad=1);for(var w=[],x=0;r[0]<i.length;){var l=N(i,r),v=G(i,r);if(!v)break;if(E(l,[163])){var I=15&v[0],h=n[I];if(h){if(0===h.idx){for(var A=new Uint8Array(v.length-4),S=4;S<v.length;S++)A[S-4]=v[S];w.push(A),x+=A.length}}else O("WebM !Track"+I,1,n)}a()}if(x){var L=new Uint8Array(i.length-t.pos[0]);L.set(i.subarray(t.pos[0])),t.bytes=L,t.pos[0]=0;for(var A=new Uint8Array(x),S=0,T=0;S<w.length;S++)A.set(w[S],T),T+=w[S].length;var k=new Float32Array(A.buffer);if(1<M.channels){for(var D=[],S=0;S<k.length;)D.push(k[S]),S+=M.channels;k=new Float32Array(D)}return k}}},E=function(e,t){if(!e||e.length!=t.length)return!1;if(1==e.length)return e[0]==t[0];for(var n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0},B=function(e){for(var t="",n=0;n<e.length;n++){var r=e[n];t+=(r<16?"0":"")+r.toString(16)}return parseInt(t,16)||0},N=function(e,t,n){var r=t[0];if(!(r>=e.length)){var a=e[r],o=("0000000"+a.toString(2)).substr(-8),i=/^(0*1)(\d*)$/.exec(o);if(i){var s=i[1].length,c=[];if(!(r+s>e.length)){for(var f=0;f<s;f++)c[f]=e[r],r++;return n&&(c[0]=parseInt(i[2]||"0",2)),t[0]=r,c}}}},G=function(e,t){var n=N(e,t,1);if(n){var r=B(n),a=t[0],o=[];if(r<2147483647){if(a+r>e.length)return;for(var i=0;i<r;i++)o[i]=e[a],a++}return t[0]=a,o}};U.TrafficImgUrl="//ia.51.la/go1?id=20469973&pvFlag=1";var o=U.Traffic=function(e){e=e?"/"+A+"/Report/"+e:"";var t=U.TrafficImgUrl;if(t){var n=U.Traffic,r=/^(https?:..[^\/#]*\/?)[^#]*/i.exec(location.href)||[],a=r[1]||"http://file/",o=(r[0]||a)+e;if(0==t.indexOf("//")&&(t=/^https:/i.test(o)?"https:"+t:"http:"+t),e&&(t=t+"&cu="+encodeURIComponent(a+e)),!n[o]){n[o]=1;var i=new Image;i.src=t,O("Traffic Analysis Image: "+(e||A+".TrafficImgUrl="+U.TrafficImgUrl))}}}}(window),"function"==typeof define&&define.amd&&define(function(){return Recorder}),"object"==typeof module&&module.exports&&(module.exports=Recorder),function(){"use strict";Recorder.prototype.enc_wav={stable:!0,testmsg:"支持位数8位、16位(填在比特率里面),采样率取值无限制"},Recorder.prototype.wav=function(e,t,n){var r=this.set,a=e.length,o=r.sampleRate,i=8==r.bitRate?8:16,s=a*(i/8),c=new ArrayBuffer(44+s),f=new DataView(c),u=0,l=function(e){for(var t=0;t<e.length;t++,u++)f.setUint8(u,e.charCodeAt(t))},v=function(e){f.setUint16(u,e,!0),u+=2},p=function(e){f.setUint32(u,e,!0),u+=4};if(l("RIFF"),p(36+s),l("WAVE"),l("fmt "),p(16),v(1),v(1),p(o),p(o*(i/8)),v(i/8),v(i),l("data"),p(s),8==i)for(var h=0;h<a;h++,u++){var g=128+(e[h]>>8);f.setInt8(u,g,!0)}else for(h=0;h<a;h++,u+=2)f.setInt16(u,e[h],!0);t(new Blob([f.buffer],{type:"audio/wav"}))}}();