diff --git a/QuickStart.html b/QuickStart.html index 24d1686..2a13d84 100644 --- a/QuickStart.html +++ b/QuickStart.html @@ -85,9 +85,9 @@
更多Demo: Recorder H5 - H5 vue + H5 vue + H5 ts Demo列表(可编辑) - RecordApp 切换到老版本测试
@@ -115,15 +115,14 @@ -
-
+
+
+ +
-
-
-
@@ -146,7 +145,7 @@ ,onProcess:function(buffers,powerLevel,bufferDuration,bufferSampleRate,newBufferIdx,asyncEnd){ //录音实时回调,大约1秒调用12次本回调 document.querySelector(".recpowerx").style.width=powerLevel+"%"; - document.querySelector(".recpowert").innerText=bufferDuration+" / "+powerLevel; + document.querySelector(".recpowert").innerText=formatMs(bufferDuration,1)+" / "+powerLevel; //可视化图形绘制 wave.input(buffers[buffers.length-1],powerLevel,bufferSampleRate); @@ -226,7 +225,7 @@ console.log(blob,(window.URL||webkitURL).createObjectURL(blob),"时长:"+duration+"ms"); recBlob=blob; - reclog("已录制mp3:"+duration+"ms "+blob.size+"字节,可以点击播放、上传了",2); + reclog("已录制mp3:"+formatMs(duration)+"ms "+blob.size+"字节,可以点击播放、上传了",2); },function(msg){ reclog("录音失败:"+msg,1); }); @@ -360,6 +359,14 @@ }; }; //recOpen弹框End + +var formatMs=function(ms,all){ + var f=Math.floor(ms/60000),m=Math.floor(ms/1000)%60; + var s=(all||f>0?(f<10?"0":"")+f+":":"") + +(all||f>0||m>0?("0"+m).substr(-2)+"″":"") + +("00"+ms%1000).substr(-3); + return s; +}; @@ -386,11 +393,14 @@ reclog('【Uncaught Error】'+message+'
'+"at:"+lineNo+":"+columnNo+" url:"+url+"\n"+(error&&error.stack||"不能获得错误堆栈")+'
'); }; -reclog("RecordApp[即将废弃] 除Recorder支持的外,支持Hybrid App,低版本IOS上支持微信网页和小程序web-view"+unescape("%uD83C%uDF89"),"#f60;font-weight:bold;font-size:24px"); +reclog('如需录音功能定制开发,网站、App、小程序、前端后端开发等需求,请加QQ群:①群 781036591、②群 748359095,口令recorder,联系群主(即作者),谢谢~',"#f60;font-size:22px;font-weight:bold"); reclog("Recorder H5使用简单,功能丰富,支持PC、Android、IOS 14.3+"+unescape("%uD83D%uDCAA"),"#0b1;font-weight:bold;font-size:24px"); -reclog('本页面修改时间(有可能修改了忘改):2022-05-24 19:31:18',"#999"); +reclog('本页面修改时间(有可能修改了忘改):2022-08-07 18:20',"#999"); reclog('Recorder库修改时间(有可能修改了忘改):'+(window.Recorder&&Recorder.LM),"#999"); +reclog("UA: "+navigator.userAgent, "#999"); +reclog("URL: "+location.href.replace(/#.*/g,""), "#999"); reclog(Tips); +reclog('当前浏览器支持录音':'red">不支持录音')+''); if(window.useCDN && useCDN.cdn){ reclog('本页面的js资源采用的CDN不稳定,已切换到:'+useCDN.cdn,'#f60'); diff --git a/README.md b/README.md index d599d8c..a8daa60 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # :open_book:Recorder用于html5录音 -[​](?Ref=Desc&Start)支持在大部分已实现`getUserMedia`的移动端、PC端浏览器麦克风录音、实时处理,主要包括:Chrome、Firefox、Safari、iOS 14.3+、Android WebView、腾讯Android X5内核(QQ、微信)、大部分2021年后更新的Android手机自带浏览器;不支持:~~UC系内核(典型的支付宝),大部分未更新的老旧国产手机自带浏览器,低版本iOS(11.0-14.2)上除Safari外的其他任何形式的浏览器(含PWA、WebClip、任何App内网页)~~。 +[​](?Ref=Desc&Start)支持在大部分已实现`getUserMedia`的移动端、PC端浏览器麦克风录音、实时处理,主要包括:Chrome、Firefox、Safari、iOS 14.3+、Android WebView、腾讯Android X5内核(QQ、微信、小程序WebView)、大部分2021年后更新的Android手机自带浏览器;不支持:~~UC系内核(典型的支付宝),大部分未更新的老旧国产手机自带浏览器,低版本iOS(11.0-14.2)上除Safari外的其他任何形式的浏览器(含PWA、WebClip、任何App内网页)~~。 支持对任意`MediaStream`进行音频录制、实时处理,包括:`getUserMedia返回的流`、`WebRTC中的remote流`、`audio、video标签的captureStream方法返回的流`、`自己创建的流` 等等。 @@ -11,7 +11,7 @@ 音频文件的播放:可直接使用常规的`Audio HTML标签`来播放完整的音频文件,参考文档下面的【快速使用】部分,有播放例子;上传了的录音直接将音频链接赋值给`audio.src`即可播放;本地的`blob音频文件`可通过`URL.createObjectURL`来生成本地链接赋值给`audio.src`即可播放,或者将blob对象直接赋值给`audio.srcObject`(兼容性没有src高)。实时的音频片段文件播放,可以使用本库自带的`BufferStreamPlayer`插件来播放,简单高效,或者采用别的途径播放。 -**如需录音功能定制,网站、App、小程序开发等需求,请加本文档下面的QQ群,联系群主(即作者),谢谢~** +**如需录音功能定制开发,网站、App、小程序、前端后端开发等需求,请加本文档下面的QQ群,联系群主(即作者),谢谢~** [​](?) @@ -49,7 +49,7 @@ > mp3默认16kbps的比特率,2kb每秒的录音大小,音质还可以(如果使用8kbps可达到1kb每秒,不过音质太渣)。主要用于语音录制,双声道语音没有意义,特意仅对单声道进行支持。mp3、wav、pcm格式支持边录边转码,录音结束时转码速度极快,支持实时转码成小片段文件和实时传输,demo中已实现一个语音通话聊天,下面有介绍;其他格式录音结束时可能需要花费比较长的时间进行转码。 > -> mp3使用lamejs编码(CBR),压缩后的recorder.mp3.min.js文件150kb左右(开启gzip后54kb)。如果对录音文件大小没有特别要求,可以仅仅使用录音核心+wav编码器(raw pcm format录音文件超大),压缩后的recorder.wav.min.js不足12kb。录音得到的mp3(CBR)、wav(PCM),均可简单拼接小的二进制录音片段文件来生成长的音频文件,具体参考下面这两种编码器的详细介绍。 +> mp3使用lamejs编码(CBR),压缩后的recorder.mp3.min.js文件160kb左右(开启gzip后60kb)。如果对录音文件大小没有特别要求,可以仅仅使用录音核心+wav编码器(raw pcm format录音文件超大),压缩后的recorder.wav.min.js不足20kb。录音得到的mp3(CBR)、wav(PCM),均可简单拼接小的二进制录音片段文件来生成长的音频文件,具体参考下面这两种编码器的详细介绍。 > 对于不支持录音的浏览器,引入js和调用相关方法都不会产生异常(IE8+),会进入相关的fail回调;一般在open的时候就能检测到不支持或被用户拒绝了权限,可在用户开始录音之前提示浏览器不支持录音或授权。 @@ -68,7 +68,7 @@ [​](?) ### Demo片段列表 -1. [【Demo库】【格式转换】-mp3格式转成其他格式](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.transform.mp32other) +1. [【Demo库】【格式转换】-mp3等格式解码转成其他格式](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.transform.mp32other) 2. [【Demo库】【格式转换】-wav格式转成其他格式](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.transform.wav2other) 3. [【Demo库】【格式转换】-amr格式转成其他格式](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.transform.amr2other) 4. [【教程】【音频流】【上传】实时转码并上传-通用版](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=teach.realtime.encode_transfer) @@ -84,7 +84,8 @@ 14. [【教程】新录音从老录音接续、或录制中途插入音频](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=teach.env_in.follow) 15. [【教程】DTMF(电话拨号按键信号)解码、编码](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=teach.dtmf.decode_and_encode) 16. [【Demo库】PCM采样率提升](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.samplerate.raise) -17. [【测试】音频可视化相关插件测试](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=test.extensions.visualization) +17. [【测试】WebM格式解析并提取音频](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=test.webm.extract_audio) +18. [【测试】音频可视化相关插件测试](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=test.extensions.visualization) ### App Demo @@ -100,7 +101,7 @@ iOS Demo App :[下载源码](https://github.com/xiangyuecn/Recorder/tree/maste ## 【QQ群】交流与支持 -欢迎加QQ群:781036591,纯小写口令:`recorder` +欢迎加QQ群:①群 781036591、②群 748359095,纯小写口令:`recorder` @@ -174,7 +175,7 @@ iOS Demo App :[下载源码](https://github.com/xiangyuecn/Recorder/tree/maste **方式二**:通过import/require引入 -通过 npm/cnpm 进行安装 `npm install recorder-core` ,如果直接clone的源码下面文件路径调整一下即可 [​](?Ref=ImportCode&Start) +通过 npm 进行安装 `npm install recorder-core` ,如果直接clone的源码下面文件路径调整一下即可 [​](?Ref=ImportCode&Start) ``` javascript //必须引入的核心,换成require也是一样的。注意:recorder-core会自动往window下挂载名称为Recorder对象,全局可调用window.Recorder,也许可自行调整相关源码清除全局污染 import Recorder from 'recorder-core' @@ -188,6 +189,8 @@ import 'recorder-core/src/engine/mp3-engine' //如果此格式有额外的编码 //可选的插件支持项 import 'recorder-core/src/extensions/waveview' + +//ts import 提示:npm包内已自带了.d.ts声明文件(不过是any类型) ``` [​](?RefEnd) @@ -418,17 +421,16 @@ iOS 11.0-14.2:纯粹的H5录音在iOS WebView中是不支持的,需要有Nat 浏览器Audio Media[兼容性](https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats#Browser_compatibility)mp3最好,wav还行,其他要么不支持播放,要么不支持编码;因此本库最佳推荐使用mp3、wav格式,代码也是优先照顾这两种格式。 -**特别注**:低版本`iOS(11.X、12.X、13.X)`上只有`Safari`支持`getUserMedia`,低版本iOS上其他浏览器均不支持,唯一有点卵用的Safari `getUserMedia` 底层实现bug奇多,参考下面的已知问题。 -**特别注**:大部分2021年以前的老旧国产手机自带的浏览器(系统浏览器)虽然支持`getUserMedia`方法,但并不能使用,表现为直接返回拒绝或者干脆没有任何回调;UC系列目测全部阵亡(含支付宝)。 +**留意中途来电话**:在移动端录音时,如果录音中途来电话,或者通话过程中打开录音,是不一定能进行录音的;经过简单测试发现,IOS上Safari将暂停返回音频数据,直到通话结束才开始继续有音频数据返回;小米上Chrome不管是来电还是通话中开始录音都能对麦克风输入的声音进行录音;只是简单测试,更多机器和浏览器并未做测试,不过整体上来看来电话或通话中进行录音的可行性并不理想,也不赞成在这种过程中进行录音;但只要通话结束后录音还是会正常进行,影响基本不大。 -**留意中途来电话**:在移动端录音时,如果录音中途来电话,或者通话过程中打开录音,是不一定能进行录音的;经过简单测试发现,IOS上Safari将暂停返回音频数据,直到通话结束才开始继续有音频数据返回;小米上Chrome不管是来电还是通话中开始录音都能对麦克风输入的声音进行录音(听筒中的并不能录到,扬声器外放的会被明显降噪);只是简单测试,更多机器和浏览器并未做测试,不过整体上来看来电话或通话中进行录音的可行性并不理想,也不赞成在这种过程中进行录音;但只要通话结束后录音还是会正常进行,影响基本不大。 +**录音时对播放音频的影响**:仅在移动端,如果录音参数中启用了降噪+回声消除,打开录音后,如果同时播放音频,此时播放声音可能会变得很小;PC上 和 禁用降噪+回声消除后 似乎无此影响。 -**录音时对播放音频的影响**:仅在移动端,录音过程中尽量不要去播放音频,正在播放的也应该暂停播放,否则不同手机系统、浏览器环境可能表现会出乎意料;已知IOS Safari上录音打开后,如果播放音频,声音会[变得非常小](https://www.cnblogs.com/cocoajin/p/7591068.html);Android上也有可能声音被切换到听筒播放,而不是扬声器大喇叭上播放导致声音也会变小;更多可能的情况需要更多设备、浏览器的测试数据才能发掘;PC上似乎无此影响。 +**移动端锁屏录音**:手机锁屏后浏览器的运行状态是一个玄学,是否能录音不可控;不同手机、甚至同一手机在不同状态下,有可能能录又有可能不能录,且无法检测;可以调用 `navigator.wakeLock` 来阻止手机自动锁屏,不支持的直接简单粗暴的 循环+静音 播放一段视频,来阻止锁屏,就是有点费电,具体实现可参考H5在线测试页面内的`wakeLockClick`方法。 **特别注**:如果在`iframe`里面调用的录音功能,并且和上层的网页是不同的域(跨域了),如果未设置相应策略,权限永远是被拒绝的,[参考此处](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security)。另外如果要在`非跨域的iframe`里面使用,最佳实践应该是让window.top去加载Recorder(异步加载js),iframe里面使用top.Recorder,免得各种莫名其妙(比如微信里面的各种渣渣功能,搞多了就习惯了)。 -> 如果需要最大限度的兼容低版本IOS(仅增加微信支持),可以使用`RecordApp`,它已包含`Recorder`,源码在`src/app-support`、`app-support-sample`中,但此兼容库需要服务器端提供微信JsSDK的签名、下载素材接口,涉及微信公众(订阅)号的开发。 +> 低版本`iOS(11.X、12.X、13.X)`上只有`Safari`支持`getUserMedia`,其他任何形式的浏览器均不支持;如果需要最大限度的兼容低版本IOS(仅增加微信支持),可以使用`RecordApp`,它已包含`Recorder`,源码在`src/app-support`、`app-support-sample`中,但此兼容库需要服务器端提供微信JsSDK的签名、下载素材接口,涉及微信公众(订阅)号的开发。 支持|Recorder|~[RecordApp](https://github.com/xiangyuecn/Recorder/tree/master/app-support-sample)~ -:|:-:|:-: @@ -449,21 +451,10 @@ iOS其他浏览器|iOS 14.3+|iOS 14.3+ ## 已知问题 -*2018-09-19* [caniuse](https://caniuse.com/#search=getUserMedia) 注明`IOS` `11.X - 12.X(13.X)` 上 只有`Safari`支持调用`getUserMedia`,其他App下WKWebView(UIWebView?)([相关资料](https://forums.developer.apple.com/thread/88052))均不支持(2021-2-15 IOS 14.3+已无此问题)。经用户测试验证IOS 12上chrome、UC都无法录音,部分IOS 12 Safari可以获取到并且能正常录音,但部分不行,原因未知,参考[ios 12 支不支持录音了](https://www.v2ex.com/t/490695)。在IOS上不支持录音的环境下应该采用其他解决方案,参考`案例演示`、`关于微信JsSDK`部分。 - -*2019-02-28* [issues#14](https://github.com/xiangyuecn/Recorder/issues/14) 如果`getUserMedia`返回的[`MediaStreamTrack.readyState == "ended"`,`"ended" which indicates that the input is not giving any more data and will never provide new data.`](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) ,导致无法录音。如果产生这种情况,目前在`rec.open`方法调用时会正确检测到,并执行`fail`回调。造成`issues#14` `ended`原因是App源码中`AndroidManifest.xml`中没有声明`android.permission.MODIFY_AUDIO_SETTINGS`权限,导致腾讯X5不能正常录音。 - -*2019-03-09* 在Android上QQ、微信里,请求授权使用麦克风的提示,经过长时间观察发现,他们的表现很随机、很奇特。可能每次在调用`getUserMedia`时候都会弹选择,也可能选择一次就不会再弹提示,也可能重启App后又会弹。如果用户拒绝了,可能第二天又会弹,或者永远都不弹了,要么重置(装)App。使用腾讯X5内核的App测试也是一样奇特表现,拒绝权限后可能必须要重置(装)。这个问题貌似跟X5内核自动升级的版本有关。QQ浏览器更加惨不忍睹,2019-08-16测试发现卸载重装、拒绝权限后永远无法弹出授权,通过浏览器设置-清理-清理地理位置授权才能恢复,重启、重装、清理系统垃圾、删除根目录文件夹(腾讯那个大文件不敢删,毒瘤)垃圾均无效,奇葩。 - -*2019-06-14* 经[#29](https://github.com/xiangyuecn/Recorder/issues/29)反馈,稍微远程真机测试了部分厂商的比较新的Android手机系统浏览器的录音支持情况;华为:直接返回拒绝,小米:没有回调,OPPO:好像是没有回调,vivo:好像是没有回调;另外专门测试了一下UC最新版(支付宝):直接返回拒绝。另[参考](https://www.jianshu.com/p/6cd5a7fa562c)。也许他们都商量好了或者本身都是用的UC?至于没有任何回调的,此种浏览器没有良心。 - -*2019-07-22* 对[#34](https://github.com/xiangyuecn/Recorder/issues/34)反馈研究后发现,问题一:~~macOS、IOS的Safari对连续调用录音(中途未调用close)是有问题的,但只要调用close后再重复录音就没有问题~~(已通过特殊手段解决)。问题二:IOS上如果录音之前先播放了任何Audio,录音过程可能会变得很诡异,但如果先录音,就不存在此问题(19-09-18 Evan:QQ1346751357反馈发现本问题并非必现,[功能页面](https://hft.bigdatahefei.com/LocateSearchService/sfc/index),但本库的Demo内却必现,原因不明)。chrome、firefox正常的很。目测这两个问题是非我等屌丝能够解决的,于是报告给苹果家程序员看看,因此发了个[帖子](https://forums.developer.apple.com/message/373108),顺手在`Feedback Assistant`提交了`bug report`,但好几天过去了没有任何回应(顺带给微软一个好评)。问题一目前已通过全局共享一个MediaStream连接来解决,原因在于Safari上MediaStream断开后就无法再次进行连接使用(表现为静音),改成了全局只连接一次就避免了此问题;全局处理也有利于屏蔽底层细节,start时无需再调用底层接口,提升兼容、可靠性。 - -*2019-10-26* 针对[#51](https://github.com/xiangyuecn/Recorder/issues/51)的问题研究后发现,如果录音时设备偶尔出现很卡的情况下(CPU被其他程序大量占用),浏览器采集到的音频是断断续续的,导致10秒的录音可能就只返回了5秒的数据量,这个时候最终编码得到的音频时长明显变短,播放时的效果就像快放一样。此问题能够稳定复现(使用别的程序大量占用CPU来模拟),目前已在`envIn`内部函数中进行了补偿处理,在浏览器两次传入PCM数据之间填充一段静默数据已弥补丢失的时长;最终编码得到的音频时长将和实际录音时长基本一致,消除了快放效果,但由于丢失的音频已被静默数据代替,听起来就是数据本身的断断续续的效果。在设备不卡时录音没有此问题。 -*2019-11-03* lamejs原版编码器编码出来的mp3文件首尾存在填充数据并且会占据一定时长(这种数据播放时静默,记录的信息数据或者填充),同一录音mp3格式的时长会比wav格式的时长要长0-100ms左右,大部分情况下不会有影响,但如果涉及到实时转码并传输的话,这些数据将会造成多段mp3片段的总时长比实际录音要长,最终播放时会均匀的感觉到停顿,并且mp3片段越小越明显。本库已对lamejs编码出来的mp3文件进行了处理,去掉了头部的非音频数据,但由于编码出来的mp3每一帧数据都有固定时长,文件结尾最后一帧可能录音的时长不能刚好填满,就会产生填充数据;因此本库编码出来的mp3文件会比wav格式长0-30ms左右,多出来的时长在mp3的结尾处;mp3解码出来的pcm数据直接去掉结尾多出来的部分,就和wav中的pcm数据基本一致了;另外可以通过调节待编码的pcm数据长度以达到刚好填满最后一帧来规避此问题,参考`Recorder.SampleData`方法提供的连续转码针对此问题的处理(但小的mp3片段拼接起来停顿导致的杂音还是非常明显,实时处理时使用`takeoffEncodeChunk`选项可完全避免此问题)。[参考wiki](https://github.com/xiangyuecn/Recorder/wiki/lamejs编码出来的mp3时长修正)。 +> 此处已清除7个已知问题,大部分无法解决的问题会随着时间消失;问题主要集中在iOS上,好在这玩意能更新 -*2020-04-26* Safari Bug:据QQ群内`1048506792`、`190451148`开发者反馈研究发现,IOS ?-13.X Safari内打开录音后,如果切换到了其他标签、或其他App并且播放了任何声音,此时将会中断已打开的录音(系统级的?),切换回正在录音的页面,这个页面的录音功能将会彻底失效,并且刷新也无法恢复录音;表现为关闭录音后再次打开录音,能够正常获得权限,但浏览器返回的采集到的音频为静默的PCM,此时地址栏也并未显示出麦克风图标,刷新这个标签也也是一样不能正常获得录音,只有关掉此标签新打开页面才可正常录音。如果打开录音后关闭了录音,然后切换到其他标签或App播放声音,然后返回录音页面,不会出现此问题。此为Safari的底层Bug(也许是少给临时工工钱了吧,无能为力)。使用长按录音类似的用户交互可大幅度避免踩到这坨翔。 +*2020-04-26* Safari Bug:据QQ群内`1048506792`、`190451148`开发者反馈研究发现,IOS ?-13.X Safari内打开录音后,如果切换到了其他标签、或其他App并且播放了任何声音,此时将会中断已打开的录音(系统级的?),切换回正在录音的页面,这个页面的录音功能将会彻底失效,并且刷新也无法恢复录音;表现为关闭录音后再次打开录音,能够正常获得权限,但浏览器返回的采集到的音频为静默的PCM,此时地址栏也并未显示出麦克风图标,刷新这个标签也也是一样不能正常获得录音,只有关掉此标签新打开页面才可正常录音。如果打开录音后关闭了录音,然后切换到其他标签或App播放声音,然后返回录音页面,不会出现此问题。此为Safari的底层Bug。使用长按录音类似的用户交互可大幅度避免踩到这坨翔。 @@ -519,7 +510,8 @@ set={ //注意:流内必须至少存在一条音轨(Audio Track),比如audio标签必须等待到可以开始播放后才会有音轨,否则open会失败 //,audioTrackSet:{ deviceId:"",groupId:"", autoGainControl:true, echoCancellation:true, noiseSuppression:true } - //普通麦克风录音时getUserMedia方法的audio配置参数,比如指定设备id,回声消除、降噪开关;注意:提供的任何配置值都不一定会生效 + //普通麦克风录音时getUserMedia方法的audio配置参数;注意:提供的任何配置值都不一定会生效 + //回声消除、降噪开关这两个已默认明确关闭,开启可能会导致移动端表现的很怪异,包括系统播放声音变小,如需开启请测试好后再开启 //由于麦克风是全局共享的,所以新配置后需要close掉以前的再重新open //更多参考: https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints @@ -540,17 +532,15 @@ set={ ### 【方法】rec.open(success,fail) 请求打开录音资源,如果浏览器不支持录音、用户拒绝麦克风权限、或者非安全环境(非https、file等)将会调用`fail`;打开后需要调用`close`来关闭,因为浏览器或设备的系统可能会显示正在录音。 -注意:此方法回调是可能是同步的(异常、或者已持有资源时)也可能是异步的(浏览器弹出权限请求时);一般使用时打开,用完立即关闭;可重复调用,可用来测试是否能录音。 - -另外:普通的麦克风录音时,因为此方法会调起用户授权请求,如果仅仅想知道浏览器是否支持录音(比如:如果浏览器不支持就走另外一套录音方案),应使用`Recorder.Support()`方法。 +`success`=fn(); -**注意:打开普通麦克风录音后,如果未调用close关闭,可能会影响audio音频的播放,表现为移动端audio播放有明显的杂音(麦克风的电流音?)、音量严重降低(被切换到听筒播放?)等奇形怪状的问题,因此如果你录音后有别的操作,尽量录完音就立即调用close关闭录音。** +`fail`=fn(errMsg,isUserNotAllow); 如果是用户主动拒绝的录音权限,除了有错误消息外,isUserNotAllow=true,方便程序中做不同的提示,提升用户主动授权概率 -> **特别注**: 鉴于UC系浏览器(大部分老旧国产手机厂商系统浏览器)大概率表面支持录音但永远不会有任何回调、或者此浏览器支持第三种情况(用户忽略 并且 此浏览器认为此种情况不需要回调 并且程序员完美实现了);如果当前环境是移动端,可以在调用此方法`8秒`后如果未收到任何回调,弹出一个自定义提示框(只需要一个按钮),提示内容范本:`录音功能需要麦克风权限,请允许;如果未看到任何请求,请点击忽略~`,按钮文本:`忽略`;当用户点击了按钮,直接手动执行`fail`逻辑,因为此时浏览器压根就没有弹移动端特有的模态化权限请求对话框;但如果收到了回调(可能是同步的,因此弹框必须在`rec.open`调用前准备好随时取消),需要把我们弹出的提示框自动关掉,不需要用户做任何处理。pc端的由于不是模态化的请求对话框,可能会被用户误点,所以尽量要判断一下是否是移动端。 +注意:此方法回调是可能是同步的(异常、或者已持有资源时)也可能是异步的(浏览器弹出权限请求时);一般使用时打开,用完立即关闭;可重复调用,可用来测试是否能录音。 -`success`=fn(); +另外:普通的麦克风录音时,因为此方法会调起用户授权请求,如果仅仅想知道浏览器是否支持录音(比如:如果浏览器不支持就走另外一套录音方案),应使用`Recorder.Support()`方法。 -`fail`=fn(errMsg,isUserNotAllow); 如果是用户主动拒绝的录音权限,除了有错误消息外,isUserNotAllow=true,方便程序中做不同的提示,提升用户主动授权概率 +> **特别注**: 鉴于UC系浏览器(大部分老旧国产手机厂商系统浏览器)大概率表面支持录音但永远不会有任何回调、或者此浏览器支持第三种情况(忽略按钮,也不会有回调);如果当前环境是移动端,可以在调用此方法`8秒`后如果未收到任何回调,弹出一个自定义提示框(只需要一个按钮),提示内容范本:`录音功能需要麦克风权限,请允许;如果未看到任何请求,请点击忽略~`,按钮文本:`忽略`;当用户点击了按钮,直接手动执行`fail`逻辑,因为此时浏览器压根就没有弹移动端特有的模态化权限请求对话框;但如果收到了回调(可能是同步的,因此弹框必须在`rec.open`调用前准备好随时取消),需要把我们弹出的提示框自动关掉,不需要用户做任何处理。pc端的由于不是模态化的请求对话框,可能会被用户误点,所以尽量要判断一下是否是移动端。 ### 【方法】rec.close(success) @@ -655,7 +645,7 @@ function transformOgg(pcmData){ 设置为空字符串后将不参与统计,大部分情况下无需关闭统计,如果你网页的url私密性要求很高,请在调用Recorder之前将此url设为空字符串;本功能于2019-11-09添加,[点此](https://www.51.la/?20469973)前往51la查看统计概况。 ### 【静态属性】Recorder.BufferSize -普通的麦克风录音时全局的AudioContext缓冲大小,默认值为4096。会影响H5录音时的onProcess调用速率,相对于AudioContext.sampleRate=48000时,4096接近12帧/s,调节此参数可生成比较流畅的回调动画。 +普通的麦克风录音时全局的AudioContext缓冲大小,默认值为4096。会影响H5录音时的onProcess调用速率,相对于AudioContext.sampleRate=48000时,4096接近12帧/s(移动端帧率可能会低一些),调节此参数可生成比较流畅的回调动画。 取值256, 512, 1024, 2048, 4096, 8192, or 16384 @@ -665,8 +655,18 @@ function transformOgg(pcmData){ *这个属性在旧版Recorder中是放在已废弃的set.bufferSize中,后面因为兼容处理Safari上MediaStream断开后就无法再次进行连接使用的问题(表现为静音),把MediaStream连接也改成了全局只连接一次,因此set.bufferSize就移出来变成了Recorder的属性* +### 【静态属性】Recorder.ConnectEnableWebM +音频采集连接方式:启用时尝试使用MediaRecorder.WebM.PCM,默认为true启用,未启用或者不支持时使用AudioWorklet或过时的ScriptProcessor来连接;本连接方式仅对普通麦克风录音时有效,直接提供了流(set.sourceStream)时将当做未启用处理。 + +使用MediaRecorder采集到的音频数据比其他方式更好,几乎不存在丢帧现象,所以音质明显会好很多,建议保持开启; 有些浏览器不支持录制PCM编码的WebM,如FireFox、低版本的Chrome,将依旧使用AudioWorklet或ScriptProcessor来连接采集。 + +*可以额外提供一个设置`Recorder.ConnectWebMOptions={}`来当做MediaRecorder的options参数,支持的参数请参考[此文档](https://developer.mozilla.org/zh-CN/docs/Web/API/MediaRecorder/MediaRecorder)。* + +> 本连接实现原理:通过MediaRecorder对MediaStream进行录制,格式`audio/webm; codecs=pcm`,MediaRecorder会将实时录制的PCM数据(48k+32位)回传给js,因此只需要知道WebM的封装格式就能提取出PCM数据,请参考测试代码:[WebM格式解析并提取音频](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=test.webm.extract_audio) + + ### 【静态属性】Recorder.ConnectEnableWorklet -音频采集连接方式:是否要启用AudioWorklet (AudioWorkletNode) 来进行连接;默认为false禁用,禁用后将使用过时的ScriptProcessor (AudioContext.createScriptProcessor) 来连接。 +音频采集连接方式:是否要启用AudioWorklet (AudioWorkletNode) 来进行连接;默认为false禁用,禁用后将使用过时的ScriptProcessor (AudioContext.createScriptProcessor) 来连接;如果启用了 Recorder.ConnectEnableWebM 并且有效时,本参数将不起作用,否则才会生效。 启用后如果浏览器不支持AudioWorklet,将只会使用老的ScriptProcessor来进行音频采集连接;如果浏览器已停止支持ScriptProcessor,将永远会尝试启用AudioWorklet而忽略此配置值。 @@ -758,7 +758,7 @@ function transformOgg(pcmData){ ## WaveView插件 [waveview.js](https://github.com/xiangyuecn/Recorder/blob/master/src/extensions/waveview.js),4kb大小源码,录音时动态显示波形,具体样子参考演示地址页面。此插件参考[MCVoiceWave](https://github.com/HaloMartin/MCVoiceWave)库编写的,具体代码在`https://github.com/HaloMartin/MCVoiceWave/blob/f6dc28975fbe0f7fc6cc4dbc2e61b0aa5574e9bc/MCVoiceWave/MCVoiceWaveView.m`中;本可视化插件可以移植到其他语言环境,如需定制可联系作者。 -此插件是在录音时`onProcess`回调中使用;`Recorder.BufferSize`会影响绘制帧率,默认配置的大概12帧/s比较流畅。基础使用方法:[​](?Ref=WaveView.Codes&Start) +此插件是在录音时`onProcess`回调中使用。基础使用方法:[​](?Ref=WaveView.Codes&Start) ``` javascript var wave; var rec=Recorder({ @@ -787,7 +787,11 @@ set={ //以上配置二选一 ,scale:2 //缩放系数,应为正整数,使用2(3? no!)倍宽高进行绘制,避免移动端绘制模糊 - ,speed:8 //移动速度系数,越大越快 + ,speed:9 //移动速度系数,越大越快 + ,phase:21.8 //相位,调整了速度后,调整这个值得到一个看起来舒服的波形 + + ,fps:20 //绘制帧率,调整后也需调整phase值 + ,keep:true //当停止了input输入时,是否保持波形,设为false停止后将变成一条线 ,lineWidth:3 //线条基础粗细 @@ -799,7 +803,7 @@ set={ ``` ### 【方法】wave.input(pcmData,powerLevel,sampleRate) -输入音频数据,更新波形显示,这个方法调用的越快,波形越流畅。pcmData `[Int16,...]` 一维数组,为当前的录音数据片段,其他参数和`onProcess`回调相同。 +输入音频数据,更新波形显示。pcmData `[Int16,...]` 一维数组,为当前的录音数据片段,其他参数和`onProcess`回调相同。 @@ -1276,7 +1280,7 @@ wav格式编码器时参考网上资料写的,会发现代码和别人家的 由于RAW格式的wav内直接就是pcm数据,因此将小的wav片段文件去掉wav头后得到的原始pcm数据合并到一起,再加上新的wav头即可合并出长的wav文件;要求待合成的所有wav片段的采样率和位数需一致。[wav合并参考和测试+可移植源码](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.merge.wav_merge) ## mp3 (CBR) 格式 -采用的是[lamejs](https://github.com/zhuker/lamejs)(LGPL License)这个库的代码,`https://github.com/zhuker/lamejs/blob/bfb7f6c6d7877e0fe1ad9e72697a871676119a0e/lame.all.js`这个版本的文件代码;已对lamejs源码进行了部分改动,用于精简代码和修复发现的问题。LGPL协议涉及到的文件:`mp3-engine.js`;这些文件也采用LGPL授权,不适用MIT协议。源码518kb大小,压缩后150kb左右,开启gzip后50来k。[mp3转其他格式参考和测试](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.transform.mp32other) +采用的是[lamejs](https://github.com/zhuker/lamejs)(LGPL License)这个库的代码,`https://github.com/zhuker/lamejs/blob/bfb7f6c6d7877e0fe1ad9e72697a871676119a0e/lame.all.js`这个版本的文件代码;已对lamejs源码进行了部分改动,用于精简代码和修复发现的问题。LGPL协议涉及到的文件:`mp3-engine.js`;这些文件也采用LGPL授权,不适用MIT协议。源码518kb大小,压缩后160kb左右,开启gzip后60来k。[mp3转其他格式参考和测试](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.transform.mp32other) ### 简单将多段小的mp3片段合成长的mp3文件 由于lamejs CBR编码出来的mp3二进制数据从头到尾全部是大小相同的数据帧(采样率44100等无法被8整除的部分帧可能存在额外多1字节填充),没有其他任何多余信息,通过文件长度可计算出mp3的时长`fileSize*8/bitRate`([参考](https://blog.csdn.net/u010650845/article/details/53520426)),数据帧之间可以直接拼接。因此将小的mp3片段文件的二进制数据全部合并到一起即可得到长的mp3文件;要求待合成的所有mp3片段的采样率和比特率需一致。[mp3合并参考和测试+可移植源码](https://xiangyuecn.gitee.io/recorder/assets/工具-代码运行和静态分发Runtime.html?jsname=lib.merge.mp3_merge) diff --git a/assets/demo-ts/dist/index.js b/assets/demo-ts/dist/index.js new file mode 100644 index 0000000..9523dce --- /dev/null +++ b/assets/demo-ts/dist/index.js @@ -0,0 +1 @@ +!function(e){var t={};function a(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=e,a.c=t,a.d=function(e,t,s){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(a.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(s,n,function(t){return e[t]}.bind(null,n));return s},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,a){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var n=s(a(1));a(2),a(3),a(4);var r,i,o,_=window,l=document,f=function(){for(var e=[],t=0;t用户主动点击的弹窗",1)}},_.recClose=function(){r?(r.close(),f("已关闭")):f("未打开录音",1)},_.recStart=function(){r&&n.default.IsOpen()?(o=null,r.start(),f("已开始录音...")):f("未打开录音",1)},_.recPause=function(){r&&n.default.IsOpen()?r.pause():f("未打开录音",1)},_.recResume=function(){r&&n.default.IsOpen()?r.resume():f("未打开录音",1)},_.recStop=function(){r&&n.default.IsOpen()?r.stop((function(e,t){console.log(e,(_.URL||webkitURL).createObjectURL(e),"时长:"+t+"ms"),o=e,f("已录制mp3:"+p(t)+"ms "+e.size+"字节,可以点击播放、上传了",2)}),(function(e){f("录音失败:"+e,1)})):f("未打开录音",1)},_.recPlay=function(){if(o){var e=("a"+Math.random()).replace(".","");f('播放中: ');var t=l.createElement("audio");t.controls=!0,l.querySelector("."+e).appendChild(t),t.src=(_.URL||webkitURL).createObjectURL(o),t.play(),setTimeout((function(){(_.URL||webkitURL).revokeObjectURL(t.src)}),5e3)}else f("请先录音,然后停止后再播放",1)},_.recUpload=function(){var e=o;if(e){var t="https://xx.xx/test_request",a=function(e){return function(){4==r.readyState&&(200==r.status?f(e+"上传成功",2):(f(e+"没有完成上传,演示上传地址无需关注上传结果,只要浏览器控制台内Network面板内看到的请求数据结构是预期的就ok了。","#d8c1a0"),console.error(e+"上传失败",r.status,r.responseText)))}};f("开始上传到"+t+",请求稍后...");var s=new _.FileReader;s.onloadend=function(){var n="";n+="mime="+encodeURIComponent(e.type),n+="&upfile_b64="+encodeURIComponent((/.+;\s*base64\s*,\s*(.+)$/i.exec(s.result)||[])[1]);var r=new XMLHttpRequest;r.open("POST",t),r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),r.onreadystatechange=a("上传方式一【Base64】"),r.send(n)},s.readAsDataURL(e);var n=new FormData;n.append("upfile",e,"recorder.mp3");var r=new XMLHttpRequest;r.open("POST",t),r.onreadystatechange=a("上传方式二【FormData】"),r.send(n)}else f("请先录音,然后停止后再上传",1)};var c,h=function(){c=setTimeout((function(){!function(){if(/mobile/i.test(navigator.userAgent)){u();var e=l.createElement("div");l.body.appendChild(e),e.innerHTML='
录音功能需要麦克风权限,请允许;如果未看到任何请求,请点击忽略~
'}}()}),8e3)},u=function(){clearTimeout(c);for(var e=l.querySelectorAll(".waitDialog"),t=0;t0?(a<10?"0":"")+a+":":"")+(t||a>0||s>0?("0"+s).substr(-2)+"″":"")+("00"+e%1e3).substr(-3)}},function(e,t,a){var s;!function(e){"use strict";var t=function(){},a=function(e){return new h(e)};a.LM="2022-08-06 20:51";var s="Recorder";a.IsOpen=function(){var e=a.Stream;if(e){var t=(e.getTracks&&e.getTracks()||e.audioTracks||[])[0];if(t){var s=t.readyState;return"live"==s||s==t.LIVE}}return!1},a.BufferSize=4096,a.Destroy=function(){for(var e in l(s+" Destroy"),_(),n)n[e]()};var n={};a.BindDestroy=function(e,t){n[e]=t},a.Support=function(){var t=e.AudioContext;if(t||(t=e.webkitAudioContext),!t)return!1;var s=navigator.mediaDevices||{};return s.getUserMedia||(s=navigator).getUserMedia||(s.getUserMedia=s.webkitGetUserMedia||s.mozGetUserMedia||s.msGetUserMedia),!!s.getUserMedia&&(a.Scope=s,a.Ctx&&"closed"!=a.Ctx.state||(a.Ctx=new t,a.BindDestroy("Ctx",(function(){var e=a.Ctx;e&&e.close&&(e.close(),a.Ctx=0)}))),!0)},a.ConnectEnableWebM=!0,a.ConnectEnableWorklet=!1;var r=function(t,n){var r,_,f,c=t.BufferSize||a.BufferSize,h=a.Ctx,p=t.Stream,m=function(e){var t=p._m=h.createMediaStreamSource(p),a=h.destination,s="createMediaStreamDestination";h[s]&&(a=h[s]()),t.connect(e),e.connect(a)},b="",d=p._call,v=function(e){for(var t in d){for(var a=e.length,s=new Int16Array(a),n=0,r=0;rf+1&&l("SampleData似乎传入了未重置chunk "+r+">"+f,3);for(var c=0,h=r;h1?c=Math.floor(c/u):(u=1,a=t),c+=o.length;var p=new Int16Array(c),m=0;for(h=0;h0){var k=2*(p.length-R);o=new Int16Array(p.buffer.slice(k)),p=new Int16Array(p.buffer.slice(0,k))}return{index:r,offset:i,frameNext:o,sampleRate:a,data:p}},a.PowerLevel=function(e,t){var a=e/t||0;return a<1251?Math.round(a/1250*10):Math.round(Math.min(100,Math.max(0,100*(1+Math.log(a/1e4)/Math.log(10)))))};var l=function(t,a){var n=new Date,r=("0"+n.getMinutes()).substr(-2)+":"+("0"+n.getSeconds()).substr(-2)+"."+("00"+n.getMilliseconds()).substr(-3),i=this&&this.envIn&&this.envCheck&&this.id,o=["["+r+" "+s+(i?":"+i:"")+"]"+t],_=arguments,l=e.console||{},c=2,h=l.log;for("number"==typeof a?h=1==a?l.error:3==a?l.warn:h:c=1;c<_.length;c++)o.push(_[c]);f?h&&h("[IsLoser]"+o[0],o.length>1?o:""):h.apply(l,o)},f=!0;try{f=!console.log.apply}catch(e){}a.CLog=l;var c=0;function h(e){this.id=++c,v();var a={type:"mp3",bitRate:16,sampleRate:16e3,onProcess:t};for(var s in e)a[s]=e[s];this.set=a,this._S=9,this.Sync={O:9,C:9}}a.Sync={O:9,C:9},a.prototype=h.prototype={CLog:l,_streamStore:function(){return this.set.sourceStream?this:a},open:function(s,n){var i=this,o=i._streamStore();s=s||t;var l=function(e,t){t=!!t,i.CLog("录音open失败:"+e+",isUserNotAllow:"+t,1),n&&n(e,t)},f=function(){i.CLog("open ok id:"+i.id),s(),i._SO=0},c=o.Sync,h=++c.O,u=c.C;i._O=i._O_=h,i._SO=i._S;var p=i.envCheck({envName:"H5",canProcess:!0});if(p)l("不能录音:"+p);else if(i.set.sourceStream){if(!a.Support())return void l("不支持此浏览器从流中获取录音");_(o),i.Stream=i.set.sourceStream,i.Stream._call={};try{r(o)}catch(e){return void l("从流中打开录音失败:"+e.message)}f()}else{var m=function(t,a){try{e.top.a}catch(e){return void l('无权录音(跨域,请尝试给iframe添加麦克风访问策略,如allow="camera;microphone")')}/Permission|Allow/i.test(t)?l("用户拒绝了录音权限",!0):!1===e.isSecureContext?l("浏览器禁止不安全页面录音,可开启https解决"):/Found/i.test(t)?l(a+",无可用麦克风"):l(a)};if(a.IsOpen())f();else if(a.Support()){var b=function(e){setTimeout((function(){e._call={};var t=a.Stream;t&&(_(),e._call=t._call),a.Stream=e,function(){if(u!=c.C||!i._O){var e="open被取消";return h==c.O?i.close():e="open被中断",l(e),!0}}()||(a.IsOpen()?(t&&i.CLog("发现同时多次调用open",1),r(o,1),f()):l("录音功能无效:无音频流"))}),100)},d=function(e){var t=e.name||e.message||e.code+":"+e;i.CLog("请求录音权限错误",1,e),m(t,"无法录音:"+t)},v={noiseSuppression:!1,echoCancellation:!1},g=i.set.audioTrackSet;for(var S in g)v[S]=g[S];v.sampleRate=a.Ctx.sampleRate;try{var M=a.Scope.getUserMedia({audio:v},b,d)}catch(e){i.CLog("getUserMedia",3,e),M=a.Scope.getUserMedia({audio:!0},b,d)}M&&M.then&&M.then(b)[s&&"catch"](d)}else m("","此浏览器不支持录音")}},close:function(e){e=e||t;var a=this._streamStore();this._stop();var s=a.Sync;if(this._O=0,this._O_!=s.O)return this.CLog("close被忽略(因为同时open了多个rec,只有最后一个会真正close)",3),void e();s.C++,_(a),this.CLog("close"),e()},mock:function(e,t){return this._stop(),this.isMock=1,this.mockEnvInfo=null,this.buffers=[e],this.recSize=e.length,this.srcSampleRate=t,this},envCheck:function(t){var s,n=this.set,r="CPU_BE";if(s||a[r]||!e.Int8Array||new Int8Array(new Int32Array([1]).buffer)[0]||(v(r),s="不支持CPU_BE架构"),!s){var i=n.type;this[i+"_envCheck"]?s=this[i+"_envCheck"](t,n):n.takeoffEncodeChunk&&(s=i+"类型"+(this[i]?"":"(未加载编码器)")+"不支持设置takeoffEncodeChunk")}return s||""},envStart:function(e,t){var a=this.set;this.isMock=e?1:0,this.mockEnvInfo=e,this.buffers=[],this.recSize=0,this.envInLast=0,this.envInFirst=0,this.envInFix=0,this.envInFixTs=[];var s=a.sampleRate;if(s>t?a.sampleRate=t:s=0,this.srcSampleRate=t,this.CLog("srcSampleRate: "+t+" set.sampleRate: "+a.sampleRate+(s?" 忽略"+s:""),s?3:0),this.engineCtx=0,this[a.type+"_start"]){var n=this.engineCtx=this[a.type+"_start"](a);n&&(n.pcmDatas=[],n.pcmSize=0)}},envResume:function(){this.envInFixTs=[]},envIn:function(e,t){var s=this,n=s.set,r=s.engineCtx,i=s.srcSampleRate,o=e.length,_=a.PowerLevel(t,o),l=s.buffers,f=l.length;l.push(e);var c=l,h=f,u=Date.now(),p=Math.round(o/i*1e3);s.envInLast=u,1==s.buffers.length&&(s.envInFirst=u-p);var m=s.envInFixTs;m.splice(0,0,{t:u,d:p});for(var b=u,d=0,v=0;v3e3){m.length=v;break}b=g.t,d+=g.d}var S=m[1],M=u-b;if(M-d>M/3&&(S&&M>1e3||m.length>=6)){var w=u-S.t-p;if(w>p/5){var R=!n.disableEnvInFix;if(s.CLog("["+u+"]"+(R?"":"未")+"补偿"+w+"ms",3),s.envInFix+=w,R){var k=new Int16Array(w*i/1e3);o+=k.length,l.push(k)}}}var A=s.recSize,B=o,y=A+B;if(s.recSize=y,r){var T=a.SampleData(l,i,n.sampleRate,r.chunkInfo);r.chunkInfo=T,y=(A=r.pcmSize)+(B=T.data.length),r.pcmSize=y,l=r.pcmDatas,f=l.length,l.push(T.data),i=T.sampleRate}var x=Math.round(y/i*1e3),E=l.length,P=c.length,L=function(){for(var e=I?0:-B,t=null==l[0],a=f;a10&&s.envInFirst-u>1e3&&s.CLog("rec.set.onProcess低性能,耗时"+H+"ms",3),!0===I){var O=0;for(v=f;v"+v.length+" 花:"+(Date.now()-n)+"ms"),setTimeout((function(){n=Date.now(),r[i.type](v,(function(e){c(e,b)}),(function(e){f(e)}))}))}else f("未加载"+i.type+"编码器");else f("音频buffers被释放");else f("未采集到录音")}},e[s]&&(l("重复引入"+s,3),e[s].Destroy()),e[s]=a;var u=function(e,t){t.pos||(t.pos=[0],t.tracks={},t.bytes=[]);var a=t.tracks,s=[t.pos[0]],n=function(){t.pos[0]=s[0]},r=t.bytes.length,i=new Uint8Array(r+e.length);if(i.set(t.bytes),i.set(e,r),t.bytes=i,!t._ht){if(b(i,s),d(i,s),!p(b(i,s),[24,83,128,103]))return;for(b(i,s);s[0]1){var O=[];for(A=0;A=e.length)){var n=("0000000"+e[s].toString(2)).substr(-8),r=/^(0*1)(\d*)$/.exec(n);if(r){var i=r[1].length,o=[];if(!(s+i>e.length)){for(var _=0;_e.length)return;for(var i=0;i0&&(c+=a.buffer.byteLength,l.push(a.buffer)),f+=57600,setTimeout(h)}else{var a;(a=_.flush()).length>0&&(c+=a.buffer.byteLength,l.push(a.buffer));var o=s.fn(l,c,i,r.sampleRate);n(o,r),t(new Blob(l,{type:"audio/mp3"}))}};h()},Recorder.BindDestroy("mp3Worker",(function(){console.log("mp3Worker Destroy"),e&&e.terminate(),e=null})),Recorder.prototype.mp3_envCheck=function(e,t){var s="";return t.takeoffEncodeChunk&&(e.canProcess?a()||(s="当前浏览器版本太低,无法实时处理"):s=e.envName+"环境不支持实时处理"),s},Recorder.prototype.mp3_start=function(e){return a(e)};var t={id:0},a=function(a){var n=e;try{if(!n){var r=");wk_lame();var wk_ctxs={};self.onmessage="+function(e){var t=e.data,a=wk_ctxs[t.id];if("init"==t.action)wk_ctxs[t.id]={sampleRate:t.sampleRate,bitRate:t.bitRate,takeoff:t.takeoff,mp3Size:0,pcmSize:0,encArr:[],encObj:new wk_lame.Mp3Encoder(1,t.sampleRate,t.bitRate)};else if(!a)return;switch(t.action){case"stop":a.encObj=null,delete wk_ctxs[t.id];break;case"encode":a.pcmSize+=t.pcm.length,(s=a.encObj.encodeBuffer(t.pcm)).length>0&&(a.takeoff?self.postMessage({action:"takeoff",id:t.id,chunk:s}):(a.mp3Size+=s.buffer.byteLength,a.encArr.push(s.buffer)));break;case"complete":var s;(s=a.encObj.flush()).length>0&&(a.takeoff?self.postMessage({action:"takeoff",id:t.id,chunk:s}):(a.mp3Size+=s.buffer.byteLength,a.encArr.push(s.buffer)));var n=wk_mp3TrimFix.fn(a.encArr,a.mp3Size,a.pcmSize,a.sampleRate);self.postMessage({action:t.action,id:t.id,blob:new Blob(a.encArr,{type:"audio/mp3"}),meta:n})}};r+=";var wk_mp3TrimFix={rm:"+s.rm+",fn:"+s.fn+"}";var i=Recorder.lamejs.toString(),o=(window.URL||webkitURL).createObjectURL(new Blob(["var wk_lame=(",i,r],{type:"text/javascript"}));n=new Worker(o),setTimeout((function(){(window.URL||webkitURL).revokeObjectURL(o)}),1e4),n.onmessage=function(e){var a=e.data,s=t[a.id];s&&("takeoff"==a.action?s.set.takeoffEncodeChunk(new Uint8Array(a.chunk.buffer)):(s.call&&s.call(a),s.call=null))}}var _={worker:n,set:a,takeoffQueue:[]};return a?(_.id=++t.id,t[_.id]=_,n.postMessage({action:"init",id:_.id,sampleRate:a.sampleRate,bitRate:a.bitRate,takeoff:!!a.takeoffEncodeChunk,x:new Int16Array(5)})):n.postMessage({x:new Int16Array(5)}),e=n,_}catch(e){return n&&n.terminate(),console.error(e),null}};Recorder.prototype.mp3_stop=function(e){if(e&&e.worker){e.worker.postMessage({action:"stop",id:e.id}),e.worker=null,delete t[e.id];var a=-1;for(var s in t)a++;a&&console.warn("mp3 worker剩"+a+"个在串行等待")}},Recorder.prototype.mp3_encode=function(e,t){e&&e.worker&&e.worker.postMessage({action:"encode",id:e.id,pcm:t})},Recorder.prototype.mp3_complete=function(e,t,a,s){var r=this;e&&e.worker?(e.call=function(a){n(a.meta,e.set),t(a.blob),s&&r.mp3_stop(e)},e.worker.postMessage({action:"complete",id:e.id})):a("mp3编码器未打开")},Recorder.mp3ReadMeta=function(e,t){var a="object"==typeof window?window.parseInt:self.parseInt,s=new Uint8Array(e[0]||[]);if(s.length<4)return null;var n=function(e,t){return("0000000"+((t||s)[e]||0).toString(2)).substr(-8)},r=n(0)+n(1),i=n(2)+n(3);if(!/^1{11}/.test(r))return null;var o={"00":2.5,10:2,11:1}[r.substr(11,2)],_={"01":3}[r.substr(13,2)],l={1:[44100,48e3,32e3],2:[22050,24e3,16e3],2.5:[11025,12e3,8e3]}[o];l&&(l=l[a(i.substr(4,2),2)]);var f=[[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160],[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320]][1==o?1:0][a(i.substr(0,4),2)];if(!(o&&_&&f&&l))return null;for(var c=Math.round(8*t/f),h=1==_?384:2==_||1==o?1152:576,u=h/l*1e3,p=Math.floor(h*f/8/l*1e3),m=0,b=0,d=0;d=p+3){var g=new Uint8Array(v);m="1"==n(v.byteLength-(b-(p+3)+1),g).charAt(6);break}}return m&&p++,{version:o,layer:_,sampleRate:l,bitRate:f,duration:c,size:t,hasPadding:m,frameSize:p,frameDurationFloat:u}};var s={rm:Recorder.mp3ReadMeta,fn:function(e,t,a,s){var n=this.rm(e,t);if(!n)return{err:"mp3非预定格式"};var r=Math.round(a/s*1e3),i=Math.floor((n.duration-r)/n.frameDurationFloat);if(i>0){var o=i*n.frameSize-(n.hasPadding?1:0);t-=o;for(var _=0,l=[],f=0;f=c.byteLength?(o-=c.byteLength,l.push(c),e.splice(f,1),f--):(e[f]=c.slice(o),_=c,o=0)}if(!this.rm(e,t)){_&&(e[0]=_);for(f=0;f "+s.duration+"ms",s.remove>2&&(e.err=(e.err?e.err+", ":"")+"移除帧数过多")):a+=(e.duration||"-")+"ms",e.err?console.error(a,e.err,e):console.log(a,e)}}()},function(e,t){!function(){"use strict";function e(){var t=function(e){return Math.log(e)/Math.log(10)};function a(e){return new Int8Array(e)}function s(e){return new Int16Array(e)}function n(e){return new Int32Array(e)}function r(e){return new Float32Array(e)}function i(e){return new Float64Array(e)}function o(e){if(1==e.length)return r(e[0]);var t=e[0];e=e.slice(1);for(var a=[],s=0;s>=1;0!=e--;)n[r++]=i>a[s++]?0:1,n[r++]=i>a[s++]?0:1}function r(t,a,s,n,r,i){var o=(t>>=1)%2;for(t>>=1;0!=t--;){var _,l,f,c,h,u,p,m;_=s[n++]*a,l=s[n++]*a,h=0|_,f=s[n++]*a,u=0|l,c=s[n++]*a,p=0|f,_+=e.adj43[h],m=0|c,l+=e.adj43[u],r[i++]=0|_,f+=e.adj43[p],r[i++]=0|l,c+=e.adj43[m],r[i++]=0|f,r[i++]=0|c}0!=o&&(h=0|(_=s[n++]*a),u=0|(l=s[n++]*a),_+=e.adj43[h],l+=e.adj43[u],r[i++]=0|_,r[i++]=0|l)}var i=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function o(e,t,a,s){var n=function(e,t,a){var s=0,n=0;do{var r=e[t++],i=e[t++];s>=16)>r&&(o=r,s++),n.bits+=o,s}(e,t,a,i[n-1],s);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return function(e,t,a,s,n){var r=0,i=0,o=0,_=B.ht[s].xlen,l=B.ht[s].hlen,f=B.ht[s+1].hlen,c=B.ht[s+2].hlen;do{var h=e[t+0]*_+e[t+1];t+=2,r+=l[h],i+=f[h],o+=c[h]}while(ti&&(r=i,u++),r>o&&(r=o,u=s+2),n.bits+=r,u}(e,t,a,i[n-1],s);default:if(n>O.IXMAX_VAL)return s.bits=O.LARGE_BITS,-1;var r,o;for(n-=15,r=24;r<32&&!(B.ht[r].linmax>=n);r++);for(o=r-8;o<24&&!(B.ht[o].linmax>=n);o++);return function(e,t,a,s,n,r){var i,o=65536*B.ht[s].xlen+B.ht[n].xlen,_=0;do{var l=e[t++],f=e[t++];0!=l&&(l>14&&(l=15,_+=o),l*=16),0!=f&&(f>14&&(f=15,_+=o),l+=f),_+=B.largetbl[l]}while(t>=16)>i&&(_=i,s=n),r.bits+=_,s}(e,t,a,o,r,s)}}function _(e,a,s,n,r,i,_,l){for(var f=a.big_values,c=2;c=f)break;var u=r[c-2]+a.count1bits;if(s.part2_3_length<=u)break;var p=new t(u),m=o(n,h,f,p);u=p.bits,s.part2_3_length<=u||(s.assign(a),s.part2_3_length=u,s.region0_count=i[c-2],s.region1_count=c-2-i[c-2],s.table_select[0]=_[c-2],s.table_select[1]=l[c-2],s.table_select[2]=m)}}this.noquant_count_bits=function(e,a,s){var n=a.l3_enc,r=Math.min(576,a.max_nonzero_coeff+2>>1<<1);for(null!=s&&(s.sfb_count1=0);r>1&&0==(n[r-1]|n[r-2]);r-=2);a.count1=r;for(var i=0,_=0;r>3;r-=4){var l;if((2147483647&(n[r-1]|n[r-2]|n[r-3]|n[r-4]))>1)break;l=2*(2*(2*n[r-4]+n[r-3])+n[r-2])+n[r-1],i+=B.t32l[l],_+=B.t33l[l]}var f=i;if(a.count1table_select=0,i>_&&(f=_,a.count1table_select=1),a.count1bits=f,a.big_values=r,0==r)return f;if(a.block_type==X.SHORT_TYPE)(i=3*e.scalefac_band.s[3])>a.big_values&&(i=a.big_values),_=a.big_values;else if(a.block_type==X.NORM_TYPE){if(i=a.region0_count=e.bv_scf[r-2],_=a.region1_count=e.bv_scf[r-1],_=e.scalefac_band.l[i+_+2],i=e.scalefac_band.l[i+1],_(_=r)&&(i=_);if(i=Math.min(i,r),_=Math.min(_,r),0_)return O.LARGE_BITS;if(function(t,a,n,i,o){var _,l,f,h=0,u=0,p=0,m=0,b=a,d=0,v=b,g=0,S=t,M=0;for(f=null!=o&&i.global_gain==o.global_gain,l=i.block_type==X.SHORT_TYPE?38:21,_=0;_<=l;_++){var w=-1;if((f||i.block_type==X.NORM_TYPE)&&(w=i.global_gain-(i.scalefac[_]+(0!=i.preflag?e.pretab[_]:0)<i.max_nonzero_coeff)R=i.max_nonzero_coeff-h+1,c.fill(a,i.max_nonzero_coeff,576,0),(k=R)<0&&(k=0),_=l+1;if(0==u&&0==p&&(v=b,g=d,S=t,M=m),null!=o&&o.sfb_count1>0&&_>=o.sfb_count1&&o.step[_]>0&&w>=o.step[_]?(0!=u&&(r(u,n,S,M,v,g),u=0,v=b,g=d,S=t,M=m),p+=k):(0!=p&&(s(p,n,S,M,v,g),p=0,v=b,g=d,S=t,M=m),u+=k),k<=0){0!=p&&(s(p,n,S,M,v,g),p=0),0!=u&&(r(u,n,S,M,v,g),u=0);break}}_<=l&&(d+=i.width[_],m+=i.width[_],h+=i.width[_])}0!=u&&(r(u,n,S,M,v,g),u=0),0!=p&&(s(p,n,S,M,v,g),p=0)}(a,o,e.IPOW20(n.global_gain),n,i),0!=(2&t.substep_shaping))for(var l=0,f=n.global_gain+n.scalefac_scale,h=.634521682242439/e.IPOW20(f),u=0;u=h?o[p]:0}return this.noquant_count_bits(t,n,i)},this.best_huffman_divide=function(e,a){var s=new V,r=a.l3_enc,i=n(23),l=n(23),f=n(23),c=n(23);if(a.block_type!=X.SHORT_TYPE||1!=e.mode_gr){s.assign(a),a.block_type==X.NORM_TYPE&&(!function(e,a,s,n,r,i,_){for(var l=a.big_values,f=0;f<=22;f++)n[f]=O.LARGE_BITS;for(f=0;f<16;f++){var c=e.scalefac_band.l[f+1];if(c>=l)break;var h=0,u=new t(h),p=o(s,0,c,u);h=u.bits;for(var m=0;m<8;m++){var b=e.scalefac_band.l[f+m+2];if(b>=l)break;var d=h,v=o(s,c,b,u=new t(d));d=u.bits,n[f+m]>d&&(n[f+m]=d,r[f+m]=f,i[f+m]=p,_[f+m]=v)}}}(e,a,r,i,l,f,c),_(e,s,a,r,i,l,f,c));var h=s.big_values;if(!(0==h||(r[h-2]|r[h-1])>1||(h=a.count1+2)>576)){s.assign(a),s.count1=h;for(var u=0,p=0;h>s.big_values;h-=4){var m=2*(2*(2*r[h-4]+r[h-3])+r[h-2])+r[h-1];u+=B.t32l[m],p+=B.t33l[m]}if(s.big_values=h,s.count1table_select=0,u>p&&(u=p,s.count1table_select=1),s.count1bits=u,s.block_type==X.NORM_TYPE)_(e,s,a,r,i,l,f,c);else{if(s.part2_3_length=u,(u=e.scalefac_band.l[8])>h&&(u=h),u>0){var b=new t(s.part2_3_length);s.table_select[0]=o(r,0,u,b),s.part2_3_length=b.bits}if(h>u){b=new t(s.part2_3_length);s.table_select[1]=o(r,u,h,b),s.part2_3_length=b.bits}a.part2_3_length>s.part2_3_length&&a.assign(s)}}}};var l=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],f=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],u=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],p=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];g.slen1_tab=u,g.slen2_tab=p,this.best_scalefac_store=function(t,a,s,n){var r,i,o,_,c=n.tt[a][s],h=0;for(o=0,r=0;r0&&(b|=c.scalefac[r]);if(0==(1&b)&&0!=b){for(r=0;r0&&(c.scalefac[r]>>=1);c.scalefac_scale=h=1}}if(0==c.preflag&&c.block_type!=X.SHORT_TYPE&&2==t.mode_gr){for(r=11;r0&&(c.scalefac[r]-=e.pretab[r]);c.preflag=h=1}}for(i=0;i<4;i++)n.scfsi[s][i]=0;for(2==t.mode_gr&&1==a&&n.tt[0][s].block_type!=X.SHORT_TYPE&&n.tt[1][s].block_type!=X.SHORT_TYPE&&(!function(e,t){for(var a,s=t.tt[1][e],n=t.tt[0][e],r=0;r=0);a++);if(a==B.scfsi_band[r+1]){for(a=B.scfsi_band[r];ah&&(s.part2_length=h,s.scalefac_compress=r)}}(s,n),h=0),r=0;rn[a]&&(t.part2_length=n[a],t.scalefac_compress=a);return t.part2_length==O.LARGE_BITS};var v=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(t,a){var s,r,i,o,_,l,f,c,u=n(4),p=a.scalefac;for(s=0!=a.preflag?2:0,f=0;f<4;f++)u[f]=0;if(a.block_type==X.SHORT_TYPE){r=1;var m=e.nr_of_sfb_block[s][r];for(c=0,i=0;i<4;i++)for(o=m[i]/3,f=0;fu[i]&&(u[i]=p[3*c+_])}else{r=0;m=e.nr_of_sfb_block[s][r];for(c=0,i=0;i<4;i++)for(o=m[i],f=0;fu[i]&&(u[i]=p[c])}for(l=!1,i=0;i<4;i++)u[i]>v[s][i]&&(l=!0);if(!l){var b,d,g,M;for(a.sfb_partition_table=e.nr_of_sfb_block[s][r],i=0;i<4;i++)a.slen[i]=S[u[i]];switch(b=a.slen[0],d=a.slen[1],g=a.slen[2],M=a.slen[3],s){case 0:a.scalefac_compress=(5*b+d<<4)+(g<<2)+M;break;case 1:a.scalefac_compress=400+(5*b+d<<2)+g;break;case 2:a.scalefac_compress=500+3*b+d;break;default:h.err.printf("intensity stereo not implemented yet\n")}}if(!l)for(a.part2_length=0,i=0;i<4;i++)a.part2_length+=a.slen[i]*a.sfb_partition_table[i];return l};var S=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(e){for(var t=2;t<=576;t+=2){for(var s,n=0;e.scalefac_band.l[++n]t;)s--;for(s<0&&(s=a[n][0]),e.bv_scf[t-2]=s,s=a[n][1];e.scalefac_band.l[s+e.bv_scf[t-2]+2]>t;)s--;s<0&&(s=a[n][1]),e.bv_scf[t-1]=s}}}function S(){}function M(){function e(e,t,a,s,n,r,i,o,_,l,f,c,h,u,p){this.vbr_q=e,this.quant_comp=t,this.quant_comp_s=a,this.expY=s,this.st_lrm=n,this.st_s=r,this.masking_adj=i,this.masking_adj_short=o,this.ath_lower=_,this.ath_curve=l,this.ath_sensitivity=f,this.interch=c,this.safejoint=h,this.sfb21mod=u,this.msfix=p}function t(e,t,a,s,n,r,i,o,_,l,f,c,h,u){this.quant_comp=t,this.quant_comp_s=a,this.safejoint=s,this.nsmsfix=n,this.st_lrm=r,this.st_s=i,this.nsbass=o,this.scale=_,this.masking_adj=l,this.ath_lower=f,this.ath_curve=c,this.interch=h,this.sfscale=u}var a;this.setModules=function(e){a=e};var s=[new e(0,9,9,0,5.2,125,-4.2,-6.3,4.8,1,0,0,2,21,.97),new e(1,9,9,0,5.3,125,-3.6,-5.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,5.6,125,-2.2,-3.5,2.8,2,0,0,2,21,1.49),new e(3,9,9,1,5.8,130,-1.8,-2.8,2.6,3,-4,0,2,20,1.64),new e(4,9,9,1,6,135,-.7,-1.1,1.1,3.5,-8,0,2,0,1.79),new e(5,9,9,1,6.4,140,.5,.4,-7.5,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,6.6,145,.67,.65,-14.7,6.5,-19,4e-4,0,0,2.3),new e(7,9,9,1,6.6,145,.8,.75,-19.7,8,-22,6e-4,0,0,2.7),new e(8,9,9,1,6.6,145,1.2,1.15,-27.5,10,-23,7e-4,0,0,0),new e(9,9,9,1,6.6,145,1.6,1.6,-36,11,-25,8e-4,0,0,0),new e(10,9,9,1,6.6,145,2,2,-36,12,-25,8e-4,0,0,0)],n=[new e(0,9,9,0,4.2,25,-7,-4,7.5,1,0,0,2,26,.97),new e(1,9,9,0,4.2,25,-5.6,-3.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,4.2,25,-4.4,-1.8,2,2,0,0,2,18,1.49),new e(3,9,9,1,4.2,25,-3.4,-1.25,1.1,3,-4,0,2,15,1.64),new e(4,9,9,1,4.2,25,-2.2,.1,0,3.5,-8,0,2,0,1.79),new e(5,9,9,1,4.2,25,-1,1.65,-7.7,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,4.2,25,-0,2.47,-7.7,6.5,-19,4e-4,0,0,2),new e(7,9,9,1,4.2,25,.5,2,-14.5,8,-22,6e-4,0,0,2),new e(8,9,9,1,4.2,25,1,2.4,-22,10,-23,7e-4,0,0,2),new e(9,9,9,1,4.2,25,1.5,2.95,-30,11,-25,8e-4,0,0,2),new e(10,9,9,1,4.2,25,2,2.95,-36,12,-30,8e-4,0,0,2)];function r(e,t,a){var r=e.VBR==b.vbr_rh?s:n,i=e.VBR_q_frac,o=r[t],_=r[t+1],l=o;o.st_lrm=o.st_lrm+i*(_.st_lrm-o.st_lrm),o.st_s=o.st_s+i*(_.st_s-o.st_s),o.masking_adj=o.masking_adj+i*(_.masking_adj-o.masking_adj),o.masking_adj_short=o.masking_adj_short+i*(_.masking_adj_short-o.masking_adj_short),o.ath_lower=o.ath_lower+i*(_.ath_lower-o.ath_lower),o.ath_curve=o.ath_curve+i*(_.ath_curve-o.ath_curve),o.ath_sensitivity=o.ath_sensitivity+i*(_.ath_sensitivity-o.ath_sensitivity),o.interch=o.interch+i*(_.interch-o.interch),o.msfix=o.msfix+i*(_.msfix-o.msfix),function(e,t){var a=0;0>t&&(a=-1,t=0);90||(e.quant_comp=l.quant_comp),0!=a?e.quant_comp_short=l.quant_comp_s:Math.abs(e.quant_comp_short- -1)>0||(e.quant_comp_short=l.quant_comp_s),0!=l.expY&&(e.experimentalY=0!=l.expY),0!=a?e.internal_flags.nsPsy.attackthre=l.st_lrm:Math.abs(e.internal_flags.nsPsy.attackthre- -1)>0||(e.internal_flags.nsPsy.attackthre=l.st_lrm),0!=a?e.internal_flags.nsPsy.attackthre_s=l.st_s:Math.abs(e.internal_flags.nsPsy.attackthre_s- -1)>0||(e.internal_flags.nsPsy.attackthre_s=l.st_s),0!=a?e.maskingadjust=l.masking_adj:Math.abs(e.maskingadjust-0)>0||(e.maskingadjust=l.masking_adj),0!=a?e.maskingadjust_short=l.masking_adj_short:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=l.masking_adj_short),0!=a?e.ATHlower=-l.ath_lower/10:Math.abs(10*-e.ATHlower-0)>0||(e.ATHlower=-l.ath_lower/10),0!=a?e.ATHcurve=l.ath_curve:Math.abs(e.ATHcurve- -1)>0||(e.ATHcurve=l.ath_curve),0!=a?e.athaa_sensitivity=l.ath_sensitivity:Math.abs(e.athaa_sensitivity- -1)>0||(e.athaa_sensitivity=l.ath_sensitivity),l.interch>0&&(0!=a?e.interChRatio=l.interch:Math.abs(e.interChRatio- -1)>0||(e.interChRatio=l.interch)),l.safejoint>0&&(e.exp_nspsytune=e.exp_nspsytune|l.safejoint),l.sfb21mod>0&&(e.exp_nspsytune=e.exp_nspsytune|l.sfb21mod<<20),0!=a?e.msfix=l.msfix:Math.abs(e.msfix- -1)>0||(e.msfix=l.msfix),0==a&&(e.VBR_q=t,e.VBR_q_frac=i)}var i=[new t(8,9,9,0,0,6.6,145,0,.95,0,-30,11,.0012,1),new t(16,9,9,0,0,6.6,145,0,.95,0,-25,11,.001,1),new t(24,9,9,0,0,6.6,145,0,.95,0,-20,11,.001,1),new t(32,9,9,0,0,6.6,145,0,.95,0,-15,11,.001,1),new t(40,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new t(48,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new t(56,9,9,0,0,6.6,145,0,.95,0,-6,11,8e-4,1),new t(64,9,9,0,0,6.6,145,0,.95,0,-2,11,8e-4,1),new t(80,9,9,0,0,6.6,145,0,.95,0,0,8,7e-4,1),new t(96,9,9,0,2.5,6.6,145,0,.95,0,1,5.5,6e-4,1),new t(112,9,9,0,2.25,6.6,145,0,.95,0,2,4.5,5e-4,1),new t(128,9,9,0,1.95,6.4,140,0,.95,0,3,4,2e-4,1),new t(160,9,9,1,1.79,6,135,0,.95,-2,5,3.5,0,1),new t(192,9,9,1,1.49,5.6,125,0,.97,-4,7,3,0,0),new t(224,9,9,1,1.25,5.2,125,0,.98,-6,9,2,0,0),new t(256,9,9,1,.97,5.2,125,0,1,-8,10,1,0,0),new t(320,9,9,1,.9,5.2,125,0,1,-10,12,0,0,0)];function o(e,t,s){var n=t,r=a.nearestBitrateFullIndex(t);if(e.VBR=b.vbr_abr,e.VBR_mean_bitrate_kbps=n,e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,320),e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.brate=e.VBR_mean_bitrate_kbps,e.VBR_mean_bitrate_kbps>320&&(e.disable_reservoir=!0),i[r].safejoint>0&&(e.exp_nspsytune=2|e.exp_nspsytune),i[r].sfscale>0&&(e.internal_flags.noise_shaping=2),Math.abs(i[r].nsbass)>0){var o=int(4*i[r].nsbass);o<0&&(o+=64),e.exp_nspsytune=e.exp_nspsytune|o<<2}return 0!=s?e.quant_comp=i[r].quant_comp:Math.abs(e.quant_comp- -1)>0||(e.quant_comp=i[r].quant_comp),0!=s?e.quant_comp_short=i[r].quant_comp_s:Math.abs(e.quant_comp_short- -1)>0||(e.quant_comp_short=i[r].quant_comp_s),0!=s?e.msfix=i[r].nsmsfix:Math.abs(e.msfix- -1)>0||(e.msfix=i[r].nsmsfix),0!=s?e.internal_flags.nsPsy.attackthre=i[r].st_lrm:Math.abs(e.internal_flags.nsPsy.attackthre- -1)>0||(e.internal_flags.nsPsy.attackthre=i[r].st_lrm),0!=s?e.internal_flags.nsPsy.attackthre_s=i[r].st_s:Math.abs(e.internal_flags.nsPsy.attackthre_s- -1)>0||(e.internal_flags.nsPsy.attackthre_s=i[r].st_s),0!=s?e.scale=i[r].scale:Math.abs(e.scale- -1)>0||(e.scale=i[r].scale),0!=s?e.maskingadjust=i[r].masking_adj:Math.abs(e.maskingadjust-0)>0||(e.maskingadjust=i[r].masking_adj),i[r].masking_adj>0?0!=s?e.maskingadjust_short=.9*i[r].masking_adj:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=.9*i[r].masking_adj):0!=s?e.maskingadjust_short=1.1*i[r].masking_adj:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=1.1*i[r].masking_adj),0!=s?e.ATHlower=-i[r].ath_lower/10:Math.abs(10*-e.ATHlower-0)>0||(e.ATHlower=-i[r].ath_lower/10),0!=s?e.ATHcurve=i[r].ath_curve:Math.abs(e.ATHcurve- -1)>0||(e.ATHcurve=i[r].ath_curve),0!=s?e.interChRatio=i[r].interch:Math.abs(e.interChRatio- -1)>0||(e.interChRatio=i[r].interch),t}this.apply_preset=function(e,t,a){switch(t){case W.R3MIX:t=W.V3,e.VBR=b.vbr_mtrh;break;case W.MEDIUM:t=W.V4,e.VBR=b.vbr_rh;break;case W.MEDIUM_FAST:t=W.V4,e.VBR=b.vbr_mtrh;break;case W.STANDARD:t=W.V2,e.VBR=b.vbr_rh;break;case W.STANDARD_FAST:t=W.V2,e.VBR=b.vbr_mtrh;break;case W.EXTREME:t=W.V0,e.VBR=b.vbr_rh;break;case W.EXTREME_FAST:t=W.V0,e.VBR=b.vbr_mtrh;break;case W.INSANE:return t=320,e.preset=t,o(e,t,a),e.VBR=b.vbr_off,t}switch(e.preset=t,t){case W.V9:return r(e,9,a),t;case W.V8:return r(e,8,a),t;case W.V7:return r(e,7,a),t;case W.V6:return r(e,6,a),t;case W.V5:return r(e,5,a),t;case W.V4:return r(e,4,a),t;case W.V3:return r(e,3,a),t;case W.V2:return r(e,2,a),t;case W.V1:return r(e,1,a),t;case W.V0:return r(e,0,a),t}return 8<=t&&t<=320?o(e,t,a):(e.preset=0,t)}}function w(){var e;this.setModules=function(t){e=t},this.ResvFrameBegin=function(t,a){var s,n=t.internal_flags,r=n.l3_side,i=e.getframebits(t);a.bits=(i-8*n.sideinfo_len)/n.mode_gr;var o=2048*n.mode_gr-8;t.brate>320?s=8*int(1e3*t.brate/(t.out_samplerate/1152)/8+.5):(s=11520,t.strict_ISO&&(s=8*int(32e4/(t.out_samplerate/1152)/8+.5))),n.ResvMax=s-i,n.ResvMax>o&&(n.ResvMax=o),(n.ResvMax<0||t.disable_reservoir)&&(n.ResvMax=0);var _=a.bits*n.mode_gr+Math.min(n.ResvSize,n.ResvMax);return _>s&&(_=s),r.resvDrain_pre=0,null!=n.pinfo&&(n.pinfo.mean_bits=a.bits/2,n.pinfo.resvsize=n.ResvSize),_},this.ResvMaxBits=function(e,t,a,s){var n,r=e.internal_flags,i=r.ResvSize,o=r.ResvMax;0!=s&&(i+=t),0!=(1&r.substep_shaping)&&(o*=.9),a.bits=t,10*i>9*o?(n=i-9*o/10,a.bits+=n,r.substep_shaping|=128):(n=0,r.substep_shaping&=127,e.disable_reservoir||0!=(1&r.substep_shaping)||(a.bits-=.1*t));var _=i<6*r.ResvMax/10?i:6*r.ResvMax/10;return(_-=n)<0&&(_=0),_},this.ResvAdjust=function(e,t){e.ResvSize-=t.part2_3_length+t.part2_length},this.ResvFrameEnd=function(e,t){var a,s=e.l3_side;e.ResvSize+=t*e.mode_gr;var n=0;s.resvDrain_post=0,s.resvDrain_pre=0,0!=(a=e.ResvSize%8)&&(n+=a),(a=e.ResvSize-n-e.ResvMax)>0&&(n+=a);var r=Math.min(8*s.main_data_begin,n)/8;s.resvDrain_pre+=8*r,n-=8*r,e.ResvSize-=8*r,s.main_data_begin-=r,s.resvDrain_post+=n,e.ResvSize-=n}}function R(){this.setModules=function(e,t,a){e,t,a};var e=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];function t(t,a){return a=a>>8^e[255&(a^t)]}this.updateMusicCRC=function(e,a,s,n){for(var r=0;r0;){var s;0==p&&(p=8,u++,e.header[e.w_ptr].write_timing==f&&m(e),l[u]=0),a-=s=Math.min(a,p),p-=s,l[u]|=t>>a<0;){var s;0==p&&(p=8,u++,l[u]=0),a-=s=Math.min(a,p),p-=s,l[u]|=t>>a<=8&&(b(s,76,8),t-=8),t>=8&&(b(s,65,8),t-=8),t>=8&&(b(s,77,8),t-=8),t>=8&&(b(s,69,8),t-=8),t>=32){var n=i.getLameShortVersion();if(t>=32)for(a=0;a=8;++a)t-=8,b(s,n.charCodeAt(a),8)}for(;t>=1;t-=1)b(s,s.ancillary_flag,1),s.ancillary_flag^=e.disable_reservoir?0:1}function M(e,t,a){for(var s=e.header[e.h_ptr].ptr;a>0;){var n=Math.min(a,8-(7&s));a-=n,e.header[e.h_ptr].buf[s>>3]|=t>>a<<8-(7&s)-n,s+=n}e.header[e.h_ptr].ptr=s}function w(e,t){e<<=8;for(var a=0;a<8;a++)0!=(65536&((t<<=1)^(e<<=1)))&&(t^=32773);return t}function R(e,t){var a,s=B.ht[t.count1table_select+32],n=0,r=t.big_values,i=t.big_values;for(a=(t.count1-t.big_values)/4;a>0;--a){var o=0,_=0;0!=t.l3_enc[r+0]&&(_+=8,t.xr[i+0]<0&&o++),0!=t.l3_enc[r+1]&&(_+=4,o*=2,t.xr[i+1]<0&&o++),0!=t.l3_enc[r+2]&&(_+=2,o*=2,t.xr[i+2]<0&&o++),0!=t.l3_enc[r+3]&&(_++,o*=2,t.xr[i+3]<0&&o++),r+=4,i+=4,b(e,o+s.table[_],s.hlen[_]),n+=s.hlen[_]}return n}function k(e,t,a,s,n){var r=B.ht[t],i=0;if(0==t)return i;for(var o=a;o15){if(u>14)h|=u-15<<1,l=f,u=15;if(p>14)h<<=f,h|=p-15,l+=f,p=15;c=16}0!=p&&(h<<=1,n.xr[o+1]<0&&h++,_--),u=u*c+p,l-=_,_+=r.hlen[u],b(e,r.table[u],_),b(e,h,l),i+=_+l}return i}function A(e,t){var a=3*e.scalefac_band.s[3];a>t.big_values&&(a=t.big_values);var s=k(e,t.table_select[0],0,a,t);return s+=k(e,t.table_select[1],a,t.big_values,t)}function y(e,t){var a,s,n,r;a=t.big_values;var i=t.region0_count+1;return n=e.scalefac_band.l[i],i+=t.region1_count+1,n>a&&(n=a),(r=e.scalefac_band.l[i])>a&&(r=a),s=k(e,t.table_select[0],0,n,t),s+=k(e,t.table_select[1],n,r,t),s+=k(e,t.table_select[2],r,a,t)}function T(){this.total=0}function x(t,a){var s,n,r,i,o,_=t.internal_flags;return o=_.w_ptr,-1==(i=_.h_ptr-1)&&(i=Z.MAX_HEADER_BUF-1),s=_.header[i].write_timing-f,a.total=s,s>=0&&(n=1+i-o,i>8),t[5]=byte(255&a)},this.flush_bitstream=function(e){var a,n,r=e.internal_flags,i=r.h_ptr-1;if(-1==i&&(i=Z.MAX_HEADER_BUF-1),a=r.l3_side,!((n=x(e,new T))<0)){if(v(e,n),r.ResvSize=0,a.main_data_begin=0,r.findReplayGain){var o=s.GetTitleGain(r.rgdata);r.RadioGain=0|Math.floor(10*o+.5)}r.findPeakSample&&(r.noclipGainChange=0|Math.ceil(20*t(r.PeakSample/32767)*10),r.noclipGainChange>0&&(EQ(e.scale,1)||EQ(e.scale,0))?r.noclipScale=Math.floor(32767/r.PeakSample*100)/100:r.noclipScale=-1)}},this.add_dummy_byte=function(e,t,a){for(var s,n=e.internal_flags;a-- >0;)for(d(0,t,8),s=0;s ResvSize"),8*t.main_data_begin!=a.ResvSize&&(h.err.printf("bit reservoir error: \nl3_side.main_data_begin: %d \nResvoir size: %d \nresv drain (post) %d \nresv drain (pre) %d \nheader and sideinfo: %d \ndata bits: %d \ntotal bits: %d (remainder: %d) \nbitsperframe: %d \n",8*t.main_data_begin,a.ResvSize,t.resvDrain_post,t.resvDrain_pre,8*a.sideinfo_len,n-t.resvDrain_post-8*a.sideinfo_len,n,n%8,s),h.err.println("This is a fatal error. It has several possible causes:"),h.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),h.err.println(" 9%% Your system is overclocked"),h.err.println(" 1%% bug in LAME encoding library"),a.ResvSize=8*t.main_data_begin),f>1e9){var r;for(r=0;ri)return-1;if(h.arraycopy(l,0,t,a,c),u=-1,p=0,0!=f){var m=n(1);if(m[0]=e.nMusicCRC,_.updateMusicCRC(m,t,a,c),e.nMusicCRC=m[0],c>0&&(e.VBR_seek_table.nBytesWritten+=c),e.decode_on_the_fly)for(var b,d=o([2,1152]),v=c,g=-1;0!=g;)if(g=r.hip_decode1_unclipped(e.hip,t,a,v,d[0],d[1]),v=0,-1==g&&(g=0),g>0){if(e.findPeakSample){for(b=0;be.PeakSample?e.PeakSample=d[0][b]:-d[0][b]>e.PeakSample&&(e.PeakSample=-d[0][b]);if(e.channels_out>1)for(b=0;be.PeakSample?e.PeakSample=d[1][b]:-d[1][b]>e.PeakSample&&(e.PeakSample=-d[1][b])}if(e.findReplayGain&&s.AnalyzeSamples(e.rgdata,d[0],0,d[1],0,g,e.channels_out)==S.GAIN_ANALYSIS_ERROR)return-6}}return c},this.init_bit_stream_w=function(e){l=a(W.LAME_MAXMP3BUFFER),e.h_ptr=e.w_ptr=0,e.header[e.h_ptr].write_timing=0,u=-1,p=0,f=0}}function A(e,t,a,s){this.xlen=e,this.linmax=t,this.table=a,this.hlen=s}d.STEREO=new d(0),d.JOINT_STEREO=new d(1),d.DUAL_CHANNEL=new d(2),d.MONO=new d(3),d.NOT_SET=new d(4),S.STEPS_per_dB=100,S.MAX_dB=120,S.GAIN_NOT_ENOUGH_SAMPLES=-24601,S.GAIN_ANALYSIS_ERROR=0,S.GAIN_ANALYSIS_OK=1,S.INIT_GAIN_ANALYSIS_ERROR=0,S.INIT_GAIN_ANALYSIS_OK=1,S.YULE_ORDER=10,S.MAX_ORDER=S.YULE_ORDER,S.MAX_SAMP_FREQ=48e3,S.RMS_WINDOW_TIME_NUMERATOR=1,S.RMS_WINDOW_TIME_DENOMINATOR=20,S.MAX_SAMPLES_PER_WINDOW=S.MAX_SAMP_FREQ*S.RMS_WINDOW_TIME_NUMERATOR/S.RMS_WINDOW_TIME_DENOMINATOR+1,R.NUMTOCENTRIES=100,R.MAXFRAMESIZE=2880,k.EQ=function(e,t){return Math.abs(e)>Math.abs(t)?Math.abs(e-t)<=1e-6*Math.abs(e):Math.abs(e-t)<=1e-6*Math.abs(t)},k.NEQ=function(e,t){return!k.EQ(e,t)};var B={};function y(e){this.bits=e}function T(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}function x(){this.setModules=function(e,t){e,t}}function E(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=r(X.SBMAX_l),this.s=r(X.SBMAX_s),this.psfb21=r(X.PSFB21),this.psfb12=r(X.PSFB12),this.cb_l=r(X.CBANDS),this.cb_s=r(X.CBANDS),this.eql_w=r(X.BLKSIZE/2)}function P(){this.class_id=0,this.num_samples=0,this.num_channels=0,this.in_samplerate=0,this.out_samplerate=0,this.scale=0,this.scale_left=0,this.scale_right=0,this.analysis=!1,this.bWriteVbrTag=!1,this.decode_only=!1,this.quality=0,this.mode=d.STEREO,this.force_ms=!1,this.free_format=!1,this.findReplayGain=!1,this.decode_on_the_fly=!1,this.write_id3tag_automatic=!1,this.brate=0,this.compression_ratio=0,this.copyright=0,this.original=0,this.extension=0,this.emphasis=0,this.error_protection=0,this.strict_ISO=!1,this.disable_reservoir=!1,this.quant_comp=0,this.quant_comp_short=0,this.experimentalY=!1,this.experimentalZ=0,this.exp_nspsytune=0,this.preset=0,this.VBR=null,this.VBR_q_frac=0,this.VBR_q=0,this.VBR_mean_bitrate_kbps=0,this.VBR_min_bitrate_kbps=0,this.VBR_max_bitrate_kbps=0,this.VBR_hard_min=0,this.lowpassfreq=0,this.highpassfreq=0,this.lowpasswidth=0,this.highpasswidth=0,this.maskingadjust=0,this.maskingadjust_short=0,this.ATHonly=!1,this.ATHshort=!1,this.noATH=!1,this.ATHtype=0,this.ATHcurve=0,this.ATHlower=0,this.athaa_type=0,this.athaa_loudapprox=0,this.athaa_sensitivity=0,this.short_blocks=null,this.useTemporal=!1,this.interChRatio=0,this.msfix=0,this.tune=!1,this.tune_value_a=0,this.version=0,this.encoder_delay=0,this.encoder_padding=0,this.framesize=0,this.frameNum=0,this.lame_allocated_gfp=0,this.internal_flags=null}function L(e){var t=e;this.quantize=t,this.iteration_loop=function(e,t,a,s){var i,o=e.internal_flags,_=r(N.SFBMAX),l=r(576),f=n(2),c=0,h=o.l3_side,u=new y(c);this.quantize.rv.ResvFrameBegin(e,u),c=u.bits;for(var p=0;p>2&63)>=32&&(s-=64),l=Math.pow(10,s/4/10),(s=a.exp_nspsytune>>8&63)>=32&&(s-=64),u=Math.pow(10,s/4/10),(s=a.exp_nspsytune>>14&63)>=32&&(s-=64),b=Math.pow(10,s/4/10),(s=a.exp_nspsytune>>20&63)>=32&&(s-=64),v=b*Math.pow(10,s/4/10),s=0;sZ.MAX_BITS_PER_GRANULE&&(m=Z.MAX_BITS_PER_GRANULE),_=0,l=0;l3*r/4&&(h[l]=3*r/4),h[l]<0&&(h[l]=0),h[l]+s[l]>Z.MAX_BITS_PER_CHANNEL&&(h[l]=Math.max(0,Z.MAX_BITS_PER_CHANNEL-s[l])),_+=h[l];if(_>p)for(l=0;lZ.MAX_BITS_PER_GRANULE){for(l=0;l.5&&(n=.5);var r=0|.5*n*(e[0]+e[1]);r>Z.MAX_BITS_PER_CHANNEL-e[0]&&(r=Z.MAX_BITS_PER_CHANNEL-e[0]),r<0&&(r=0),e[1]>=125&&(e[1]-r>125?(e[0]s&&(e[0]=s*e[0]/r,e[1]=s*e[1]/r)},this.athAdjust=function(e,t,a){var s=90.30873362,n=u.FAST_LOG10_X(t,10),r=e*e,i=0;return n-=a,r>1e-20&&(i=1+u.FAST_LOG10_X(r,10/s)),i<0&&(i=0),n*=i,n+=a+s-94.82444863,Math.pow(10,.1*n)},this.calc_xmin=function(e,t,a,s){var n,r=0,i=e.internal_flags,o=0,_=0,l=i.ATH,f=a.xr,c=e.VBR==b.vbr_mtrh?1:0,h=i.masking_lower;for(e.VBR!=b.vbr_mtrh&&e.VBR!=b.vbr_mt||(h=1),n=0;n>1,B=0;do{B+=T=f[o]*f[o],w+=T0);if(B>S&&_++,n==X.SBPSY_l)w<(A=S*i.nsPsy.longfact[n])&&(w=A);if(0!=c&&(S=w),!e.ATHonly)if((R=t.en.l[n])>0)A=B*t.thm.l[n]*h/R,0!=c&&(A*=i.nsPsy.longfact[n]),S>1;M=g/d,w=2220446049250313e-31;do{var T,x;B+=T=f[o]*f[o],w+=T0);if(B>g&&_++,m==X.SBPSY_s)w<(A=g*i.nsPsy.shortfact[m])&&(w=A);if(S=0!=c?w:g,!e.ATHonly&&!e.ATHshort)if((R=t.en.s[m][v])>0)A=B*t.thm.s[m][v]*h/R,0!=c&&(A*=i.nsPsy.shortfact[m]),Ss[r-3+1]&&(s[r-3+1]+=(s[r-3]-s[r-3+1])*i.decay),s[r-3+1]>s[r-3+2]&&(s[r-3+2]+=(s[r-3+1]-s[r-3+2])*i.decay))}return _},this.calc_noise_core=function(e,t,a,s){var n=0,i=t.s,o=e.l3_enc;if(i>e.count1)for(;0!=a--;){l=e.xr[i],i++,n+=l*l,l=e.xr[i],i++,n+=l*l}else if(i>e.big_values){var _=r(2);for(_[0]=0,_[1]=s;0!=a--;){l=Math.abs(e.xr[i])-_[o[i]],i++,n+=l*l,l=Math.abs(e.xr[i])-_[o[i]],i++,n+=l*l}}else for(;0!=a--;){var l;l=Math.abs(e.xr[i])-h[o[i]]*s,i++,n+=l*l,l=Math.abs(e.xr[i])-h[o[i]]*s,i++,n+=l*l}return t.s=i,n},this.calc_noise=function(e,t,a,s,n){var r,i,o=0,_=0,c=0,h=0,p=0,m=-20,b=0,d=e.scalefac,g=0;for(s.over_SSD=0,r=0;r>1,b+e.width[r]>e.max_nonzero_coeff)i=(R=e.max_nonzero_coeff-b+1)>0?R>>1:0;var A=new v(b);w=this.calc_noise_core(e,A,i,k),b=A.s,null!=n&&(n.step[r]=M,n.noise[r]=w),w=a[o++]=w/t[_++],w=u.FAST_LOG10(Math.max(w,1e-20)),null!=n&&(n.noise_log[r]=w)}if(null!=n&&(n.global_gain=e.global_gain),p+=w,w>0)S=Math.max(0|10*w+.5,1),s.over_SSD+=S*S,c++,h+=w;m=Math.max(m,w)}return s.over_count=c,s.tot_noise=p,s.over_noise=h,s.max_noise=m,c},this.set_pinfo=function(e,t,a,s,n){var i,o,_,f,c,h=e.internal_flags,u=0==t.scalefac_scale?.5:1,p=t.scalefac,m=r(N.SFBMAX),b=r(N.SFBMAX),d=new T;calc_xmin(e,a,t,m),calc_noise(t,m,b,d,null);var v=0;for(o=t.sfb_lmax,t.block_type!=X.SHORT_TYPE&&0==t.mixed_block_flag&&(o=22),i=0;i0&&!e.ATHonly?f/=a.en.l[i]:f=0,h.pinfo.thr[s][n][i]=c*Math.max(f*a.thm.l[i],h.ATH.l[i]),h.pinfo.LAMEsfb[s][n][i]=0,0!=t.preflag&&i>=11&&(h.pinfo.LAMEsfb[s][n][i]=-u*l[i]),i0?f/=a.en.s[i][w]:f=0,(e.ATHonly||e.ATHshort)&&(f=0),h.pinfo.thr_s[s][n][3*i+w]=c*Math.max(f*a.thm.s[i][w],h.ATH.s[i]),h.pinfo.LAMEsfb_s[s][n][3*i+w]=-2*t.subblock_gain[w],i0?(r=a.over_SSD<=t.over_SSD,a.over_SSD==t.over_SSD&&(r=a.bits.2||a.max_noise<=0&&t.max_noise<0&&t.max_noise>a.max_noise-.2&&a.tot_noise0&&t.max_noise>a.max_noise-.2&&a.tot_noise0&&t.max_noise>-.05&&t.max_noise>a.max_noise-.1&&a.tot_noise+a.over_noise0&&t.max_noise>-.1&&t.max_noise>a.max_noise-.15&&a.tot_noise+a.over_noise+a.over_noise1?o=Math.pow(o,.5):o*=.95;break;case 0:default:o>1?o=1:o*=.95}var f=0;for(_=0;_t.xrpow_max&&(t.xrpow_max=s[f+c]);if(2==i.noise_shaping_amp)return}}}(e,t,n,r,i);var l=o(t);return!l&&(!(l=2==_.mode_gr?s.scale_bitcount(t):s.scale_bitcount_lsf(_,t))||(_.noise_shaping>1&&(c.fill(_.pseudohalf,0),0==t.scalefac_scale?(!function(e,t){for(var s=0,n=0;ne.xrpow_max&&(e.xrpow_max=t[s+o])}e.scalefac[n]=i>>1}e.preflag=0,e.scalefac_scale=1}(t,r),l=!1):t.block_type==X.SHORT_TYPE&&_.subblock_gain>0&&(l=function(e,t,s){var n,r=t.scalefac;for(n=0;n=16)return!0;for(var i=0;i<3;i++){var o=0,_=0;for(n=t.sfb_lmax+i;n=7)return!0;t.subblock_gain[i]++;var l=e.scalefac_band.l[t.sfb_lmax];for(n=t.sfb_lmax+i;n>t.scalefac_scale)>=0)r[n]=c,l+=3*f;else{r[n]=0;var h=210+(c<t.xrpow_max&&(t.xrpow_max=s[l+u]);l+=f*(3-i-1)}}var p=a.IPOW20(202);l+=t.width[n]*(i+1);for(u=-t.width[n];u<0;u++)s[l+u]*=p,s[l+u]>t.xrpow_max&&(t.xrpow_max=s[l+u])}}return!1}(_,t,r)||o(t))),l||(l=2==_.mode_gr?s.scale_bitcount(t):s.scale_bitcount_lsf(_,t)),!l))}this.setModules=function(r,i,o,_){e=r,t=i,this.rv=i,a=o,this.qupvt=o,s=_,n.setModules(a,s)},this.ms_convert=function(e,t){for(var a=0;a<576;++a){var s=e.tt[t][0].xr[a],n=e.tt[t][1].xr[a];e.tt[t][0].xr[a]=(s+n)*(.5*u.SQRT2),e.tt[t][1].xr[a]=(s-n)*(.5*u.SQRT2)}},this.init_xrpow=function(e,t,a){var s=0,n=0|t.max_nonzero_coeff;if(t.xrpow_max=0,c.fill(a,n,576,0),(s=function(e,t,a,s){s=0;for(var n=0;n<=a;++n){var r=Math.abs(e.xr[n]);s+=r,t[n]=Math.sqrt(r*Math.sqrt(r)),t[n]>e.xrpow_max&&(e.xrpow_max=t[n])}return s}(t,a,n,s))>1e-20){var r=0;0!=(2&e.substep_shaping)&&(r=1);for(var i=0;i=0&&!r;i--){var o=e.scalefac_band.psfb21[i],_=e.scalefac_band.psfb21[i+1],l=a.athAdjust(s.adjust,s.psfb21[i],s.floor);e.nsPsy.longfact[21]>1e-12&&(l*=e.nsPsy.longfact[21]);for(var f=_-1;f>=o;f--){if(!(Math.abs(n[f])=0&&!r;i--){_=(o=3*e.scalefac_band.s[12]+(e.scalefac_band.s[13]-e.scalefac_band.s[12])*c+(e.scalefac_band.psfb12[i]-e.scalefac_band.psfb12[0]))+(e.scalefac_band.psfb12[i+1]-e.scalefac_band.psfb12[i]);var h=a.athAdjust(s.adjust,s.psfb12[i],s.floor);e.nsPsy.shortfact[12]>1e-12&&(h*=e.nsPsy.shortfact[12]);for(f=_-1;f>=o;f--){if(!(Math.abs(n[f])=1||(c.sort(i,_-b,b),k.EQ(i[_-1],0)))){h=(1-o[f])*n[f],u=0,m=0;do{var d;for(p=1;m+p0)}}while(++fa?(c==i.BINSEARCH_DOWN&&(l=!0),l&&(_/=2),c=i.BINSEARCH_UP,h=_):(c==i.BINSEARCH_UP&&(l=!0),l&&(_/=2),c=i.BINSEARCH_DOWN,h=-_),t.global_gain+=h,t.global_gain<0&&(t.global_gain=0,l=!0),t.global_gain>255&&(t.global_gain=255,l=!0)}for(;o>a&&t.global_gain<255;)t.global_gain++,o=s.count_bits(e,r,t,null);e.CurrentStep[n]=f-t.global_gain>=4?4:2,e.OldValue[n]=t.global_gain,t.part2_3_length=o}(u,t,c,f,o),0==u.noise_shaping)return 100;a.calc_noise(t,n,d,v,g),v.bits=t.part2_3_length,p.assign(t);var k=0;for(h.arraycopy(o,0,m,0,576);!M;){do{var A,B=new T,y=255;if(A=0!=(2&u.substep_shaping)?20:3,u.sfb21_extra){if(d[p.sfbmax]>1)break;if(p.block_type==X.SHORT_TYPE&&(d[p.sfbmax+1]>1||d[p.sfbmax+2]>1))break}if(!l(e,p,d,o,w))break;0!=p.scalefac_scale&&(y=254);var x=c-p.part2_length;if(x<=0)break;for(;(p.part2_3_length=s.count_bits(u,o,p,g))>x&&p.global_gain<=y;)p.global_gain++;if(p.global_gain>y)break;if(0==v.over_count){for(;(p.part2_3_length=s.count_bits(u,o,p,g))>S&&p.global_gain<=y;)p.global_gain++;if(p.global_gain>y)break}if(a.calc_noise(p,n,d,B,g),B.bits=p.part2_3_length,0!=(_(t.block_type!=X.SHORT_TYPE?e.quant_comp:e.quant_comp_short,v,B,p,d)?1:0))S=t.part2_3_length,v=B,t.assign(p),k=0,h.arraycopy(o,0,m,0,576);else if(0==u.full_outer_loop){if(++k>A&&0==v.over_count)break;if(3==u.noise_shaping_amp&&w&&k>30)break;if(3==u.noise_shaping_amp&&w&&p.global_gain-R>15)break}}while(p.global_gain+p.scalefac_scale<255);3==u.noise_shaping_amp?w?M=!0:(p.assign(t),h.arraycopy(m,0,o,0,576),k=0,R=p.global_gain,w=!0):M=!0}return e.VBR==b.vbr_rh||e.VBR==b.vbr_mtrh?h.arraycopy(m,0,o,0,576):0!=(1&u.substep_shaping)&&trancate_smallspectrums(u,t,n,o),v.over_count},this.iteration_finish_one=function(e,a,n){var r=e.l3_side,i=r.tt[a][n];s.best_scalefac_store(e,a,n,r),1==e.use_best_huffman&&s.best_huffman_divide(e,i),t.ResvAdjust(e,i)},this.VBR_encode_granule=function(e,t,a,s,n,i,o){var _,l=e.internal_flags,f=new V,u=r(576),p=o,m=o+1,b=(o+i)/2,d=0,v=l.sfb21_extra;c.fill(f.l3_enc,0);do{l.sfb21_extra=!(b>p-42)&&v,outer_loop(e,t,a,s,n,b)<=0?(d=1,m=t.part2_3_length,f.assign(t),h.arraycopy(s,0,u,0,576),_=(o=m-32)-i,b=(o+i)/2):(_=o-(i=b+32),b=(o+i)/2,0!=d&&(d=2,t.assign(f),h.arraycopy(u,0,s,0,576)))}while(_>12);l.sfb21_extra=v,2==d&&h.arraycopy(f.l3_enc,0,t.l3_enc,0,576)},this.get_framebits=function(a,s){var n=a.internal_flags;n.bitrate_index=n.VBR_min_bitrate;var r=e.getframebits(a);n.bitrate_index=1,r=e.getframebits(a);for(var i=1;i<=n.VBR_max_bitrate;i++){n.bitrate_index=i;var o=new y(r);s[i]=t.ResvFrameBegin(a,o),r=o.bits}},this.VBR_old_prepare=function(e,s,n,r,i,o,_,l,f){var c,h=e.internal_flags,u=0,p=1,m=0;h.bitrate_index=h.VBR_max_bitrate;var b=t.ResvFrameBegin(e,new y(0))/h.mode_gr;get_framebits(e,o);for(var d=0;do[h.VBR_max_bitrate]&&(l[d][g]*=o[h.VBR_max_bitrate],l[d][g]/=m),_[d][g]>l[d][g]&&(_[d][g]=l[d][g]);return p},this.bitpressure_strategy=function(e,t,a,s){for(var n=0;n_&&(o[p][m]*=_,o[p][m]/=h);return f},this.calc_target_bits=function(s,n,r,i,o,_){var l,f,c,h,u=s.internal_flags,p=u.l3_side,m=0;u.bitrate_index=u.VBR_max_bitrate;var b=new y(m);for(_[0]=t.ResvFrameBegin(s,b),m=b.bits,u.bitrate_index=1,m=e.getframebits(s)-8*u.sideinfo_len,o[0]=m/(u.mode_gr*u.channels_out),m=s.VBR_mean_bitrate_kbps*s.framesize*1e3,0!=(1&u.substep_shaping)&&(m*=1.09),m/=s.out_samplerate,m-=8*u.sideinfo_len,m/=u.mode_gr*u.channels_out,(l=.93+.07*(11-s.compression_ratio)/5.5)<.9&&(l=.9),l>1&&(l=1),f=0;f700){var v=int((n[f][c]-700)/1.4),g=p.tt[f][c];i[f][c]=int(l*m),g.block_type==X.SHORT_TYPE&&v3*m/2?v=3*m/2:v<0&&(v=0),i[f][c]+=v}i[f][c]>Z.MAX_BITS_PER_CHANNEL&&(i[f][c]=Z.MAX_BITS_PER_CHANNEL),d+=i[f][c]}if(d>Z.MAX_BITS_PER_GRANULE)for(c=0;cZ.MAX_BITS_PER_CHANNEL&&(i[f][c]=Z.MAX_BITS_PER_CHANNEL),h+=i[f][c];if(h>_[0])for(f=0;f=0;--U){var ee,te;ee=q[j+U]*n[20+U]+q[j+-1-U]*i[28+U],te=q[j+U]*i[28+U]-q[j+-1-U]*n[20+U],q[j+-1-U]=ee,q[j+U]=te}}}if(O=u,C=286,1==e.mode_gr)for(var ae=0;ae<18;ae++)h.arraycopy(e.sb_sample[V][1][ae],0,e.sb_sample[V][0][ae],0,32)}}}function q(){this.thm=new z,this.en=new z}function X(){var e=X.FFTOFFSET,t=X.MPG_MD_MS_LR,a=null;this.psy=null;var s=null,i=null,_=null;this.setModules=function(e,t,n,r){a=e,this.psy=t,s=t,i=r,_=n};var l=new Y;this.lame_encode_mp3_frame=function(c,u,p,m,v,g){var S,M=f([2,2]);M[0][0]=new q,M[0][1]=new q,M[1][0]=new q,M[1][1]=new q;var w,R=f([2,2]);R[0][0]=new q,R[0][1]=new q,R[1][0]=new q,R[1][1]=new q;var k,A,B,y=[null,null],T=c.internal_flags,x=o([2,4]),E=[.5,.5],P=[[0,0],[0,0]],L=[[0,0],[0,0]];if(y[0]=u,y[1]=p,0==T.lame_encode_frame_init&&function(e,t){var a,s,n=e.internal_flags;if(0==n.lame_encode_frame_init){var i,o,_=r(2014),f=r(2014);for(n.lame_encode_frame_init=1,i=0,o=0;i<286+576*(1+n.mode_gr);++i)i<576*n.mode_gr?(_[i]=0,2==n.channels_out&&(f[i]=0)):(_[i]=t[0][o],2==n.channels_out&&(f[i]=t[1][o]),++o);for(s=0;s0&&(E[B]=x[B][3]/E[B])),A=0;A.03125)e.ATH.adjust>=1?e.ATH.adjust=1:e.ATH.adjust=s?(e.ATH.adjust*=.075*s+.925,e.ATH.adjust=s?e.ATH.adjust=s:e.ATH.adjust>1,m=(p=n<<1)+(h=n),n=p<<1,i=(r=t)+b;do{R=e[r+0]-e[r+h],w=e[r+0]+e[r+h],y=e[r+p]-e[r+m],A=e[r+p]+e[r+m],e[r+p]=w-A,e[r+0]=w+A,e[r+m]=R-y,e[r+h]=R+y,R=e[i+0]-e[i+h],w=e[i+0]+e[i+h],y=u.SQRT2*e[i+m],A=u.SQRT2*e[i+p],e[i+p]=w-A,e[i+0]=w+A,e[i+m]=R-y,e[i+h]=R+y,i+=n,r+=n}while(r<_);for(f=a[o+0],l=a[o+1],c=1;c=0);s(a[_],l,X.BLKSIZE_s/2)}},this.fft_long=function(t,a,r,i,o){var _=X.BLKSIZE/8-1,l=X.BLKSIZE/2;do{var f,c,h,u,p,m=255&n[_];c=(f=e[m]*i[r][o+m])-(p=e[m+512]*i[r][o+m+512]),f+=p,u=(h=e[m+256]*i[r][o+m+256])-(p=e[m+768]*i[r][o+m+768]),h+=p,a[(l-=4)+0]=f+h,a[l+2]=f-h,a[l+1]=c+u,a[l+3]=c-u,c=(f=e[m+1]*i[r][o+m+1])-(p=e[m+513]*i[r][o+m+513]),f+=p,u=(h=e[m+257]*i[r][o+m+257])-(p=e[m+769]*i[r][o+m+769]),h+=p,a[l+X.BLKSIZE/2+0]=f+h,a[l+X.BLKSIZE/2+2]=f-h,a[l+X.BLKSIZE/2+1]=c+u,a[l+X.BLKSIZE/2+3]=c-u}while(--_>=0);s(a,l,X.BLKSIZE/2)},this.init_fft=function(a){for(var s=0;s=0;--m){var b=r[i+0][m],d=r[i+1][m];r[i+0][m]=(b+d)*u.SQRT2*.5,r[i+1][m]=(b-d)*u.SQRT2*.5}for(var v=2;v>=0;--v)for(m=X.BLKSIZE_s-1;m>=0;--m){b=o[_+0][v][m],d=o[_+1][v][m];o[_+0][v][m]=(b+d)*u.SQRT2*.5,o[_+1][v][m]=(b-d)*u.SQRT2*.5}}a[0]=r[i+0][0],a[0]*=a[0];for(m=X.BLKSIZE/2-1;m>=0;--m){var g=r[i+0][X.BLKSIZE/2-m],S=r[i+0][X.BLKSIZE/2+m];a[X.BLKSIZE/2-m]=.5*(g*g+S*S)}for(v=2;v>=0;--v){n[v][0]=o[_+0][v][0],n[v][0]*=n[v][0];for(m=X.BLKSIZE_s/2-1;m>=0;--m){g=o[_+0][v][X.BLKSIZE_s/2-m],S=o[_+0][v][X.BLKSIZE_s/2+m];n[v][X.BLKSIZE_s/2-m]=.5*(g*g+S*S)}}var M=0;for(m=11;me){if(!(t=t*l)return e+t;i=e/t}if(e+=t,s+3<=6){if(i>=_)return e;var o=0|u.FAST_LOG10_X(i,16);return e*g[o]}var c,h;o=0|u.FAST_LOG10_X(i,16);return t=0!=r?n.ATH.cb_s[a]*n.ATH.adjust:n.ATH.cb_l[a]*n.ATH.adjust,et?(c=1,o<=13&&(c=S[o]),h=u.FAST_LOG10_X(e/t,10/15),e*((v[o]-c)*h+c)):o>13?e:e*S[o]:e*v[o]}var w=[1.7782755904,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.6999465924,1.22321*1.22321,1.3169398564,1];function R(e,t,a){var s;if(e<0&&(e=0),t<0&&(t=0),e<=0)return t;if(t<=0)return e;if(s=t>e?t/e:e/t,-2<=a&&a<=2){if(s>=_)return e+t;var n=0|u.FAST_LOG10_X(s,16);return(e+t)*w[n]}return s=f){++r;break}var h=e.PSY.bo_s_weight[r],u=1-h;o=h*t[i],_=h*a[i],e.en[s].s[r][n]+=o,e.thm[s].s[r][n]+=_,o=u*t[i],_=u*a[i]}for(;r=l){++n;break}var c=e.PSY.bo_l_weight[n],h=1-c;i=c*t[r],o=c*a[r],e.en[s].l[n]+=i,e.thm[s].l[n]+=o,i=h*t[r],o=h*a[r]}for(;n=1?e:a<=0?t:t>0?Math.pow(e/t,a)*t:0}var T=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function x(e,a){for(var s=309.07,n=0;n0){var o=i*a,_=e.en.s[n][r];_>o&&(s+=_>1e10*o?T[n]*(10*t):T[n]*u.FAST_LOG10(_/o))}}return s}var E=[6.8,5.8,5.8,6.4,6.5,9.9,12.1,14.4,15,18.9,21.6,26.9,34.2,40.2,46.8,56.5,60.7,73.9,85.7,93.4,126.1];function P(e,a){for(var s=281.0575,n=0;n0){var i=r*a,o=e.en.l[n];o>i&&(s+=o>1e10*i?E[n]*(10*t):E[n]*u.FAST_LOG10(o/i))}}return s}function L(e,t,a,s,n){var r,i;for(r=i=0;r0?((o=t[r])n&&(_=n),s[r]=_):s[r]=0;for(r=1;r0)(o=t[r-1])n&&(_=n),s[r]=_;else s[r]=0}(i=a[r-1]+a[r])>0?((o=t[r-1])n&&(_=n),s[r]=_):s[r]=0}var H=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function O(t,a,s,n,r,i,o,_){var l=t.internal_flags;if(n<2)e.fft_long(l,o[_],n,a,s);else if(2==n)for(var f=X.BLKSIZE-1;f>=0;--f){var c=o[_+0][f],h=o[_+1][f];o[_+0][f]=(c+h)*u.SQRT2*.5,o[_+1][f]=(c-h)*u.SQRT2*.5}i[0]=o[_+0][0],i[0]*=i[0];for(f=X.BLKSIZE/2-1;f>=0;--f){var p=o[_+0][X.BLKSIZE/2-f],m=o[_+0][X.BLKSIZE/2+f];i[X.BLKSIZE/2-f]=.5*(p*p+m*m)}var b=0;for(f=11;f=0;--f){var c=o[_+0][r][f],h=o[_+1][r][f];o[_+0][r][f]=(c+h)*u.SQRT2*.5,o[_+1][r][f]=(c-h)*u.SQRT2*.5}i[r][0]=o[_+0][r][0],i[r][0]*=i[r][0];for(f=X.BLKSIZE_s/2-1;f>=0;--f){var p=o[_+0][r][X.BLKSIZE_s/2-f],m=o[_+0][r][X.BLKSIZE_s/2+f];i[r][X.BLKSIZE_s/2-f]=.5*(p*p+m*m)}}function V(e,t,a,n){var r=e.internal_flags;2==e.athaa_loudapprox&&a<2&&(r.loudness_sq[t][a]=r.loudness_sq_save[a],r.loudness_sq_save[a]=s(n,r))}this.L3psycho_anal_ns=function(e,t,a,s,_,l,f,u,m,v){var g,S,w,R,T,E,O,C,V,N,D=e.internal_flags,Y=o([2,X.BLKSIZE]),q=o([2,3,X.BLKSIZE_s]),j=r(X.CBANDS+1),F=r(X.CBANDS+1),z=r(X.CBANDS+2),U=n(2),Z=n(2),K=o([2,576]),G=n(X.CBANDS+2),W=n(X.CBANDS+2);for(c.fill(W,0),g=D.channels_out,e.mode==d.JOINT_STEREO&&(g=4),V=e.VBR==b.vbr_off?0==D.ResvMax?0:D.ResvSize/D.ResvMax*.5:e.VBR==b.vbr_rh||e.VBR==b.vbr_mtrh||e.VBR==b.vbr_mt?.6:1,S=0;S2&&(l[s][S].en.assign(D.en[S+2]),l[s][S].thm.assign(D.thm[S+2]))}for(S=0;Sae[R+3-2]?be/=ae[R+3-2]:be=ae[R+3-2]>10*be?ae[R+3-2]/(10*be):0,ne[R+3]=be}if(e.analysis){var de=ne[0];for(R=1;R<12;R++)dete&&(_e[R/3]=R%3+1);for(R=1;R<4;R++){(se[R-1]>se[R]?se[R-1]/se[R]:se[R]/se[R-1])<1.7&&(_e[R]=0,1==R&&(_e[0]=0))}for(0!=_e[0]&&0!=D.nsPsy.lastAttacks[S]&&(_e[0]=0),3!=D.nsPsy.lastAttacks[S]&&_e[0]+_e[1]+_e[2]+_e[3]==0||(re=0,0!=_e[1]&&0!=_e[0]&&(_e[1]=0),0!=_e[2]&&0!=_e[1]&&(_e[2]=0),0!=_e[3]&&0!=_e[2]&&(_e[3]=0)),S<2?Z[S]=re:0==re&&(Z[0]=Z[1]=0),m[S]=D.tot_ener[S],i(e,le,fe,Y,1&S,q,1&S,s,S,t,a),L(D,le,j,ie,oe),I(D,ie,oe,G),C=0;C<3;C++){var ve,ge;for(B(e,fe,F,z,S,C),k(D,F,z,S,C),O=0;O=2||1==_e[C+1]){var Se=0!=C?C-1:2;be=y(D.thm[S].s[O][Se],ge,.6*V);ge=Math.min(ge,be)}if(1==_e[C]){Se=0!=C?C-1:2,be=y(D.thm[S].s[O][Se],ge,.3*V);ge=Math.min(ge,be)}else if(0!=C&&3==_e[C-1]||0==C&&3==D.nsPsy.lastAttacks[S]){Se=2!=C?C+1:0,be=y(D.thm[S].s[O][Se],ge,.3*V);ge=Math.min(ge,be)}ve=ae[3*C+3]+ae[3*C+4]+ae[3*C+5],6*ae[3*C+5]0&&function(e,t){var a=e.internal_flags;if(a.channels_out>1){for(var s=0;s1.58*e.thm[1].l[t]||e.thm[1].l[t]>1.58*e.thm[0].l[t])){var a=e.mld_l[t]*e.en[3].l[t],s=Math.max(e.thm[2].l[t],Math.min(e.thm[3].l[t],a));a=e.mld_l[t]*e.en[2].l[t];var n=Math.max(e.thm[3].l[t],Math.min(e.thm[2].l[t],a));e.thm[2].l[t]=s,e.thm[3].l[t]=n}for(t=0;t1.58*e.thm[1].s[t][r]||e.thm[1].s[t][r]>1.58*e.thm[0].s[t][r])){a=e.mld_s[t]*e.en[3].s[t][r],s=Math.max(e.thm[2].s[t][r],Math.min(e.thm[3].s[t][r],a));a=e.mld_s[t]*e.en[2].s[t][r];n=Math.max(e.thm[3].s[t][r],Math.min(e.thm[2].s[t][r],a));e.thm[2].s[t][r]=s,e.thm[3].s[t][r]=n}}(D),N=e.msfix,Math.abs(N)>0&&function(e,t,a){var s=t,n=Math.pow(10,a);t*=2,s*=2;for(var r=0;r1?(ke=u,ye=-2,Ae=X.NORM_TYPE,v[0]!=X.SHORT_TYPE&&v[1]!=X.SHORT_TYPE||(Ae=X.SHORT_TYPE),Be=l[s][S-2]):(ke=f,ye=0,Ae=v[S],Be=_[s][S]),Ae==X.SHORT_TYPE?ke[ye+S]=x(Be,D.masking_lower):ke[ye+S]=P(Be,D.masking_lower),e.analysis&&(D.pinfo.pe[s][S]=ke[ye+S])}return 0};var N=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function D(e,t,a){if(0==a)for(var s=0;s0?((o=t[r])n&&(_=n),s[r]=_):s[r]=0,r=1;r0)(o=t[r-1])n&&(_=n),s[r]=_;else s[r]=0}(i=a[r-1]+a[r])>0?((o=t[r-1])n&&(_=n),s[r]=_):s[r]=0}(f,c,u,p),_=l=0;lM&&(s[l]=M),f.masking_lower>1&&(s[l]*=f.masking_lower),s[l]>a[l]&&(s[l]=a[l]),f.masking_lower<1&&(s[l]*=f.masking_lower)}for(;l0?Math.min(p,S):Math.min(p,.3*a[o])}else{var M=16*e.nb_2[i][o],w=2*e.nb_1[i][o];M<=0&&(M=p),w<=0&&(w=p),S=e.blocktype_old[1&i]==X.NORM_TYPE?Math.min(w,M):w,s[o]=Math.min(p,S)}e.nb_2[i][o]=e.nb_1[i][o],e.nb_1[i][o]=p,u=_[o],u*=e.minval_l[o],u*=m,s[o]>u&&(s[o]=u),e.masking_lower>1&&(s[o]*=e.masking_lower),s[o]>a[o]&&(s[o]=a[o]),e.masking_lower<1&&(s[o]*=e.masking_lower)}for(;o0?Math.pow(10,n):1,c=0;c0){var S,M,w=s[c]*f;if(S=Math.min(Math.max(p,w),Math.max(m,w)),(M=(b=Math.max(_,w))+(d=Math.max(o,w)))>0&&S*lh&&(_=h),o>u&&(o=u),t[2][c]=_,t[3][c]=o}}function z(e,t){var a;return(a=e>=0?27*-e:e*t)<=-72?0:Math.exp(.2302585093*a)}function U(e){var t,a,s=0;for(s=0;z(s,e)>1e-20;s-=1);for(n=s,r=0;Math.abs(r-n)>1e-12;)z(s=(r+n)/2,e)>0?r=s:n=s;t=n;var n,r;s=0;for(s=0;z(s,e)>1e-20;s+=1);for(n=0,r=s;Math.abs(r-n)>1e-12;)z(s=(r+n)/2,e)>0?n=s:r=s;a=r;var i,o=0,_=1e3;for(i=0;i<=_;++i){o+=z(s=t+i*(a-t)/_,e)}return 1001/(o*(a-t))}function Z(e){return e<0&&(e=0),e*=.001,13*Math.atan(.76*e)+3.5*Math.atan(e*e/56.25)}function G(e,t,a,s,i,o,_,l,f,c,h,u){var p,m=r(X.CBANDS+1),b=l/(u>15?1152:384),d=n(X.HBLKSIZE);l/=f;var v=0,g=0;for(p=0;pf/2){v=f/2,++p;break}}m[p]=l*v;for(var M=0;Mf/2&&(R=f/2),a[M]=(d[w]+d[R])/2,t[M]=d[R];var y=b*A;_[M]=(y-m[t[M]])/(m[t[M]+1]-m[t[M]]),_[M]<0?_[M]=0:_[M]>1&&(_[M]=1),B=Z(l*c[M]*h),B=Math.min(B,15.5)/15.5,o[M]=Math.pow(10,1.25*(1-Math.cos(Math.PI*B))-2.5)}v=0;for(var T=0;T=0?3:1.5)>=.5&&f<=2.5?8*((u=f-.5)*u-2*u):0,((h=15.811389+7.5*(f+=.474)-17.5*Math.sqrt(1+f*f))<=-60?0:(f=Math.exp(.2302585093*(c+h)),f/=.6609193))*s[_]);p[b][_]=d*n[b]}else for(_=0;_0);_++);for(e[b][0]=_,_=t-1;_>0&&!(p[b][_]>0);_--);e[b][1]=_,m+=e[b][1]-e[b][0]+1}var S=r(m),M=0;for(b=0;b2&&(i[s][b].en.assign(u.en[b+2]),i[s][b].thm.assign(u.thm[b+2]))}for(b=0;b0;++g,--w){var E=h[0][g],P=h[1][g];h[0][g]=E+P,h[1][g]=E-P}for(g=0;g<3;g++)k[g]=u.nsPsy.last_en_subshort[b][g+6],R[g]=k[g]/u.nsPsy.last_en_subshort[b][g+4],A[0]+=k[g];for(g=0;g<9;g++){for(var L=y+64,I=1;yk[g+3-2]?I/=k[g+3-2]:I=k[g+3-2]>10*I?k[g+3-2]/(10*I):0,R[g+3]=I}for(g=0;g<3;++g){var H=k[3*g+3]+k[3*g+4]+k[3*g+5],O=1;6*k[3*g+5]T&&(f[b][g/3]=g%3+1);for(g=1;g<4;g++){var V=A[g-1],D=A[g];Math.max(V,D)<4e4&&V<1.7*D&&D<1.7*V&&(1==g&&f[b][0]<=f[b][g]&&(f[b][0]=0),f[b][g]=0)}f[b][0]<=u.nsPsy.lastAttacks[b]&&(f[b][0]=0),3!=u.nsPsy.lastAttacks[b]&&f[b][0]+f[b][1]+f[b][2]+f[b][3]==0||(x=0,0!=f[b][1]&&0!=f[b][0]&&(f[b][1]=0),0!=f[b][2]&&0!=f[b][1]&&(f[b][2]=0),0!=f[b][3]&&0!=f[b][2]&&(f[b][3]=0)),b<2?c[b]=x:0==x&&(c[0]=c[1]=0),_[b]=u.tot_ener[b]}}(e,t,a,s,i,_,c,w,R,B),function(e,t){var a=e.internal_flags;e.short_blocks!=p.short_block_coupled||0!=t[0]&&0!=t[1]||(t[0]=t[1]=0);for(var s=0;s=2||1==R[E][L+1]){var Z=0!=L?L-1:2,K=y(u.thm[E].s[H][Z],U,.36);U=Math.min(U,K)}else if(1==R[E][L]){Z=0!=L?L-1:2,K=y(u.thm[E].s[H][Z],U,.18);U=Math.min(U,K)}else if(0!=L&&3==R[E][L-1]||0==L&&3==u.nsPsy.lastAttacks[E]){Z=2!=L?L+1:0,K=y(u.thm[E].s[H][Z],U,.18);U=Math.min(U,K)}U*=w[E][L],z[L]=U}for(L=0;L<3;L++)u.thm[E].s[H][L]=z[L]}}for(E=0;E1?(G=f,W=-2,Q=X.NORM_TYPE,h[0]!=X.SHORT_TYPE&&h[1]!=X.SHORT_TYPE||(Q=X.SHORT_TYPE),J=_[s][E-2]):(G=l,W=0,Q=h[E],J=i[s][E]),Q==X.SHORT_TYPE?G[W+E]=x(J,u.masking_lower):G[W+E]=P(J,u.masking_lower),e.analysis&&(u.pinfo.pe[s][E]=G[W+E])}return 0},this.psymodel_init=function(a){var s,n=a.internal_flags,i=!0,o=13,c=0,h=0,u=-8.25,p=-4.5,d=r(X.CBANDS),v=r(X.CBANDS),g=r(X.CBANDS),S=a.out_samplerate;switch(a.experimentalZ){default:case 0:i=!0;break;case 1:i=a.VBR!=b.vbr_mtrh&&a.VBR!=b.vbr_mt;break;case 2:i=!1;break;case 3:o=8,c=-1.75,h=-.0125,u=-8.25,p=-2.25}for(n.ms_ener_ratio_old=.25,n.blocktype_old[0]=n.blocktype_old[1]=X.NORM_TYPE,s=0;s<4;++s){for(var M=0;M=o&&(R=h*(d[s]-o)/(24-o)+c*(24-d[s])/(24-o)),g[s]=Math.pow(10,R/10),n.numlines_l[s]>0?n.rnumlines_l[s]=1/n.numlines_l[s]:n.rnumlines_l[s]=0}n.s3_ll=W(n.s3ind,n.npart_l,d,v,g,i);var k;M=0;for(s=0;s(T*=n.numlines_l[s])&&(y=T)}n.ATH.cb_l[s]=y,(y=20*d[s]/10-20)>6&&(y=100),y<-15&&(y=-15),y-=8,n.minval_l[s]=Math.pow(10,y/10)*n.numlines_l[s]}for(n.npart_s=G(n.numlines_s,n.bo_s,n.bm_s,d,v,n.mld_s,n.PSY.bo_s_weight,S,X.BLKSIZE_s,n.scalefac_band.s,X.BLKSIZE_s/384,X.SBMAX_s),M=0,s=0;s=o&&(R=p*(d[s]-o)/(24-o)+u*(24-d[s])/(24-o)),g[s]=Math.pow(10,R/10),y=m.MAX_VALUE;for(A=0;A(T*=n.numlines_s[s])&&(y=T)}n.ATH.cb_s[s]=y,y=7*d[s]/12-7,d[s]>12&&(y*=1+3.1*Math.log(1+y)),d[s]<12&&(y*=1+2.3*Math.log(1-y)),y<-15&&(y=-15),y-=8,n.minval_s[s]=Math.pow(10,y/10)*n.numlines_s[s]}n.s3_ss=W(n.s3ind_s,n.npart_s,d,v,g,i),_=Math.pow(10,9/16),l=Math.pow(10,1.5),f=Math.pow(10,1.5),e.init_fft(n),n.decay=Math.exp(-1*t/(.01*S/192)),k=3.5,0!=(2&a.exp_nspsytune)&&(k=1),Math.abs(a.msfix)>0&&(k=a.msfix),a.msfix=k;for(var x=0;xn.npart_l-1&&(n.s3ind[x][1]=n.npart_l-1);var E=576*n.mode_gr/S;if(n.ATH.decay=Math.pow(10,-1.2*E),n.ATH.adjust=.01,n.ATH.adjustLimit=1,-1!=a.ATHtype){var P=a.out_samplerate/X.BLKSIZE,L=0;for(B=0,s=0;s=0;)n.ATH.eql_w[s]*=L}for(x=M=0;x1?0:e<=0?1:Math.cos(Math.PI/2*e)}function w(e,t){switch(e){case 44100:return t.version=1,0;case 48e3:return t.version=1,1;case 32e3:return t.version=1,2;case 22050:return t.version=0,0;case 24e3:return t.version=0,1;case 16e3:return t.version=0,2;case 11025:return t.version=0,0;case 12e3:return t.version=0,1;case 8e3:return t.version=0,2;default:return t.version=0,-1}}function R(e,t,a){a<16e3&&(t=2);for(var s=B.bitrate_table[t][1],n=2;n<=14;n++)B.bitrate_table[t][n]>0&&Math.abs(B.bitrate_table[t][n]-e)0&&B.bitrate_table[t][s]==e)return s;return-1}function y(t,a){var s=[new g(8,2e3),new g(16,3700),new g(24,3900),new g(32,5500),new g(40,7e3),new g(48,7500),new g(56,1e4),new g(64,11e3),new g(80,13500),new g(96,15100),new g(112,15600),new g(128,17e3),new g(160,17500),new g(192,18600),new g(224,19400),new g(256,19700),new g(320,20500)],n=e.nearestBitrateFullIndex(a);t.lowerlimit=s[n].lowpass}function T(e){var t=X.BLKSIZE+e.framesize-X.FFTOFFSET;return t=Math.max(t,512+e.framesize-32)}function x(t,a,s,n,r,i){var o=e.enc.lame_encode_mp3_frame(t,a,s,n,r,i);return t.frameNum++,o}function H(){this.n_in=0,this.n_out=0}function O(){this.num_used=0}function C(e,t,a){var s=Math.PI*t;(e/=a)<0&&(e=0),e>1&&(e=1);var n=e-.5,r=.42-.5*Math.cos(2*e*Math.PI)+.08*Math.cos(4*e*Math.PI);return Math.abs(n)<1e-9?s/Math.PI:r*Math.sin(a*s*n)/(Math.PI*a*n)}function V(e,t,a,s,n,i,o,_,l){var f,c,h=e.internal_flags,u=0,p=e.out_samplerate/function e(t,a){return 0!=a?e(a,t%a):t}(e.out_samplerate,e.in_samplerate);p>Z.BPC&&(p=Z.BPC);var m=Math.abs(h.resample_ratio-Math.floor(.5+h.resample_ratio))<1e-4?1:0,b=1/h.resample_ratio;b>1&&(b=1);var d=31;0==d%2&&--d;var v=(d+=m)+1;if(0==h.fill_buffer_resample_init){for(h.inbuf_old[0]=r(v),h.inbuf_old[1]=r(v),f=0;f<=2*p;++f)h.blackfilt[f]=r(v);for(h.itime[0]=0,h.itime[1]=0,u=0;u<=2*p;u++){var g=0,S=(u-p)/(2*p);for(f=0;f<=d;f++)g+=h.blackfilt[u][f]=C(f-S,b,d);for(f=0;f<=d;f++)h.blackfilt[u][f]/=g}h.fill_buffer_resample_init=1}var M=h.inbuf_old[l];for(c=0;c=o)break;S=w-h.itime[l]-(u+d%2*.5);R=0|Math.floor(2*S*p+p+.5);var k=0;for(f=0;f<=d;++f){var A=f+u-d/2;k+=(A<0?M[v+A]:n[i+A])*h.blackfilt[R][f]}t[a+c]=k}if(_.num_used=Math.min(o,d+u-d/2),h.itime[l]+=_.num_used-c*h.resample_ratio,_.num_used>=v)for(f=0;f1.0001)for(var o=0;oe-s?a:n},this.lame_init_params=function(e){var r,l,g,T=e.internal_flags;if(T.Class_ID=0,null==T.ATH&&(T.ATH=new E),null==T.PSY&&(T.PSY=new m),null==T.rgdata&&(T.rgdata=new I),T.channels_in=e.num_channels,1==T.channels_in&&(e.mode=d.MONO),T.channels_out=e.mode==d.MONO?1:2,T.mode_ext=X.MPG_MD_MS_LR,e.mode==d.MONO&&(e.force_ms=!1),e.VBR==b.vbr_off&&128!=e.VBR_mean_bitrate_kbps&&0==e.brate&&(e.brate=e.VBR_mean_bitrate_kbps),e.VBR==b.vbr_off||e.VBR==b.vbr_mtrh||e.VBR==b.vbr_mt||(e.free_format=!1),e.VBR==b.vbr_off&&0==e.brate&&k.EQ(e.compression_ratio,0)&&(e.compression_ratio=11.025),e.VBR==b.vbr_off&&e.compression_ratio>0&&(0==e.out_samplerate&&(e.out_samplerate=map2MP3Frequency(int(.97*e.in_samplerate))),e.brate=0|16*e.out_samplerate*T.channels_out/(1e3*e.compression_ratio),T.samplerate_index=w(e.out_samplerate,e),e.free_format||(e.brate=R(e.brate,e.version,e.out_samplerate))),0!=e.out_samplerate&&(e.out_samplerate<16e3?(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,64)):e.out_samplerate<32e3?(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,160)):(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,32),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,320))),0==e.lowpassfreq){var x=16e3;switch(e.VBR){case b.vbr_off:y(P=new v,e.brate),x=P.lowerlimit;break;case b.vbr_abr:var P;y(P=new v,e.VBR_mean_bitrate_kbps),x=P.lowerlimit;break;case b.vbr_rh:var H=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=e.VBR_q&&e.VBR_q<=9){var O=H[e.VBR_q],C=H[e.VBR_q+1],V=e.VBR_q_frac;x=linear_int(O,C,V)}else x=19500;break;default:H=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=e.VBR_q&&e.VBR_q<=9){O=H[e.VBR_q],C=H[e.VBR_q+1],V=e.VBR_q_frac;x=linear_int(O,C,V)}else x=19500}e.mode!=d.MONO||e.VBR!=b.vbr_off&&e.VBR!=b.vbr_abr||(x*=1.5),e.lowpassfreq=0|x}if(0==e.out_samplerate&&(2*e.lowpassfreq>e.in_samplerate&&(e.lowpassfreq=e.in_samplerate/2),e.out_samplerate=(r=0|e.lowpassfreq,l=e.in_samplerate,g=44100,l>=48e3?g=48e3:l>=44100?g=44100:l>=32e3?g=32e3:l>=24e3?g=24e3:l>=22050?g=22050:l>=16e3?g=16e3:l>=12e3?g=12e3:l>=11025?g=11025:l>=8e3&&(g=8e3),-1==r?g:(r<=15960&&(g=44100),r<=15250&&(g=32e3),r<=11220&&(g=24e3),r<=9970&&(g=22050),r<=7230&&(g=16e3),r<=5420&&(g=12e3),r<=4510&&(g=11025),r<=3970&&(g=8e3),l44100?48e3:l>32e3?44100:l>24e3?32e3:l>22050?24e3:l>16e3?22050:l>12e3?16e3:l>11025?12e3:l>8e3?11025:8e3:g))),e.lowpassfreq=Math.min(20500,e.lowpassfreq),e.lowpassfreq=Math.min(e.out_samplerate/2,e.lowpassfreq),e.VBR==b.vbr_off&&(e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.brate)),e.VBR==b.vbr_abr&&(e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.VBR_mean_bitrate_kbps)),e.bWriteVbrTag||(e.findReplayGain=!1,e.decode_on_the_fly=!1,T.findPeakSample=!1),T.findReplayGain=e.findReplayGain,T.decode_on_the_fly=e.decode_on_the_fly,T.decode_on_the_fly&&(T.findPeakSample=!0),T.findReplayGain&&t.InitGainAnalysis(T.rgdata,e.out_samplerate)==S.INIT_GAIN_ANALYSIS_ERROR)return e.internal_flags=null,-6;switch(T.decode_on_the_fly&&!e.decode_only&&(null!=T.hip&&c.hip_decode_exit(T.hip),T.hip=c.hip_decode_init()),T.mode_gr=e.out_samplerate<=24e3?1:2,e.framesize=576*T.mode_gr,e.encoder_delay=X.ENCDELAY,T.resample_ratio=e.in_samplerate/e.out_samplerate,e.VBR){case b.vbr_mt:case b.vbr_rh:case b.vbr_mtrh:e.compression_ratio=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5][e.VBR_q];break;case b.vbr_abr:e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.VBR_mean_bitrate_kbps);break;default:e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.brate)}if(e.mode==d.NOT_SET&&(e.mode=d.JOINT_STEREO),e.highpassfreq>0?(T.highpass1=2*e.highpassfreq,e.highpasswidth>=0?T.highpass2=2*(e.highpassfreq+e.highpasswidth):T.highpass2=2*e.highpassfreq,T.highpass1/=e.out_samplerate,T.highpass2/=e.out_samplerate):(T.highpass1=0,T.highpass2=0),e.lowpassfreq>0?(T.lowpass2=2*e.lowpassfreq,e.lowpasswidth>=0?(T.lowpass1=2*(e.lowpassfreq-e.lowpasswidth),T.lowpass1<0&&(T.lowpass1=0)):T.lowpass1=2*e.lowpassfreq,T.lowpass1/=e.out_samplerate,T.lowpass2/=e.out_samplerate):(T.lowpass1=0,T.lowpass2=0),function(e){var t=e.internal_flags,a=32,s=-1;if(t.lowpass1>0){for(var n=999,r=0;r<=31;r++){(l=r/31)>=t.lowpass2&&(a=Math.min(a,r)),t.lowpass10&&t.highpass2<.75/31*.9&&(t.highpass1=0,t.highpass2=0,h.err.println("Warning: highpass filter disabled. highpass frequency too small\n")),t.highpass2>0){var i=-1;for(r=0;r<=31;r++){(l=r/31)<=t.highpass1&&(s=Math.max(s,r)),t.highpass1t.highpass1?M((t.highpass2-l)/(t.highpass2-t.highpass1+1e-20)):1,_=t.lowpass2>t.lowpass1?M((l-t.lowpass1)/(t.lowpass2-t.lowpass1+1e-20)):1,t.amp_filter[r]=o*_}}(e),T.samplerate_index=w(e.out_samplerate,e),T.samplerate_index<0)return e.internal_flags=null,-1;if(e.VBR==b.vbr_off){if(e.free_format)T.bitrate_index=0;else if(e.brate=R(e.brate,e.version,e.out_samplerate),T.bitrate_index=A(e.brate,e.version,e.out_samplerate),T.bitrate_index<=0)return e.internal_flags=null,-1}else T.bitrate_index=1;e.analysis&&(e.bWriteVbrTag=!1),null!=T.pinfo&&(e.bWriteVbrTag=!1),a.init_bit_stream_w(T);for(var N,D=T.samplerate_index+3*e.version+6*(e.out_samplerate<16e3?1:0),Y=0;Y5&&(e.quality=5),T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,e.experimentalY?T.sfb21_extra=!1:T.sfb21_extra=e.out_samplerate>44e3,T.iteration_loop=new VBRNewIterationLoop(i);break;case b.vbr_rh:s.apply_preset(e,500-10*e.VBR_q,0),T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,e.experimentalY?T.sfb21_extra=!1:T.sfb21_extra=e.out_samplerate>44e3,e.quality>6&&(e.quality=6),e.quality<0&&(e.quality=LAME_DEFAULT_QUALITY),T.iteration_loop=new VBROldIterationLoop(i);break;default:var F;T.sfb21_extra=!1,e.quality<0&&(e.quality=LAME_DEFAULT_QUALITY),(F=e.VBR)==b.vbr_off&&(e.VBR_mean_bitrate_kbps=e.brate),s.apply_preset(e,e.VBR_mean_bitrate_kbps,0),e.VBR=F,T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,F==b.vbr_off?T.iteration_loop=new L(i):T.iteration_loop=new ABRIterationLoop(i)}if(e.VBR!=b.vbr_off){if(T.VBR_min_bitrate=1,T.VBR_max_bitrate=14,e.out_samplerate<16e3&&(T.VBR_max_bitrate=8),0!=e.VBR_min_bitrate_kbps&&(e.VBR_min_bitrate_kbps=R(e.VBR_min_bitrate_kbps,e.version,e.out_samplerate),T.VBR_min_bitrate=A(e.VBR_min_bitrate_kbps,e.version,e.out_samplerate),T.VBR_min_bitrate<0))return-1;if(0!=e.VBR_max_bitrate_kbps&&(e.VBR_max_bitrate_kbps=R(e.VBR_max_bitrate_kbps,e.version,e.out_samplerate),T.VBR_max_bitrate=A(e.VBR_max_bitrate_kbps,e.version,e.out_samplerate),T.VBR_max_bitrate<0))return-1;e.VBR_min_bitrate_kbps=B.bitrate_table[e.version][T.VBR_min_bitrate],e.VBR_max_bitrate_kbps=B.bitrate_table[e.version][T.VBR_max_bitrate],e.VBR_mean_bitrate_kbps=Math.min(B.bitrate_table[e.version][T.VBR_max_bitrate],e.VBR_mean_bitrate_kbps),e.VBR_mean_bitrate_kbps=Math.max(B.bitrate_table[e.version][T.VBR_min_bitrate],e.VBR_mean_bitrate_kbps)}return e.tune&&(T.PSY.mask_adjust+=e.tune_value_a,T.PSY.mask_adjust_short+=e.tune_value_a),function(e){var t=e.internal_flags;switch(e.quality){default:case 9:t.psymodel=0,t.noise_shaping=0,t.noise_shaping_amp=0,t.noise_shaping_stop=0,t.use_best_huffman=0,t.full_outer_loop=0;break;case 8:e.quality=7;case 7:t.psymodel=1,t.noise_shaping=0,t.noise_shaping_amp=0,t.noise_shaping_stop=0,t.use_best_huffman=0,t.full_outer_loop=0;break;case 6:case 5:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=0,t.noise_shaping_stop=0,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=0,t.full_outer_loop=0;break;case 4:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=0,t.noise_shaping_stop=0,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 3:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=1,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 2:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),0==t.substep_shaping&&(t.substep_shaping=2),t.noise_shaping_amp=1,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 1:case 0:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),0==t.substep_shaping&&(t.substep_shaping=2),t.noise_shaping_amp=2,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0}}(e),e.athaa_type<0?T.ATH.useAdjust=3:T.ATH.useAdjust=e.athaa_type,T.ATH.aaSensitivityP=Math.pow(10,e.athaa_sensitivity/-10),null==e.short_blocks&&(e.short_blocks=p.short_block_allowed),e.short_blocks!=p.short_block_allowed||e.mode!=d.JOINT_STEREO&&e.mode!=d.STEREO||(e.short_blocks=p.short_block_coupled),e.quant_comp<0&&(e.quant_comp=1),e.quant_comp_short<0&&(e.quant_comp_short=0),e.msfix<0&&(e.msfix=0),e.exp_nspsytune=1|e.exp_nspsytune,e.internal_flags.nsPsy.attackthre<0&&(e.internal_flags.nsPsy.attackthre=G.NSATTACKTHRE),e.internal_flags.nsPsy.attackthre_s<0&&(e.internal_flags.nsPsy.attackthre_s=G.NSATTACKTHRE_S),e.scale<0&&(e.scale=1),e.ATHtype<0&&(e.ATHtype=4),e.ATHcurve<0&&(e.ATHcurve=4),e.athaa_loudapprox<0&&(e.athaa_loudapprox=2),e.interChRatio<0&&(e.interChRatio=0),null==e.useTemporal&&(e.useTemporal=!0),T.slot_lag=T.frac_SpF=0,e.VBR==b.vbr_off&&(T.slot_lag=T.frac_SpF=72e3*(e.version+1)*e.brate%e.out_samplerate|0),n.iteration_init(e),u.psymodel_init(e),0},this.lame_encode_flush=function(e,t,s,n){var r,i,o,_,c=e.internal_flags,h=l([2,1152]),u=0,p=c.mf_samples_to_encode-X.POSTDELAY,m=T(e);if(c.mf_samples_to_encode<1)return 0;for(r=0,e.in_samplerate!=e.out_samplerate&&(p+=16*e.out_samplerate/e.in_samplerate),(o=e.framesize-p%e.framesize)<576&&(o+=e.framesize),e.encoder_padding=o,_=(p+o)/e.framesize;_>0&&u>=0;){var b=m-c.mf_size,d=e.frameNum;b*=e.in_samplerate,(b/=e.out_samplerate)>1152&&(b=1152),b<1&&(b=1),i=n-r,0==n&&(i=0),s+=u=this.lame_encode_buffer(e,h[0],h[1],b,t,s,i),r+=u,_-=d!=e.frameNum?1:0}if(c.mf_samples_to_encode=0,u<0)return u;if(i=n-r,0==n&&(i=0),a.flush_bitstream(e),(u=a.copy_buffer(c,t,s,i,1))<0)return u;if(s+=u,i=n-(r+=u),0==n&&(i=0),e.write_id3tag_automatic){if(f.id3tag_write_v1(e),(u=a.copy_buffer(c,t,s,i,0))<0)return u;r+=u}return r},this.lame_encode_buffer=function(e,s,n,i,o,_,l){var f=e.internal_flags,c=[null,null];if(4294479419!=f.Class_ID)return-3;if(0==i)return 0;!function(e,t){(null==e.in_buffer_0||e.in_buffer_nsamples1&&(c[1][h]=n[h]);return function(e,s,n,r,i,o,_){var l,f,c,h,u,p=e.internal_flags,m=0,b=[null,null],d=[null,null];if(4294479419!=p.Class_ID)return-3;if(0==r)return 0;if((u=a.copy_buffer(p,i,o,_,0))<0)return u;if(o+=u,m+=u,d[0]=s,d[1]=n,k.NEQ(e.scale,0)&&k.NEQ(e.scale,1))for(f=0;f0;){var g,M,w=[null,null];w[0]=d[0],w[1]=d[1];var R=new H;if(N(e,b,w,v,r,R),g=R.n_in,M=R.n_out,p.findReplayGain&&!p.decode_on_the_fly&&t.AnalyzeSamples(p.rgdata,b[0],p.mf_size,b[1],p.mf_size,M,p.channels_out)==S.GAIN_ANALYSIS_ERROR)return-6;if(r-=g,v+=g,p.channels_out,p.mf_size+=M,p.mf_samples_to_encode<1&&(p.mf_samples_to_encode=X.ENCDELAY+X.POSTDELAY),p.mf_samples_to_encode+=M,p.mf_size>=h){var A=_-m;if(0==_&&(A=0),(l=x(e,b[0],b[1],i,o,A))<0)return l;for(o+=l,m+=l,p.mf_size-=e.framesize,p.mf_samples_to_encode-=e.framesize,c=0;cy&&(y=t.length,x=a(T=0|1.25*y+7200));var r=n.lame_encode_buffer(B,t,s,t.length,x,0,T);return new Int8Array(x.subarray(0,r))},this.flush=function(){var e=n.lame_encode_flush(B,x,0,T);return new Int8Array(x.subarray(0,e))}}}e(),Recorder.lamejs=e}()},function(e,t){var a,s;a=function(e){return new s(e)},(s=function(e){var t={scale:2,speed:9,phase:21.8,fps:20,keep:!0,lineWidth:3,linear1:[0,"rgba(150,96,238,1)",.2,"rgba(170,79,249,1)",1,"rgba(53,199,253,1)"],linear2:[0,"rgba(209,130,255,0.6)",1,"rgba(53,199,255,0.6)"],linearBg:[0,"rgba(255,255,255,0.2)",1,"rgba(54,197,252,0.2)"]};for(var a in e)t[a]=e[a];this.set=e=t;var s=e.elem;s&&("string"==typeof s?s=document.querySelector(s):s.length&&(s=s[0])),s&&(e.width=s.offsetWidth,e.height=s.offsetHeight);var n=e.scale,r=e.width*n,i=e.height*n;if(!r||!i)throw new Error("WaveView无宽高");var o=this.elem=document.createElement("div"),_=["","transform-origin:0 0;","transform:scale("+1/n+");"];o.innerHTML='
';var l=this.canvas=o.querySelector("canvas"),f=this.ctx=l.getContext("2d");l.width=r,l.height=i,this.linear1=this.genLinear(f,r,e.linear1),this.linear2=this.genLinear(f,r,e.linear2),this.linearBg=this.genLinear(f,i,e.linearBg,!0),s&&(s.innerHTML="",s.appendChild(o)),this._phase=0}).prototype=a.prototype={genLinear:function(e,t,a,s){for(var n=e.createLinearGradient(0,0,s?0:t,s?t:0),r=0;r1300&&(clearInterval(e.timer),e.timer=0)}},draw:function(e){var t=this.set,a=this.ctx,s=t.scale,n=t.width*s,r=t.height*s,i=t.speed/t.fps,o=this._phase-=i,_=o+i*t.phase,l=e/100,f=this.genPath(2,l,o),c=this.genPath(1.8,l,_);a.clearRect(0,0,n,r),a.beginPath();for(var h=0,u=0;u=0;h--,u-=s)a.lineTo(u,c[h]);a.closePath(),a.fillStyle=this.linearBg,a.fill(),this.drawPath(c,this.linear2),this.drawPath(f,this.linear1)},drawPath:function(e,t){var a=this.set,s=this.ctx,n=a.scale,r=a.width*n;s.beginPath();for(var i=0,o=0;o + + + + + + +Recorder H5 TypeScript测试 + + + + + +
+
+ Recorder H5 TypeScript测试 + GitHub + | Gitee + + +
+ +
+ +
+
+ + +
+ + + + + + + + + + + + +
+ + +
+
+ +
+
+
+
+
+
+ + +
+
+
+ +
+
本测试的码源码在/assets/demo-ts目录内,主要的文件为/assets/demo-ts/index.ts
+ +
源码修改后测试方法: +
+> npm install
+> npm run build-dev
+
+ 然后就可以打开index.html查看效果了。
+
+
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/demo-ts/index.ts b/assets/demo-ts/index.ts new file mode 100644 index 0000000..8250fdd --- /dev/null +++ b/assets/demo-ts/index.ts @@ -0,0 +1,257 @@ +//====================引入Recorder===================== +// 必须引入的核心,recorder-core会自动往window下挂载名称为Recorder对象,全局可调用window.Recorder +import Recorder from 'recorder-core'; + +//需要使用到的音频格式编码引擎的js文件统统加载进来 +import 'recorder-core/src/engine/mp3'; +import 'recorder-core/src/engine/mp3-engine'; + +//以上三个也可以合并使用压缩好的recorder.xxx.min.js +//import Recorder from 'recorder-core/recorder.mp3.min' //已包含recorder-core和mp3格式支持 +//import Recorder from 'recorder-core/recorder.wav.min' //已包含recorder-core和wav格式支持 + +//可选的插件支持项 +import 'recorder-core/src/extensions/waveview'; +//====================End===================== + +// copy 的 QuickStart.html 代码,统统any,这些代码和普通js代码没有区别,主要用途是验证上面的import能正常引入和打包就完成目的了,对于ts 这些代码并没有什么特殊的地方 +var win=window as any; +var doc=document as any; +var reclog=function(...args:any):void{ win.reclog.apply(null, args); } + + + +var rec : any,wave : any, recBlob: any; +/**调用open打开录音请求好录音权限**/ +win.recOpen=function(){//一般在显示出录音按钮或相关的录音界面时进行此方法调用,后面用户点击开始录音时就能畅通无阻了 + rec=null; + wave=null; + recBlob=null; + var newRec=Recorder({ + type:"mp3",sampleRate:16000,bitRate:16 //mp3格式,指定采样率hz、比特率kbps,其他参数使用默认配置;注意:是数字的参数必须提供数字,不要用字符串;需要使用的type类型,需提前把格式支持文件加载进来,比如使用wav格式需要提前加载wav.js编码引擎 + ,onProcess:function(buffers:any,powerLevel:any,bufferDuration:any,bufferSampleRate:any,newBufferIdx:any,asyncEnd:any){ + //录音实时回调,大约1秒调用12次本回调 + doc.querySelector(".recpowerx").style.width=powerLevel+"%"; + doc.querySelector(".recpowert").innerText=formatMs(bufferDuration,1)+" / "+powerLevel; + + //可视化图形绘制 + wave.input(buffers[buffers.length-1],powerLevel,bufferSampleRate); + } + }); + + createDelayDialog(); //我们可以选择性的弹一个对话框:为了防止移动端浏览器存在第三种情况:用户忽略,并且(或者国产系统UC系)浏览器没有任何回调,此处demo省略了弹窗的代码 + newRec.open(function(){//打开麦克风授权获得相关资源 + dialogCancel(); //如果开启了弹框,此处需要取消 + + rec=newRec; + + //此处创建这些音频可视化图形绘制浏览器支持妥妥的 + wave=Recorder.WaveView({elem:".recwave"}); + + reclog("已打开录音,可以点击录制开始录音了",2); + },function(msg:any,isUserNotAllow:any){//用户拒绝未授权或不支持 + dialogCancel(); //如果开启了弹框,此处需要取消 + reclog((isUserNotAllow?"UserNotAllow,":"")+"打开录音失败:"+msg,1); + }); + + win.waitDialogClick=function(){ + dialogCancel(); + reclog("打开失败:权限请求被忽略,用户主动点击的弹窗",1); + }; +}; + + + +/**关闭录音,释放资源**/ +win.recClose=function(){ + if(rec){ + rec.close(); + reclog("已关闭"); + }else{ + reclog("未打开录音",1); + }; +}; + + + +/**开始录音**/ +win.recStart=function(){//打开了录音后才能进行start、stop调用 + if(rec&&Recorder.IsOpen()){ + recBlob=null; + rec.start(); + reclog("已开始录音..."); + }else{ + reclog("未打开录音",1); + }; +}; + +/**暂停录音**/ +win.recPause=function(){ + if(rec&&Recorder.IsOpen()){ + rec.pause(); + }else{ + reclog("未打开录音",1); + }; +}; +/**恢复录音**/ +win.recResume=function(){ + if(rec&&Recorder.IsOpen()){ + rec.resume(); + }else{ + reclog("未打开录音",1); + }; +}; + +/**结束录音,得到音频文件**/ +win.recStop=function(){ + if(!(rec&&Recorder.IsOpen())){ + reclog("未打开录音",1); + return; + }; + rec.stop(function(blob:any,duration:any){ + console.log(blob,(win.URL||webkitURL).createObjectURL(blob),"时长:"+duration+"ms"); + + recBlob=blob; + reclog("已录制mp3:"+formatMs(duration)+"ms "+blob.size+"字节,可以点击播放、上传了",2); + },function(msg:any){ + reclog("录音失败:"+msg,1); + }); +}; + + + + + + + + + +/**播放**/ +win.recPlay=function(){ + if(!recBlob){ + reclog("请先录音,然后停止后再播放",1); + return; + }; + var cls=("a"+Math.random()).replace(".",""); + reclog('播放中: '); + var audio=doc.createElement("audio"); + audio.controls=true; + doc.querySelector("."+cls).appendChild(audio); + //简单利用URL生成播放地址,注意不用了时需要revokeObjectURL,否则霸占内存 + audio.src=(win.URL||webkitURL).createObjectURL(recBlob); + audio.play(); + + setTimeout(function(){ + (win.URL||webkitURL).revokeObjectURL(audio.src); + },5000); +}; + +/**上传**/ +win.recUpload=function(){ + var blob=recBlob; + if(!blob){ + reclog("请先录音,然后停止后再上传",1); + return; + }; + + //本例子假设使用原始XMLHttpRequest请求方式,实际使用中自行调整为自己的请求方式 + //录音结束时拿到了blob文件对象,可以用FileReader读取出内容,或者用FormData上传 + var api="https://xx.xx/test_request"; + var onreadystatechange=function(title:any){ + return function(){ + if(xhr.readyState==4){ + if(xhr.status==200){ + reclog(title+"上传成功",2); + }else{ + reclog(title+"没有完成上传,演示上传地址无需关注上传结果,只要浏览器控制台内Network面板内看到的请求数据结构是预期的就ok了。", "#d8c1a0"); + + console.error(title+"上传失败",xhr.status,xhr.responseText); + }; + }; + }; + }; + reclog("开始上传到"+api+",请求稍后..."); + + /***方式一:将blob文件转成base64纯文本编码,使用普通application/x-www-form-urlencoded表单上传***/ + var reader=new win.FileReader(); + reader.onloadend=function(){ + var postData=""; + postData+="mime="+encodeURIComponent(blob.type);//告诉后端,这个录音是什么格式的,可能前后端都固定的mp3可以不用写 + postData+="&upfile_b64="+encodeURIComponent((/.+;\s*base64\s*,\s*(.+)$/i.exec(reader.result)||[])[1]) //录音文件内容,后端进行base64解码成二进制 + //...其他表单参数 + + var xhr=new XMLHttpRequest(); + xhr.open("POST", api); + xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); + xhr.onreadystatechange=onreadystatechange("上传方式一【Base64】"); + xhr.send(postData); + }; + reader.readAsDataURL(blob); + + /***方式二:使用FormData用multipart/form-data表单上传文件***/ + var form=new FormData(); + form.append("upfile",blob,"recorder.mp3"); //和普通form表单并无二致,后端接收到upfile参数的文件,文件名为recorder.mp3 + //...其他表单参数 + + var xhr=new XMLHttpRequest(); + xhr.open("POST", api); + xhr.onreadystatechange=onreadystatechange("上传方式二【FormData】"); + xhr.send(form); +}; + + + + + + + + + + +//recOpen我们可以选择性的弹一个对话框:为了防止移动端浏览器存在第三种情况:用户忽略,并且(或者国产系统UC系)浏览器没有任何回调 +var showDialog=function(){ + if(!/mobile/i.test(navigator.userAgent)){ + return;//只在移动端开启没有权限请求的检测 + }; + dialogCancel(); + + //显示弹框,应该使用自己的弹框方式 + var div=doc.createElement("div"); + doc.body.appendChild(div); + div.innerHTML=('' + +'
' + +'
' + +'
' + +'
' + +'
录音功能需要麦克风权限,请允许;如果未看到任何请求,请点击忽略~
' + +'' + +'
' + +'
' + +'
' + +'
'); +}; +var createDelayDialog=function(){ + dialogInt=setTimeout(function(){//定时8秒后打开弹窗,用于监测浏览器没有发起权限请求的情况,在open前放置定时器利于收到了回调能及时取消(不管open是同步还是异步回调的) + showDialog(); + },8000); +}; +var dialogInt:any; +var dialogCancel=function(){ + clearTimeout(dialogInt); + + //关闭弹框,应该使用自己的弹框方式 + var elems=doc.querySelectorAll(".waitDialog"); + for(var i=0;i0?(f<10?"0":"")+f+":":"") + +(all||f>0||m>0?("0"+m).substr(-2)+"″":"") + +("00"+ms%1000).substr(-3); + return s; +}; + diff --git a/assets/demo-ts/package.json b/assets/demo-ts/package.json new file mode 100644 index 0000000..aab297d --- /dev/null +++ b/assets/demo-ts/package.json @@ -0,0 +1,15 @@ +{ + "name": "recorder-ts-demo", + "version": "1.0.0", + "scripts": { + "build": "webpack --progress --mode production --config package.webpack.build.js", + "build-dev": "webpack --progress --mode development --config package.webpack.build.js" + }, + "dependencies": { + "recorder-core": "*", + "webpack": "4.41.2", + "webpack-cli": "3.3.10", + "typescript": "4.7.4", + "ts-loader": "8.4.0" + } +} diff --git a/assets/demo-ts/package.webpack.build.js b/assets/demo-ts/package.webpack.build.js new file mode 100644 index 0000000..a2b8ec3 --- /dev/null +++ b/assets/demo-ts/package.webpack.build.js @@ -0,0 +1,19 @@ +var path = require('path'); + +module.exports = { + entry: { + index:'./index.ts' + }, + output: { + path: path.resolve(__dirname, './dist'), + filename: '[name].js' + }, + module: { + rules: [ + { + test: /\.ts$/, + use:['ts-loader'] + } + ] + } +}; \ No newline at end of file diff --git a/assets/demo-ts/tsconfig.json b/assets/demo-ts/tsconfig.json new file mode 100644 index 0000000..cd2abc3 --- /dev/null +++ b/assets/demo-ts/tsconfig.json @@ -0,0 +1,103 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./dist", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/assets/demo-vue/README.md b/assets/demo-vue/README.md index d0048a7..ae9b8aa 100644 --- a/assets/demo-vue/README.md +++ b/assets/demo-vue/README.md @@ -6,7 +6,7 @@ # 运行方法 ## 【1】编译vue源码 ``` -cnpm install +npm install npm run build-dev ``` ## 【2】浏览器访问 diff --git a/assets/demo-vue/dist/index.js b/assets/demo-vue/dist/index.js index a29a7bb..a4818e4 100644 --- a/assets/demo-vue/dist/index.js +++ b/assets/demo-vue/dist/index.js @@ -1,6 +1,6 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=19)}([function(e,t,n){"use strict";var r,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"===("undefined"==typeof window?"undefined":a(window))&&(r=window)}e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r,a,i,s,o){var l,c="function"==typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),r&&(c.functional=!0),i&&(c._scopeId="data-v-"+i),s?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),a&&a.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},c._ssrRegister=l):a&&(l=o?function(){a.call(this,this.$root.$options.shadowRoot)}:a),l)if(c.functional){c._injectStyles=l;var f=c.render;c.render=function(e,t){return l.call(t),f(e,t)}}else{var u=c.beforeCreate;c.beforeCreate=u?[].concat(u,l):[l]}return{exports:e,options:c}}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";n.r(t);var r=n(4),a=n.n(r);for(var i in r)"default"!==i&&function(e){n.d(t,e,(function(){return r[e]}))}(i);t.default=a.a},function(e,t,n){"use strict";var r,a=n(13),i=(r=a)&&r.__esModule?r:{default:r};n(21),n(22),n(14),e.exports={data:function(){return{Rec:i.default,type:"mp3",bitRate:16,sampleRate:16e3,rec:0,duration:0,powerLevel:0,recOpenDialogShow:0,logs:[]}},methods:{recOpen:function(){var e=this,t=this.rec=(0,i.default)({type:e.type,bitRate:e.bitRate,sampleRate:e.sampleRate,onProcess:function(t,n,r,a){e.duration=r,e.powerLevel=n,e.wave.input(t[t.length-1],n,a)}});e.dialogInt=setTimeout((function(){e.showDialog()}),8e3),t.open((function(){e.dialogCancel(),e.reclog("已打开:"+e.type+" "+e.sampleRate+"hz "+e.bitRate+"kbps",2),e.wave=i.default.WaveView({elem:".ctrlProcessWave"})}),(function(t,n){e.dialogCancel(),e.reclog((n?"UserNotAllow,":"")+"打开失败:"+t,1)})),e.waitDialogClickFn=function(){e.dialogCancel(),e.reclog("打开失败:权限请求被忽略,用户主动点击的弹窗",1)}},recClose:function(){var e=this.rec;this.rec=null,e?(e.close(),this.reclog("已关闭")):this.reclog("未打开录音",1)},recStart:function(){if(this.rec&&i.default.IsOpen()){this.rec.start();var e=this.rec.set;this.reclog("录制中:"+e.type+" "+e.sampleRate+"hz "+e.bitRate+"kbps")}else this.reclog("未打开录音",1)},recPause:function(){this.rec&&i.default.IsOpen()?this.rec.pause():this.reclog("未打开录音",1)},recResume:function(){this.rec&&i.default.IsOpen()?this.rec.resume():this.reclog("未打开录音",1)},recStop:function(){if(this.rec&&i.default.IsOpen()){var e=this,t=e.rec;t.stop((function(n,r){e.reclog("已录制:","",{blob:n,duration:r,rec:t})}),(function(t){e.reclog("录音失败:"+t,1)}))}else e.reclog("未打开录音",1)},recPlayLast:function(){this.recLogLast?this.recplay(this.recLogLast.idx):this.reclog("请先录音,然后停止后再播放",1)},recUploadLast:function(){if(this.recLogLast){var e=this,t=this.recLogLast.res.blob,n="https://xx.xx/test_request",r=function(t){return function(){4==s.readyState&&(200==s.status?e.reclog(t+"上传成功",2):(e.reclog(t+"没有完成上传,演示上传地址无需关注上传结果,只要浏览器控制台内Network面板内看到的请求数据结构是预期的就ok了。","#d8c1a0"),console.error(t+"上传失败",s.status,s.responseText)))}};e.reclog("开始上传到"+n+",请求稍后...","#f60");var a=new FileReader;a.onloadend=function(){var e="";e+="mime="+encodeURIComponent(t.type),e+="&upfile_b64="+encodeURIComponent((/.+;\s*base64\s*,\s*(.+)$/i.exec(a.result)||[])[1]);var i=new XMLHttpRequest;i.open("POST",n),i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.onreadystatechange=r("上传方式一【Base64】"),i.send(e)},a.readAsDataURL(t);var i=new FormData;i.append("upfile",t,"recorder.mp3");var s=new XMLHttpRequest;s.open("POST",n),s.onreadystatechange=r("上传方式二【FormData】"),s.send(i)}else this.reclog("请先录音,然后停止后再上传",1)},reclog:function(e,t,n){var r={idx:this.logs.length,msg:e,color:t,res:n,playMsg:"",down:0,down64Val:""};n&&n.blob&&(this.recLogLast=r),this.logs.splice(0,0,r)},recplay:function(e){var t=this,n=this.logs[this.logs.length-e-1];n.play=(n.play||0)+1;var r=function(e){n.playMsg=''+n.play+" "+t.getTime()+" "+e};r("");var a=this.$refs.LogAudioPlayer;a.controls=!0,a.ended||a.paused||a.pause(),a.onerror=function(e){r('播放失败['+a.error.code+"]"+a.error.message+"")},a.src=(window.URL||webkitURL).createObjectURL(n.res.blob),a.play()},recdown:function(e){var t=this.logs[this.logs.length-e-1];t.down=(t.down||0)+1;var n="rec-"+(t=t.res).duration+"ms-"+(t.rec.set.bitRate||"-")+"kbps-"+(t.rec.set.sampleRate||"-")+"hz."+(t.rec.set.type||(/\w+$/.exec(t.blob.type)||[])[0]||"unknown"),r=document.createElement("A");r.href=(window.URL||webkitURL).createObjectURL(t.blob),r.download=n,r.click()},recdown64:function(e){var t=this.logs[this.logs.length-e-1],n=new FileReader;n.onloadend=function(){t.down64Val=n.result},n.readAsDataURL(t.res.blob)},getTime:function(){var e=new Date;return("0"+e.getHours()).substr(-2)+":"+("0"+e.getMinutes()).substr(-2)+":"+("0"+e.getSeconds()).substr(-2)},intp:function(e,t){return(e=null==e?"-":e+"").length>=t?e:("_______"+e).substr(-t)},showDialog:function(){/mobile/i.test(navigator.userAgent)&&(this.recOpenDialogShow=1)},dialogCancel:function(){clearTimeout(this.dialogInt),this.recOpenDialogShow=0},waitDialogClick:function(){this.dialogCancel(),this.waitDialogClickFn()}}}},function(e,t,n){var r=n(24);"string"==typeof r&&(r=[[e.i,r,""]]);var a={insert:"head",singleton:!1};n(16)(r,a);r.locals&&(e.exports=r.locals)},,,,function(e,t,n){"use strict";(function(e,n){Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=Object.freeze({}); +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";n.r(t);var r=n(1),a=n.n(r);for(var i in r)"default"!==i&&function(e){n.d(t,e,(function(){return r[e]}))}(i);t.default=a.a},function(e,t,n){"use strict";var r,a=n(12),i=(r=a)&&r.__esModule?r:{default:r};n(14),n(15),n(16),e.exports={data:function(){return{Rec:i.default,type:"mp3",bitRate:16,sampleRate:16e3,rec:0,duration:0,powerLevel:0,recOpenDialogShow:0,logs:[]}},methods:{recOpen:function(){var e=this,t=this.rec=(0,i.default)({type:e.type,bitRate:e.bitRate,sampleRate:e.sampleRate,onProcess:function(t,n,r,a){e.duration=r,e.powerLevel=n,e.wave.input(t[t.length-1],n,a)}});e.dialogInt=setTimeout((function(){e.showDialog()}),8e3),t.open((function(){e.dialogCancel(),e.reclog("已打开:"+e.type+" "+e.sampleRate+"hz "+e.bitRate+"kbps",2),e.wave=i.default.WaveView({elem:".ctrlProcessWave"})}),(function(t,n){e.dialogCancel(),e.reclog((n?"UserNotAllow,":"")+"打开失败:"+t,1)})),e.waitDialogClickFn=function(){e.dialogCancel(),e.reclog("打开失败:权限请求被忽略,用户主动点击的弹窗",1)}},recClose:function(){var e=this.rec;this.rec=null,e?(e.close(),this.reclog("已关闭")):this.reclog("未打开录音",1)},recStart:function(){if(this.rec&&i.default.IsOpen()){this.rec.start();var e=this.rec.set;this.reclog("录制中:"+e.type+" "+e.sampleRate+"hz "+e.bitRate+"kbps")}else this.reclog("未打开录音",1)},recPause:function(){this.rec&&i.default.IsOpen()?this.rec.pause():this.reclog("未打开录音",1)},recResume:function(){this.rec&&i.default.IsOpen()?this.rec.resume():this.reclog("未打开录音",1)},recStop:function(){if(this.rec&&i.default.IsOpen()){var e=this,t=e.rec;t.stop((function(n,r){e.reclog("已录制:","",{blob:n,duration:r,rec:t})}),(function(t){e.reclog("录音失败:"+t,1)}))}else e.reclog("未打开录音",1)},recPlayLast:function(){this.recLogLast?this.recplay(this.recLogLast.idx):this.reclog("请先录音,然后停止后再播放",1)},recUploadLast:function(){if(this.recLogLast){var e=this,t=this.recLogLast.res.blob,n="https://xx.xx/test_request",r=function(t){return function(){4==s.readyState&&(200==s.status?e.reclog(t+"上传成功",2):(e.reclog(t+"没有完成上传,演示上传地址无需关注上传结果,只要浏览器控制台内Network面板内看到的请求数据结构是预期的就ok了。","#d8c1a0"),console.error(t+"上传失败",s.status,s.responseText)))}};e.reclog("开始上传到"+n+",请求稍后...","#f60");var a=new FileReader;a.onloadend=function(){var e="";e+="mime="+encodeURIComponent(t.type),e+="&upfile_b64="+encodeURIComponent((/.+;\s*base64\s*,\s*(.+)$/i.exec(a.result)||[])[1]);var i=new XMLHttpRequest;i.open("POST",n),i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.onreadystatechange=r("上传方式一【Base64】"),i.send(e)},a.readAsDataURL(t);var i=new FormData;i.append("upfile",t,"recorder.mp3");var s=new XMLHttpRequest;s.open("POST",n),s.onreadystatechange=r("上传方式二【FormData】"),s.send(i)}else this.reclog("请先录音,然后停止后再上传",1)},reclog:function(e,t,n){var r={idx:this.logs.length,msg:e,color:t,res:n,playMsg:"",down:0,down64Val:""};n&&n.blob&&(this.recLogLast=r),this.logs.splice(0,0,r)},recplay:function(e){var t=this,n=this.logs[this.logs.length-e-1];n.play=(n.play||0)+1;var r=function(e){n.playMsg=''+n.play+" "+t.getTime()+" "+e};r("");var a=this.$refs.LogAudioPlayer;a.controls=!0,a.ended||a.paused||a.pause(),a.onerror=function(e){r('播放失败['+a.error.code+"]"+a.error.message+"")},a.src=(window.URL||webkitURL).createObjectURL(n.res.blob),a.play()},recdown:function(e){var t=this.logs[this.logs.length-e-1];t.down=(t.down||0)+1;var n="rec-"+(t=t.res).duration+"ms-"+(t.rec.set.bitRate||"-")+"kbps-"+(t.rec.set.sampleRate||"-")+"hz."+(t.rec.set.type||(/\w+$/.exec(t.blob.type)||[])[0]||"unknown"),r=document.createElement("A");r.href=(window.URL||webkitURL).createObjectURL(t.blob),r.download=n,r.click()},recdown64:function(e){var t=this.logs[this.logs.length-e-1],n=new FileReader;n.onloadend=function(){t.down64Val=n.result},n.readAsDataURL(t.res.blob)},getTime:function(){var e=new Date;return("0"+e.getHours()).substr(-2)+":"+("0"+e.getMinutes()).substr(-2)+":"+("0"+e.getSeconds()).substr(-2)},intp:function(e,t){return(e=null==e?"-":e+"").length>=t?e:("_______"+e).substr(-t)},showDialog:function(){/mobile/i.test(navigator.userAgent)&&(this.recOpenDialogShow=1)},dialogCancel:function(){clearTimeout(this.dialogInt),this.recOpenDialogShow=0},waitDialogClick:function(){this.dialogCancel(),this.waitDialogClickFn()}}}},function(e,t,n){var r=n(18);"string"==typeof r&&(r=[[e.i,r,""]]);var a={insert:"head",singleton:!1};n(20)(r,a);r.locals&&(e.exports=r.locals)},function(e,t,n){"use strict";var r,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"===("undefined"==typeof window?"undefined":a(window))&&(r=window)}e.exports=r},function(e,t,n){"use strict";var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"main"},[e._t("top"),e._v(" "),n("div",{staticClass:"mainBox"},[n("div",{staticClass:"pd"},[e._v("\r\n 类型:"+e._s(e.type)+"\r\n "),n("span",{staticStyle:{margin:"0 20px"}},[e._v("\r\n 比特率: "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.bitRate,expression:"bitRate"}],staticStyle:{width:"60px"},attrs:{type:"text"},domProps:{value:e.bitRate},on:{input:function(t){t.target.composing||(e.bitRate=t.target.value)}}}),e._v(" kbps\r\n ")]),e._v("\r\n 采样率: "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.sampleRate,expression:"sampleRate"}],staticStyle:{width:"60px"},attrs:{type:"text"},domProps:{value:e.sampleRate},on:{input:function(t){t.target.composing||(e.sampleRate=t.target.value)}}}),e._v(" hz\r\n ")]),e._v(" "),n("div",{staticClass:"btns"},[n("div",[n("button",{on:{click:e.recOpen}},[e._v("打开录音,请求权限")]),e._v(" "),n("button",{on:{click:e.recClose}},[e._v("关闭录音,释放资源")])]),e._v(" "),n("button",{on:{click:e.recStart}},[e._v("录制")]),e._v(" "),n("button",{staticStyle:{"margin-right":"80px"},on:{click:e.recStop}},[e._v("停止")]),e._v(" "),n("span",{staticStyle:{display:"inline-block"}},[n("button",{on:{click:e.recPause}},[e._v("暂停")]),e._v(" "),n("button",{on:{click:e.recResume}},[e._v("继续")])]),e._v(" "),n("span",{staticStyle:{display:"inline-block"}},[n("button",{on:{click:e.recPlayLast}},[e._v("播放")]),e._v(" "),n("button",{on:{click:e.recUploadLast}},[e._v("上传")])])])]),e._v(" "),n("div",{staticClass:"mainBox"},[n("div",{staticClass:"ctrlProcessWave",staticStyle:{height:"100px",width:"300px",border:"1px solid #ccc","box-sizing":"border-box",display:"inline-block","vertical-align":"bottom"}}),e._v(" "),n("div",{staticStyle:{height:"40px",width:"300px",display:"inline-block",background:"#999",position:"relative","vertical-align":"bottom"}},[n("div",{staticClass:"ctrlProcessX",staticStyle:{height:"40px",background:"#0B1",position:"absolute"},style:{width:e.powerLevel+"%"}}),e._v(" "),n("div",{staticClass:"ctrlProcessT",staticStyle:{"padding-left":"50px","line-height":"40px",position:"relative"}},[e._v(e._s(e.duration+"/"+e.powerLevel))])])]),e._v(" "),n("div",{staticClass:"mainBox"},[n("audio",{ref:"LogAudioPlayer",staticStyle:{width:"100%"}}),e._v(" "),n("div",{staticClass:"mainLog"},e._l(e.logs,(function(t){return n("div",{key:t.idx},[n("div",{style:{color:1==t.color?"red":2==t.color?"green":t.color}},[e._o(n("span",[e._v("["+e._s(e.getTime())+"]")]),0,t.idx),n("span",{domProps:{innerHTML:e._s(t.msg)}}),e._v(" "),t.res?[e._v("\r\n "+e._s(e.intp(t.res.rec.set.bitRate,3))+"kbps\r\n "+e._s(e.intp(t.res.rec.set.sampleRate,5))+"hz\r\n 编码"+e._s(e.intp(t.res.blob.size,6))+"b\r\n ["+e._s(t.res.rec.set.type)+"]"+e._s(e.intp(t.res.duration,6))+"ms \r\n \r\n "),n("button",{on:{click:function(n){return e.recdown(t.idx)}}},[e._v("下载")]),e._v(" "),n("button",{on:{click:function(n){return e.recplay(t.idx)}}},[e._v("播放")]),e._v(" "),n("span",{domProps:{innerHTML:e._s(t.playMsg)}}),e._v(" "),t.down?n("span",[n("span",{staticStyle:{color:"red"}},[e._v(e._s(t.down))]),e._v("\r\n \r\n 没弹下载?试一下链接或复制文本"),n("button",{on:{click:function(n){return e.recdown64(t.idx)}}},[e._v("生成Base64文本")]),e._v(" "),t.down64Val?n("textarea",{directives:[{name:"model",rawName:"v-model",value:t.down64Val,expression:"obj.down64Val"}],domProps:{value:t.down64Val},on:{input:function(n){n.target.composing||e.$set(t,"down64Val",n.target.value)}}}):e._e()]):e._e()]:e._e()],2)])})),0)]),e._v(" "),e.recOpenDialogShow?n("div",{staticStyle:{"z-index":"99999",width:"100%",height:"100%",top:"0",left:"0",position:"fixed",background:"rgba(0,0,0,0.3)"}},[n("div",{staticStyle:{display:"flex",height:"100%","align-items":"center"}},[n("div",{staticStyle:{flex:"1"}}),e._v(" "),n("div",{staticStyle:{width:"240px",background:"#fff",padding:"15px 20px","border-radius":"10px"}},[n("div",{staticStyle:{"padding-bottom":"10px"}},[e._v("录音功能需要麦克风权限,请允许;如果未看到任何请求,请点击忽略~")]),e._v(" "),n("div",{staticStyle:{"text-align":"center"}},[n("a",{staticStyle:{color:"#0B1"},on:{click:e.waitDialogClick}},[e._v("忽略")])])]),e._v(" "),n("div",{staticStyle:{flex:"1"}})])]):e._e(),e._v(" "),e._t("bottom")],2)},a=[];r._withStripped=!0,n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return a}))},function(e,t,n){"use strict";function r(e,t,n,r,a,i,s,o){var l,c="function"==typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),r&&(c.functional=!0),i&&(c._scopeId="data-v-"+i),s?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),a&&a.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},c._ssrRegister=l):a&&(l=o?function(){a.call(this,this.$root.$options.shadowRoot)}:a),l)if(c.functional){c._injectStyles=l;var f=c.render;c.render=function(e,t){return l.call(t),f(e,t)}}else{var u=c.beforeCreate;c.beforeCreate=u?[].concat(u,l):[l]}return{exports:e,options:c}}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";var r=i(n(7)),a=i(n(11));function i(e){return e&&e.__esModule?e:{default:e}}var s=new r.default({el:".rootView",data:{},components:{MainView:a.default},template:'\n\n \n\n \n\n '});window.vue_vue=r.default,window.vue_root=s,window.vue_main=s.$refs.mainView,console.log("Vue",r.default),console.log("Recorder",vue_main.Rec)},function(e,t,n){"use strict";(function(e,n){Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=Object.freeze({}); /*! * Vue.js v2.6.10 * (c) 2014-2019 Evan You * Released under the MIT License. - */function i(e){return null==e}function s(e){return null!=e}function o(e){return!0===e}function l(e){return"string"==typeof e||"number"==typeof e||"symbol"===(void 0===e?"undefined":r(e))||"boolean"==typeof e}function c(e){return null!==e&&"object"===(void 0===e?"undefined":r(e))}var f=Object.prototype.toString;function u(e){return"[object Object]"===f.call(e)}function _(e){return"[object RegExp]"===f.call(e)}function p(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function h(e){return s(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function d(e){return null==e?"":Array.isArray(e)||u(e)&&e.toString===f?JSON.stringify(e,null,2):String(e)}function v(e){var t=parseFloat(e);return isNaN(t)?e:t}function m(e,t){for(var n=Object.create(null),r=e.split(","),a=0;a-1)return e.splice(n,1)}}var w=Object.prototype.hasOwnProperty;function S(e,t){return w.call(e,t)}function x(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var k=/-(\w)/g,A=x((function(e){return e.replace(k,(function(e,t){return t?t.toUpperCase():""}))})),M=x((function(e){return e.charAt(0).toUpperCase()+e.slice(1)})),R=/\B([A-Z])/g,T=x((function(e){return e.replace(R,"-$1").toLowerCase()}));var B=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function E(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function C(e,t){for(var n in t)e[n]=t[n];return e}function P(e){for(var t={},n=0;n0,ee=Q&&Q.indexOf("edge/")>0,te=(Q&&Q.indexOf("android"),Q&&/iphone|ipad|ipod|ios/.test(Q)||"ios"===G),ne=(Q&&/chrome\/\d+/.test(Q),Q&&/phantomjs/.test(Q),Q&&Q.match(/firefox\/(\d+)/)),re={}.watch,ae=!1;if(K)try{var ie={};Object.defineProperty(ie,"passive",{get:function(){ae=!0}}),window.addEventListener("test-passive",null,ie)}catch(e){}var se=function(){return void 0===z&&(z=!K&&!Z&&void 0!==e&&(e.process&&"server"===e.process.env.VUE_ENV)),z},oe=K&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function le(e){return"function"==typeof e&&/native code/.test(e.toString())}var ce,fe="undefined"!=typeof Symbol&&le(Symbol)&&"undefined"!=typeof Reflect&&le(Reflect.ownKeys);ce="undefined"!=typeof Set&&le(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var ue=O,_e=0,pe=function(){this.id=_e++,this.subs=[]};pe.prototype.addSub=function(e){this.subs.push(e)},pe.prototype.removeSub=function(e){y(this.subs,e)},pe.prototype.depend=function(){pe.target&&pe.target.addDep(this)},pe.prototype.notify=function(){var e=this.subs.slice();for(var t=0,n=e.length;t-1)if(i&&!S(a,"default"))s=!1;else if(""===s||s===T(e)){var l=Ye(String,a.type);(l<0||o0&&(pt((a=e(a,(n||"")+"_"+r))[0])&&pt(f)&&(u[c]=ye(f.text+a[0].text),a.shift()),u.push.apply(u,a)):l(a)?pt(f)?u[c]=ye(f.text+a):""!==a&&u.push(ye(a)):pt(a)&&pt(f)?u[c]=ye(f.text+a.text):(o(t._isVList)&&s(a.tag)&&i(a.key)&&s(n)&&(a.key="__vlist"+n+"_"+r+"__"),u.push(a)));return u}(e):void 0}function pt(e){return s(e)&&s(e.text)&&!1===e.isComment}function ht(e,t){if(e){for(var n=Object.create(null),r=fe?Reflect.ownKeys(e):Object.keys(e),a=0;a0,s=e?!!e.$stable:!i,o=e&&e.$key;if(e){if(e._normalized)return e._normalized;if(s&&n&&n!==a&&o===n.$key&&!i&&!n.$hasNormal)return n;for(var l in r={},e)e[l]&&"$"!==l[0]&&(r[l]=bt(t,l,e[l]))}else r={};for(var c in t)c in r||(r[c]=gt(t,c));return e&&Object.isExtensible(e)&&(e._normalized=r),Y(r,"$stable",s),Y(r,"$key",o),Y(r,"$hasNormal",i),r}function bt(e,t,n){var a=function(){var e=arguments.length?n.apply(null,arguments):n({});return(e=e&&"object"===(void 0===e?"undefined":r(e))&&!Array.isArray(e)?[e]:_t(e))&&(0===e.length||1===e.length&&e[0].isComment)?void 0:e};return n.proxy&&Object.defineProperty(e,t,{get:a,enumerable:!0,configurable:!0}),a}function gt(e,t){return function(){return e[t]}}function yt(e,t){var n,r,a,i,o;if(Array.isArray(e)||"string"==typeof e)for(n=new Array(e.length),r=0,a=e.length;rdocument.createEvent("Event").timeStamp&&(un=function(){return _n.now()})}function pn(){var e,t;for(fn=un(),ln=!0,rn.sort((function(e,t){return e.id-t.id})),cn=0;cncn&&rn[n].id>e.id;)n--;rn.splice(n+1,0,e)}else rn.push(e);on||(on=!0,at(pn))}}(this)},dn.prototype.run=function(){if(this.active){var e=this.get();if(e!==this.value||c(e)||this.deep){var t=this.value;if(this.value=e,this.user)try{this.cb.call(this.vm,e,t)}catch(e){Xe(e,this.vm,'callback for watcher "'+this.expression+'"')}else this.cb.call(this.vm,e,t)}}},dn.prototype.evaluate=function(){this.value=this.get(),this.dirty=!1},dn.prototype.depend=function(){for(var e=this.deps.length;e--;)this.deps[e].depend()},dn.prototype.teardown=function(){if(this.active){this.vm._isBeingDestroyed||y(this.vm._watchers,this);for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1}};var vn={enumerable:!0,configurable:!0,get:O,set:O};function mn(e,t,n){vn.get=function(){return this[t][n]},vn.set=function(e){this[t][n]=e},Object.defineProperty(e,n,vn)}function bn(e){e._watchers=[];var t=e.$options;t.props&&function(e,t){var n=e.$options.propsData||{},r=e._props={},a=e.$options._propKeys=[];e.$parent&&Me(!1);var i=function(i){a.push(i);var s=Ve(i,t,n,e);Be(r,i,s),i in e||mn(e,"_props",i)};for(var s in t)i(s);Me(!0)}(e,t.props),t.methods&&function(e,t){e.$options.props;for(var n in t)e[n]="function"!=typeof t[n]?O:B(t[n],e)}(e,t.methods),t.data?function(e){var t=e.$options.data;u(t=e._data="function"==typeof t?function(e,t){de();try{return e.call(t,t)}catch(e){return Xe(e,t,"data()"),{}}finally{ve()}}(t,e):t||{})||(t={});var n=Object.keys(t),r=e.$options.props,a=(e.$options.methods,n.length);for(;a--;){var i=n[a];0,r&&S(r,i)||q(i)||mn(e,"_data",i)}Te(t,!0)}(e):Te(e._data={},!0),t.computed&&function(e,t){var n=e._computedWatchers=Object.create(null),r=se();for(var a in t){var i=t[a],s="function"==typeof i?i:i.get;0,r||(n[a]=new dn(e,s||O,O,gn)),a in e||yn(e,a,i)}}(e,t.computed),t.watch&&t.watch!==re&&function(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var a=0;a-1:"string"==typeof e?e.split(",").indexOf(t)>-1:!!_(e)&&e.test(t)}function En(e,t){var n=e.cache,r=e.keys,a=e._vnode;for(var i in n){var s=n[i];if(s){var o=Tn(s.componentOptions);o&&!t(o)&&Cn(n,i,r,a)}}}function Cn(e,t,n,r){var a=e[t];!a||r&&a.tag===r.tag||a.componentInstance.$destroy(),e[t]=null,y(n,t)}!function(e){e.prototype._init=function(e){var t=this;t._uid=kn++,t._isVue=!0,e&&e._isComponent?function(e,t){var n=e.$options=Object.create(e.constructor.options),r=t._parentVnode;n.parent=t.parent,n._parentVnode=r;var a=r.componentOptions;n.propsData=a.propsData,n._parentListeners=a.listeners,n._renderChildren=a.children,n._componentTag=a.tag,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}(t,e):t.$options=De(An(t.constructor),e||{},t),t._renderProxy=t,t._self=t,function(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}(t),function(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&Qt(e,t)}(t),function(e){e._vnode=null,e._staticTrees=null;var t=e.$options,n=e.$vnode=t._parentVnode,r=n&&n.context;e.$slots=dt(t._renderChildren,r),e.$scopedSlots=a,e._c=function(t,n,r,a){return Ft(e,t,n,r,a,!1)},e.$createElement=function(t,n,r,a){return Ft(e,t,n,r,a,!0)};var i=n&&n.data;Be(e,"$attrs",i&&i.attrs||a,null,!0),Be(e,"$listeners",t._parentListeners||a,null,!0)}(t),nn(t,"beforeCreate"),function(e){var t=ht(e.$options.inject,e);t&&(Me(!1),Object.keys(t).forEach((function(n){Be(e,n,t[n])})),Me(!0))}(t),bn(t),function(e){var t=e.$options.provide;t&&(e._provided="function"==typeof t?t.call(e):t)}(t),nn(t,"created"),t.$options.el&&t.$mount(t.$options.el)}}(Mn),function(e){var t={get:function(){return this._data}},n={get:function(){return this._props}};Object.defineProperty(e.prototype,"$data",t),Object.defineProperty(e.prototype,"$props",n),e.prototype.$set=Ee,e.prototype.$delete=Ce,e.prototype.$watch=function(e,t,n){if(u(t))return xn(this,e,t,n);(n=n||{}).user=!0;var r=new dn(this,e,t,n);if(n.immediate)try{t.call(this,r.value)}catch(e){Xe(e,this,'callback for immediate watcher "'+r.expression+'"')}return function(){r.teardown()}}}(Mn),function(e){var t=/^hook:/;e.prototype.$on=function(e,n){var r=this;if(Array.isArray(e))for(var a=0,i=e.length;a1?E(n):n;for(var r=E(arguments,1),a='event handler for "'+e+'"',i=0,s=n.length;iparseInt(this.max)&&Cn(s,o[0],o,this._vnode)),t.data.keepAlive=!0}return t||e&&e[0]}}};!function(e){var t={get:function(){return V}};Object.defineProperty(e,"config",t),e.util={warn:ue,extend:C,mergeOptions:De,defineReactive:Be},e.set=Ee,e.delete=Ce,e.nextTick=at,e.observable=function(e){return Te(e),e},e.options=Object.create(null),D.forEach((function(t){e.options[t+"s"]=Object.create(null)})),e.options._base=e,C(e.options.components,On),function(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=E(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}(e),function(e){e.mixin=function(e){return this.options=De(this.options,e),this}}(e),Rn(e),function(e){D.forEach((function(t){e[t]=function(e,n){return n?("component"===t&&u(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}}))}(e)}(Mn),Object.defineProperty(Mn.prototype,"$isServer",{get:se}),Object.defineProperty(Mn.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Object.defineProperty(Mn,"FunctionalRenderContext",{value:It}),Mn.version="2.6.10";var Ln=m("style,class"),In=m("input,textarea,option,select,progress"),Hn=function(e,t,n){return"value"===n&&In(e)&&"button"!==t||"selected"===n&&"option"===e||"checked"===n&&"input"===e||"muted"===n&&"video"===e},Nn=m("contenteditable,draggable,spellcheck"),$n=m("events,caret,typing,plaintext-only"),Dn=m("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),jn="http://www.w3.org/1999/xlink",Vn=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},Fn=function(e){return Vn(e)?e.slice(6,e.length):""},qn=function(e){return null==e||!1===e};function Yn(e){for(var t=e.data,n=e,r=e;s(r.componentInstance);)(r=r.componentInstance._vnode)&&r.data&&(t=Xn(r.data,t));for(;s(n=n.parent);)n&&n.data&&(t=Xn(t,n.data));return function(e,t){if(s(e)||s(t))return zn(e,Un(t));return""}(t.staticClass,t.class)}function Xn(e,t){return{staticClass:zn(e.staticClass,t.staticClass),class:s(e.class)?[e.class,t.class]:t.class}}function zn(e,t){return e?t?e+" "+t:e:t||""}function Un(e){return Array.isArray(e)?function(e){for(var t,n="",r=0,a=e.length;r-1?br(e,t,n):Dn(t)?qn(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Nn(t)?e.setAttribute(t,function(e,t){return qn(t)||"false"===t?"false":"contenteditable"===e&&$n(t)?t:"true"}(t,n)):Vn(t)?qn(n)?e.removeAttributeNS(jn,Fn(t)):e.setAttributeNS(jn,t,n):br(e,t,n)}function br(e,t,n){if(qn(n))e.removeAttribute(t);else{if(W&&!J&&"TEXTAREA"===e.tagName&&"placeholder"===t&&""!==n&&!e.__ieph){e.addEventListener("input",(function t(n){n.stopImmediatePropagation(),e.removeEventListener("input",t)})),e.__ieph=!0}e.setAttribute(t,n)}}var gr={create:vr,update:vr};function yr(e,t){var n=t.elm,r=t.data,a=e.data;if(!(i(r.staticClass)&&i(r.class)&&(i(a)||i(a.staticClass)&&i(a.class)))){var o=Yn(t),l=n._transitionClasses;s(l)&&(o=zn(o,Un(l))),o!==n._prevClass&&(n.setAttribute("class",o),n._prevClass=o)}}var wr,Sr,xr,kr,Ar,Mr,Rr={create:yr,update:yr},Tr=/[\w).+\-_$\]]/;function Br(e){var t,n,r,a,i,s=!1,o=!1,l=!1,c=!1,f=0,u=0,_=0,p=0;for(r=0;r=0&&" "===(d=e.charAt(h));h--);d&&Tr.test(d)||(c=!0)}}else void 0===a?(p=r+1,a=e.slice(0,r).trim()):v();function v(){(i||(i=[])).push(e.slice(p,r).trim()),p=r+1}if(void 0===a?a=e.slice(0,r).trim():0!==p&&v(),i)for(r=0;r-1?{exp:e.slice(0,kr),key:'"'+e.slice(kr+1)+'"'}:{exp:e,key:null};Sr=e,kr=Ar=Mr=0;for(;!zr();)Ur(xr=Xr())?Zr(xr):91===xr&&Kr(xr);return{exp:e.slice(0,Ar),key:e.slice(Ar+1,Mr)}}(e);return null===n.key?e+"="+t:"$set("+n.exp+", "+n.key+", "+t+")"}function Xr(){return Sr.charCodeAt(++kr)}function zr(){return kr>=wr}function Ur(e){return 34===e||39===e}function Kr(e){var t=1;for(Ar=kr;!zr();)if(Ur(e=Xr()))Zr(e);else if(91===e&&t++,93===e&&t--,0===t){Mr=kr;break}}function Zr(e){for(var t=e;!zr()&&(e=Xr())!==t;);}var Gr;function Qr(e,t,n){var r=Gr;return function a(){var i=t.apply(null,arguments);null!==i&&ea(e,a,n,r)}}var Wr=Ge&&!(ne&&Number(ne[1])<=53);function Jr(e,t,n,r){if(Wr){var a=fn,i=t;t=i._wrapper=function(e){if(e.target===e.currentTarget||e.timeStamp>=a||e.timeStamp<=0||e.target.ownerDocument!==document)return i.apply(this,arguments)}}Gr.addEventListener(e,t,ae?{capture:n,passive:r}:n)}function ea(e,t,n,r){(r||Gr).removeEventListener(e,t._wrapper||t,n)}function ta(e,t){if(!i(e.data.on)||!i(t.data.on)){var n=t.data.on||{},r=e.data.on||{};Gr=t.elm,function(e){if(s(e.__r)){var t=W?"change":"input";e[t]=[].concat(e.__r,e[t]||[]),delete e.__r}s(e.__c)&&(e.change=[].concat(e.__c,e.change||[]),delete e.__c)}(n),ct(n,r,Jr,ea,Qr,t.context),Gr=void 0}}var na,ra={create:ta,update:ta};function aa(e,t){if(!i(e.data.domProps)||!i(t.data.domProps)){var n,r,a=t.elm,o=e.data.domProps||{},l=t.data.domProps||{};for(n in s(l.__ob__)&&(l=t.data.domProps=C({},l)),o)n in l||(a[n]="");for(n in l){if(r=l[n],"textContent"===n||"innerHTML"===n){if(t.children&&(t.children.length=0),r===o[n])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===n&&"PROGRESS"!==a.tagName){a._value=r;var c=i(r)?"":String(r);ia(a,c)&&(a.value=c)}else if("innerHTML"===n&&Gn(a.tagName)&&i(a.innerHTML)){(na=na||document.createElement("div")).innerHTML=""+r+"";for(var f=na.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;f.firstChild;)a.appendChild(f.firstChild)}else if(r!==o[n])try{a[n]=r}catch(e){}}}}function ia(e,t){return!e.composing&&("OPTION"===e.tagName||function(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}(e,t)||function(e,t){var n=e.value,r=e._vModifiers;if(s(r)){if(r.number)return v(n)!==v(t);if(r.trim)return n.trim()!==t.trim()}return n!==t}(e,t))}var sa={create:aa,update:aa},oa=x((function(e){var t={},n=/:(.+)/;return e.split(/;(?![^(]*\))/g).forEach((function(e){if(e){var r=e.split(n);r.length>1&&(t[r[0].trim()]=r[1].trim())}})),t}));function la(e){var t=ca(e.style);return e.staticStyle?C(e.staticStyle,t):t}function ca(e){return Array.isArray(e)?P(e):"string"==typeof e?oa(e):e}var fa,ua=/^--/,_a=/\s*!important$/,pa=function(e,t,n){if(ua.test(t))e.style.setProperty(t,n);else if(_a.test(n))e.style.setProperty(T(t),n.replace(_a,""),"important");else{var r=da(t);if(Array.isArray(n))for(var a=0,i=n.length;a-1?t.split(ba).forEach((function(t){return e.classList.add(t)})):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function ya(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(ba).forEach((function(t){return e.classList.remove(t)})):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");(n=n.trim())?e.setAttribute("class",n):e.removeAttribute("class")}}function wa(e){if(e){if("object"===(void 0===e?"undefined":r(e))){var t={};return!1!==e.css&&C(t,Sa(e.name||"v")),C(t,e),t}return"string"==typeof e?Sa(e):void 0}}var Sa=x((function(e){return{enterClass:e+"-enter",enterToClass:e+"-enter-to",enterActiveClass:e+"-enter-active",leaveClass:e+"-leave",leaveToClass:e+"-leave-to",leaveActiveClass:e+"-leave-active"}})),xa=K&&!J,ka="transition",Aa="transitionend",Ma="animation",Ra="animationend";xa&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(ka="WebkitTransition",Aa="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(Ma="WebkitAnimation",Ra="webkitAnimationEnd"));var Ta=K?window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout:function(e){return e()};function Ba(e){Ta((function(){Ta(e)}))}function Ea(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),ga(e,t))}function Ca(e,t){e._transitionClasses&&y(e._transitionClasses,t),ya(e,t)}function Pa(e,t,n){var r=La(e,t),a=r.type,i=r.timeout,s=r.propCount;if(!a)return n();var o="transition"===a?Aa:Ra,l=0,c=function(){e.removeEventListener(o,f),n()},f=function(t){t.target===e&&++l>=s&&c()};setTimeout((function(){l0&&(n="transition",f=s,u=i.length):"animation"===t?c>0&&(n="animation",f=c,u=l.length):u=(n=(f=Math.max(s,c))>0?s>c?"transition":"animation":null)?"transition"===n?i.length:l.length:0,{type:n,timeout:f,propCount:u,hasTransform:"transition"===n&&Oa.test(r[ka+"Property"])}}function Ia(e,t){for(;e.length1}function Va(e,t){!0!==t.data.show&&Na(t)}var Fa=function(e){var t,n,r={},a=e.modules,c=e.nodeOps;for(t=0;th?g(e,i(n[m+1])?null:n[m+1].elm,n,p,m,r):p>m&&w(0,t,_,h)}(_,v,m,n,f):s(m)?(s(e.text)&&c.setTextContent(_,""),g(_,null,m,0,m.length-1,n)):s(v)?w(0,v,0,v.length-1):s(e.text)&&c.setTextContent(_,""):e.text!==t.text&&c.setTextContent(_,t.text),s(h)&&s(p=h.hook)&&s(p=p.postpatch)&&p(e,t)}}}function A(e,t,n){if(o(n)&&s(e.parent))e.parent.data.pendingInsert=t;else for(var r=0;r-1,s.selected!==i&&(s.selected=i);else if(H(Ua(s),r))return void(e.selectedIndex!==o&&(e.selectedIndex=o));a||(e.selectedIndex=-1)}}function za(e,t){return t.every((function(t){return!H(t,e)}))}function Ua(e){return"_value"in e?e._value:e.value}function Ka(e){e.target.composing=!0}function Za(e){e.target.composing&&(e.target.composing=!1,Ga(e.target,"input"))}function Ga(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Qa(e){return!e.componentInstance||e.data&&e.data.transition?e:Qa(e.componentInstance._vnode)}var Wa={model:qa,show:{bind:function(e,t,n){var r=t.value,a=(n=Qa(n)).data&&n.data.transition,i=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&a?(n.data.show=!0,Na(n,(function(){e.style.display=i}))):e.style.display=r?i:"none"},update:function(e,t,n){var r=t.value;!r!=!t.oldValue&&((n=Qa(n)).data&&n.data.transition?(n.data.show=!0,r?Na(n,(function(){e.style.display=e.__vOriginalDisplay})):$a(n,(function(){e.style.display="none"}))):e.style.display=r?e.__vOriginalDisplay:"none")},unbind:function(e,t,n,r,a){a||(e.style.display=e.__vOriginalDisplay)}}},Ja={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]};function ei(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?ei(Ut(t.children)):e}function ti(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var a=n._parentListeners;for(var i in a)t[A(i)]=a[i];return t}function ni(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}var ri=function(e){return e.tag||zt(e)},ai=function(e){return"show"===e.name},ii={name:"transition",props:Ja,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(ri)).length){0;var r=this.mode;0;var a=n[0];if(function(e){for(;e=e.parent;)if(e.data.transition)return!0}(this.$vnode))return a;var i=ei(a);if(!i)return a;if(this._leaving)return ni(e,a);var s="__transition-"+this._uid+"-";i.key=null==i.key?i.isComment?s+"comment":s+i.tag:l(i.key)?0===String(i.key).indexOf(s)?i.key:s+i.key:i.key;var o=(i.data||(i.data={})).transition=ti(this),c=this._vnode,f=ei(c);if(i.data.directives&&i.data.directives.some(ai)&&(i.data.show=!0),f&&f.data&&!function(e,t){return t.key===e.key&&t.tag===e.tag}(i,f)&&!zt(f)&&(!f.componentInstance||!f.componentInstance._vnode.isComment)){var u=f.data.transition=C({},o);if("out-in"===r)return this._leaving=!0,ft(u,"afterLeave",(function(){t._leaving=!1,t.$forceUpdate()})),ni(e,a);if("in-out"===r){if(zt(i))return c;var _,p=function(){_()};ft(o,"afterEnter",p),ft(o,"enterCancelled",p),ft(u,"delayLeave",(function(e){_=e}))}}return a}}},si=C({tag:String,moveClass:String},Ja);function oi(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function li(e){e.data.newPos=e.elm.getBoundingClientRect()}function ci(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,a=t.top-n.top;if(r||a){e.data.moved=!0;var i=e.elm.style;i.transform=i.WebkitTransform="translate("+r+"px,"+a+"px)",i.transitionDuration="0s"}}delete si.mode;var fi={Transition:ii,TransitionGroup:{props:si,beforeMount:function(){var e=this,t=this._update;this._update=function(n,r){var a=Jt(e);e.__patch__(e._vnode,e.kept,!1,!0),e._vnode=e.kept,a(),t.call(e,n,r)}},render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,a=this.$slots.default||[],i=this.children=[],s=ti(this),o=0;o-1?Jn[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:Jn[e]=/HTMLUnknownElement/.test(t.toString())},C(Mn.options.directives,Wa),C(Mn.options.components,fi),Mn.prototype.__patch__=K?Fa:O,Mn.prototype.$mount=function(e,t){return function(e,t,n){var r;return e.$el=t,e.$options.render||(e.$options.render=ge),nn(e,"beforeMount"),r=function(){e._update(e._render(),n)},new dn(e,r,O,{before:function(){e._isMounted&&!e._isDestroyed&&nn(e,"beforeUpdate")}},!0),n=!1,null==e.$vnode&&(e._isMounted=!0,nn(e,"mounted")),e}(this,e=e&&K?tr(e):void 0,t)},K&&setTimeout((function(){V.devtools&&oe&&oe.emit("init",Mn)}),0);var ui=/\{\{((?:.|\r?\n)+?)\}\}/g,_i=/[-.*+?^${}()|[\]\/\\]/g,pi=x((function(e){var t=e[0].replace(_i,"\\$&"),n=e[1].replace(_i,"\\$&");return new RegExp(t+"((?:.|\\n)+?)"+n,"g")}));var hi={staticKeys:["staticClass"],transformNode:function(e,t){t.warn;var n=jr(e,"class");n&&(e.staticClass=JSON.stringify(n));var r=Dr(e,"class",!1);r&&(e.classBinding=r)},genData:function(e){var t="";return e.staticClass&&(t+="staticClass:"+e.staticClass+","),e.classBinding&&(t+="class:"+e.classBinding+","),t}};var di,vi={staticKeys:["staticStyle"],transformNode:function(e,t){t.warn;var n=jr(e,"style");n&&(e.staticStyle=JSON.stringify(oa(n)));var r=Dr(e,"style",!1);r&&(e.styleBinding=r)},genData:function(e){var t="";return e.staticStyle&&(t+="staticStyle:"+e.staticStyle+","),e.styleBinding&&(t+="style:("+e.styleBinding+"),"),t}},mi=function(e){return(di=di||document.createElement("div")).innerHTML=e,di.textContent},bi=m("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),gi=m("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),yi=m("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),wi=/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,Si=/^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,xi="[a-zA-Z_][\\-\\.0-9_a-zA-Z"+F.source+"]*",ki="((?:"+xi+"\\:)?"+xi+")",Ai=new RegExp("^<"+ki),Mi=/^\s*(\/?)>/,Ri=new RegExp("^<\\/"+ki+"[^>]*>"),Ti=/^]+>/i,Bi=/^",""":'"',"&":"&"," ":"\n"," ":"\t","'":"'"},Li=/&(?:lt|gt|quot|amp|#39);/g,Ii=/&(?:lt|gt|quot|amp|#39|#10|#9);/g,Hi=m("pre,textarea",!0),Ni=function(e,t){return e&&Hi(e)&&"\n"===t[0]};function $i(e,t){var n=t?Ii:Li;return e.replace(n,(function(e){return Oi[e]}))}var Di,ji,Vi,Fi,qi,Yi,Xi,zi,Ui=/^@|^v-on:/,Ki=/^v-|^@|^:/,Zi=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,Gi=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Qi=/^\(|\)$/g,Wi=/^\[.*\]$/,Ji=/:(.*)$/,es=/^:|^\.|^v-bind:/,ts=/\.[^.\]]+(?=[^\]]*$)/g,ns=/^v-slot(:|$)|^#/,rs=/[\r\n]/,as=/\s+/g,is=x(mi);function ss(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:ps(t),rawAttrsMap:{},parent:n,children:[]}}function os(e,t){Di=t.warn||Cr,Yi=t.isPreTag||L,Xi=t.mustUseProp||L,zi=t.getTagNamespace||L;var n=t.isReservedTag||L;(function(e){return!!e.component||!n(e.tag)}),Vi=Pr(t.modules,"transformNode"),Fi=Pr(t.modules,"preTransformNode"),qi=Pr(t.modules,"postTransformNode"),ji=t.delimiters;var r,a,i=[],s=!1!==t.preserveWhitespace,o=t.whitespace,l=!1,c=!1;function f(e){if(u(e),l||e.processed||(e=ls(e,t)),i.length||e===r||r.if&&(e.elseif||e.else)&&fs(r,{exp:e.elseif,block:e}),a&&!e.forbidden)if(e.elseif||e.else)s=e,(o=function(e){for(var t=e.length;t--;){if(1===e[t].type)return e[t];e.pop()}}(a.children))&&o.if&&fs(o,{exp:s.elseif,block:s});else{if(e.slotScope){var n=e.slotTarget||'"default"';(a.scopedSlots||(a.scopedSlots={}))[n]=e}a.children.push(e),e.parent=a}var s,o;e.children=e.children.filter((function(e){return!e.slotScope})),u(e),e.pre&&(l=!1),Yi(e.tag)&&(c=!1);for(var f=0;f]*>)","i")),_=e.replace(u,(function(e,n,r){return c=r.length,Ci(f)||"noscript"===f||(n=n.replace(//g,"$1").replace(//g,"$1")),Ni(f,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""}));l+=e.length-_.length,e=_,M(f,l-c,l)}else{var p=e.indexOf("<");if(0===p){if(Bi.test(e)){var h=e.indexOf("--\x3e");if(h>=0){t.shouldKeepComment&&t.comment(e.substring(4,h),l,l+h+3),x(h+3);continue}}if(Ei.test(e)){var d=e.indexOf("]>");if(d>=0){x(d+2);continue}}var v=e.match(Ti);if(v){x(v[0].length);continue}var m=e.match(Ri);if(m){var b=l;x(m[0].length),M(m[1],b,l);continue}var g=k();if(g){A(g),Ni(g.tagName,e)&&x(1);continue}}var y=void 0,w=void 0,S=void 0;if(p>=0){for(w=e.slice(p);!(Ri.test(w)||Ai.test(w)||Bi.test(w)||Ei.test(w)||(S=w.indexOf("<",1))<0);)p+=S,w=e.slice(p);y=e.substring(0,p)}p<0&&(y=e),y&&x(y.length),t.chars&&y&&t.chars(y,l-y.length,l)}if(e===n){t.chars&&t.chars(e);break}}function x(t){l+=t,e=e.substring(t)}function k(){var t=e.match(Ai);if(t){var n,r,a={tagName:t[1],attrs:[],start:l};for(x(t[0].length);!(n=e.match(Mi))&&(r=e.match(Si)||e.match(wi));)r.start=l,x(r[0].length),r.end=l,a.attrs.push(r);if(n)return a.unarySlash=n[1],x(n[0].length),a.end=l,a}}function A(e){var n=e.tagName,l=e.unarySlash;i&&("p"===r&&yi(n)&&M(r),o(n)&&r===n&&M(n));for(var c=s(n)||!!l,f=e.attrs.length,u=new Array(f),_=0;_=0&&a[s].lowerCasedTag!==o;s--);else s=0;if(s>=0){for(var c=a.length-1;c>=s;c--)t.end&&t.end(a[c].tag,n,i);a.length=s,r=s&&a[s-1].tag}else"br"===o?t.start&&t.start(e,[],!0,n,i):"p"===o&&(t.start&&t.start(e,[],!1,n,i),t.end&&t.end(e,n,i))}M()}(e,{warn:Di,expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,canBeLeftOpenTag:t.canBeLeftOpenTag,shouldDecodeNewlines:t.shouldDecodeNewlines,shouldDecodeNewlinesForHref:t.shouldDecodeNewlinesForHref,shouldKeepComment:t.comments,outputSourceRange:t.outputSourceRange,start:function(e,n,s,o,u){var _=a&&a.ns||zi(e);W&&"svg"===_&&(n=function(e){for(var t=[],n=0;nl&&(o.push(i=e.slice(l,a)),s.push(JSON.stringify(i)));var c=Br(r[1].trim());s.push("_s("+c+")"),o.push({"@binding":c}),l=a+r[0].length}return l-1"+("true"===i?":("+t+")":":_q("+t+","+i+")")),$r(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+i+"):("+s+");if(Array.isArray($$a)){var $$v="+(r?"_n("+a+")":a)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+Yr(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+Yr(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+Yr(t,"$$c")+"}",null,!0)}(e,r,a);else if("input"===i&&"radio"===s)!function(e,t,n){var r=n&&n.number,a=Dr(e,"value")||"null";Or(e,"checked","_q("+t+","+(a=r?"_n("+a+")":a)+")"),$r(e,"change",Yr(t,a),null,!0)}(e,r,a);else if("input"===i||"textarea"===i)!function(e,t,n){var r=e.attrsMap.type;0;var a=n||{},i=a.lazy,s=a.number,o=a.trim,l=!i&&"range"!==r,c=i?"change":"range"===r?"__r":"input",f="$event.target.value";o&&(f="$event.target.value.trim()");s&&(f="_n("+f+")");var u=Yr(t,f);l&&(u="if($event.target.composing)return;"+u);Or(e,"value","("+t+")"),$r(e,c,u,null,!0),(o||s)&&$r(e,"blur","$forceUpdate()")}(e,r,a);else{if(!V.isReservedTag(i))return qr(e,r,a),!1}return!0},text:function(e,t){t.value&&Or(e,"textContent","_s("+t.value+")",t)},html:function(e,t){t.value&&Or(e,"innerHTML","_s("+t.value+")",t)}},isPreTag:function(e){return"pre"===e},isUnaryTag:bi,mustUseProp:Hn,canBeLeftOpenTag:gi,isReservedTag:Qn,getTagNamespace:Wn,staticKeys:function(e){return e.reduce((function(e,t){return e.concat(t.staticKeys||[])}),[]).join(",")}(ms)},ws=x((function(e){return m("type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap"+(e?","+e:""))}));function Ss(e,t){e&&(bs=ws(t.staticKeys||""),gs=t.isReservedTag||L,function e(t){if(t.static=function(e){if(2===e.type)return!1;if(3===e.type)return!0;return!(!e.pre&&(e.hasBindings||e.if||e.for||b(e.tag)||!gs(e.tag)||function(e){for(;e.parent;){if("template"!==(e=e.parent).tag)return!1;if(e.for)return!0}return!1}(e)||!Object.keys(e).every(bs)))}(t),1===t.type){if(!gs(t.tag)&&"slot"!==t.tag&&null==t.attrsMap["inline-template"])return;for(var n=0,r=t.children.length;n|^function\s*(?:[\w$]+)?\s*\(/,ks=/\([^)]*?\);*$/,As=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/,Ms={esc:27,tab:9,enter:13,space:32,up:38,left:37,right:39,down:40,delete:[8,46]},Rs={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]},Ts=function(e){return"if("+e+")return null;"},Bs={stop:"$event.stopPropagation();",prevent:"$event.preventDefault();",self:Ts("$event.target !== $event.currentTarget"),ctrl:Ts("!$event.ctrlKey"),shift:Ts("!$event.shiftKey"),alt:Ts("!$event.altKey"),meta:Ts("!$event.metaKey"),left:Ts("'button' in $event && $event.button !== 0"),middle:Ts("'button' in $event && $event.button !== 1"),right:Ts("'button' in $event && $event.button !== 2")};function Es(e,t){var n=t?"nativeOn:":"on:",r="",a="";for(var i in e){var s=Cs(e[i]);e[i]&&e[i].dynamic?a+=i+","+s+",":r+='"'+i+'":'+s+","}return r="{"+r.slice(0,-1)+"}",a?n+"_d("+r+",["+a.slice(0,-1)+"])":n+r}function Cs(e){if(!e)return"function(){}";if(Array.isArray(e))return"["+e.map((function(e){return Cs(e)})).join(",")+"]";var t=As.test(e.value),n=xs.test(e.value),r=As.test(e.value.replace(ks,""));if(e.modifiers){var a="",i="",s=[];for(var o in e.modifiers)if(Bs[o])i+=Bs[o],Ms[o]&&s.push(o);else if("exact"===o){var l=e.modifiers;i+=Ts(["ctrl","shift","alt","meta"].filter((function(e){return!l[e]})).map((function(e){return"$event."+e+"Key"})).join("||"))}else s.push(o);return s.length&&(a+=function(e){return"if(!$event.type.indexOf('key')&&"+e.map(Ps).join("&&")+")return null;"}(s)),i&&(a+=i),"function($event){"+a+(t?"return "+e.value+"($event)":n?"return ("+e.value+")($event)":r?"return "+e.value:e.value)+"}"}return t||n?e.value:"function($event){"+(r?"return "+e.value:e.value)+"}"}function Ps(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var n=Ms[e],r=Rs[e];return"_k($event.keyCode,"+JSON.stringify(e)+","+JSON.stringify(n)+",$event.key,"+JSON.stringify(r)+")"}var Os={on:function(e,t){e.wrapListeners=function(e){return"_g("+e+","+t.value+")"}},bind:function(e,t){e.wrapData=function(n){return"_b("+n+",'"+e.tag+"',"+t.value+","+(t.modifiers&&t.modifiers.prop?"true":"false")+(t.modifiers&&t.modifiers.sync?",true":"")+")"}},cloak:O},Ls=function(e){this.options=e,this.warn=e.warn||Cr,this.transforms=Pr(e.modules,"transformCode"),this.dataGenFns=Pr(e.modules,"genData"),this.directives=C(C({},Os),e.directives);var t=e.isReservedTag||L;this.maybeComponent=function(e){return!!e.component||!t(e.tag)},this.onceId=0,this.staticRenderFns=[],this.pre=!1};function Is(e,t){var n=new Ls(t);return{render:"with(this){return "+(e?Hs(e,n):'_c("div")')+"}",staticRenderFns:n.staticRenderFns}}function Hs(e,t){if(e.parent&&(e.pre=e.pre||e.parent.pre),e.staticRoot&&!e.staticProcessed)return Ns(e,t);if(e.once&&!e.onceProcessed)return $s(e,t);if(e.for&&!e.forProcessed)return js(e,t);if(e.if&&!e.ifProcessed)return Ds(e,t);if("template"!==e.tag||e.slotTarget||t.pre){if("slot"===e.tag)return function(e,t){var n=e.slotName||'"default"',r=Ys(e,t),a="_t("+n+(r?","+r:""),i=e.attrs||e.dynamicAttrs?Us((e.attrs||[]).concat(e.dynamicAttrs||[]).map((function(e){return{name:A(e.name),value:e.value,dynamic:e.dynamic}}))):null,s=e.attrsMap["v-bind"];!i&&!s||r||(a+=",null");i&&(a+=","+i);s&&(a+=(i?"":",null")+","+s);return a+")"}(e,t);var n;if(e.component)n=function(e,t,n){var r=t.inlineTemplate?null:Ys(t,n,!0);return"_c("+e+","+Vs(t,n)+(r?","+r:"")+")"}(e.component,e,t);else{var r;(!e.plain||e.pre&&t.maybeComponent(e))&&(r=Vs(e,t));var a=e.inlineTemplate?null:Ys(e,t,!0);n="_c('"+e.tag+"'"+(r?","+r:"")+(a?","+a:"")+")"}for(var i=0;i>>0}(s):"")+")"}(e,e.scopedSlots,t)+","),e.model&&(n+="model:{value:"+e.model.value+",callback:"+e.model.callback+",expression:"+e.model.expression+"},"),e.inlineTemplate){var i=function(e,t){var n=e.children[0];0;if(n&&1===n.type){var r=Is(n,t.options);return"inlineTemplate:{render:function(){"+r.render+"},staticRenderFns:["+r.staticRenderFns.map((function(e){return"function(){"+e+"}"})).join(",")+"]}"}}(e,t);i&&(n+=i+",")}return n=n.replace(/,$/,"")+"}",e.dynamicAttrs&&(n="_b("+n+',"'+e.tag+'",'+Us(e.dynamicAttrs)+")"),e.wrapData&&(n=e.wrapData(n)),e.wrapListeners&&(n=e.wrapListeners(n)),n}function Fs(e){return 1===e.type&&("slot"===e.tag||e.children.some(Fs))}function qs(e,t){var n=e.attrsMap["slot-scope"];if(e.if&&!e.ifProcessed&&!n)return Ds(e,t,qs,"null");if(e.for&&!e.forProcessed)return js(e,t,qs);var r="_empty_"===e.slotScope?"":String(e.slotScope),a="function("+r+"){return "+("template"===e.tag?e.if&&n?"("+e.if+")?"+(Ys(e,t)||"undefined")+":undefined":Ys(e,t)||"undefined":Hs(e,t))+"}",i=r?"":",proxy:true";return"{key:"+(e.slotTarget||'"default"')+",fn:"+a+i+"}"}function Ys(e,t,n,r,a){var i=e.children;if(i.length){var s=i[0];if(1===i.length&&s.for&&"template"!==s.tag&&"slot"!==s.tag){var o=n?t.maybeComponent(s)?",1":",0":"";return""+(r||Hs)(s,t)+o}var l=n?function(e,t){for(var n=0,r=0;r':'
',Ws.innerHTML.indexOf(" ")>0}var no=!!K&&to(!1),ro=!!K&&to(!0),ao=x((function(e){var t=tr(e);return t&&t.innerHTML})),io=Mn.prototype.$mount;Mn.prototype.$mount=function(e,t){if((e=e&&tr(e))===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=ao(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=function(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}(e));if(r){0;var a=eo(r,{outputSourceRange:!1,shouldDecodeNewlines:no,shouldDecodeNewlinesForHref:ro,delimiters:n.delimiters,comments:n.comments},this),i=a.render,s=a.staticRenderFns;n.render=i,n.staticRenderFns=s}}return io.call(this,e,t)},Mn.compile=eo,t.default=Mn}).call(this,n(0),n(10).setImmediate)},function(e,t,n){"use strict";(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(11),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||void 0,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||void 0}).call(this,n(0))},function(e,t,n){"use strict";(function(e,t){!function(e,n){if(!e.setImmediate){var r,a,i,s,o,l=1,c={},f=!1,u=e.document,_=Object.getPrototypeOf&&Object.getPrototypeOf(e);_=_&&_.setTimeout?_:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){h(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){h(e.data)},r=function(e){i.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(a=u.documentElement,r=function(e){var t=u.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):r=function(e){setTimeout(h,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&h(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),r=function(t){e.postMessage(s+t,"*")}),_.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n1)for(var n=1;n1?c=Math.floor(c/u):(u=1,n=t),c+=o.length;var _=new Int16Array(c),p=0;for(f=0;f0){var x=2*(_.length-S);o=new Int16Array(_.buffer.slice(x)),_=new Int16Array(_.buffer.slice(0,x))}return{index:i,offset:s,frameNext:o,sampleRate:n,data:_}},n.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)))))};var o=function(t,n){var r=new Date,a=("0"+r.getMinutes()).substr(-2)+":"+("0"+r.getSeconds()).substr(-2)+"."+("00"+r.getMilliseconds()).substr(-3),i=this&&this.envIn&&this.envCheck&&this.id,s=["["+a+" Recorder"+(i?":"+i:"")+"]"+t],o=arguments,c=e.console||{},f=2,u=c.log;for("number"==typeof n?u=1==n?c.error:3==n?c.warn:u:f=1;f1?s:""):u.apply(c,s)},l=!0;try{l=!console.log.apply}catch(e){}n.CLog=o;var c=0;function f(e){this.id=++c,n.Traffic&&n.Traffic();var r={type:"mp3",bitRate:16,sampleRate:16e3,onProcess:t};for(var a in e)r[a]=e[a];this.set=r,this._S=9,this.Sync={O:9,C:9}}n.Sync={O:9,C:9},n.prototype=f.prototype={CLog:o,_streamStore:function(){return this.set.sourceStream?this:n},open:function(r,i){var o=this,l=o._streamStore();r=r||t;var c=function(e,t){t=!!t,o.CLog("录音open失败:"+e+",isUserNotAllow:"+t,1),i&&i(e,t)},f=function(){o.CLog("open ok id:"+o.id),r(),o._SO=0},u=l.Sync,_=++u.O,p=u.C;o._O=o._O_=_,o._SO=o._S;var h=function(){if(p!=u.C||!o._O){var e="open被取消";return _==u.O?o.close():e="open被中断",c(e),!0}},d=o.envCheck({envName:"H5",canProcess:!0});if(d)c("不能录音:"+d);else if(o.set.sourceStream){if(!n.Support())return void c("不支持此浏览器从流中获取录音");s(l),o.Stream=o.set.sourceStream,o.Stream._call={};try{a(l)}catch(e){return void c("从流中打开录音失败:"+e.message)}f()}else{var v=function(t,n){try{e.top.a}catch(e){return void c('无权录音(跨域,请尝试给iframe添加麦克风访问策略,如allow="camera;microphone")')}/Permission|Allow/i.test(t)?c("用户拒绝了录音权限",!0):!1===e.isSecureContext?c("无权录音(需https)"):/Found/i.test(t)?c(n+",无可用麦克风"):c(n)};if(n.IsOpen())f();else if(n.Support()){var m=function(e){n.Stream=e,e._call={},h()||setTimeout((function(){h()||(n.IsOpen()?(a(),f()):c("录音功能无效:无音频流"))}),100)},b=function(e){var t=e.name||e.message||e.code+":"+e;o.CLog("请求录音权限错误",1,e),v(t,"无法录音:"+t)},g=n.Scope.getUserMedia({audio:o.set.audioTrackSet||!0},m,b);g&&g.then&&g.then(m)[r&&"catch"](b)}else v("","此浏览器不支持录音")}},close:function(e){e=e||t;var n=this._streamStore();this._stop();var r=n.Sync;if(this._O=0,this._O_!=r.O)return this.CLog("close被忽略(因为同时open了多个rec,只有最后一个会真正close)",3),void e();r.C++,s(n),this.CLog("close"),e()},mock:function(e,t){return this._stop(),this.isMock=1,this.mockEnvInfo=null,this.buffers=[e],this.recSize=e.length,this.srcSampleRate=t,this},envCheck:function(e){var t,n=this.set;return t||(this[n.type+"_envCheck"]?t=this[n.type+"_envCheck"](e,n):n.takeoffEncodeChunk&&(t=n.type+"类型不支持设置takeoffEncodeChunk")),t||""},envStart:function(e,t){var n=this.set;if(this.isMock=e?1:0,this.mockEnvInfo=e,this.buffers=[],this.recSize=0,this.envInLast=0,this.envInFirst=0,this.envInFix=0,this.envInFixTs=[],n.sampleRate=Math.min(t,n.sampleRate),this.srcSampleRate=t,this.engineCtx=0,this[n.type+"_start"]){var r=this.engineCtx=this[n.type+"_start"](n);r&&(r.pcmDatas=[],r.pcmSize=0)}},envResume:function(){this.envInFixTs=[]},envIn:function(e,t){var r=this,a=r.set,i=r.engineCtx,s=r.srcSampleRate,o=e.length,l=n.PowerLevel(t,o),c=r.buffers,f=c.length;c.push(e);var u=c,_=f,p=Date.now(),h=Math.round(o/s*1e3);r.envInLast=p,1==r.buffers.length&&(r.envInFirst=p-h);var d=r.envInFixTs;d.splice(0,0,{t:p,d:h});for(var v=p,m=0,b=0;b3e3){d.length=b;break}v=g.t,m+=g.d}var y=d[1],w=p-v;if(w-m>w/3&&(y&&w>1e3||d.length>=6)){var S=p-y.t-h;if(S>h/5){var x=!a.disableEnvInFix;if(r.CLog("["+p+"]"+(x?"":"未")+"补偿"+S+"ms",3),r.envInFix+=S,x){var k=new Int16Array(S*s/1e3);o+=k.length,c.push(k)}}}var A=r.recSize,M=o,R=A+M;if(r.recSize=R,i){var T=n.SampleData(c,s,a.sampleRate,i.chunkInfo);i.chunkInfo=T,R=(A=i.pcmSize)+(M=T.data.length),i.pcmSize=R,c=i.pcmDatas,f=c.length,c.push(T.data),s=T.sampleRate}var B=Math.round(R/s*1e3),E=c.length,C=u.length,P=function(){for(var e=O?0:-M,t=null==c[0],n=f;n"+v.length+" 花:"+(Date.now()-a)+"ms"),setTimeout((function(){a=Date.now(),i[s.type](v,(function(e){c(e,h)}),(function(e){l(e)}))}))}else l("未加载"+s.type+"编码器");else l("音频buffers被释放");else l("未采集到录音")}},e.Recorder&&e.Recorder.Destroy(),e.Recorder=n,n.LM="2022-03-05 11:53:19",n.TrafficImgUrl="//ia.51.la/go1?id=20469973&pvFlag=1",n.Traffic=function(){var e=n.TrafficImgUrl;if(e){var t=n.Traffic,r=location.href.replace(/#.*/,"");0==e.indexOf("//")&&(e=/^https:/i.test(r)?"https:"+e:"http:"+e),t[r]||(t[r]=1,(new Image).src=e,o("Traffic Analysis Image: Recorder.TrafficImgUrl="+n.TrafficImgUrl))}}}(window),void 0===(r=function(){return Recorder}.call(t,n,t,e))||(e.exports=r),"object"==a(e)&&e.exports&&(e.exports=Recorder)}).call(this,n(2)(e))},function(e,t,n){"use strict";var r,a;r=function(e){return new a(e)},(a=function(e){var t={scale:2,speed:8,lineWidth:3,linear1:[0,"rgba(150,96,238,1)",.2,"rgba(170,79,249,1)",1,"rgba(53,199,253,1)"],linear2:[0,"rgba(209,130,255,0.6)",1,"rgba(53,199,255,0.6)"],linearBg:[0,"rgba(255,255,255,0.2)",1,"rgba(54,197,252,0.2)"]};for(var n in e)t[n]=e[n];this.set=e=t;var r=e.elem;r&&("string"==typeof r?r=document.querySelector(r):r.length&&(r=r[0])),r&&(e.width=r.offsetWidth,e.height=r.offsetHeight);var a=e.scale,i=e.width*a,s=e.height*a,o=this.elem=document.createElement("div"),l=["","transform-origin:0 0;","transform:scale("+1/a+");"];o.innerHTML='
';var c=this.canvas=o.querySelector("canvas"),f=this.ctx=c.getContext("2d");c.width=i,c.height=s,this.linear1=this.genLinear(f,i,e.linear1),this.linear2=this.genLinear(f,i,e.linear2),this.linearBg=this.genLinear(f,s,e.linearBg,!0),r&&(r.innerHTML="",r.appendChild(o)),this._phase=0}).prototype=r.prototype={genLinear:function(e,t,n,r){for(var a=e.createLinearGradient(0,0,r?0:t,r?t:0),i=0;i=0;p--,h-=i)a.lineTo(h,_[p]);a.closePath(),a.fillStyle=this.linearBg,a.fill(),this.drawPath(_,this.linear2),this.drawPath(u,this.linear1)},drawPath:function(e,t){var n=this.set,r=this.ctx,a=n.scale,i=n.width*a;r.beginPath();for(var s=0,o=0;o\n \n\n \n\n '}),o=s.$refs.mainView;o.reclog('RecordApp[即将废弃] 除Recorder支持的外,支持Hybrid App,低版本IOS上支持微信网页和小程序web-view'+unescape("%uD83C%uDF89")+""),o.reclog('Recorder H5使用简单,功能丰富,支持PC、Android、IOS 14.3+'+unescape("%uD83D%uDCAA")+""),o.reclog('绿油油的一大片,真有食欲'+unescape("%uD83D%uDE02")+' 当前浏览器支持录音':'red">不支持录音')+"");var l=function(e,t){o.reclog(''+e+": "+t+"")};l("本页面修改时间(有可能修改了忘改)","2022-03-03 21:52:39"),l("Recorder库修改时间(有可能修改了忘改)",o.Rec.LM),l("UA",navigator.userAgent),l("URL",location.href.replace(/#.*/g,"")),l("Vue",r.default.version),o.reclog("点击打开录音,然后再点击开始录音",2),window.vue_root=s,window.vue_main=o,console.log("Vue",r.default),console.log("Recorder",o.Rec)},function(e,t,n){"use strict";n.r(t);var r=n(17),a=n(3);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);n(23);var s=n(1),o=Object(s.a)(a.default,r.a,r.b,!1,null,null,null);o.options.__file="component/recorder.vue",t.default=o.exports},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(){var e;Recorder.prototype.enc_mp3={stable:!0,testmsg:"采样率范围48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000"},Recorder.prototype.mp3=function(e,t,n){var r=this.set,s=e.length,o=this.mp3_start(r);if(o)return this.mp3_encode(o,e),void this.mp3_complete(o,t,n,1);var l=new Recorder.lamejs.Mp3Encoder(1,r.sampleRate,r.bitRate),c=[],f=0,u=0;!function n(){if(f0&&(u+=o.buffer.byteLength,c.push(o.buffer)),f+=57600,setTimeout(n)}else{var o;(o=l.flush()).length>0&&(u+=o.buffer.byteLength,c.push(o.buffer));var _=a.fn(c,u,s,r.sampleRate);i(_,r),t(new Blob(c,{type:"audio/mp3"}))}}()},Recorder.BindDestroy("mp3Worker",(function(){console.log("mp3Worker Destroy"),e&&e.terminate(),e=null})),Recorder.prototype.mp3_envCheck=function(e,t){var r="";return t.takeoffEncodeChunk&&(e.canProcess?n()||(r="当前浏览器版本太低,无法实时处理"):r=e.envName+"环境不支持实时处理"),r},Recorder.prototype.mp3_start=function(e){return n(e)};var t={id:0},n=function(n){var r=e;try{if(!r){var i=");wk_lame();var wk_ctxs={};self.onmessage="+function(e){var t=e.data,n=wk_ctxs[t.id];if("init"==t.action)wk_ctxs[t.id]={sampleRate:t.sampleRate,bitRate:t.bitRate,takeoff:t.takeoff,mp3Size:0,pcmSize:0,encArr:[],encObj:new wk_lame.Mp3Encoder(1,t.sampleRate,t.bitRate)};else if(!n)return;switch(t.action){case"stop":n.encObj=null,delete wk_ctxs[t.id];break;case"encode":n.pcmSize+=t.pcm.length,(r=n.encObj.encodeBuffer(t.pcm)).length>0&&(n.takeoff?self.postMessage({action:"takeoff",id:t.id,chunk:r}):(n.mp3Size+=r.buffer.byteLength,n.encArr.push(r.buffer)));break;case"complete":var r;(r=n.encObj.flush()).length>0&&(n.takeoff?self.postMessage({action:"takeoff",id:t.id,chunk:r}):(n.mp3Size+=r.buffer.byteLength,n.encArr.push(r.buffer)));var a=wk_mp3TrimFix.fn(n.encArr,n.mp3Size,n.pcmSize,n.sampleRate);self.postMessage({action:t.action,id:t.id,blob:new Blob(n.encArr,{type:"audio/mp3"}),meta:a})}};i+=";var wk_mp3TrimFix={rm:"+a.rm+",fn:"+a.fn+"}";var s=Recorder.lamejs.toString(),o=(window.URL||webkitURL).createObjectURL(new Blob(["var wk_lame=(",s,i],{type:"text/javascript"}));r=new Worker(o),setTimeout((function(){(window.URL||webkitURL).revokeObjectURL(o)}),1e4),r.onmessage=function(e){var n=e.data,r=t[n.id];r&&("takeoff"==n.action?r.set.takeoffEncodeChunk(new Uint8Array(n.chunk.buffer)):(r.call&&r.call(n),r.call=null))}}var l={worker:r,set:n,takeoffQueue:[]};return n?(l.id=++t.id,t[l.id]=l,r.postMessage({action:"init",id:l.id,sampleRate:n.sampleRate,bitRate:n.bitRate,takeoff:!!n.takeoffEncodeChunk,x:new Int16Array(5)})):r.postMessage({x:new Int16Array(5)}),e=r,l}catch(e){return r&&r.terminate(),console.error(e),null}};Recorder.prototype.mp3_stop=function(e){if(e&&e.worker){e.worker.postMessage({action:"stop",id:e.id}),e.worker=null,delete t[e.id];var n=-1;for(var r in t)n++;n&&console.warn("mp3 worker剩"+n+"个在串行等待")}},Recorder.prototype.mp3_encode=function(e,t){e&&e.worker&&e.worker.postMessage({action:"encode",id:e.id,pcm:t})},Recorder.prototype.mp3_complete=function(e,t,n,r){var a=this;e&&e.worker?(e.call=function(n){i(n.meta,e.set),t(n.blob),r&&a.mp3_stop(e)},e.worker.postMessage({action:"complete",id:e.id})):n("mp3编码器未打开")},Recorder.mp3ReadMeta=function(e,t){var n="object"==("undefined"==typeof window?"undefined":r(window))?window.parseInt:self.parseInt,a=new Uint8Array(e[0]||[]);if(a.length<4)return null;var i=function(e,t){return("0000000"+((t||a)[e]||0).toString(2)).substr(-8)},s=i(0)+i(1),o=i(2)+i(3);if(!/^1{11}/.test(s))return null;var l={"00":2.5,10:2,11:1}[s.substr(11,2)],c={"01":3}[s.substr(13,2)],f={1:[44100,48e3,32e3],2:[22050,24e3,16e3],2.5:[11025,12e3,8e3]}[l];f&&(f=f[n(o.substr(4,2),2)]);var u=[[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160],[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320]][1==l?1:0][n(o.substr(0,4),2)];if(!(l&&c&&u&&f))return null;for(var _=Math.round(8*t/u),p=1==c?384:2==c||1==l?1152:576,h=p/f*1e3,d=Math.floor(p*u/8/f*1e3),v=0,m=0,b=0;b=d+3){var y=new Uint8Array(g);v="1"==i(g.byteLength-(m-(d+3)+1),y).charAt(6);break}}return v&&d++,{version:l,layer:c,sampleRate:f,bitRate:u,duration:_,size:t,hasPadding:v,frameSize:d,frameDurationFloat:h}};var a={rm:Recorder.mp3ReadMeta,fn:function(e,t,n,r){var a=this.rm(e,t);if(!a)return{err:"mp3非预定格式"};var i=Math.round(n/r*1e3),s=Math.floor((a.duration-i)/a.frameDurationFloat);if(s>0){var o=s*a.frameSize-(a.hasPadding?1:0);t-=o;for(var l=0,c=[],f=0;f=u.byteLength?(o-=u.byteLength,c.push(u),e.splice(f,1),f--):(e[f]=u.slice(o),l=u,o=0)}if(!this.rm(e,t)){l&&(e[0]=l);for(f=0;f "+r.duration+"ms",r.remove>2&&(e.err=(e.err?e.err+", ":"")+"移除帧数过多")):n+=(e.duration||"-")+"ms",e.err?console.error(n,e.err,e):console.log(n,e)}}()},function(e,t,n){"use strict";!function(){function e(){var t=function(e){return Math.log(e)/Math.log(10)};function n(e){return new Int8Array(e)}function r(e){return new Int16Array(e)}function a(e){return new Int32Array(e)}function i(e){return new Float32Array(e)}function s(e){return new Float64Array(e)}function o(e){if(1==e.length)return i(e[0]);var t=e[0];e=e.slice(1);for(var n=[],r=0;r>=1;0!=e--;)a[i++]=s>n[r++]?0:1,a[i++]=s>n[r++]?0:1}function i(t,n,r,a,i,s){var o=(t>>=1)%2;for(t>>=1;0!=t--;){var l,c,f,u,_,p,h,d;l=r[a++]*n,c=r[a++]*n,_=0|l,f=r[a++]*n,p=0|c,u=r[a++]*n,h=0|f,l+=e.adj43[_],d=0|u,c+=e.adj43[p],i[s++]=0|l,f+=e.adj43[h],i[s++]=0|c,u+=e.adj43[d],i[s++]=0|f,i[s++]=0|u}0!=o&&(_=0|(l=r[a++]*n),p=0|(c=r[a++]*n),l+=e.adj43[_],c+=e.adj43[p],i[s++]=0|l,i[s++]=0|c)}var s=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function o(e,t,n,r){var a=function(e,t,n){var r=0,a=0;do{var i=e[t++],s=e[t++];r>=16)>i&&(o=i,r++),a.bits+=o,r}(e,t,n,s[a-1],r);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return function(e,t,n,r,a){var i=0,s=0,o=0,l=M.ht[r].xlen,c=M.ht[r].hlen,f=M.ht[r+1].hlen,u=M.ht[r+2].hlen;do{var _=e[t+0]*l+e[t+1];t+=2,i+=c[_],s+=f[_],o+=u[_]}while(ts&&(i=s,p++),i>o&&(i=o,p=r+2),a.bits+=i,p}(e,t,n,s[a-1],r);default:if(a>I.IXMAX_VAL)return r.bits=I.LARGE_BITS,-1;var i,o;for(a-=15,i=24;i<32&&!(M.ht[i].linmax>=a);i++);for(o=i-8;o<24&&!(M.ht[o].linmax>=a);o++);return function(e,t,n,r,a,i){var s,o=65536*M.ht[r].xlen+M.ht[a].xlen,l=0;do{var c=e[t++],f=e[t++];0!=c&&(c>14&&(c=15,l+=o),c*=16),0!=f&&(f>14&&(f=15,l+=o),c+=f),l+=M.largetbl[c]}while(t>=16)>s&&(l=s,r=a),i.bits+=l,r}(e,t,n,o,i,r)}}function l(e,n,r,a,i,s,l,c){for(var f=n.big_values,u=2;u=f)break;var p=i[u-2]+n.count1bits;if(r.part2_3_length<=p)break;var h=new t(p),d=o(a,_,f,h);p=h.bits,r.part2_3_length<=p||(r.assign(n),r.part2_3_length=p,r.region0_count=s[u-2],r.region1_count=u-2-s[u-2],r.table_select[0]=l[u-2],r.table_select[1]=c[u-2],r.table_select[2]=d)}}this.noquant_count_bits=function(e,n,r){var a=n.l3_enc,i=Math.min(576,n.max_nonzero_coeff+2>>1<<1);for(null!=r&&(r.sfb_count1=0);i>1&&0==(a[i-1]|a[i-2]);i-=2);n.count1=i;for(var s=0,l=0;i>3;i-=4){var c;if((2147483647&(a[i-1]|a[i-2]|a[i-3]|a[i-4]))>1)break;c=2*(2*(2*a[i-4]+a[i-3])+a[i-2])+a[i-1],s+=M.t32l[c],l+=M.t33l[c]}var f=s;if(n.count1table_select=0,s>l&&(f=l,n.count1table_select=1),n.count1bits=f,n.big_values=i,0==i)return f;if(n.block_type==F.SHORT_TYPE)(s=3*e.scalefac_band.s[3])>n.big_values&&(s=n.big_values),l=n.big_values;else if(n.block_type==F.NORM_TYPE){if(s=n.region0_count=e.bv_scf[i-2],l=n.region1_count=e.bv_scf[i-1],l=e.scalefac_band.l[s+l+2],s=e.scalefac_band.l[s+1],l(l=i)&&(s=l);if(s=Math.min(s,i),l=Math.min(l,i),0l)return I.LARGE_BITS;if(function(t,n,a,s,o){var l,c,f,_=0,p=0,h=0,d=0,v=n,m=0,b=v,g=0,y=t,w=0;for(f=null!=o&&s.global_gain==o.global_gain,c=s.block_type==F.SHORT_TYPE?38:21,l=0;l<=c;l++){var S=-1;if((f||s.block_type==F.NORM_TYPE)&&(S=s.global_gain-(s.scalefac[l]+(0!=s.preflag?e.pretab[l]:0)<s.max_nonzero_coeff)x=s.max_nonzero_coeff-_+1,u.fill(n,s.max_nonzero_coeff,576,0),(k=x)<0&&(k=0),l=c+1;if(0==p&&0==h&&(b=v,g=m,y=t,w=d),null!=o&&o.sfb_count1>0&&l>=o.sfb_count1&&o.step[l]>0&&S>=o.step[l]?(0!=p&&(i(p,a,y,w,b,g),p=0,b=v,g=m,y=t,w=d),h+=k):(0!=h&&(r(h,a,y,w,b,g),h=0,b=v,g=m,y=t,w=d),p+=k),k<=0){0!=h&&(r(h,a,y,w,b,g),h=0),0!=p&&(i(p,a,y,w,b,g),p=0);break}}l<=c&&(m+=s.width[l],d+=s.width[l],_+=s.width[l])}0!=p&&(i(p,a,y,w,b,g),p=0),0!=h&&(r(h,a,y,w,b,g),h=0)}(n,o,e.IPOW20(a.global_gain),a,s),0!=(2&t.substep_shaping))for(var c=0,f=a.global_gain+a.scalefac_scale,_=.634521682242439/e.IPOW20(f),p=0;p=_?o[h]:0}return this.noquant_count_bits(t,a,s)},this.best_huffman_divide=function(e,n){var r=new N,i=n.l3_enc,s=a(23),c=a(23),f=a(23),u=a(23);if(n.block_type!=F.SHORT_TYPE||1!=e.mode_gr){r.assign(n),n.block_type==F.NORM_TYPE&&(!function(e,n,r,a,i,s,l){for(var c=n.big_values,f=0;f<=22;f++)a[f]=I.LARGE_BITS;for(f=0;f<16;f++){var u=e.scalefac_band.l[f+1];if(u>=c)break;var _=0,p=new t(_),h=o(r,0,u,p);_=p.bits;for(var d=0;d<8;d++){var v=e.scalefac_band.l[f+d+2];if(v>=c)break;var m=_,b=o(r,u,v,p=new t(m));m=p.bits,a[f+d]>m&&(a[f+d]=m,i[f+d]=f,s[f+d]=h,l[f+d]=b)}}}(e,n,i,s,c,f,u),l(e,r,n,i,s,c,f,u));var _=r.big_values;if(!(0==_||(i[_-2]|i[_-1])>1||(_=n.count1+2)>576)){r.assign(n),r.count1=_;for(var p=0,h=0;_>r.big_values;_-=4){var d=2*(2*(2*i[_-4]+i[_-3])+i[_-2])+i[_-1];p+=M.t32l[d],h+=M.t33l[d]}if(r.big_values=_,r.count1table_select=0,p>h&&(p=h,r.count1table_select=1),r.count1bits=p,r.block_type==F.NORM_TYPE)l(e,r,n,i,s,c,f,u);else{if(r.part2_3_length=p,(p=e.scalefac_band.l[8])>_&&(p=_),p>0){var v=new t(r.part2_3_length);r.table_select[0]=o(i,0,p,v),r.part2_3_length=v.bits}if(_>p){v=new t(r.part2_3_length);r.table_select[1]=o(i,p,_,v),r.part2_3_length=v.bits}n.part2_3_length>r.part2_3_length&&n.assign(r)}}}};var c=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],f=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],p=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],h=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];g.slen1_tab=p,g.slen2_tab=h,this.best_scalefac_store=function(t,n,r,a){var i,s,o,l,u=a.tt[n][r],_=0;for(o=0,i=0;i0&&(v|=u.scalefac[i]);if(0==(1&v)&&0!=v){for(i=0;i0&&(u.scalefac[i]>>=1);u.scalefac_scale=_=1}}if(0==u.preflag&&u.block_type!=F.SHORT_TYPE&&2==t.mode_gr){for(i=11;i0&&(u.scalefac[i]-=e.pretab[i]);u.preflag=_=1}}for(s=0;s<4;s++)a.scfsi[r][s]=0;for(2==t.mode_gr&&1==n&&a.tt[0][r].block_type!=F.SHORT_TYPE&&a.tt[1][r].block_type!=F.SHORT_TYPE&&(!function(e,t){for(var n,r=t.tt[1][e],a=t.tt[0][e],i=0;i=0);n++);if(n==M.scfsi_band[i+1]){for(n=M.scfsi_band[i];n_&&(r.part2_length=_,r.scalefac_compress=i)}}(r,a),_=0),i=0;ia[n]&&(t.part2_length=a[n],t.scalefac_compress=n);return t.part2_length==I.LARGE_BITS};var b=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(t,n){var r,i,s,o,l,c,f,u,p=a(4),h=n.scalefac;for(r=0!=n.preflag?2:0,f=0;f<4;f++)p[f]=0;if(n.block_type==F.SHORT_TYPE){i=1;var d=e.nr_of_sfb_block[r][i];for(u=0,s=0;s<4;s++)for(o=d[s]/3,f=0;fp[s]&&(p[s]=h[3*u+l])}else{i=0;d=e.nr_of_sfb_block[r][i];for(u=0,s=0;s<4;s++)for(o=d[s],f=0;fp[s]&&(p[s]=h[u])}for(c=!1,s=0;s<4;s++)p[s]>b[r][s]&&(c=!0);if(!c){var v,m,g,w;for(n.sfb_partition_table=e.nr_of_sfb_block[r][i],s=0;s<4;s++)n.slen[s]=y[p[s]];switch(v=n.slen[0],m=n.slen[1],g=n.slen[2],w=n.slen[3],r){case 0:n.scalefac_compress=(5*v+m<<4)+(g<<2)+w;break;case 1:n.scalefac_compress=400+(5*v+m<<2)+g;break;case 2:n.scalefac_compress=500+3*v+m;break;default:_.err.printf("intensity stereo not implemented yet\n")}}if(!c)for(n.part2_length=0,s=0;s<4;s++)n.part2_length+=n.slen[s]*n.sfb_partition_table[s];return c};var y=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(e){for(var t=2;t<=576;t+=2){for(var r,a=0;e.scalefac_band.l[++a]t;)r--;for(r<0&&(r=n[a][0]),e.bv_scf[t-2]=r,r=n[a][1];e.scalefac_band.l[r+e.bv_scf[t-2]+2]>t;)r--;r<0&&(r=n[a][1]),e.bv_scf[t-1]=r}}}function y(){}function w(){function e(e,t,n,r,a,i,s,o,l,c,f,u,_,p,h){this.vbr_q=e,this.quant_comp=t,this.quant_comp_s=n,this.expY=r,this.st_lrm=a,this.st_s=i,this.masking_adj=s,this.masking_adj_short=o,this.ath_lower=l,this.ath_curve=c,this.ath_sensitivity=f,this.interch=u,this.safejoint=_,this.sfb21mod=p,this.msfix=h}function t(e,t,n,r,a,i,s,o,l,c,f,u,_,p){this.quant_comp=t,this.quant_comp_s=n,this.safejoint=r,this.nsmsfix=a,this.st_lrm=i,this.st_s=s,this.nsbass=o,this.scale=l,this.masking_adj=c,this.ath_lower=f,this.ath_curve=u,this.interch=_,this.sfscale=p}var n;this.setModules=function(e){n=e};var r=[new e(0,9,9,0,5.2,125,-4.2,-6.3,4.8,1,0,0,2,21,.97),new e(1,9,9,0,5.3,125,-3.6,-5.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,5.6,125,-2.2,-3.5,2.8,2,0,0,2,21,1.49),new e(3,9,9,1,5.8,130,-1.8,-2.8,2.6,3,-4,0,2,20,1.64),new e(4,9,9,1,6,135,-.7,-1.1,1.1,3.5,-8,0,2,0,1.79),new e(5,9,9,1,6.4,140,.5,.4,-7.5,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,6.6,145,.67,.65,-14.7,6.5,-19,4e-4,0,0,2.3),new e(7,9,9,1,6.6,145,.8,.75,-19.7,8,-22,6e-4,0,0,2.7),new e(8,9,9,1,6.6,145,1.2,1.15,-27.5,10,-23,7e-4,0,0,0),new e(9,9,9,1,6.6,145,1.6,1.6,-36,11,-25,8e-4,0,0,0),new e(10,9,9,1,6.6,145,2,2,-36,12,-25,8e-4,0,0,0)],a=[new e(0,9,9,0,4.2,25,-7,-4,7.5,1,0,0,2,26,.97),new e(1,9,9,0,4.2,25,-5.6,-3.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,4.2,25,-4.4,-1.8,2,2,0,0,2,18,1.49),new e(3,9,9,1,4.2,25,-3.4,-1.25,1.1,3,-4,0,2,15,1.64),new e(4,9,9,1,4.2,25,-2.2,.1,0,3.5,-8,0,2,0,1.79),new e(5,9,9,1,4.2,25,-1,1.65,-7.7,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,4.2,25,-0,2.47,-7.7,6.5,-19,4e-4,0,0,2),new e(7,9,9,1,4.2,25,.5,2,-14.5,8,-22,6e-4,0,0,2),new e(8,9,9,1,4.2,25,1,2.4,-22,10,-23,7e-4,0,0,2),new e(9,9,9,1,4.2,25,1.5,2.95,-30,11,-25,8e-4,0,0,2),new e(10,9,9,1,4.2,25,2,2.95,-36,12,-30,8e-4,0,0,2)];function i(e,t,n){var i=e.VBR==v.vbr_rh?r:a,s=e.VBR_q_frac,o=i[t],l=i[t+1],c=o;o.st_lrm=o.st_lrm+s*(l.st_lrm-o.st_lrm),o.st_s=o.st_s+s*(l.st_s-o.st_s),o.masking_adj=o.masking_adj+s*(l.masking_adj-o.masking_adj),o.masking_adj_short=o.masking_adj_short+s*(l.masking_adj_short-o.masking_adj_short),o.ath_lower=o.ath_lower+s*(l.ath_lower-o.ath_lower),o.ath_curve=o.ath_curve+s*(l.ath_curve-o.ath_curve),o.ath_sensitivity=o.ath_sensitivity+s*(l.ath_sensitivity-o.ath_sensitivity),o.interch=o.interch+s*(l.interch-o.interch),o.msfix=o.msfix+s*(l.msfix-o.msfix),function(e,t){var n=0;0>t&&(n=-1,t=0);90||(e.quant_comp=c.quant_comp),0!=n?e.quant_comp_short=c.quant_comp_s:Math.abs(e.quant_comp_short- -1)>0||(e.quant_comp_short=c.quant_comp_s),0!=c.expY&&(e.experimentalY=0!=c.expY),0!=n?e.internal_flags.nsPsy.attackthre=c.st_lrm:Math.abs(e.internal_flags.nsPsy.attackthre- -1)>0||(e.internal_flags.nsPsy.attackthre=c.st_lrm),0!=n?e.internal_flags.nsPsy.attackthre_s=c.st_s:Math.abs(e.internal_flags.nsPsy.attackthre_s- -1)>0||(e.internal_flags.nsPsy.attackthre_s=c.st_s),0!=n?e.maskingadjust=c.masking_adj:Math.abs(e.maskingadjust-0)>0||(e.maskingadjust=c.masking_adj),0!=n?e.maskingadjust_short=c.masking_adj_short:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=c.masking_adj_short),0!=n?e.ATHlower=-c.ath_lower/10:Math.abs(10*-e.ATHlower-0)>0||(e.ATHlower=-c.ath_lower/10),0!=n?e.ATHcurve=c.ath_curve:Math.abs(e.ATHcurve- -1)>0||(e.ATHcurve=c.ath_curve),0!=n?e.athaa_sensitivity=c.ath_sensitivity:Math.abs(e.athaa_sensitivity- -1)>0||(e.athaa_sensitivity=c.ath_sensitivity),c.interch>0&&(0!=n?e.interChRatio=c.interch:Math.abs(e.interChRatio- -1)>0||(e.interChRatio=c.interch)),c.safejoint>0&&(e.exp_nspsytune=e.exp_nspsytune|c.safejoint),c.sfb21mod>0&&(e.exp_nspsytune=e.exp_nspsytune|c.sfb21mod<<20),0!=n?e.msfix=c.msfix:Math.abs(e.msfix- -1)>0||(e.msfix=c.msfix),0==n&&(e.VBR_q=t,e.VBR_q_frac=s)}var s=[new t(8,9,9,0,0,6.6,145,0,.95,0,-30,11,.0012,1),new t(16,9,9,0,0,6.6,145,0,.95,0,-25,11,.001,1),new t(24,9,9,0,0,6.6,145,0,.95,0,-20,11,.001,1),new t(32,9,9,0,0,6.6,145,0,.95,0,-15,11,.001,1),new t(40,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new t(48,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new t(56,9,9,0,0,6.6,145,0,.95,0,-6,11,8e-4,1),new t(64,9,9,0,0,6.6,145,0,.95,0,-2,11,8e-4,1),new t(80,9,9,0,0,6.6,145,0,.95,0,0,8,7e-4,1),new t(96,9,9,0,2.5,6.6,145,0,.95,0,1,5.5,6e-4,1),new t(112,9,9,0,2.25,6.6,145,0,.95,0,2,4.5,5e-4,1),new t(128,9,9,0,1.95,6.4,140,0,.95,0,3,4,2e-4,1),new t(160,9,9,1,1.79,6,135,0,.95,-2,5,3.5,0,1),new t(192,9,9,1,1.49,5.6,125,0,.97,-4,7,3,0,0),new t(224,9,9,1,1.25,5.2,125,0,.98,-6,9,2,0,0),new t(256,9,9,1,.97,5.2,125,0,1,-8,10,1,0,0),new t(320,9,9,1,.9,5.2,125,0,1,-10,12,0,0,0)];function o(e,t,r){var a=t,i=n.nearestBitrateFullIndex(t);if(e.VBR=v.vbr_abr,e.VBR_mean_bitrate_kbps=a,e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,320),e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.brate=e.VBR_mean_bitrate_kbps,e.VBR_mean_bitrate_kbps>320&&(e.disable_reservoir=!0),s[i].safejoint>0&&(e.exp_nspsytune=2|e.exp_nspsytune),s[i].sfscale>0&&(e.internal_flags.noise_shaping=2),Math.abs(s[i].nsbass)>0){var o=int(4*s[i].nsbass);o<0&&(o+=64),e.exp_nspsytune=e.exp_nspsytune|o<<2}return 0!=r?e.quant_comp=s[i].quant_comp:Math.abs(e.quant_comp- -1)>0||(e.quant_comp=s[i].quant_comp),0!=r?e.quant_comp_short=s[i].quant_comp_s:Math.abs(e.quant_comp_short- -1)>0||(e.quant_comp_short=s[i].quant_comp_s),0!=r?e.msfix=s[i].nsmsfix:Math.abs(e.msfix- -1)>0||(e.msfix=s[i].nsmsfix),0!=r?e.internal_flags.nsPsy.attackthre=s[i].st_lrm:Math.abs(e.internal_flags.nsPsy.attackthre- -1)>0||(e.internal_flags.nsPsy.attackthre=s[i].st_lrm),0!=r?e.internal_flags.nsPsy.attackthre_s=s[i].st_s:Math.abs(e.internal_flags.nsPsy.attackthre_s- -1)>0||(e.internal_flags.nsPsy.attackthre_s=s[i].st_s),0!=r?e.scale=s[i].scale:Math.abs(e.scale- -1)>0||(e.scale=s[i].scale),0!=r?e.maskingadjust=s[i].masking_adj:Math.abs(e.maskingadjust-0)>0||(e.maskingadjust=s[i].masking_adj),s[i].masking_adj>0?0!=r?e.maskingadjust_short=.9*s[i].masking_adj:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=.9*s[i].masking_adj):0!=r?e.maskingadjust_short=1.1*s[i].masking_adj:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=1.1*s[i].masking_adj),0!=r?e.ATHlower=-s[i].ath_lower/10:Math.abs(10*-e.ATHlower-0)>0||(e.ATHlower=-s[i].ath_lower/10),0!=r?e.ATHcurve=s[i].ath_curve:Math.abs(e.ATHcurve- -1)>0||(e.ATHcurve=s[i].ath_curve),0!=r?e.interChRatio=s[i].interch:Math.abs(e.interChRatio- -1)>0||(e.interChRatio=s[i].interch),t}this.apply_preset=function(e,t,n){switch(t){case G.R3MIX:t=G.V3,e.VBR=v.vbr_mtrh;break;case G.MEDIUM:t=G.V4,e.VBR=v.vbr_rh;break;case G.MEDIUM_FAST:t=G.V4,e.VBR=v.vbr_mtrh;break;case G.STANDARD:t=G.V2,e.VBR=v.vbr_rh;break;case G.STANDARD_FAST:t=G.V2,e.VBR=v.vbr_mtrh;break;case G.EXTREME:t=G.V0,e.VBR=v.vbr_rh;break;case G.EXTREME_FAST:t=G.V0,e.VBR=v.vbr_mtrh;break;case G.INSANE:return t=320,e.preset=t,o(e,t,n),e.VBR=v.vbr_off,t}switch(e.preset=t,t){case G.V9:return i(e,9,n),t;case G.V8:return i(e,8,n),t;case G.V7:return i(e,7,n),t;case G.V6:return i(e,6,n),t;case G.V5:return i(e,5,n),t;case G.V4:return i(e,4,n),t;case G.V3:return i(e,3,n),t;case G.V2:return i(e,2,n),t;case G.V1:return i(e,1,n),t;case G.V0:return i(e,0,n),t}return 8<=t&&t<=320?o(e,t,n):(e.preset=0,t)}}function S(){var e;this.setModules=function(t){e=t},this.ResvFrameBegin=function(t,n){var r,a=t.internal_flags,i=a.l3_side,s=e.getframebits(t);n.bits=(s-8*a.sideinfo_len)/a.mode_gr;var o=2048*a.mode_gr-8;t.brate>320?r=8*int(1e3*t.brate/(t.out_samplerate/1152)/8+.5):(r=11520,t.strict_ISO&&(r=8*int(32e4/(t.out_samplerate/1152)/8+.5))),a.ResvMax=r-s,a.ResvMax>o&&(a.ResvMax=o),(a.ResvMax<0||t.disable_reservoir)&&(a.ResvMax=0);var l=n.bits*a.mode_gr+Math.min(a.ResvSize,a.ResvMax);return l>r&&(l=r),i.resvDrain_pre=0,null!=a.pinfo&&(a.pinfo.mean_bits=n.bits/2,a.pinfo.resvsize=a.ResvSize),l},this.ResvMaxBits=function(e,t,n,r){var a,i=e.internal_flags,s=i.ResvSize,o=i.ResvMax;0!=r&&(s+=t),0!=(1&i.substep_shaping)&&(o*=.9),n.bits=t,10*s>9*o?(a=s-9*o/10,n.bits+=a,i.substep_shaping|=128):(a=0,i.substep_shaping&=127,e.disable_reservoir||0!=(1&i.substep_shaping)||(n.bits-=.1*t));var l=s<6*i.ResvMax/10?s:6*i.ResvMax/10;return(l-=a)<0&&(l=0),l},this.ResvAdjust=function(e,t){e.ResvSize-=t.part2_3_length+t.part2_length},this.ResvFrameEnd=function(e,t){var n,r=e.l3_side;e.ResvSize+=t*e.mode_gr;var a=0;r.resvDrain_post=0,r.resvDrain_pre=0,0!=(n=e.ResvSize%8)&&(a+=n),(n=e.ResvSize-a-e.ResvMax)>0&&(a+=n);var i=Math.min(8*r.main_data_begin,a)/8;r.resvDrain_pre+=8*i,a-=8*i,e.ResvSize-=8*i,r.main_data_begin-=i,r.resvDrain_post+=a,e.ResvSize-=a}}function x(){this.setModules=function(e,t,n){e,t,n};var e=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];function t(t,n){return n=n>>8^e[255&(n^t)]}this.updateMusicCRC=function(e,n,r,a){for(var i=0;i0;){var r;0==h&&(h=8,p++,e.header[e.w_ptr].write_timing==f&&d(e),c[p]=0),n-=r=Math.min(n,h),h-=r,c[p]|=t>>n<0;){var r;0==h&&(h=8,p++,c[p]=0),n-=r=Math.min(n,h),h-=r,c[p]|=t>>n<=8&&(v(r,76,8),t-=8),t>=8&&(v(r,65,8),t-=8),t>=8&&(v(r,77,8),t-=8),t>=8&&(v(r,69,8),t-=8),t>=32){var a=s.getLameShortVersion();if(t>=32)for(n=0;n=8;++n)t-=8,v(r,a.charCodeAt(n),8)}for(;t>=1;t-=1)v(r,r.ancillary_flag,1),r.ancillary_flag^=e.disable_reservoir?0:1}function w(e,t,n){for(var r=e.header[e.h_ptr].ptr;n>0;){var a=Math.min(n,8-(7&r));n-=a,e.header[e.h_ptr].buf[r>>3]|=t>>n<<8-(7&r)-a,r+=a}e.header[e.h_ptr].ptr=r}function S(e,t){e<<=8;for(var n=0;n<8;n++)0!=(65536&((t<<=1)^(e<<=1)))&&(t^=32773);return t}function x(e,t){var n,r=M.ht[t.count1table_select+32],a=0,i=t.big_values,s=t.big_values;for(n=(t.count1-t.big_values)/4;n>0;--n){var o=0,l=0;0!=t.l3_enc[i+0]&&(l+=8,t.xr[s+0]<0&&o++),0!=t.l3_enc[i+1]&&(l+=4,o*=2,t.xr[s+1]<0&&o++),0!=t.l3_enc[i+2]&&(l+=2,o*=2,t.xr[s+2]<0&&o++),0!=t.l3_enc[i+3]&&(l++,o*=2,t.xr[s+3]<0&&o++),i+=4,s+=4,v(e,o+r.table[l],r.hlen[l]),a+=r.hlen[l]}return a}function k(e,t,n,r,a){var i=M.ht[t],s=0;if(0==t)return s;for(var o=n;o15){if(p>14)_|=p-15<<1,c=f,p=15;if(h>14)_<<=f,_|=h-15,c+=f,h=15;u=16}0!=h&&(_<<=1,a.xr[o+1]<0&&_++,l--),p=p*u+h,c-=l,l+=i.hlen[p],v(e,i.table[p],l),v(e,_,c),s+=l+c}return s}function A(e,t){var n=3*e.scalefac_band.s[3];n>t.big_values&&(n=t.big_values);var r=k(e,t.table_select[0],0,n,t);return r+=k(e,t.table_select[1],n,t.big_values,t)}function R(e,t){var n,r,a,i;n=t.big_values;var s=t.region0_count+1;return a=e.scalefac_band.l[s],s+=t.region1_count+1,a>n&&(a=n),(i=e.scalefac_band.l[s])>n&&(i=n),r=k(e,t.table_select[0],0,a,t),r+=k(e,t.table_select[1],a,i,t),r+=k(e,t.table_select[2],i,n,t)}function T(){this.total=0}function B(t,n){var r,a,i,s,o,l=t.internal_flags;return o=l.w_ptr,-1==(s=l.h_ptr-1)&&(s=U.MAX_HEADER_BUF-1),r=l.header[s].write_timing-f,n.total=r,r>=0&&(a=1+s-o,s>8),t[5]=byte(255&n)},this.flush_bitstream=function(e){var n,a,i=e.internal_flags,s=i.h_ptr-1;if(-1==s&&(s=U.MAX_HEADER_BUF-1),n=i.l3_side,!((a=B(e,new T))<0)){if(b(e,a),i.ResvSize=0,n.main_data_begin=0,i.findReplayGain){var o=r.GetTitleGain(i.rgdata);i.RadioGain=0|Math.floor(10*o+.5)}i.findPeakSample&&(i.noclipGainChange=0|Math.ceil(20*t(i.PeakSample/32767)*10),i.noclipGainChange>0&&(EQ(e.scale,1)||EQ(e.scale,0))?i.noclipScale=Math.floor(32767/i.PeakSample*100)/100:i.noclipScale=-1)}},this.add_dummy_byte=function(e,t,n){for(var r,a=e.internal_flags;n-- >0;)for(m(0,t,8),r=0;r ResvSize"),8*t.main_data_begin!=n.ResvSize&&(_.err.printf("bit reservoir error: \nl3_side.main_data_begin: %d \nResvoir size: %d \nresv drain (post) %d \nresv drain (pre) %d \nheader and sideinfo: %d \ndata bits: %d \ntotal bits: %d (remainder: %d) \nbitsperframe: %d \n",8*t.main_data_begin,n.ResvSize,t.resvDrain_post,t.resvDrain_pre,8*n.sideinfo_len,a-t.resvDrain_post-8*n.sideinfo_len,a,a%8,r),_.err.println("This is a fatal error. It has several possible causes:"),_.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),_.err.println(" 9%% Your system is overclocked"),_.err.println(" 1%% bug in LAME encoding library"),n.ResvSize=8*t.main_data_begin),f>1e9){var i;for(i=0;is)return-1;if(_.arraycopy(c,0,t,n,u),p=-1,h=0,0!=f){var d=a(1);if(d[0]=e.nMusicCRC,l.updateMusicCRC(d,t,n,u),e.nMusicCRC=d[0],u>0&&(e.VBR_seek_table.nBytesWritten+=u),e.decode_on_the_fly)for(var v,m=o([2,1152]),b=u,g=-1;0!=g;)if(g=i.hip_decode1_unclipped(e.hip,t,n,b,m[0],m[1]),b=0,-1==g&&(g=0),g>0){if(e.findPeakSample){for(v=0;ve.PeakSample?e.PeakSample=m[0][v]:-m[0][v]>e.PeakSample&&(e.PeakSample=-m[0][v]);if(e.channels_out>1)for(v=0;ve.PeakSample?e.PeakSample=m[1][v]:-m[1][v]>e.PeakSample&&(e.PeakSample=-m[1][v])}if(e.findReplayGain&&r.AnalyzeSamples(e.rgdata,m[0],0,m[1],0,g,e.channels_out)==y.GAIN_ANALYSIS_ERROR)return-6}}return u},this.init_bit_stream_w=function(e){c=n(G.LAME_MAXMP3BUFFER),e.h_ptr=e.w_ptr=0,e.header[e.h_ptr].write_timing=0,p=-1,h=0,f=0}}function A(e,t,n,r){this.xlen=e,this.linmax=t,this.table=n,this.hlen=r}m.STEREO=new m(0),m.JOINT_STEREO=new m(1),m.DUAL_CHANNEL=new m(2),m.MONO=new m(3),m.NOT_SET=new m(4),y.STEPS_per_dB=100,y.MAX_dB=120,y.GAIN_NOT_ENOUGH_SAMPLES=-24601,y.GAIN_ANALYSIS_ERROR=0,y.GAIN_ANALYSIS_OK=1,y.INIT_GAIN_ANALYSIS_ERROR=0,y.INIT_GAIN_ANALYSIS_OK=1,y.YULE_ORDER=10,y.MAX_ORDER=y.YULE_ORDER,y.MAX_SAMP_FREQ=48e3,y.RMS_WINDOW_TIME_NUMERATOR=1,y.RMS_WINDOW_TIME_DENOMINATOR=20,y.MAX_SAMPLES_PER_WINDOW=y.MAX_SAMP_FREQ*y.RMS_WINDOW_TIME_NUMERATOR/y.RMS_WINDOW_TIME_DENOMINATOR+1,x.NUMTOCENTRIES=100,x.MAXFRAMESIZE=2880,k.EQ=function(e,t){return Math.abs(e)>Math.abs(t)?Math.abs(e-t)<=1e-6*Math.abs(e):Math.abs(e-t)<=1e-6*Math.abs(t)},k.NEQ=function(e,t){return!k.EQ(e,t)};var M={};function R(e){this.bits=e}function T(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}function B(){this.setModules=function(e,t){e,t}}function E(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=i(F.SBMAX_l),this.s=i(F.SBMAX_s),this.psfb21=i(F.PSFB21),this.psfb12=i(F.PSFB12),this.cb_l=i(F.CBANDS),this.cb_s=i(F.CBANDS),this.eql_w=i(F.BLKSIZE/2)}function C(){this.class_id=0,this.num_samples=0,this.num_channels=0,this.in_samplerate=0,this.out_samplerate=0,this.scale=0,this.scale_left=0,this.scale_right=0,this.analysis=!1,this.bWriteVbrTag=!1,this.decode_only=!1,this.quality=0,this.mode=m.STEREO,this.force_ms=!1,this.free_format=!1,this.findReplayGain=!1,this.decode_on_the_fly=!1,this.write_id3tag_automatic=!1,this.brate=0,this.compression_ratio=0,this.copyright=0,this.original=0,this.extension=0,this.emphasis=0,this.error_protection=0,this.strict_ISO=!1,this.disable_reservoir=!1,this.quant_comp=0,this.quant_comp_short=0,this.experimentalY=!1,this.experimentalZ=0,this.exp_nspsytune=0,this.preset=0,this.VBR=null,this.VBR_q_frac=0,this.VBR_q=0,this.VBR_mean_bitrate_kbps=0,this.VBR_min_bitrate_kbps=0,this.VBR_max_bitrate_kbps=0,this.VBR_hard_min=0,this.lowpassfreq=0,this.highpassfreq=0,this.lowpasswidth=0,this.highpasswidth=0,this.maskingadjust=0,this.maskingadjust_short=0,this.ATHonly=!1,this.ATHshort=!1,this.noATH=!1,this.ATHtype=0,this.ATHcurve=0,this.ATHlower=0,this.athaa_type=0,this.athaa_loudapprox=0,this.athaa_sensitivity=0,this.short_blocks=null,this.useTemporal=!1,this.interChRatio=0,this.msfix=0,this.tune=!1,this.tune_value_a=0,this.version=0,this.encoder_delay=0,this.encoder_padding=0,this.framesize=0,this.frameNum=0,this.lame_allocated_gfp=0,this.internal_flags=null}function P(e){var t=e;this.quantize=t,this.iteration_loop=function(e,t,n,r){var s,o=e.internal_flags,l=i($.SFBMAX),c=i(576),f=a(2),u=0,_=o.l3_side,p=new R(u);this.quantize.rv.ResvFrameBegin(e,p),u=p.bits;for(var h=0;h>2&63)>=32&&(r-=64),c=Math.pow(10,r/4/10),(r=n.exp_nspsytune>>8&63)>=32&&(r-=64),p=Math.pow(10,r/4/10),(r=n.exp_nspsytune>>14&63)>=32&&(r-=64),v=Math.pow(10,r/4/10),(r=n.exp_nspsytune>>20&63)>=32&&(r-=64),b=v*Math.pow(10,r/4/10),r=0;rU.MAX_BITS_PER_GRANULE&&(d=U.MAX_BITS_PER_GRANULE),l=0,c=0;c3*i/4&&(_[c]=3*i/4),_[c]<0&&(_[c]=0),_[c]+r[c]>U.MAX_BITS_PER_CHANNEL&&(_[c]=Math.max(0,U.MAX_BITS_PER_CHANNEL-r[c])),l+=_[c];if(l>h)for(c=0;cU.MAX_BITS_PER_GRANULE){for(c=0;c.5&&(a=.5);var i=0|.5*a*(e[0]+e[1]);i>U.MAX_BITS_PER_CHANNEL-e[0]&&(i=U.MAX_BITS_PER_CHANNEL-e[0]),i<0&&(i=0),e[1]>=125&&(e[1]-i>125?(e[0]r&&(e[0]=r*e[0]/i,e[1]=r*e[1]/i)},this.athAdjust=function(e,t,n){var r=90.30873362,a=p.FAST_LOG10_X(t,10),i=e*e,s=0;return a-=n,i>1e-20&&(s=1+p.FAST_LOG10_X(i,10/r)),s<0&&(s=0),a*=s,a+=n+r-94.82444863,Math.pow(10,.1*a)},this.calc_xmin=function(e,t,n,r){var a,i=0,s=e.internal_flags,o=0,l=0,c=s.ATH,f=n.xr,u=e.VBR==v.vbr_mtrh?1:0,_=s.masking_lower;for(e.VBR!=v.vbr_mtrh&&e.VBR!=v.vbr_mt||(_=1),a=0;a>1,M=0;do{M+=T=f[o]*f[o],S+=T0);if(M>y&&l++,a==F.SBPSY_l)S<(A=y*s.nsPsy.longfact[a])&&(S=A);if(0!=u&&(y=S),!e.ATHonly)if((x=t.en.l[a])>0)A=M*t.thm.l[a]*_/x,0!=u&&(A*=s.nsPsy.longfact[a]),y>1;w=g/m,S=2220446049250313e-31;do{var T,B;M+=T=f[o]*f[o],S+=T0);if(M>g&&l++,d==F.SBPSY_s)S<(A=g*s.nsPsy.shortfact[d])&&(S=A);if(y=0!=u?S:g,!e.ATHonly&&!e.ATHshort)if((x=t.en.s[d][b])>0)A=M*t.thm.s[d][b]*_/x,0!=u&&(A*=s.nsPsy.shortfact[d]),yr[i-3+1]&&(r[i-3+1]+=(r[i-3]-r[i-3+1])*s.decay),r[i-3+1]>r[i-3+2]&&(r[i-3+2]+=(r[i-3+1]-r[i-3+2])*s.decay))}return l},this.calc_noise_core=function(e,t,n,r){var a=0,s=t.s,o=e.l3_enc;if(s>e.count1)for(;0!=n--;){c=e.xr[s],s++,a+=c*c,c=e.xr[s],s++,a+=c*c}else if(s>e.big_values){var l=i(2);for(l[0]=0,l[1]=r;0!=n--;){c=Math.abs(e.xr[s])-l[o[s]],s++,a+=c*c,c=Math.abs(e.xr[s])-l[o[s]],s++,a+=c*c}}else for(;0!=n--;){var c;c=Math.abs(e.xr[s])-_[o[s]]*r,s++,a+=c*c,c=Math.abs(e.xr[s])-_[o[s]]*r,s++,a+=c*c}return t.s=s,a},this.calc_noise=function(e,t,n,r,a){var i,s,o=0,l=0,u=0,_=0,h=0,d=-20,v=0,m=e.scalefac,g=0;for(r.over_SSD=0,i=0;i>1,v+e.width[i]>e.max_nonzero_coeff)s=(x=e.max_nonzero_coeff-v+1)>0?x>>1:0;var A=new b(v);S=this.calc_noise_core(e,A,s,k),v=A.s,null!=a&&(a.step[i]=w,a.noise[i]=S),S=n[o++]=S/t[l++],S=p.FAST_LOG10(Math.max(S,1e-20)),null!=a&&(a.noise_log[i]=S)}if(null!=a&&(a.global_gain=e.global_gain),h+=S,S>0)y=Math.max(0|10*S+.5,1),r.over_SSD+=y*y,u++,_+=S;d=Math.max(d,S)}return r.over_count=u,r.tot_noise=h,r.over_noise=_,r.max_noise=d,u},this.set_pinfo=function(e,t,n,r,a){var s,o,l,f,u,_=e.internal_flags,p=0==t.scalefac_scale?.5:1,h=t.scalefac,d=i($.SFBMAX),v=i($.SFBMAX),m=new T;calc_xmin(e,n,t,d),calc_noise(t,d,v,m,null);var b=0;for(o=t.sfb_lmax,t.block_type!=F.SHORT_TYPE&&0==t.mixed_block_flag&&(o=22),s=0;s0&&!e.ATHonly?f/=n.en.l[s]:f=0,_.pinfo.thr[r][a][s]=u*Math.max(f*n.thm.l[s],_.ATH.l[s]),_.pinfo.LAMEsfb[r][a][s]=0,0!=t.preflag&&s>=11&&(_.pinfo.LAMEsfb[r][a][s]=-p*c[s]),s0?f/=n.en.s[s][S]:f=0,(e.ATHonly||e.ATHshort)&&(f=0),_.pinfo.thr_s[r][a][3*s+S]=u*Math.max(f*n.thm.s[s][S],_.ATH.s[s]),_.pinfo.LAMEsfb_s[r][a][3*s+S]=-2*t.subblock_gain[S],s0?(i=n.over_SSD<=t.over_SSD,n.over_SSD==t.over_SSD&&(i=n.bits.2||n.max_noise<=0&&t.max_noise<0&&t.max_noise>n.max_noise-.2&&n.tot_noise0&&t.max_noise>n.max_noise-.2&&n.tot_noise0&&t.max_noise>-.05&&t.max_noise>n.max_noise-.1&&n.tot_noise+n.over_noise0&&t.max_noise>-.1&&t.max_noise>n.max_noise-.15&&n.tot_noise+n.over_noise+n.over_noise1?o=Math.pow(o,.5):o*=.95;break;case 0:default:o>1?o=1:o*=.95}var f=0;for(l=0;lt.xrpow_max&&(t.xrpow_max=r[f+u]);if(2==s.noise_shaping_amp)return}}}(e,t,a,i,s);var c=o(t);return!c&&(!(c=2==l.mode_gr?r.scale_bitcount(t):r.scale_bitcount_lsf(l,t))||(l.noise_shaping>1&&(u.fill(l.pseudohalf,0),0==t.scalefac_scale?(!function(e,t){for(var r=0,a=0;ae.xrpow_max&&(e.xrpow_max=t[r+o])}e.scalefac[a]=s>>1}e.preflag=0,e.scalefac_scale=1}(t,i),c=!1):t.block_type==F.SHORT_TYPE&&l.subblock_gain>0&&(c=function(e,t,r){var a,i=t.scalefac;for(a=0;a=16)return!0;for(var s=0;s<3;s++){var o=0,l=0;for(a=t.sfb_lmax+s;a=7)return!0;t.subblock_gain[s]++;var c=e.scalefac_band.l[t.sfb_lmax];for(a=t.sfb_lmax+s;a>t.scalefac_scale)>=0)i[a]=u,c+=3*f;else{i[a]=0;var _=210+(u<t.xrpow_max&&(t.xrpow_max=r[c+p]);c+=f*(3-s-1)}}var h=n.IPOW20(202);c+=t.width[a]*(s+1);for(p=-t.width[a];p<0;p++)r[c+p]*=h,r[c+p]>t.xrpow_max&&(t.xrpow_max=r[c+p])}}return!1}(l,t,i)||o(t))),c||(c=2==l.mode_gr?r.scale_bitcount(t):r.scale_bitcount_lsf(l,t)),!c))}this.setModules=function(i,s,o,l){e=i,t=s,this.rv=s,n=o,this.qupvt=o,r=l,a.setModules(n,r)},this.ms_convert=function(e,t){for(var n=0;n<576;++n){var r=e.tt[t][0].xr[n],a=e.tt[t][1].xr[n];e.tt[t][0].xr[n]=(r+a)*(.5*p.SQRT2),e.tt[t][1].xr[n]=(r-a)*(.5*p.SQRT2)}},this.init_xrpow=function(e,t,n){var r=0,a=0|t.max_nonzero_coeff;if(t.xrpow_max=0,u.fill(n,a,576,0),(r=function(e,t,n,r){r=0;for(var a=0;a<=n;++a){var i=Math.abs(e.xr[a]);r+=i,t[a]=Math.sqrt(i*Math.sqrt(i)),t[a]>e.xrpow_max&&(e.xrpow_max=t[a])}return r}(t,n,a,r))>1e-20){var i=0;0!=(2&e.substep_shaping)&&(i=1);for(var s=0;s=0&&!i;s--){var o=e.scalefac_band.psfb21[s],l=e.scalefac_band.psfb21[s+1],c=n.athAdjust(r.adjust,r.psfb21[s],r.floor);e.nsPsy.longfact[21]>1e-12&&(c*=e.nsPsy.longfact[21]);for(var f=l-1;f>=o;f--){if(!(Math.abs(a[f])=0&&!i;s--){l=(o=3*e.scalefac_band.s[12]+(e.scalefac_band.s[13]-e.scalefac_band.s[12])*u+(e.scalefac_band.psfb12[s]-e.scalefac_band.psfb12[0]))+(e.scalefac_band.psfb12[s+1]-e.scalefac_band.psfb12[s]);var _=n.athAdjust(r.adjust,r.psfb12[s],r.floor);e.nsPsy.shortfact[12]>1e-12&&(_*=e.nsPsy.shortfact[12]);for(f=l-1;f>=o;f--){if(!(Math.abs(a[f])<_)){i=!0;break}a[f]=0}}}(e,t)},s.BINSEARCH_NONE=new s(0),s.BINSEARCH_UP=new s(1),s.BINSEARCH_DOWN=new s(2),this.trancate_smallspectrums=function(e,t,a,s){var o=i($.SFBMAX);if((0!=(4&e.substep_shaping)||t.block_type!=F.SHORT_TYPE)&&0==(128&e.substep_shaping)){n.calc_noise(t,a,o,new T,null);for(var l=0;l<576;l++){var c=0;0!=t.l3_enc[l]&&(c=Math.abs(t.xr[l])),s[l]=c}l=0;var f=8;t.block_type==F.SHORT_TYPE&&(f=6);do{var _,p,h,d,v=t.width[f];if(l+=v,!(o[f]>=1||(u.sort(s,l-v,v),k.EQ(s[l-1],0)))){_=(1-o[f])*a[f],p=0,d=0;do{var m;for(h=1;d+h0)}}while(++fn?(u==s.BINSEARCH_DOWN&&(c=!0),c&&(l/=2),u=s.BINSEARCH_UP,_=l):(u==s.BINSEARCH_UP&&(c=!0),c&&(l/=2),u=s.BINSEARCH_DOWN,_=-l),t.global_gain+=_,t.global_gain<0&&(t.global_gain=0,c=!0),t.global_gain>255&&(t.global_gain=255,c=!0)}for(;o>n&&t.global_gain<255;)t.global_gain++,o=r.count_bits(e,i,t,null);e.CurrentStep[a]=f-t.global_gain>=4?4:2,e.OldValue[a]=t.global_gain,t.part2_3_length=o}(p,t,u,f,o),0==p.noise_shaping)return 100;n.calc_noise(t,a,m,b,g),b.bits=t.part2_3_length,h.assign(t);var k=0;for(_.arraycopy(o,0,d,0,576);!w;){do{var A,M=new T,R=255;if(A=0!=(2&p.substep_shaping)?20:3,p.sfb21_extra){if(m[h.sfbmax]>1)break;if(h.block_type==F.SHORT_TYPE&&(m[h.sfbmax+1]>1||m[h.sfbmax+2]>1))break}if(!c(e,h,m,o,S))break;0!=h.scalefac_scale&&(R=254);var B=u-h.part2_length;if(B<=0)break;for(;(h.part2_3_length=r.count_bits(p,o,h,g))>B&&h.global_gain<=R;)h.global_gain++;if(h.global_gain>R)break;if(0==b.over_count){for(;(h.part2_3_length=r.count_bits(p,o,h,g))>y&&h.global_gain<=R;)h.global_gain++;if(h.global_gain>R)break}if(n.calc_noise(h,a,m,M,g),M.bits=h.part2_3_length,0!=(l(t.block_type!=F.SHORT_TYPE?e.quant_comp:e.quant_comp_short,b,M,h,m)?1:0))y=t.part2_3_length,b=M,t.assign(h),k=0,_.arraycopy(o,0,d,0,576);else if(0==p.full_outer_loop){if(++k>A&&0==b.over_count)break;if(3==p.noise_shaping_amp&&S&&k>30)break;if(3==p.noise_shaping_amp&&S&&h.global_gain-x>15)break}}while(h.global_gain+h.scalefac_scale<255);3==p.noise_shaping_amp?S?w=!0:(h.assign(t),_.arraycopy(d,0,o,0,576),k=0,x=h.global_gain,S=!0):w=!0}return e.VBR==v.vbr_rh||e.VBR==v.vbr_mtrh?_.arraycopy(d,0,o,0,576):0!=(1&p.substep_shaping)&&trancate_smallspectrums(p,t,a,o),b.over_count},this.iteration_finish_one=function(e,n,a){var i=e.l3_side,s=i.tt[n][a];r.best_scalefac_store(e,n,a,i),1==e.use_best_huffman&&r.best_huffman_divide(e,s),t.ResvAdjust(e,s)},this.VBR_encode_granule=function(e,t,n,r,a,s,o){var l,c=e.internal_flags,f=new N,p=i(576),h=o,d=o+1,v=(o+s)/2,m=0,b=c.sfb21_extra;u.fill(f.l3_enc,0);do{c.sfb21_extra=!(v>h-42)&&b,outer_loop(e,t,n,r,a,v)<=0?(m=1,d=t.part2_3_length,f.assign(t),_.arraycopy(r,0,p,0,576),l=(o=d-32)-s,v=(o+s)/2):(l=o-(s=v+32),v=(o+s)/2,0!=m&&(m=2,t.assign(f),_.arraycopy(p,0,r,0,576)))}while(l>12);c.sfb21_extra=b,2==m&&_.arraycopy(f.l3_enc,0,t.l3_enc,0,576)},this.get_framebits=function(n,r){var a=n.internal_flags;a.bitrate_index=a.VBR_min_bitrate;var i=e.getframebits(n);a.bitrate_index=1,i=e.getframebits(n);for(var s=1;s<=a.VBR_max_bitrate;s++){a.bitrate_index=s;var o=new R(i);r[s]=t.ResvFrameBegin(n,o),i=o.bits}},this.VBR_old_prepare=function(e,r,a,i,s,o,l,c,f){var u,_=e.internal_flags,p=0,h=1,d=0;_.bitrate_index=_.VBR_max_bitrate;var v=t.ResvFrameBegin(e,new R(0))/_.mode_gr;get_framebits(e,o);for(var m=0;m<_.mode_gr;m++){var b=n.on_pe(e,r,c[m],v,m,0);_.mode_ext==F.MPG_MD_MS_LR&&(ms_convert(_.l3_side,m),n.reduce_side(c[m],a[m],v,b));for(var g=0;g<_.channels_out;++g){var y=_.l3_side.tt[m][g];y.block_type!=F.SHORT_TYPE?(p=1.28/(1+Math.exp(3.5-r[m][g]/300))-.05,u=_.PSY.mask_adjust-p):(p=2.56/(1+Math.exp(3.5-r[m][g]/300))-.14,u=_.PSY.mask_adjust_short-p),_.masking_lower=Math.pow(10,.1*u),init_outer_loop(_,y),f[m][g]=n.calc_xmin(e,i[m][g],y,s[m][g]),0!=f[m][g]&&(h=0),l[m][g]=126,d+=c[m][g]}}for(m=0;m<_.mode_gr;m++)for(g=0;g<_.channels_out;g++)d>o[_.VBR_max_bitrate]&&(c[m][g]*=o[_.VBR_max_bitrate],c[m][g]/=d),l[m][g]>c[m][g]&&(l[m][g]=c[m][g]);return h},this.bitpressure_strategy=function(e,t,n,r){for(var a=0;al&&(o[h][d]*=l,o[h][d]/=_);return f},this.calc_target_bits=function(r,a,i,s,o,l){var c,f,u,_,p=r.internal_flags,h=p.l3_side,d=0;p.bitrate_index=p.VBR_max_bitrate;var v=new R(d);for(l[0]=t.ResvFrameBegin(r,v),d=v.bits,p.bitrate_index=1,d=e.getframebits(r)-8*p.sideinfo_len,o[0]=d/(p.mode_gr*p.channels_out),d=r.VBR_mean_bitrate_kbps*r.framesize*1e3,0!=(1&p.substep_shaping)&&(d*=1.09),d/=r.out_samplerate,d-=8*p.sideinfo_len,d/=p.mode_gr*p.channels_out,(c=.93+.07*(11-r.compression_ratio)/5.5)<.9&&(c=.9),c>1&&(c=1),f=0;f700){var b=int((a[f][u]-700)/1.4),g=h.tt[f][u];s[f][u]=int(c*d),g.block_type==F.SHORT_TYPE&&b3*d/2?b=3*d/2:b<0&&(b=0),s[f][u]+=b}s[f][u]>U.MAX_BITS_PER_CHANNEL&&(s[f][u]=U.MAX_BITS_PER_CHANNEL),m+=s[f][u]}if(m>U.MAX_BITS_PER_GRANULE)for(u=0;uU.MAX_BITS_PER_CHANNEL&&(s[f][u]=U.MAX_BITS_PER_CHANNEL),_+=s[f][u];if(_>l[0])for(f=0;f=0;--z){var ee,te;ee=V[q+z]*a[20+z]+V[q+-1-z]*s[28+z],te=V[q+z]*s[28+z]-V[q+-1-z]*a[20+z],V[q+-1-z]=ee,V[q+z]=te}}}if(I=p,H=286,1==e.mode_gr)for(var ne=0;ne<18;ne++)_.arraycopy(e.sb_sample[N][1][ne],0,e.sb_sample[N][0][ne],0,32)}}}function V(){this.thm=new X,this.en=new X}function F(){var e=F.FFTOFFSET,t=F.MPG_MD_MS_LR,n=null;this.psy=null;var r=null,s=null,l=null;this.setModules=function(e,t,a,i){n=e,this.psy=t,r=t,s=i,l=a};var c=new j;this.lame_encode_mp3_frame=function(u,p,h,d,b,g){var y,w=f([2,2]);w[0][0]=new V,w[0][1]=new V,w[1][0]=new V,w[1][1]=new V;var S,x=f([2,2]);x[0][0]=new V,x[0][1]=new V,x[1][0]=new V,x[1][1]=new V;var k,A,M,R=[null,null],T=u.internal_flags,B=o([2,4]),E=[.5,.5],C=[[0,0],[0,0]],P=[[0,0],[0,0]];if(R[0]=p,R[1]=h,0==T.lame_encode_frame_init&&function(e,t){var n,r,a=e.internal_flags;if(0==a.lame_encode_frame_init){var s,o,l=i(2014),f=i(2014);for(a.lame_encode_frame_init=1,s=0,o=0;s<286+576*(1+a.mode_gr);++s)s<576*a.mode_gr?(l[s]=0,2==a.channels_out&&(f[s]=0)):(l[s]=t[0][o],2==a.channels_out&&(f[s]=t[1][o]),++o);for(r=0;r0&&(E[M]=B[M][3]/E[M])),A=0;A.03125)e.ATH.adjust>=1?e.ATH.adjust=1:e.ATH.adjust=r?(e.ATH.adjust*=.075*r+.925,e.ATH.adjust=r?e.ATH.adjust=r:e.ATH.adjust>1,d=(h=a<<1)+(_=a),a=h<<1,s=(i=t)+v;do{x=e[i+0]-e[i+_],S=e[i+0]+e[i+_],R=e[i+h]-e[i+d],A=e[i+h]+e[i+d],e[i+h]=S-A,e[i+0]=S+A,e[i+d]=x-R,e[i+_]=x+R,x=e[s+0]-e[s+_],S=e[s+0]+e[s+_],R=p.SQRT2*e[s+d],A=p.SQRT2*e[s+h],e[s+h]=S-A,e[s+0]=S+A,e[s+d]=x-R,e[s+_]=x+R,s+=a,i+=a}while(i=0);r(n[l],c,F.BLKSIZE_s/2)}},this.fft_long=function(t,n,i,s,o){var l=F.BLKSIZE/8-1,c=F.BLKSIZE/2;do{var f,u,_,p,h,d=255&a[l];u=(f=e[d]*s[i][o+d])-(h=e[d+512]*s[i][o+d+512]),f+=h,p=(_=e[d+256]*s[i][o+d+256])-(h=e[d+768]*s[i][o+d+768]),_+=h,n[(c-=4)+0]=f+_,n[c+2]=f-_,n[c+1]=u+p,n[c+3]=u-p,u=(f=e[d+1]*s[i][o+d+1])-(h=e[d+513]*s[i][o+d+513]),f+=h,p=(_=e[d+257]*s[i][o+d+257])-(h=e[d+769]*s[i][o+d+769]),_+=h,n[c+F.BLKSIZE/2+0]=f+_,n[c+F.BLKSIZE/2+2]=f-_,n[c+F.BLKSIZE/2+1]=u+p,n[c+F.BLKSIZE/2+3]=u-p}while(--l>=0);r(n,c,F.BLKSIZE/2)},this.init_fft=function(n){for(var r=0;r=0;--d){var v=i[s+0][d],m=i[s+1][d];i[s+0][d]=(v+m)*p.SQRT2*.5,i[s+1][d]=(v-m)*p.SQRT2*.5}for(var b=2;b>=0;--b)for(d=F.BLKSIZE_s-1;d>=0;--d){v=o[l+0][b][d],m=o[l+1][b][d];o[l+0][b][d]=(v+m)*p.SQRT2*.5,o[l+1][b][d]=(v-m)*p.SQRT2*.5}}n[0]=i[s+0][0],n[0]*=n[0];for(d=F.BLKSIZE/2-1;d>=0;--d){var g=i[s+0][F.BLKSIZE/2-d],y=i[s+0][F.BLKSIZE/2+d];n[F.BLKSIZE/2-d]=.5*(g*g+y*y)}for(b=2;b>=0;--b){a[b][0]=o[l+0][b][0],a[b][0]*=a[b][0];for(d=F.BLKSIZE_s/2-1;d>=0;--d){g=o[l+0][b][F.BLKSIZE_s/2-d],y=o[l+0][b][F.BLKSIZE_s/2+d];a[b][F.BLKSIZE_s/2-d]=.5*(g*g+y*y)}}var w=0;for(d=11;de){if(!(t=t*c)return e+t;s=e/t}if(e+=t,r+3<=6){if(s>=l)return e;var o=0|p.FAST_LOG10_X(s,16);return e*g[o]}var u,_;o=0|p.FAST_LOG10_X(s,16);return t=0!=i?a.ATH.cb_s[n]*a.ATH.adjust:a.ATH.cb_l[n]*a.ATH.adjust,et?(u=1,o<=13&&(u=y[o]),_=p.FAST_LOG10_X(e/t,10/15),e*((b[o]-u)*_+u)):o>13?e:e*y[o]:e*b[o]}var S=[1.7782755904,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.6999465924,1.22321*1.22321,1.3169398564,1];function x(e,t,n){var r;if(e<0&&(e=0),t<0&&(t=0),e<=0)return t;if(t<=0)return e;if(r=t>e?t/e:e/t,-2<=n&&n<=2){if(r>=l)return e+t;var a=0|p.FAST_LOG10_X(r,16);return(e+t)*S[a]}return r=f){++i;break}var _=e.PSY.bo_s_weight[i],p=1-_;o=_*t[s],l=_*n[s],e.en[r].s[i][a]+=o,e.thm[r].s[i][a]+=l,o=p*t[s],l=p*n[s]}for(;i=c){++a;break}var u=e.PSY.bo_l_weight[a],_=1-u;s=u*t[i],o=u*n[i],e.en[r].l[a]+=s,e.thm[r].l[a]+=o,s=_*t[i],o=_*n[i]}for(;a=1?e:n<=0?t:t>0?Math.pow(e/t,n)*t:0}var T=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function B(e,n){for(var r=309.07,a=0;a0){var o=s*n,l=e.en.s[a][i];l>o&&(r+=l>1e10*o?T[a]*(10*t):T[a]*p.FAST_LOG10(l/o))}}return r}var E=[6.8,5.8,5.8,6.4,6.5,9.9,12.1,14.4,15,18.9,21.6,26.9,34.2,40.2,46.8,56.5,60.7,73.9,85.7,93.4,126.1];function C(e,n){for(var r=281.0575,a=0;a0){var s=i*n,o=e.en.l[a];o>s&&(r+=o>1e10*s?E[a]*(10*t):E[a]*p.FAST_LOG10(o/s))}}return r}function P(e,t,n,r,a){var i,s;for(i=s=0;i0?((o=t[i])a&&(l=a),r[i]=l):r[i]=0;for(i=1;i0)(o=t[i-1])a&&(l=a),r[i]=l;else r[i]=0}(s=n[i-1]+n[i])>0?((o=t[i-1])a&&(l=a),r[i]=l):r[i]=0}var L=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function I(t,n,r,a,i,s,o,l){var c=t.internal_flags;if(a<2)e.fft_long(c,o[l],a,n,r);else if(2==a)for(var f=F.BLKSIZE-1;f>=0;--f){var u=o[l+0][f],_=o[l+1][f];o[l+0][f]=(u+_)*p.SQRT2*.5,o[l+1][f]=(u-_)*p.SQRT2*.5}s[0]=o[l+0][0],s[0]*=s[0];for(f=F.BLKSIZE/2-1;f>=0;--f){var h=o[l+0][F.BLKSIZE/2-f],d=o[l+0][F.BLKSIZE/2+f];s[F.BLKSIZE/2-f]=.5*(h*h+d*d)}var v=0;for(f=11;f=0;--f){var u=o[l+0][i][f],_=o[l+1][i][f];o[l+0][i][f]=(u+_)*p.SQRT2*.5,o[l+1][i][f]=(u-_)*p.SQRT2*.5}s[i][0]=o[l+0][i][0],s[i][0]*=s[i][0];for(f=F.BLKSIZE_s/2-1;f>=0;--f){var h=o[l+0][i][F.BLKSIZE_s/2-f],d=o[l+0][i][F.BLKSIZE_s/2+f];s[i][F.BLKSIZE_s/2-f]=.5*(h*h+d*d)}}function N(e,t,n,a){var i=e.internal_flags;2==e.athaa_loudapprox&&n<2&&(i.loudness_sq[t][n]=i.loudness_sq_save[n],i.loudness_sq_save[n]=r(a,i))}this.L3psycho_anal_ns=function(e,t,n,r,l,c,f,p,d,b){var g,y,S,x,T,E,I,H,N,$,D=e.internal_flags,j=o([2,F.BLKSIZE]),V=o([2,3,F.BLKSIZE_s]),q=i(F.CBANDS+1),Y=i(F.CBANDS+1),X=i(F.CBANDS+2),z=a(2),U=a(2),K=o([2,576]),Z=a(F.CBANDS+2),G=a(F.CBANDS+2);for(u.fill(G,0),g=D.channels_out,e.mode==m.JOINT_STEREO&&(g=4),N=e.VBR==v.vbr_off?0==D.ResvMax?0:D.ResvSize/D.ResvMax*.5:e.VBR==v.vbr_rh||e.VBR==v.vbr_mtrh||e.VBR==v.vbr_mt?.6:1,y=0;y2&&(c[r][y].en.assign(D.en[y+2]),c[r][y].thm.assign(D.thm[y+2]))}for(y=0;yne[x+3-2]?ve/=ne[x+3-2]:ve=ne[x+3-2]>10*ve?ne[x+3-2]/(10*ve):0,ae[x+3]=ve}if(e.analysis){var me=ae[0];for(x=1;x<12;x++)mete&&(le[x/3]=x%3+1);for(x=1;x<4;x++){(re[x-1]>re[x]?re[x-1]/re[x]:re[x]/re[x-1])<1.7&&(le[x]=0,1==x&&(le[0]=0))}for(0!=le[0]&&0!=D.nsPsy.lastAttacks[y]&&(le[0]=0),3!=D.nsPsy.lastAttacks[y]&&le[0]+le[1]+le[2]+le[3]==0||(ie=0,0!=le[1]&&0!=le[0]&&(le[1]=0),0!=le[2]&&0!=le[1]&&(le[2]=0),0!=le[3]&&0!=le[2]&&(le[3]=0)),y<2?U[y]=ie:0==ie&&(U[0]=U[1]=0),d[y]=D.tot_ener[y],s(e,ce,fe,j,1&y,V,1&y,r,y,t,n),P(D,ce,q,se,oe),O(D,se,oe,Z),H=0;H<3;H++){var be,ge;for(M(e,fe,Y,X,y,H),k(D,Y,X,y,H),I=0;I=2||1==le[H+1]){var ye=0!=H?H-1:2;ve=R(D.thm[y].s[I][ye],ge,.6*N);ge=Math.min(ge,ve)}if(1==le[H]){ye=0!=H?H-1:2,ve=R(D.thm[y].s[I][ye],ge,.3*N);ge=Math.min(ge,ve)}else if(0!=H&&3==le[H-1]||0==H&&3==D.nsPsy.lastAttacks[y]){ye=2!=H?H+1:0,ve=R(D.thm[y].s[I][ye],ge,.3*N);ge=Math.min(ge,ve)}be=ne[3*H+3]+ne[3*H+4]+ne[3*H+5],6*ne[3*H+5]0&&function(e,t){var n=e.internal_flags;if(n.channels_out>1){for(var r=0;r1.58*e.thm[1].l[t]||e.thm[1].l[t]>1.58*e.thm[0].l[t])){var n=e.mld_l[t]*e.en[3].l[t],r=Math.max(e.thm[2].l[t],Math.min(e.thm[3].l[t],n));n=e.mld_l[t]*e.en[2].l[t];var a=Math.max(e.thm[3].l[t],Math.min(e.thm[2].l[t],n));e.thm[2].l[t]=r,e.thm[3].l[t]=a}for(t=0;t1.58*e.thm[1].s[t][i]||e.thm[1].s[t][i]>1.58*e.thm[0].s[t][i])){n=e.mld_s[t]*e.en[3].s[t][i],r=Math.max(e.thm[2].s[t][i],Math.min(e.thm[3].s[t][i],n));n=e.mld_s[t]*e.en[2].s[t][i];a=Math.max(e.thm[3].s[t][i],Math.min(e.thm[2].s[t][i],n));e.thm[2].s[t][i]=r,e.thm[3].s[t][i]=a}}(D),$=e.msfix,Math.abs($)>0&&function(e,t,n){var r=t,a=Math.pow(10,n);t*=2,r*=2;for(var i=0;i1?(ke=p,Re=-2,Ae=F.NORM_TYPE,b[0]!=F.SHORT_TYPE&&b[1]!=F.SHORT_TYPE||(Ae=F.SHORT_TYPE),Me=c[r][y-2]):(ke=f,Re=0,Ae=b[y],Me=l[r][y]),Ae==F.SHORT_TYPE?ke[Re+y]=B(Me,D.masking_lower):ke[Re+y]=C(Me,D.masking_lower),e.analysis&&(D.pinfo.pe[r][y]=ke[Re+y])}return 0};var $=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function D(e,t,n){if(0==n)for(var r=0;r0?((o=t[i])a&&(l=a),r[i]=l):r[i]=0,i=1;i0)(o=t[i-1])a&&(l=a),r[i]=l;else r[i]=0}(s=n[i-1]+n[i])>0?((o=t[i-1])a&&(l=a),r[i]=l):r[i]=0}(f,u,p,h),l=c=0;cw&&(r[c]=w),f.masking_lower>1&&(r[c]*=f.masking_lower),r[c]>n[c]&&(r[c]=n[c]),f.masking_lower<1&&(r[c]*=f.masking_lower)}for(;c0?Math.min(h,y):Math.min(h,.3*n[o])}else{var w=16*e.nb_2[s][o],S=2*e.nb_1[s][o];w<=0&&(w=h),S<=0&&(S=h),y=e.blocktype_old[1&s]==F.NORM_TYPE?Math.min(S,w):S,r[o]=Math.min(h,y)}e.nb_2[s][o]=e.nb_1[s][o],e.nb_1[s][o]=h,p=l[o],p*=e.minval_l[o],p*=d,r[o]>p&&(r[o]=p),e.masking_lower>1&&(r[o]*=e.masking_lower),r[o]>n[o]&&(r[o]=n[o]),e.masking_lower<1&&(r[o]*=e.masking_lower)}for(;o0?Math.pow(10,a):1,u=0;u0){var y,w,S=r[u]*f;if(y=Math.min(Math.max(h,S),Math.max(d,S)),(w=(v=Math.max(l,S))+(m=Math.max(o,S)))>0&&y*c_&&(l=_),o>p&&(o=p),t[2][u]=l,t[3][u]=o}}function X(e,t){var n;return(n=e>=0?27*-e:e*t)<=-72?0:Math.exp(.2302585093*n)}function z(e){var t,n,r=0;for(r=0;X(r,e)>1e-20;r-=1);for(a=r,i=0;Math.abs(i-a)>1e-12;)X(r=(i+a)/2,e)>0?i=r:a=r;t=a;var a,i;r=0;for(r=0;X(r,e)>1e-20;r+=1);for(a=0,i=r;Math.abs(i-a)>1e-12;)X(r=(i+a)/2,e)>0?a=r:i=r;n=i;var s,o=0,l=1e3;for(s=0;s<=l;++s){o+=X(r=t+s*(n-t)/l,e)}return 1001/(o*(n-t))}function U(e){return e<0&&(e=0),e*=.001,13*Math.atan(.76*e)+3.5*Math.atan(e*e/56.25)}function Z(e,t,n,r,s,o,l,c,f,u,_,p){var h,d=i(F.CBANDS+1),v=c/(p>15?1152:384),m=a(F.HBLKSIZE);c/=f;var b=0,g=0;for(h=0;hf/2){b=f/2,++h;break}}d[h]=c*b;for(var w=0;wf/2&&(x=f/2),n[w]=(m[S]+m[x])/2,t[w]=m[x];var R=v*A;l[w]=(R-d[t[w]])/(d[t[w]+1]-d[t[w]]),l[w]<0?l[w]=0:l[w]>1&&(l[w]=1),M=U(c*u[w]*_),M=Math.min(M,15.5)/15.5,o[w]=Math.pow(10,1.25*(1-Math.cos(Math.PI*M))-2.5)}b=0;for(var T=0;T=0?3:1.5)>=.5&&f<=2.5?8*((p=f-.5)*p-2*p):0,((_=15.811389+7.5*(f+=.474)-17.5*Math.sqrt(1+f*f))<=-60?0:(f=Math.exp(.2302585093*(u+_)),f/=.6609193))*r[l]);h[v][l]=m*a[v]}else for(l=0;l0);l++);for(e[v][0]=l,l=t-1;l>0&&!(h[v][l]>0);l--);e[v][1]=l,d+=e[v][1]-e[v][0]+1}var y=i(d),w=0;for(v=0;v2&&(s[r][v].en.assign(p.en[v+2]),s[r][v].thm.assign(p.thm[v+2]))}for(v=0;v0;++g,--S){var E=_[0][g],C=_[1][g];_[0][g]=E+C,_[1][g]=E-C}for(g=0;g<3;g++)k[g]=p.nsPsy.last_en_subshort[v][g+6],x[g]=k[g]/p.nsPsy.last_en_subshort[v][g+4],A[0]+=k[g];for(g=0;g<9;g++){for(var P=R+64,O=1;Rk[g+3-2]?O/=k[g+3-2]:O=k[g+3-2]>10*O?k[g+3-2]/(10*O):0,x[g+3]=O}for(g=0;g<3;++g){var L=k[3*g+3]+k[3*g+4]+k[3*g+5],I=1;6*k[3*g+5]T&&(f[v][g/3]=g%3+1);for(g=1;g<4;g++){var N=A[g-1],D=A[g];Math.max(N,D)<4e4&&N<1.7*D&&D<1.7*N&&(1==g&&f[v][0]<=f[v][g]&&(f[v][0]=0),f[v][g]=0)}f[v][0]<=p.nsPsy.lastAttacks[v]&&(f[v][0]=0),3!=p.nsPsy.lastAttacks[v]&&f[v][0]+f[v][1]+f[v][2]+f[v][3]==0||(B=0,0!=f[v][1]&&0!=f[v][0]&&(f[v][1]=0),0!=f[v][2]&&0!=f[v][1]&&(f[v][2]=0),0!=f[v][3]&&0!=f[v][2]&&(f[v][3]=0)),v<2?u[v]=B:0==B&&(u[0]=u[1]=0),l[v]=p.tot_ener[v]}}(e,t,n,r,s,l,u,S,x,M),function(e,t){var n=e.internal_flags;e.short_blocks!=h.short_block_coupled||0!=t[0]&&0!=t[1]||(t[0]=t[1]=0);for(var r=0;r=2||1==x[E][P+1]){var U=0!=P?P-1:2,K=R(p.thm[E].s[L][U],z,.36);z=Math.min(z,K)}else if(1==x[E][P]){U=0!=P?P-1:2,K=R(p.thm[E].s[L][U],z,.18);z=Math.min(z,K)}else if(0!=P&&3==x[E][P-1]||0==P&&3==p.nsPsy.lastAttacks[E]){U=2!=P?P+1:0,K=R(p.thm[E].s[L][U],z,.18);z=Math.min(z,K)}z*=S[E][P],X[P]=z}for(P=0;P<3;P++)p.thm[E].s[L][P]=X[P]}}for(E=0;E1?(Z=f,G=-2,Q=F.NORM_TYPE,_[0]!=F.SHORT_TYPE&&_[1]!=F.SHORT_TYPE||(Q=F.SHORT_TYPE),W=l[r][E-2]):(Z=c,G=0,Q=_[E],W=s[r][E]),Q==F.SHORT_TYPE?Z[G+E]=B(W,p.masking_lower):Z[G+E]=C(W,p.masking_lower),e.analysis&&(p.pinfo.pe[r][E]=Z[G+E])}return 0},this.psymodel_init=function(n){var r,a=n.internal_flags,s=!0,o=13,u=0,_=0,p=-8.25,h=-4.5,m=i(F.CBANDS),b=i(F.CBANDS),g=i(F.CBANDS),y=n.out_samplerate;switch(n.experimentalZ){default:case 0:s=!0;break;case 1:s=n.VBR!=v.vbr_mtrh&&n.VBR!=v.vbr_mt;break;case 2:s=!1;break;case 3:o=8,u=-1.75,_=-.0125,p=-8.25,h=-2.25}for(a.ms_ener_ratio_old=.25,a.blocktype_old[0]=a.blocktype_old[1]=F.NORM_TYPE,r=0;r<4;++r){for(var w=0;w=o&&(x=_*(m[r]-o)/(24-o)+u*(24-m[r])/(24-o)),g[r]=Math.pow(10,x/10),a.numlines_l[r]>0?a.rnumlines_l[r]=1/a.numlines_l[r]:a.rnumlines_l[r]=0}a.s3_ll=G(a.s3ind,a.npart_l,m,b,g,s);var k;w=0;for(r=0;r(T*=a.numlines_l[r])&&(R=T)}a.ATH.cb_l[r]=R,(R=20*m[r]/10-20)>6&&(R=100),R<-15&&(R=-15),R-=8,a.minval_l[r]=Math.pow(10,R/10)*a.numlines_l[r]}for(a.npart_s=Z(a.numlines_s,a.bo_s,a.bm_s,m,b,a.mld_s,a.PSY.bo_s_weight,y,F.BLKSIZE_s,a.scalefac_band.s,F.BLKSIZE_s/384,F.SBMAX_s),w=0,r=0;r=o&&(x=h*(m[r]-o)/(24-o)+p*(24-m[r])/(24-o)),g[r]=Math.pow(10,x/10),R=d.MAX_VALUE;for(A=0;A(T*=a.numlines_s[r])&&(R=T)}a.ATH.cb_s[r]=R,R=7*m[r]/12-7,m[r]>12&&(R*=1+3.1*Math.log(1+R)),m[r]<12&&(R*=1+2.3*Math.log(1-R)),R<-15&&(R=-15),R-=8,a.minval_s[r]=Math.pow(10,R/10)*a.numlines_s[r]}a.s3_ss=G(a.s3ind_s,a.npart_s,m,b,g,s),l=Math.pow(10,9/16),c=Math.pow(10,1.5),f=Math.pow(10,1.5),e.init_fft(a),a.decay=Math.exp(-1*t/(.01*y/192)),k=3.5,0!=(2&n.exp_nspsytune)&&(k=1),Math.abs(n.msfix)>0&&(k=n.msfix),n.msfix=k;for(var B=0;Ba.npart_l-1&&(a.s3ind[B][1]=a.npart_l-1);var E=576*a.mode_gr/y;if(a.ATH.decay=Math.pow(10,-1.2*E),a.ATH.adjust=.01,a.ATH.adjustLimit=1,-1!=n.ATHtype){var C=n.out_samplerate/F.BLKSIZE,P=0;for(M=0,r=0;r=0;)a.ATH.eql_w[r]*=P}for(B=w=0;B1?0:e<=0?1:Math.cos(Math.PI/2*e)}function S(e,t){switch(e){case 44100:return t.version=1,0;case 48e3:return t.version=1,1;case 32e3:return t.version=1,2;case 22050:return t.version=0,0;case 24e3:return t.version=0,1;case 16e3:return t.version=0,2;case 11025:return t.version=0,0;case 12e3:return t.version=0,1;case 8e3:return t.version=0,2;default:return t.version=0,-1}}function x(e,t,n){n<16e3&&(t=2);for(var r=M.bitrate_table[t][1],a=2;a<=14;a++)M.bitrate_table[t][a]>0&&Math.abs(M.bitrate_table[t][a]-e)0&&M.bitrate_table[t][r]==e)return r;return-1}function R(t,n){var r=[new g(8,2e3),new g(16,3700),new g(24,3900),new g(32,5500),new g(40,7e3),new g(48,7500),new g(56,1e4),new g(64,11e3),new g(80,13500),new g(96,15100),new g(112,15600),new g(128,17e3),new g(160,17500),new g(192,18600),new g(224,19400),new g(256,19700),new g(320,20500)],a=e.nearestBitrateFullIndex(n);t.lowerlimit=r[a].lowpass}function T(e){var t=F.BLKSIZE+e.framesize-F.FFTOFFSET;return t=Math.max(t,512+e.framesize-32)}function B(t,n,r,a,i,s){var o=e.enc.lame_encode_mp3_frame(t,n,r,a,i,s);return t.frameNum++,o}function L(){this.n_in=0,this.n_out=0}function I(){this.num_used=0}function H(e,t,n){var r=Math.PI*t;(e/=n)<0&&(e=0),e>1&&(e=1);var a=e-.5,i=.42-.5*Math.cos(2*e*Math.PI)+.08*Math.cos(4*e*Math.PI);return Math.abs(a)<1e-9?r/Math.PI:i*Math.sin(n*r*a)/(Math.PI*n*a)}function N(e,t,n,r,a,s,o,l,c){var f,u,_=e.internal_flags,p=0,h=e.out_samplerate/function e(t,n){return 0!=n?e(n,t%n):t}(e.out_samplerate,e.in_samplerate);h>U.BPC&&(h=U.BPC);var d=Math.abs(_.resample_ratio-Math.floor(.5+_.resample_ratio))<1e-4?1:0,v=1/_.resample_ratio;v>1&&(v=1);var m=31;0==m%2&&--m;var b=(m+=d)+1;if(0==_.fill_buffer_resample_init){for(_.inbuf_old[0]=i(b),_.inbuf_old[1]=i(b),f=0;f<=2*h;++f)_.blackfilt[f]=i(b);for(_.itime[0]=0,_.itime[1]=0,p=0;p<=2*h;p++){var g=0,y=(p-h)/(2*h);for(f=0;f<=m;f++)g+=_.blackfilt[p][f]=H(f-y,v,m);for(f=0;f<=m;f++)_.blackfilt[p][f]/=g}_.fill_buffer_resample_init=1}var w=_.inbuf_old[c];for(u=0;u=o)break;y=S-_.itime[c]-(p+m%2*.5);x=0|Math.floor(2*y*h+h+.5);var k=0;for(f=0;f<=m;++f){var A=f+p-m/2;k+=(A<0?w[b+A]:a[s+A])*_.blackfilt[x][f]}t[n+u]=k}if(l.num_used=Math.min(o,m+p-m/2),_.itime[c]+=l.num_used-u*_.resample_ratio,l.num_used>=b)for(f=0;f1.0001)for(var o=0;oe-r?n:a},this.lame_init_params=function(e){var i,c,g,T=e.internal_flags;if(T.Class_ID=0,null==T.ATH&&(T.ATH=new E),null==T.PSY&&(T.PSY=new d),null==T.rgdata&&(T.rgdata=new O),T.channels_in=e.num_channels,1==T.channels_in&&(e.mode=m.MONO),T.channels_out=e.mode==m.MONO?1:2,T.mode_ext=F.MPG_MD_MS_LR,e.mode==m.MONO&&(e.force_ms=!1),e.VBR==v.vbr_off&&128!=e.VBR_mean_bitrate_kbps&&0==e.brate&&(e.brate=e.VBR_mean_bitrate_kbps),e.VBR==v.vbr_off||e.VBR==v.vbr_mtrh||e.VBR==v.vbr_mt||(e.free_format=!1),e.VBR==v.vbr_off&&0==e.brate&&k.EQ(e.compression_ratio,0)&&(e.compression_ratio=11.025),e.VBR==v.vbr_off&&e.compression_ratio>0&&(0==e.out_samplerate&&(e.out_samplerate=map2MP3Frequency(int(.97*e.in_samplerate))),e.brate=0|16*e.out_samplerate*T.channels_out/(1e3*e.compression_ratio),T.samplerate_index=S(e.out_samplerate,e),e.free_format||(e.brate=x(e.brate,e.version,e.out_samplerate))),0!=e.out_samplerate&&(e.out_samplerate<16e3?(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,64)):e.out_samplerate<32e3?(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,160)):(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,32),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,320))),0==e.lowpassfreq){var B=16e3;switch(e.VBR){case v.vbr_off:R(C=new b,e.brate),B=C.lowerlimit;break;case v.vbr_abr:var C;R(C=new b,e.VBR_mean_bitrate_kbps),B=C.lowerlimit;break;case v.vbr_rh:var L=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=e.VBR_q&&e.VBR_q<=9){var I=L[e.VBR_q],H=L[e.VBR_q+1],N=e.VBR_q_frac;B=linear_int(I,H,N)}else B=19500;break;default:L=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=e.VBR_q&&e.VBR_q<=9){I=L[e.VBR_q],H=L[e.VBR_q+1],N=e.VBR_q_frac;B=linear_int(I,H,N)}else B=19500}e.mode!=m.MONO||e.VBR!=v.vbr_off&&e.VBR!=v.vbr_abr||(B*=1.5),e.lowpassfreq=0|B}if(0==e.out_samplerate&&(2*e.lowpassfreq>e.in_samplerate&&(e.lowpassfreq=e.in_samplerate/2),e.out_samplerate=(i=0|e.lowpassfreq,c=e.in_samplerate,g=44100,c>=48e3?g=48e3:c>=44100?g=44100:c>=32e3?g=32e3:c>=24e3?g=24e3:c>=22050?g=22050:c>=16e3?g=16e3:c>=12e3?g=12e3:c>=11025?g=11025:c>=8e3&&(g=8e3),-1==i?g:(i<=15960&&(g=44100),i<=15250&&(g=32e3),i<=11220&&(g=24e3),i<=9970&&(g=22050),i<=7230&&(g=16e3),i<=5420&&(g=12e3),i<=4510&&(g=11025),i<=3970&&(g=8e3),c44100?48e3:c>32e3?44100:c>24e3?32e3:c>22050?24e3:c>16e3?22050:c>12e3?16e3:c>11025?12e3:c>8e3?11025:8e3:g))),e.lowpassfreq=Math.min(20500,e.lowpassfreq),e.lowpassfreq=Math.min(e.out_samplerate/2,e.lowpassfreq),e.VBR==v.vbr_off&&(e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.brate)),e.VBR==v.vbr_abr&&(e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.VBR_mean_bitrate_kbps)),e.bWriteVbrTag||(e.findReplayGain=!1,e.decode_on_the_fly=!1,T.findPeakSample=!1),T.findReplayGain=e.findReplayGain,T.decode_on_the_fly=e.decode_on_the_fly,T.decode_on_the_fly&&(T.findPeakSample=!0),T.findReplayGain&&t.InitGainAnalysis(T.rgdata,e.out_samplerate)==y.INIT_GAIN_ANALYSIS_ERROR)return e.internal_flags=null,-6;switch(T.decode_on_the_fly&&!e.decode_only&&(null!=T.hip&&u.hip_decode_exit(T.hip),T.hip=u.hip_decode_init()),T.mode_gr=e.out_samplerate<=24e3?1:2,e.framesize=576*T.mode_gr,e.encoder_delay=F.ENCDELAY,T.resample_ratio=e.in_samplerate/e.out_samplerate,e.VBR){case v.vbr_mt:case v.vbr_rh:case v.vbr_mtrh:e.compression_ratio=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5][e.VBR_q];break;case v.vbr_abr:e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.VBR_mean_bitrate_kbps);break;default:e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.brate)}if(e.mode==m.NOT_SET&&(e.mode=m.JOINT_STEREO),e.highpassfreq>0?(T.highpass1=2*e.highpassfreq,e.highpasswidth>=0?T.highpass2=2*(e.highpassfreq+e.highpasswidth):T.highpass2=2*e.highpassfreq,T.highpass1/=e.out_samplerate,T.highpass2/=e.out_samplerate):(T.highpass1=0,T.highpass2=0),e.lowpassfreq>0?(T.lowpass2=2*e.lowpassfreq,e.lowpasswidth>=0?(T.lowpass1=2*(e.lowpassfreq-e.lowpasswidth),T.lowpass1<0&&(T.lowpass1=0)):T.lowpass1=2*e.lowpassfreq,T.lowpass1/=e.out_samplerate,T.lowpass2/=e.out_samplerate):(T.lowpass1=0,T.lowpass2=0),function(e){var t=e.internal_flags,n=32,r=-1;if(t.lowpass1>0){for(var a=999,i=0;i<=31;i++){(c=i/31)>=t.lowpass2&&(n=Math.min(n,i)),t.lowpass10&&t.highpass2<.75/31*.9&&(t.highpass1=0,t.highpass2=0,_.err.println("Warning: highpass filter disabled. highpass frequency too small\n")),t.highpass2>0){var s=-1;for(i=0;i<=31;i++){(c=i/31)<=t.highpass1&&(r=Math.max(r,i)),t.highpass1t.highpass1?w((t.highpass2-c)/(t.highpass2-t.highpass1+1e-20)):1,l=t.lowpass2>t.lowpass1?w((c-t.lowpass1)/(t.lowpass2-t.lowpass1+1e-20)):1,t.amp_filter[i]=o*l}}(e),T.samplerate_index=S(e.out_samplerate,e),T.samplerate_index<0)return e.internal_flags=null,-1;if(e.VBR==v.vbr_off){if(e.free_format)T.bitrate_index=0;else if(e.brate=x(e.brate,e.version,e.out_samplerate),T.bitrate_index=A(e.brate,e.version,e.out_samplerate),T.bitrate_index<=0)return e.internal_flags=null,-1}else T.bitrate_index=1;e.analysis&&(e.bWriteVbrTag=!1),null!=T.pinfo&&(e.bWriteVbrTag=!1),n.init_bit_stream_w(T);for(var $,D=T.samplerate_index+3*e.version+6*(e.out_samplerate<16e3?1:0),j=0;j5&&(e.quality=5),T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,e.experimentalY?T.sfb21_extra=!1:T.sfb21_extra=e.out_samplerate>44e3,T.iteration_loop=new VBRNewIterationLoop(s);break;case v.vbr_rh:r.apply_preset(e,500-10*e.VBR_q,0),T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,e.experimentalY?T.sfb21_extra=!1:T.sfb21_extra=e.out_samplerate>44e3,e.quality>6&&(e.quality=6),e.quality<0&&(e.quality=LAME_DEFAULT_QUALITY),T.iteration_loop=new VBROldIterationLoop(s);break;default:var Y;T.sfb21_extra=!1,e.quality<0&&(e.quality=LAME_DEFAULT_QUALITY),(Y=e.VBR)==v.vbr_off&&(e.VBR_mean_bitrate_kbps=e.brate),r.apply_preset(e,e.VBR_mean_bitrate_kbps,0),e.VBR=Y,T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,Y==v.vbr_off?T.iteration_loop=new P(s):T.iteration_loop=new ABRIterationLoop(s)}if(e.VBR!=v.vbr_off){if(T.VBR_min_bitrate=1,T.VBR_max_bitrate=14,e.out_samplerate<16e3&&(T.VBR_max_bitrate=8),0!=e.VBR_min_bitrate_kbps&&(e.VBR_min_bitrate_kbps=x(e.VBR_min_bitrate_kbps,e.version,e.out_samplerate),T.VBR_min_bitrate=A(e.VBR_min_bitrate_kbps,e.version,e.out_samplerate),T.VBR_min_bitrate<0))return-1;if(0!=e.VBR_max_bitrate_kbps&&(e.VBR_max_bitrate_kbps=x(e.VBR_max_bitrate_kbps,e.version,e.out_samplerate),T.VBR_max_bitrate=A(e.VBR_max_bitrate_kbps,e.version,e.out_samplerate),T.VBR_max_bitrate<0))return-1;e.VBR_min_bitrate_kbps=M.bitrate_table[e.version][T.VBR_min_bitrate],e.VBR_max_bitrate_kbps=M.bitrate_table[e.version][T.VBR_max_bitrate],e.VBR_mean_bitrate_kbps=Math.min(M.bitrate_table[e.version][T.VBR_max_bitrate],e.VBR_mean_bitrate_kbps),e.VBR_mean_bitrate_kbps=Math.max(M.bitrate_table[e.version][T.VBR_min_bitrate],e.VBR_mean_bitrate_kbps)}return e.tune&&(T.PSY.mask_adjust+=e.tune_value_a,T.PSY.mask_adjust_short+=e.tune_value_a),function(e){var t=e.internal_flags;switch(e.quality){default:case 9:t.psymodel=0,t.noise_shaping=0,t.noise_shaping_amp=0,t.noise_shaping_stop=0,t.use_best_huffman=0,t.full_outer_loop=0;break;case 8:e.quality=7;case 7:t.psymodel=1,t.noise_shaping=0,t.noise_shaping_amp=0,t.noise_shaping_stop=0,t.use_best_huffman=0,t.full_outer_loop=0;break;case 6:case 5:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=0,t.noise_shaping_stop=0,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=0,t.full_outer_loop=0;break;case 4:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=0,t.noise_shaping_stop=0,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 3:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=1,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 2:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),0==t.substep_shaping&&(t.substep_shaping=2),t.noise_shaping_amp=1,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 1:case 0:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),0==t.substep_shaping&&(t.substep_shaping=2),t.noise_shaping_amp=2,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0}}(e),e.athaa_type<0?T.ATH.useAdjust=3:T.ATH.useAdjust=e.athaa_type,T.ATH.aaSensitivityP=Math.pow(10,e.athaa_sensitivity/-10),null==e.short_blocks&&(e.short_blocks=h.short_block_allowed),e.short_blocks!=h.short_block_allowed||e.mode!=m.JOINT_STEREO&&e.mode!=m.STEREO||(e.short_blocks=h.short_block_coupled),e.quant_comp<0&&(e.quant_comp=1),e.quant_comp_short<0&&(e.quant_comp_short=0),e.msfix<0&&(e.msfix=0),e.exp_nspsytune=1|e.exp_nspsytune,e.internal_flags.nsPsy.attackthre<0&&(e.internal_flags.nsPsy.attackthre=Z.NSATTACKTHRE),e.internal_flags.nsPsy.attackthre_s<0&&(e.internal_flags.nsPsy.attackthre_s=Z.NSATTACKTHRE_S),e.scale<0&&(e.scale=1),e.ATHtype<0&&(e.ATHtype=4),e.ATHcurve<0&&(e.ATHcurve=4),e.athaa_loudapprox<0&&(e.athaa_loudapprox=2),e.interChRatio<0&&(e.interChRatio=0),null==e.useTemporal&&(e.useTemporal=!0),T.slot_lag=T.frac_SpF=0,e.VBR==v.vbr_off&&(T.slot_lag=T.frac_SpF=72e3*(e.version+1)*e.brate%e.out_samplerate|0),a.iteration_init(e),p.psymodel_init(e),0},this.lame_encode_flush=function(e,t,r,a){var i,s,o,l,u=e.internal_flags,_=c([2,1152]),p=0,h=u.mf_samples_to_encode-F.POSTDELAY,d=T(e);if(u.mf_samples_to_encode<1)return 0;for(i=0,e.in_samplerate!=e.out_samplerate&&(h+=16*e.out_samplerate/e.in_samplerate),(o=e.framesize-h%e.framesize)<576&&(o+=e.framesize),e.encoder_padding=o,l=(h+o)/e.framesize;l>0&&p>=0;){var v=d-u.mf_size,m=e.frameNum;v*=e.in_samplerate,(v/=e.out_samplerate)>1152&&(v=1152),v<1&&(v=1),s=a-i,0==a&&(s=0),r+=p=this.lame_encode_buffer(e,_[0],_[1],v,t,r,s),i+=p,l-=m!=e.frameNum?1:0}if(u.mf_samples_to_encode=0,p<0)return p;if(s=a-i,0==a&&(s=0),n.flush_bitstream(e),(p=n.copy_buffer(u,t,r,s,1))<0)return p;if(r+=p,s=a-(i+=p),0==a&&(s=0),e.write_id3tag_automatic){if(f.id3tag_write_v1(e),(p=n.copy_buffer(u,t,r,s,0))<0)return p;i+=p}return i},this.lame_encode_buffer=function(e,r,a,s,o,l,c){var f=e.internal_flags,u=[null,null];if(4294479419!=f.Class_ID)return-3;if(0==s)return 0;!function(e,t){(null==e.in_buffer_0||e.in_buffer_nsamples1&&(u[1][_]=a[_]);return function(e,r,a,i,s,o,l){var c,f,u,_,p,h=e.internal_flags,d=0,v=[null,null],m=[null,null];if(4294479419!=h.Class_ID)return-3;if(0==i)return 0;if((p=n.copy_buffer(h,s,o,l,0))<0)return p;if(o+=p,d+=p,m[0]=r,m[1]=a,k.NEQ(e.scale,0)&&k.NEQ(e.scale,1))for(f=0;f0;){var g,w,S=[null,null];S[0]=m[0],S[1]=m[1];var x=new L;if($(e,v,S,b,i,x),g=x.n_in,w=x.n_out,h.findReplayGain&&!h.decode_on_the_fly&&t.AnalyzeSamples(h.rgdata,v[0],h.mf_size,v[1],h.mf_size,w,h.channels_out)==y.GAIN_ANALYSIS_ERROR)return-6;if(i-=g,b+=g,h.channels_out,h.mf_size+=w,h.mf_samples_to_encode<1&&(h.mf_samples_to_encode=F.ENCDELAY+F.POSTDELAY),h.mf_samples_to_encode+=w,h.mf_size>=_){var A=l-d;if(0==l&&(A=0),(c=B(e,v[0],v[1],s,o,A))<0)return c;for(o+=c,d+=c,h.mf_size-=e.framesize,h.mf_samples_to_encode-=e.framesize,u=0;uR&&(R=t.length,B=n(T=0|1.25*R+7200));var i=a.lame_encode_buffer(M,t,r,t.length,B,0,T);return new Int8Array(B.subarray(0,i))},this.flush=function(){var e=a.lame_encode_flush(M,B,0,T);return new Int8Array(B.subarray(0,e))}}}e(),Recorder.lamejs=e}()},function(e,t,n){"use strict";var r=n(5);n.n(r).a},function(e,t,n){(e.exports=n(15)(!1)).push([e.i,"\nbody{\r\n word-wrap: break-word;\r\n background:#f5f5f5 center top no-repeat;\r\n background-size: auto 680px;\n}\npre{\r\n white-space:pre-wrap;\n}\na{\r\n text-decoration: none;\r\n color:#06c;\n}\na:hover{\r\n color:#f00;\n}\n.main{\r\n max-width:700px;\r\n margin:0 auto;\r\n padding-bottom:80px\n}\n.mainBox{\r\n margin-top:12px;\r\n padding: 12px;\r\n border-radius: 6px;\r\n background: #fff;\r\n --border: 1px solid #0b1;\r\n box-shadow: 2px 2px 3px #aaa;\n}\n.btns button{\r\n display: inline-block;\r\n cursor: pointer;\r\n border: none;\r\n border-radius: 3px;\r\n background: #0b1;\r\n color:#fff;\r\n padding: 0 15px;\r\n margin:3px 20px 3px 0;\r\n line-height: 36px;\r\n height: 36px;\r\n overflow: hidden;\r\n vertical-align: middle;\n}\n.btns button:active{\r\n background: #0a1;\n}\n.pd{\r\n\tpadding:0 0 6px 0;\n}\n.lb{\r\n\tdisplay:inline-block;\r\n\tvertical-align: middle;\r\n\tbackground:#00940e;\r\n\tcolor:#fff;\r\n\tfont-size:14px;\r\n\tpadding:2px 8px;\r\n\tborder-radius: 99px;\n}\r\n",""])}]); \ No newline at end of file + */function i(e){return null==e}function s(e){return null!=e}function o(e){return!0===e}function l(e){return"string"==typeof e||"number"==typeof e||"symbol"===(void 0===e?"undefined":r(e))||"boolean"==typeof e}function c(e){return null!==e&&"object"===(void 0===e?"undefined":r(e))}var f=Object.prototype.toString;function u(e){return"[object Object]"===f.call(e)}function _(e){return"[object RegExp]"===f.call(e)}function p(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function h(e){return s(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function d(e){return null==e?"":Array.isArray(e)||u(e)&&e.toString===f?JSON.stringify(e,null,2):String(e)}function v(e){var t=parseFloat(e);return isNaN(t)?e:t}function m(e,t){for(var n=Object.create(null),r=e.split(","),a=0;a-1)return e.splice(n,1)}}var w=Object.prototype.hasOwnProperty;function S(e,t){return w.call(e,t)}function x(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var k=/-(\w)/g,A=x((function(e){return e.replace(k,(function(e,t){return t?t.toUpperCase():""}))})),M=x((function(e){return e.charAt(0).toUpperCase()+e.slice(1)})),R=/\B([A-Z])/g,T=x((function(e){return e.replace(R,"-$1").toLowerCase()}));var B=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function E(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function C(e,t){for(var n in t)e[n]=t[n];return e}function P(e){for(var t={},n=0;n0,ee=G&&G.indexOf("edge/")>0,te=(G&&G.indexOf("android"),G&&/iphone|ipad|ipod|ios/.test(G)||"ios"===Z),ne=(G&&/chrome\/\d+/.test(G),G&&/phantomjs/.test(G),G&&G.match(/firefox\/(\d+)/)),re={}.watch,ae=!1;if(K)try{var ie={};Object.defineProperty(ie,"passive",{get:function(){ae=!0}}),window.addEventListener("test-passive",null,ie)}catch(e){}var se=function(){return void 0===z&&(z=!K&&!W&&void 0!==e&&(e.process&&"server"===e.process.env.VUE_ENV)),z},oe=K&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function le(e){return"function"==typeof e&&/native code/.test(e.toString())}var ce,fe="undefined"!=typeof Symbol&&le(Symbol)&&"undefined"!=typeof Reflect&&le(Reflect.ownKeys);ce="undefined"!=typeof Set&&le(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var ue=O,_e=0,pe=function(){this.id=_e++,this.subs=[]};pe.prototype.addSub=function(e){this.subs.push(e)},pe.prototype.removeSub=function(e){y(this.subs,e)},pe.prototype.depend=function(){pe.target&&pe.target.addDep(this)},pe.prototype.notify=function(){var e=this.subs.slice();for(var t=0,n=e.length;t-1)if(i&&!S(a,"default"))s=!1;else if(""===s||s===T(e)){var l=Ye(String,a.type);(l<0||o0&&(pt((a=e(a,(n||"")+"_"+r))[0])&&pt(f)&&(u[c]=ye(f.text+a[0].text),a.shift()),u.push.apply(u,a)):l(a)?pt(f)?u[c]=ye(f.text+a):""!==a&&u.push(ye(a)):pt(a)&&pt(f)?u[c]=ye(f.text+a.text):(o(t._isVList)&&s(a.tag)&&i(a.key)&&s(n)&&(a.key="__vlist"+n+"_"+r+"__"),u.push(a)));return u}(e):void 0}function pt(e){return s(e)&&s(e.text)&&!1===e.isComment}function ht(e,t){if(e){for(var n=Object.create(null),r=fe?Reflect.ownKeys(e):Object.keys(e),a=0;a0,s=e?!!e.$stable:!i,o=e&&e.$key;if(e){if(e._normalized)return e._normalized;if(s&&n&&n!==a&&o===n.$key&&!i&&!n.$hasNormal)return n;for(var l in r={},e)e[l]&&"$"!==l[0]&&(r[l]=bt(t,l,e[l]))}else r={};for(var c in t)c in r||(r[c]=gt(t,c));return e&&Object.isExtensible(e)&&(e._normalized=r),Y(r,"$stable",s),Y(r,"$key",o),Y(r,"$hasNormal",i),r}function bt(e,t,n){var a=function(){var e=arguments.length?n.apply(null,arguments):n({});return(e=e&&"object"===(void 0===e?"undefined":r(e))&&!Array.isArray(e)?[e]:_t(e))&&(0===e.length||1===e.length&&e[0].isComment)?void 0:e};return n.proxy&&Object.defineProperty(e,t,{get:a,enumerable:!0,configurable:!0}),a}function gt(e,t){return function(){return e[t]}}function yt(e,t){var n,r,a,i,o;if(Array.isArray(e)||"string"==typeof e)for(n=new Array(e.length),r=0,a=e.length;rdocument.createEvent("Event").timeStamp&&(un=function(){return _n.now()})}function pn(){var e,t;for(fn=un(),ln=!0,rn.sort((function(e,t){return e.id-t.id})),cn=0;cncn&&rn[n].id>e.id;)n--;rn.splice(n+1,0,e)}else rn.push(e);on||(on=!0,at(pn))}}(this)},dn.prototype.run=function(){if(this.active){var e=this.get();if(e!==this.value||c(e)||this.deep){var t=this.value;if(this.value=e,this.user)try{this.cb.call(this.vm,e,t)}catch(e){Xe(e,this.vm,'callback for watcher "'+this.expression+'"')}else this.cb.call(this.vm,e,t)}}},dn.prototype.evaluate=function(){this.value=this.get(),this.dirty=!1},dn.prototype.depend=function(){for(var e=this.deps.length;e--;)this.deps[e].depend()},dn.prototype.teardown=function(){if(this.active){this.vm._isBeingDestroyed||y(this.vm._watchers,this);for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1}};var vn={enumerable:!0,configurable:!0,get:O,set:O};function mn(e,t,n){vn.get=function(){return this[t][n]},vn.set=function(e){this[t][n]=e},Object.defineProperty(e,n,vn)}function bn(e){e._watchers=[];var t=e.$options;t.props&&function(e,t){var n=e.$options.propsData||{},r=e._props={},a=e.$options._propKeys=[];e.$parent&&Me(!1);var i=function(i){a.push(i);var s=Ve(i,t,n,e);Be(r,i,s),i in e||mn(e,"_props",i)};for(var s in t)i(s);Me(!0)}(e,t.props),t.methods&&function(e,t){e.$options.props;for(var n in t)e[n]="function"!=typeof t[n]?O:B(t[n],e)}(e,t.methods),t.data?function(e){var t=e.$options.data;u(t=e._data="function"==typeof t?function(e,t){de();try{return e.call(t,t)}catch(e){return Xe(e,t,"data()"),{}}finally{ve()}}(t,e):t||{})||(t={});var n=Object.keys(t),r=e.$options.props,a=(e.$options.methods,n.length);for(;a--;){var i=n[a];0,r&&S(r,i)||q(i)||mn(e,"_data",i)}Te(t,!0)}(e):Te(e._data={},!0),t.computed&&function(e,t){var n=e._computedWatchers=Object.create(null),r=se();for(var a in t){var i=t[a],s="function"==typeof i?i:i.get;0,r||(n[a]=new dn(e,s||O,O,gn)),a in e||yn(e,a,i)}}(e,t.computed),t.watch&&t.watch!==re&&function(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var a=0;a-1:"string"==typeof e?e.split(",").indexOf(t)>-1:!!_(e)&&e.test(t)}function En(e,t){var n=e.cache,r=e.keys,a=e._vnode;for(var i in n){var s=n[i];if(s){var o=Tn(s.componentOptions);o&&!t(o)&&Cn(n,i,r,a)}}}function Cn(e,t,n,r){var a=e[t];!a||r&&a.tag===r.tag||a.componentInstance.$destroy(),e[t]=null,y(n,t)}!function(e){e.prototype._init=function(e){var t=this;t._uid=kn++,t._isVue=!0,e&&e._isComponent?function(e,t){var n=e.$options=Object.create(e.constructor.options),r=t._parentVnode;n.parent=t.parent,n._parentVnode=r;var a=r.componentOptions;n.propsData=a.propsData,n._parentListeners=a.listeners,n._renderChildren=a.children,n._componentTag=a.tag,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}(t,e):t.$options=De(An(t.constructor),e||{},t),t._renderProxy=t,t._self=t,function(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}(t),function(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&Gt(e,t)}(t),function(e){e._vnode=null,e._staticTrees=null;var t=e.$options,n=e.$vnode=t._parentVnode,r=n&&n.context;e.$slots=dt(t._renderChildren,r),e.$scopedSlots=a,e._c=function(t,n,r,a){return Ft(e,t,n,r,a,!1)},e.$createElement=function(t,n,r,a){return Ft(e,t,n,r,a,!0)};var i=n&&n.data;Be(e,"$attrs",i&&i.attrs||a,null,!0),Be(e,"$listeners",t._parentListeners||a,null,!0)}(t),nn(t,"beforeCreate"),function(e){var t=ht(e.$options.inject,e);t&&(Me(!1),Object.keys(t).forEach((function(n){Be(e,n,t[n])})),Me(!0))}(t),bn(t),function(e){var t=e.$options.provide;t&&(e._provided="function"==typeof t?t.call(e):t)}(t),nn(t,"created"),t.$options.el&&t.$mount(t.$options.el)}}(Mn),function(e){var t={get:function(){return this._data}},n={get:function(){return this._props}};Object.defineProperty(e.prototype,"$data",t),Object.defineProperty(e.prototype,"$props",n),e.prototype.$set=Ee,e.prototype.$delete=Ce,e.prototype.$watch=function(e,t,n){if(u(t))return xn(this,e,t,n);(n=n||{}).user=!0;var r=new dn(this,e,t,n);if(n.immediate)try{t.call(this,r.value)}catch(e){Xe(e,this,'callback for immediate watcher "'+r.expression+'"')}return function(){r.teardown()}}}(Mn),function(e){var t=/^hook:/;e.prototype.$on=function(e,n){var r=this;if(Array.isArray(e))for(var a=0,i=e.length;a1?E(n):n;for(var r=E(arguments,1),a='event handler for "'+e+'"',i=0,s=n.length;iparseInt(this.max)&&Cn(s,o[0],o,this._vnode)),t.data.keepAlive=!0}return t||e&&e[0]}}};!function(e){var t={get:function(){return V}};Object.defineProperty(e,"config",t),e.util={warn:ue,extend:C,mergeOptions:De,defineReactive:Be},e.set=Ee,e.delete=Ce,e.nextTick=at,e.observable=function(e){return Te(e),e},e.options=Object.create(null),D.forEach((function(t){e.options[t+"s"]=Object.create(null)})),e.options._base=e,C(e.options.components,On),function(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=E(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}(e),function(e){e.mixin=function(e){return this.options=De(this.options,e),this}}(e),Rn(e),function(e){D.forEach((function(t){e[t]=function(e,n){return n?("component"===t&&u(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}}))}(e)}(Mn),Object.defineProperty(Mn.prototype,"$isServer",{get:se}),Object.defineProperty(Mn.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Object.defineProperty(Mn,"FunctionalRenderContext",{value:It}),Mn.version="2.6.10";var Ln=m("style,class"),In=m("input,textarea,option,select,progress"),Hn=function(e,t,n){return"value"===n&&In(e)&&"button"!==t||"selected"===n&&"option"===e||"checked"===n&&"input"===e||"muted"===n&&"video"===e},Nn=m("contenteditable,draggable,spellcheck"),$n=m("events,caret,typing,plaintext-only"),Dn=m("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),jn="http://www.w3.org/1999/xlink",Vn=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},Fn=function(e){return Vn(e)?e.slice(6,e.length):""},qn=function(e){return null==e||!1===e};function Yn(e){for(var t=e.data,n=e,r=e;s(r.componentInstance);)(r=r.componentInstance._vnode)&&r.data&&(t=Xn(r.data,t));for(;s(n=n.parent);)n&&n.data&&(t=Xn(t,n.data));return function(e,t){if(s(e)||s(t))return zn(e,Un(t));return""}(t.staticClass,t.class)}function Xn(e,t){return{staticClass:zn(e.staticClass,t.staticClass),class:s(e.class)?[e.class,t.class]:t.class}}function zn(e,t){return e?t?e+" "+t:e:t||""}function Un(e){return Array.isArray(e)?function(e){for(var t,n="",r=0,a=e.length;r-1?br(e,t,n):Dn(t)?qn(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Nn(t)?e.setAttribute(t,function(e,t){return qn(t)||"false"===t?"false":"contenteditable"===e&&$n(t)?t:"true"}(t,n)):Vn(t)?qn(n)?e.removeAttributeNS(jn,Fn(t)):e.setAttributeNS(jn,t,n):br(e,t,n)}function br(e,t,n){if(qn(n))e.removeAttribute(t);else{if(Q&&!J&&"TEXTAREA"===e.tagName&&"placeholder"===t&&""!==n&&!e.__ieph){e.addEventListener("input",(function t(n){n.stopImmediatePropagation(),e.removeEventListener("input",t)})),e.__ieph=!0}e.setAttribute(t,n)}}var gr={create:vr,update:vr};function yr(e,t){var n=t.elm,r=t.data,a=e.data;if(!(i(r.staticClass)&&i(r.class)&&(i(a)||i(a.staticClass)&&i(a.class)))){var o=Yn(t),l=n._transitionClasses;s(l)&&(o=zn(o,Un(l))),o!==n._prevClass&&(n.setAttribute("class",o),n._prevClass=o)}}var wr,Sr,xr,kr,Ar,Mr,Rr={create:yr,update:yr},Tr=/[\w).+\-_$\]]/;function Br(e){var t,n,r,a,i,s=!1,o=!1,l=!1,c=!1,f=0,u=0,_=0,p=0;for(r=0;r=0&&" "===(d=e.charAt(h));h--);d&&Tr.test(d)||(c=!0)}}else void 0===a?(p=r+1,a=e.slice(0,r).trim()):v();function v(){(i||(i=[])).push(e.slice(p,r).trim()),p=r+1}if(void 0===a?a=e.slice(0,r).trim():0!==p&&v(),i)for(r=0;r-1?{exp:e.slice(0,kr),key:'"'+e.slice(kr+1)+'"'}:{exp:e,key:null};Sr=e,kr=Ar=Mr=0;for(;!zr();)Ur(xr=Xr())?Wr(xr):91===xr&&Kr(xr);return{exp:e.slice(0,Ar),key:e.slice(Ar+1,Mr)}}(e);return null===n.key?e+"="+t:"$set("+n.exp+", "+n.key+", "+t+")"}function Xr(){return Sr.charCodeAt(++kr)}function zr(){return kr>=wr}function Ur(e){return 34===e||39===e}function Kr(e){var t=1;for(Ar=kr;!zr();)if(Ur(e=Xr()))Wr(e);else if(91===e&&t++,93===e&&t--,0===t){Mr=kr;break}}function Wr(e){for(var t=e;!zr()&&(e=Xr())!==t;);}var Zr;function Gr(e,t,n){var r=Zr;return function a(){var i=t.apply(null,arguments);null!==i&&ea(e,a,n,r)}}var Qr=Ze&&!(ne&&Number(ne[1])<=53);function Jr(e,t,n,r){if(Qr){var a=fn,i=t;t=i._wrapper=function(e){if(e.target===e.currentTarget||e.timeStamp>=a||e.timeStamp<=0||e.target.ownerDocument!==document)return i.apply(this,arguments)}}Zr.addEventListener(e,t,ae?{capture:n,passive:r}:n)}function ea(e,t,n,r){(r||Zr).removeEventListener(e,t._wrapper||t,n)}function ta(e,t){if(!i(e.data.on)||!i(t.data.on)){var n=t.data.on||{},r=e.data.on||{};Zr=t.elm,function(e){if(s(e.__r)){var t=Q?"change":"input";e[t]=[].concat(e.__r,e[t]||[]),delete e.__r}s(e.__c)&&(e.change=[].concat(e.__c,e.change||[]),delete e.__c)}(n),ct(n,r,Jr,ea,Gr,t.context),Zr=void 0}}var na,ra={create:ta,update:ta};function aa(e,t){if(!i(e.data.domProps)||!i(t.data.domProps)){var n,r,a=t.elm,o=e.data.domProps||{},l=t.data.domProps||{};for(n in s(l.__ob__)&&(l=t.data.domProps=C({},l)),o)n in l||(a[n]="");for(n in l){if(r=l[n],"textContent"===n||"innerHTML"===n){if(t.children&&(t.children.length=0),r===o[n])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===n&&"PROGRESS"!==a.tagName){a._value=r;var c=i(r)?"":String(r);ia(a,c)&&(a.value=c)}else if("innerHTML"===n&&Zn(a.tagName)&&i(a.innerHTML)){(na=na||document.createElement("div")).innerHTML=""+r+"";for(var f=na.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;f.firstChild;)a.appendChild(f.firstChild)}else if(r!==o[n])try{a[n]=r}catch(e){}}}}function ia(e,t){return!e.composing&&("OPTION"===e.tagName||function(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}(e,t)||function(e,t){var n=e.value,r=e._vModifiers;if(s(r)){if(r.number)return v(n)!==v(t);if(r.trim)return n.trim()!==t.trim()}return n!==t}(e,t))}var sa={create:aa,update:aa},oa=x((function(e){var t={},n=/:(.+)/;return e.split(/;(?![^(]*\))/g).forEach((function(e){if(e){var r=e.split(n);r.length>1&&(t[r[0].trim()]=r[1].trim())}})),t}));function la(e){var t=ca(e.style);return e.staticStyle?C(e.staticStyle,t):t}function ca(e){return Array.isArray(e)?P(e):"string"==typeof e?oa(e):e}var fa,ua=/^--/,_a=/\s*!important$/,pa=function(e,t,n){if(ua.test(t))e.style.setProperty(t,n);else if(_a.test(n))e.style.setProperty(T(t),n.replace(_a,""),"important");else{var r=da(t);if(Array.isArray(n))for(var a=0,i=n.length;a-1?t.split(ba).forEach((function(t){return e.classList.add(t)})):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function ya(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(ba).forEach((function(t){return e.classList.remove(t)})):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");(n=n.trim())?e.setAttribute("class",n):e.removeAttribute("class")}}function wa(e){if(e){if("object"===(void 0===e?"undefined":r(e))){var t={};return!1!==e.css&&C(t,Sa(e.name||"v")),C(t,e),t}return"string"==typeof e?Sa(e):void 0}}var Sa=x((function(e){return{enterClass:e+"-enter",enterToClass:e+"-enter-to",enterActiveClass:e+"-enter-active",leaveClass:e+"-leave",leaveToClass:e+"-leave-to",leaveActiveClass:e+"-leave-active"}})),xa=K&&!J,ka="transition",Aa="transitionend",Ma="animation",Ra="animationend";xa&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(ka="WebkitTransition",Aa="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(Ma="WebkitAnimation",Ra="webkitAnimationEnd"));var Ta=K?window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout:function(e){return e()};function Ba(e){Ta((function(){Ta(e)}))}function Ea(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),ga(e,t))}function Ca(e,t){e._transitionClasses&&y(e._transitionClasses,t),ya(e,t)}function Pa(e,t,n){var r=La(e,t),a=r.type,i=r.timeout,s=r.propCount;if(!a)return n();var o="transition"===a?Aa:Ra,l=0,c=function(){e.removeEventListener(o,f),n()},f=function(t){t.target===e&&++l>=s&&c()};setTimeout((function(){l0&&(n="transition",f=s,u=i.length):"animation"===t?c>0&&(n="animation",f=c,u=l.length):u=(n=(f=Math.max(s,c))>0?s>c?"transition":"animation":null)?"transition"===n?i.length:l.length:0,{type:n,timeout:f,propCount:u,hasTransform:"transition"===n&&Oa.test(r[ka+"Property"])}}function Ia(e,t){for(;e.length1}function Va(e,t){!0!==t.data.show&&Na(t)}var Fa=function(e){var t,n,r={},a=e.modules,c=e.nodeOps;for(t=0;th?g(e,i(n[m+1])?null:n[m+1].elm,n,p,m,r):p>m&&w(0,t,_,h)}(_,v,m,n,f):s(m)?(s(e.text)&&c.setTextContent(_,""),g(_,null,m,0,m.length-1,n)):s(v)?w(0,v,0,v.length-1):s(e.text)&&c.setTextContent(_,""):e.text!==t.text&&c.setTextContent(_,t.text),s(h)&&s(p=h.hook)&&s(p=p.postpatch)&&p(e,t)}}}function A(e,t,n){if(o(n)&&s(e.parent))e.parent.data.pendingInsert=t;else for(var r=0;r-1,s.selected!==i&&(s.selected=i);else if(H(Ua(s),r))return void(e.selectedIndex!==o&&(e.selectedIndex=o));a||(e.selectedIndex=-1)}}function za(e,t){return t.every((function(t){return!H(t,e)}))}function Ua(e){return"_value"in e?e._value:e.value}function Ka(e){e.target.composing=!0}function Wa(e){e.target.composing&&(e.target.composing=!1,Za(e.target,"input"))}function Za(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Ga(e){return!e.componentInstance||e.data&&e.data.transition?e:Ga(e.componentInstance._vnode)}var Qa={model:qa,show:{bind:function(e,t,n){var r=t.value,a=(n=Ga(n)).data&&n.data.transition,i=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&a?(n.data.show=!0,Na(n,(function(){e.style.display=i}))):e.style.display=r?i:"none"},update:function(e,t,n){var r=t.value;!r!=!t.oldValue&&((n=Ga(n)).data&&n.data.transition?(n.data.show=!0,r?Na(n,(function(){e.style.display=e.__vOriginalDisplay})):$a(n,(function(){e.style.display="none"}))):e.style.display=r?e.__vOriginalDisplay:"none")},unbind:function(e,t,n,r,a){a||(e.style.display=e.__vOriginalDisplay)}}},Ja={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]};function ei(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?ei(Ut(t.children)):e}function ti(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var a=n._parentListeners;for(var i in a)t[A(i)]=a[i];return t}function ni(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}var ri=function(e){return e.tag||zt(e)},ai=function(e){return"show"===e.name},ii={name:"transition",props:Ja,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(ri)).length){0;var r=this.mode;0;var a=n[0];if(function(e){for(;e=e.parent;)if(e.data.transition)return!0}(this.$vnode))return a;var i=ei(a);if(!i)return a;if(this._leaving)return ni(e,a);var s="__transition-"+this._uid+"-";i.key=null==i.key?i.isComment?s+"comment":s+i.tag:l(i.key)?0===String(i.key).indexOf(s)?i.key:s+i.key:i.key;var o=(i.data||(i.data={})).transition=ti(this),c=this._vnode,f=ei(c);if(i.data.directives&&i.data.directives.some(ai)&&(i.data.show=!0),f&&f.data&&!function(e,t){return t.key===e.key&&t.tag===e.tag}(i,f)&&!zt(f)&&(!f.componentInstance||!f.componentInstance._vnode.isComment)){var u=f.data.transition=C({},o);if("out-in"===r)return this._leaving=!0,ft(u,"afterLeave",(function(){t._leaving=!1,t.$forceUpdate()})),ni(e,a);if("in-out"===r){if(zt(i))return c;var _,p=function(){_()};ft(o,"afterEnter",p),ft(o,"enterCancelled",p),ft(u,"delayLeave",(function(e){_=e}))}}return a}}},si=C({tag:String,moveClass:String},Ja);function oi(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function li(e){e.data.newPos=e.elm.getBoundingClientRect()}function ci(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,a=t.top-n.top;if(r||a){e.data.moved=!0;var i=e.elm.style;i.transform=i.WebkitTransform="translate("+r+"px,"+a+"px)",i.transitionDuration="0s"}}delete si.mode;var fi={Transition:ii,TransitionGroup:{props:si,beforeMount:function(){var e=this,t=this._update;this._update=function(n,r){var a=Jt(e);e.__patch__(e._vnode,e.kept,!1,!0),e._vnode=e.kept,a(),t.call(e,n,r)}},render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,a=this.$slots.default||[],i=this.children=[],s=ti(this),o=0;o-1?Jn[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:Jn[e]=/HTMLUnknownElement/.test(t.toString())},C(Mn.options.directives,Qa),C(Mn.options.components,fi),Mn.prototype.__patch__=K?Fa:O,Mn.prototype.$mount=function(e,t){return function(e,t,n){var r;return e.$el=t,e.$options.render||(e.$options.render=ge),nn(e,"beforeMount"),r=function(){e._update(e._render(),n)},new dn(e,r,O,{before:function(){e._isMounted&&!e._isDestroyed&&nn(e,"beforeUpdate")}},!0),n=!1,null==e.$vnode&&(e._isMounted=!0,nn(e,"mounted")),e}(this,e=e&&K?tr(e):void 0,t)},K&&setTimeout((function(){V.devtools&&oe&&oe.emit("init",Mn)}),0);var ui=/\{\{((?:.|\r?\n)+?)\}\}/g,_i=/[-.*+?^${}()|[\]\/\\]/g,pi=x((function(e){var t=e[0].replace(_i,"\\$&"),n=e[1].replace(_i,"\\$&");return new RegExp(t+"((?:.|\\n)+?)"+n,"g")}));var hi={staticKeys:["staticClass"],transformNode:function(e,t){t.warn;var n=jr(e,"class");n&&(e.staticClass=JSON.stringify(n));var r=Dr(e,"class",!1);r&&(e.classBinding=r)},genData:function(e){var t="";return e.staticClass&&(t+="staticClass:"+e.staticClass+","),e.classBinding&&(t+="class:"+e.classBinding+","),t}};var di,vi={staticKeys:["staticStyle"],transformNode:function(e,t){t.warn;var n=jr(e,"style");n&&(e.staticStyle=JSON.stringify(oa(n)));var r=Dr(e,"style",!1);r&&(e.styleBinding=r)},genData:function(e){var t="";return e.staticStyle&&(t+="staticStyle:"+e.staticStyle+","),e.styleBinding&&(t+="style:("+e.styleBinding+"),"),t}},mi=function(e){return(di=di||document.createElement("div")).innerHTML=e,di.textContent},bi=m("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),gi=m("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),yi=m("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),wi=/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,Si=/^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,xi="[a-zA-Z_][\\-\\.0-9_a-zA-Z"+F.source+"]*",ki="((?:"+xi+"\\:)?"+xi+")",Ai=new RegExp("^<"+ki),Mi=/^\s*(\/?)>/,Ri=new RegExp("^<\\/"+ki+"[^>]*>"),Ti=/^]+>/i,Bi=/^",""":'"',"&":"&"," ":"\n"," ":"\t","'":"'"},Li=/&(?:lt|gt|quot|amp|#39);/g,Ii=/&(?:lt|gt|quot|amp|#39|#10|#9);/g,Hi=m("pre,textarea",!0),Ni=function(e,t){return e&&Hi(e)&&"\n"===t[0]};function $i(e,t){var n=t?Ii:Li;return e.replace(n,(function(e){return Oi[e]}))}var Di,ji,Vi,Fi,qi,Yi,Xi,zi,Ui=/^@|^v-on:/,Ki=/^v-|^@|^:/,Wi=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,Zi=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Gi=/^\(|\)$/g,Qi=/^\[.*\]$/,Ji=/:(.*)$/,es=/^:|^\.|^v-bind:/,ts=/\.[^.\]]+(?=[^\]]*$)/g,ns=/^v-slot(:|$)|^#/,rs=/[\r\n]/,as=/\s+/g,is=x(mi);function ss(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:ps(t),rawAttrsMap:{},parent:n,children:[]}}function os(e,t){Di=t.warn||Cr,Yi=t.isPreTag||L,Xi=t.mustUseProp||L,zi=t.getTagNamespace||L;var n=t.isReservedTag||L;(function(e){return!!e.component||!n(e.tag)}),Vi=Pr(t.modules,"transformNode"),Fi=Pr(t.modules,"preTransformNode"),qi=Pr(t.modules,"postTransformNode"),ji=t.delimiters;var r,a,i=[],s=!1!==t.preserveWhitespace,o=t.whitespace,l=!1,c=!1;function f(e){if(u(e),l||e.processed||(e=ls(e,t)),i.length||e===r||r.if&&(e.elseif||e.else)&&fs(r,{exp:e.elseif,block:e}),a&&!e.forbidden)if(e.elseif||e.else)s=e,(o=function(e){for(var t=e.length;t--;){if(1===e[t].type)return e[t];e.pop()}}(a.children))&&o.if&&fs(o,{exp:s.elseif,block:s});else{if(e.slotScope){var n=e.slotTarget||'"default"';(a.scopedSlots||(a.scopedSlots={}))[n]=e}a.children.push(e),e.parent=a}var s,o;e.children=e.children.filter((function(e){return!e.slotScope})),u(e),e.pre&&(l=!1),Yi(e.tag)&&(c=!1);for(var f=0;f]*>)","i")),_=e.replace(u,(function(e,n,r){return c=r.length,Ci(f)||"noscript"===f||(n=n.replace(//g,"$1").replace(//g,"$1")),Ni(f,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""}));l+=e.length-_.length,e=_,M(f,l-c,l)}else{var p=e.indexOf("<");if(0===p){if(Bi.test(e)){var h=e.indexOf("--\x3e");if(h>=0){t.shouldKeepComment&&t.comment(e.substring(4,h),l,l+h+3),x(h+3);continue}}if(Ei.test(e)){var d=e.indexOf("]>");if(d>=0){x(d+2);continue}}var v=e.match(Ti);if(v){x(v[0].length);continue}var m=e.match(Ri);if(m){var b=l;x(m[0].length),M(m[1],b,l);continue}var g=k();if(g){A(g),Ni(g.tagName,e)&&x(1);continue}}var y=void 0,w=void 0,S=void 0;if(p>=0){for(w=e.slice(p);!(Ri.test(w)||Ai.test(w)||Bi.test(w)||Ei.test(w)||(S=w.indexOf("<",1))<0);)p+=S,w=e.slice(p);y=e.substring(0,p)}p<0&&(y=e),y&&x(y.length),t.chars&&y&&t.chars(y,l-y.length,l)}if(e===n){t.chars&&t.chars(e);break}}function x(t){l+=t,e=e.substring(t)}function k(){var t=e.match(Ai);if(t){var n,r,a={tagName:t[1],attrs:[],start:l};for(x(t[0].length);!(n=e.match(Mi))&&(r=e.match(Si)||e.match(wi));)r.start=l,x(r[0].length),r.end=l,a.attrs.push(r);if(n)return a.unarySlash=n[1],x(n[0].length),a.end=l,a}}function A(e){var n=e.tagName,l=e.unarySlash;i&&("p"===r&&yi(n)&&M(r),o(n)&&r===n&&M(n));for(var c=s(n)||!!l,f=e.attrs.length,u=new Array(f),_=0;_=0&&a[s].lowerCasedTag!==o;s--);else s=0;if(s>=0){for(var c=a.length-1;c>=s;c--)t.end&&t.end(a[c].tag,n,i);a.length=s,r=s&&a[s-1].tag}else"br"===o?t.start&&t.start(e,[],!0,n,i):"p"===o&&(t.start&&t.start(e,[],!1,n,i),t.end&&t.end(e,n,i))}M()}(e,{warn:Di,expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,canBeLeftOpenTag:t.canBeLeftOpenTag,shouldDecodeNewlines:t.shouldDecodeNewlines,shouldDecodeNewlinesForHref:t.shouldDecodeNewlinesForHref,shouldKeepComment:t.comments,outputSourceRange:t.outputSourceRange,start:function(e,n,s,o,u){var _=a&&a.ns||zi(e);Q&&"svg"===_&&(n=function(e){for(var t=[],n=0;nl&&(o.push(i=e.slice(l,a)),s.push(JSON.stringify(i)));var c=Br(r[1].trim());s.push("_s("+c+")"),o.push({"@binding":c}),l=a+r[0].length}return l-1"+("true"===i?":("+t+")":":_q("+t+","+i+")")),$r(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+i+"):("+s+");if(Array.isArray($$a)){var $$v="+(r?"_n("+a+")":a)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+Yr(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+Yr(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+Yr(t,"$$c")+"}",null,!0)}(e,r,a);else if("input"===i&&"radio"===s)!function(e,t,n){var r=n&&n.number,a=Dr(e,"value")||"null";Or(e,"checked","_q("+t+","+(a=r?"_n("+a+")":a)+")"),$r(e,"change",Yr(t,a),null,!0)}(e,r,a);else if("input"===i||"textarea"===i)!function(e,t,n){var r=e.attrsMap.type;0;var a=n||{},i=a.lazy,s=a.number,o=a.trim,l=!i&&"range"!==r,c=i?"change":"range"===r?"__r":"input",f="$event.target.value";o&&(f="$event.target.value.trim()");s&&(f="_n("+f+")");var u=Yr(t,f);l&&(u="if($event.target.composing)return;"+u);Or(e,"value","("+t+")"),$r(e,c,u,null,!0),(o||s)&&$r(e,"blur","$forceUpdate()")}(e,r,a);else{if(!V.isReservedTag(i))return qr(e,r,a),!1}return!0},text:function(e,t){t.value&&Or(e,"textContent","_s("+t.value+")",t)},html:function(e,t){t.value&&Or(e,"innerHTML","_s("+t.value+")",t)}},isPreTag:function(e){return"pre"===e},isUnaryTag:bi,mustUseProp:Hn,canBeLeftOpenTag:gi,isReservedTag:Gn,getTagNamespace:Qn,staticKeys:function(e){return e.reduce((function(e,t){return e.concat(t.staticKeys||[])}),[]).join(",")}(ms)},ws=x((function(e){return m("type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap"+(e?","+e:""))}));function Ss(e,t){e&&(bs=ws(t.staticKeys||""),gs=t.isReservedTag||L,function e(t){if(t.static=function(e){if(2===e.type)return!1;if(3===e.type)return!0;return!(!e.pre&&(e.hasBindings||e.if||e.for||b(e.tag)||!gs(e.tag)||function(e){for(;e.parent;){if("template"!==(e=e.parent).tag)return!1;if(e.for)return!0}return!1}(e)||!Object.keys(e).every(bs)))}(t),1===t.type){if(!gs(t.tag)&&"slot"!==t.tag&&null==t.attrsMap["inline-template"])return;for(var n=0,r=t.children.length;n|^function\s*(?:[\w$]+)?\s*\(/,ks=/\([^)]*?\);*$/,As=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/,Ms={esc:27,tab:9,enter:13,space:32,up:38,left:37,right:39,down:40,delete:[8,46]},Rs={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]},Ts=function(e){return"if("+e+")return null;"},Bs={stop:"$event.stopPropagation();",prevent:"$event.preventDefault();",self:Ts("$event.target !== $event.currentTarget"),ctrl:Ts("!$event.ctrlKey"),shift:Ts("!$event.shiftKey"),alt:Ts("!$event.altKey"),meta:Ts("!$event.metaKey"),left:Ts("'button' in $event && $event.button !== 0"),middle:Ts("'button' in $event && $event.button !== 1"),right:Ts("'button' in $event && $event.button !== 2")};function Es(e,t){var n=t?"nativeOn:":"on:",r="",a="";for(var i in e){var s=Cs(e[i]);e[i]&&e[i].dynamic?a+=i+","+s+",":r+='"'+i+'":'+s+","}return r="{"+r.slice(0,-1)+"}",a?n+"_d("+r+",["+a.slice(0,-1)+"])":n+r}function Cs(e){if(!e)return"function(){}";if(Array.isArray(e))return"["+e.map((function(e){return Cs(e)})).join(",")+"]";var t=As.test(e.value),n=xs.test(e.value),r=As.test(e.value.replace(ks,""));if(e.modifiers){var a="",i="",s=[];for(var o in e.modifiers)if(Bs[o])i+=Bs[o],Ms[o]&&s.push(o);else if("exact"===o){var l=e.modifiers;i+=Ts(["ctrl","shift","alt","meta"].filter((function(e){return!l[e]})).map((function(e){return"$event."+e+"Key"})).join("||"))}else s.push(o);return s.length&&(a+=function(e){return"if(!$event.type.indexOf('key')&&"+e.map(Ps).join("&&")+")return null;"}(s)),i&&(a+=i),"function($event){"+a+(t?"return "+e.value+"($event)":n?"return ("+e.value+")($event)":r?"return "+e.value:e.value)+"}"}return t||n?e.value:"function($event){"+(r?"return "+e.value:e.value)+"}"}function Ps(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var n=Ms[e],r=Rs[e];return"_k($event.keyCode,"+JSON.stringify(e)+","+JSON.stringify(n)+",$event.key,"+JSON.stringify(r)+")"}var Os={on:function(e,t){e.wrapListeners=function(e){return"_g("+e+","+t.value+")"}},bind:function(e,t){e.wrapData=function(n){return"_b("+n+",'"+e.tag+"',"+t.value+","+(t.modifiers&&t.modifiers.prop?"true":"false")+(t.modifiers&&t.modifiers.sync?",true":"")+")"}},cloak:O},Ls=function(e){this.options=e,this.warn=e.warn||Cr,this.transforms=Pr(e.modules,"transformCode"),this.dataGenFns=Pr(e.modules,"genData"),this.directives=C(C({},Os),e.directives);var t=e.isReservedTag||L;this.maybeComponent=function(e){return!!e.component||!t(e.tag)},this.onceId=0,this.staticRenderFns=[],this.pre=!1};function Is(e,t){var n=new Ls(t);return{render:"with(this){return "+(e?Hs(e,n):'_c("div")')+"}",staticRenderFns:n.staticRenderFns}}function Hs(e,t){if(e.parent&&(e.pre=e.pre||e.parent.pre),e.staticRoot&&!e.staticProcessed)return Ns(e,t);if(e.once&&!e.onceProcessed)return $s(e,t);if(e.for&&!e.forProcessed)return js(e,t);if(e.if&&!e.ifProcessed)return Ds(e,t);if("template"!==e.tag||e.slotTarget||t.pre){if("slot"===e.tag)return function(e,t){var n=e.slotName||'"default"',r=Ys(e,t),a="_t("+n+(r?","+r:""),i=e.attrs||e.dynamicAttrs?Us((e.attrs||[]).concat(e.dynamicAttrs||[]).map((function(e){return{name:A(e.name),value:e.value,dynamic:e.dynamic}}))):null,s=e.attrsMap["v-bind"];!i&&!s||r||(a+=",null");i&&(a+=","+i);s&&(a+=(i?"":",null")+","+s);return a+")"}(e,t);var n;if(e.component)n=function(e,t,n){var r=t.inlineTemplate?null:Ys(t,n,!0);return"_c("+e+","+Vs(t,n)+(r?","+r:"")+")"}(e.component,e,t);else{var r;(!e.plain||e.pre&&t.maybeComponent(e))&&(r=Vs(e,t));var a=e.inlineTemplate?null:Ys(e,t,!0);n="_c('"+e.tag+"'"+(r?","+r:"")+(a?","+a:"")+")"}for(var i=0;i>>0}(s):"")+")"}(e,e.scopedSlots,t)+","),e.model&&(n+="model:{value:"+e.model.value+",callback:"+e.model.callback+",expression:"+e.model.expression+"},"),e.inlineTemplate){var i=function(e,t){var n=e.children[0];0;if(n&&1===n.type){var r=Is(n,t.options);return"inlineTemplate:{render:function(){"+r.render+"},staticRenderFns:["+r.staticRenderFns.map((function(e){return"function(){"+e+"}"})).join(",")+"]}"}}(e,t);i&&(n+=i+",")}return n=n.replace(/,$/,"")+"}",e.dynamicAttrs&&(n="_b("+n+',"'+e.tag+'",'+Us(e.dynamicAttrs)+")"),e.wrapData&&(n=e.wrapData(n)),e.wrapListeners&&(n=e.wrapListeners(n)),n}function Fs(e){return 1===e.type&&("slot"===e.tag||e.children.some(Fs))}function qs(e,t){var n=e.attrsMap["slot-scope"];if(e.if&&!e.ifProcessed&&!n)return Ds(e,t,qs,"null");if(e.for&&!e.forProcessed)return js(e,t,qs);var r="_empty_"===e.slotScope?"":String(e.slotScope),a="function("+r+"){return "+("template"===e.tag?e.if&&n?"("+e.if+")?"+(Ys(e,t)||"undefined")+":undefined":Ys(e,t)||"undefined":Hs(e,t))+"}",i=r?"":",proxy:true";return"{key:"+(e.slotTarget||'"default"')+",fn:"+a+i+"}"}function Ys(e,t,n,r,a){var i=e.children;if(i.length){var s=i[0];if(1===i.length&&s.for&&"template"!==s.tag&&"slot"!==s.tag){var o=n?t.maybeComponent(s)?",1":",0":"";return""+(r||Hs)(s,t)+o}var l=n?function(e,t){for(var n=0,r=0;r':'
',Qs.innerHTML.indexOf(" ")>0}var no=!!K&&to(!1),ro=!!K&&to(!0),ao=x((function(e){var t=tr(e);return t&&t.innerHTML})),io=Mn.prototype.$mount;Mn.prototype.$mount=function(e,t){if((e=e&&tr(e))===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=ao(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=function(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}(e));if(r){0;var a=eo(r,{outputSourceRange:!1,shouldDecodeNewlines:no,shouldDecodeNewlinesForHref:ro,delimiters:n.delimiters,comments:n.comments},this),i=a.render,s=a.staticRenderFns;n.render=i,n.staticRenderFns=s}}return io.call(this,e,t)},Mn.compile=eo,t.default=Mn}).call(this,n(3),n(8).setImmediate)},function(e,t,n){"use strict";(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(9),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||void 0,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||void 0}).call(this,n(3))},function(e,t,n){"use strict";(function(e,t){!function(e,n){if(!e.setImmediate){var r,a,i,s,o,l=1,c={},f=!1,u=e.document,_=Object.getPrototypeOf&&Object.getPrototypeOf(e);_=_&&_.setTimeout?_:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){h(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){h(e.data)},r=function(e){i.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(a=u.documentElement,r=function(e){var t=u.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):r=function(e){setTimeout(h,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&h(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),r=function(t){e.postMessage(s+t,"*")}),_.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n1)for(var n=1;nf+1&&c("SampleData似乎传入了未重置chunk "+i+">"+f,3);for(var u=0,_=i;_1?u=Math.floor(u/p):(p=1,n=t),u+=o.length;var h=new Int16Array(u),d=0;for(_=0;_0){var k=2*(h.length-x);o=new Int16Array(h.buffer.slice(k)),h=new Int16Array(h.buffer.slice(0,k))}return{index:i,offset:s,frameNext:o,sampleRate:n,data:h}},n.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)))))};var c=function(t,n){var a=new Date,i=("0"+a.getMinutes()).substr(-2)+":"+("0"+a.getSeconds()).substr(-2)+"."+("00"+a.getMilliseconds()).substr(-3),s=this&&this.envIn&&this.envCheck&&this.id,o=["["+i+" "+r+(s?":"+s:"")+"]"+t],l=arguments,c=e.console||{},u=2,_=c.log;for("number"==typeof n?_=1==n?c.error:3==n?c.warn:_:u=1;u1?o:""):_.apply(c,o)},f=!0;try{f=!console.log.apply}catch(e){}n.CLog=c;var u=0;function _(e){this.id=++u,b();var n={type:"mp3",bitRate:16,sampleRate:16e3,onProcess:t};for(var r in e)n[r]=e[r];this.set=n,this._S=9,this.Sync={O:9,C:9}}n.Sync={O:9,C:9},n.prototype=_.prototype={CLog:c,_streamStore:function(){return this.set.sourceStream?this:n},open:function(r,a){var s=this,o=s._streamStore();r=r||t;var c=function(e,t){t=!!t,s.CLog("录音open失败:"+e+",isUserNotAllow:"+t,1),a&&a(e,t)},f=function(){s.CLog("open ok id:"+s.id),r(),s._SO=0},u=o.Sync,_=++u.O,p=u.C;s._O=s._O_=_,s._SO=s._S;var h=s.envCheck({envName:"H5",canProcess:!0});if(h)c("不能录音:"+h);else if(s.set.sourceStream){if(!n.Support())return void c("不支持此浏览器从流中获取录音");l(o),s.Stream=s.set.sourceStream,s.Stream._call={};try{i(o)}catch(e){return void c("从流中打开录音失败:"+e.message)}f()}else{var d=function(t,n){try{e.top.a}catch(e){return void c('无权录音(跨域,请尝试给iframe添加麦克风访问策略,如allow="camera;microphone")')}/Permission|Allow/i.test(t)?c("用户拒绝了录音权限",!0):!1===e.isSecureContext?c("浏览器禁止不安全页面录音,可开启https解决"):/Found/i.test(t)?c(n+",无可用麦克风"):c(n)};if(n.IsOpen())f();else if(n.Support()){var v=function(e){setTimeout((function(){e._call={};var t=n.Stream;t&&(l(),e._call=t._call),n.Stream=e,function(){if(p!=u.C||!s._O){var e="open被取消";return _==u.O?s.close():e="open被中断",c(e),!0}}()||(n.IsOpen()?(t&&s.CLog("发现同时多次调用open",1),i(o,1),f()):c("录音功能无效:无音频流"))}),100)},m=function(e){var t=e.name||e.message||e.code+":"+e;s.CLog("请求录音权限错误",1,e),d(t,"无法录音:"+t)},b={noiseSuppression:!1,echoCancellation:!1},g=s.set.audioTrackSet;for(var y in g)b[y]=g[y];b.sampleRate=n.Ctx.sampleRate;try{var w=n.Scope.getUserMedia({audio:b},v,m)}catch(e){s.CLog("getUserMedia",3,e),w=n.Scope.getUserMedia({audio:!0},v,m)}w&&w.then&&w.then(v)[r&&"catch"](m)}else d("","此浏览器不支持录音")}},close:function(e){e=e||t;var n=this._streamStore();this._stop();var r=n.Sync;if(this._O=0,this._O_!=r.O)return this.CLog("close被忽略(因为同时open了多个rec,只有最后一个会真正close)",3),void e();r.C++,l(n),this.CLog("close"),e()},mock:function(e,t){return this._stop(),this.isMock=1,this.mockEnvInfo=null,this.buffers=[e],this.recSize=e.length,this.srcSampleRate=t,this},envCheck:function(t){var r,a=this.set,i="CPU_BE";if(r||n[i]||!e.Int8Array||new Int8Array(new Int32Array([1]).buffer)[0]||(b(i),r="不支持CPU_BE架构"),!r){var s=a.type;this[s+"_envCheck"]?r=this[s+"_envCheck"](t,a):a.takeoffEncodeChunk&&(r=s+"类型"+(this[s]?"":"(未加载编码器)")+"不支持设置takeoffEncodeChunk")}return r||""},envStart:function(e,t){var n=this.set;this.isMock=e?1:0,this.mockEnvInfo=e,this.buffers=[],this.recSize=0,this.envInLast=0,this.envInFirst=0,this.envInFix=0,this.envInFixTs=[];var r=n.sampleRate;if(r>t?n.sampleRate=t:r=0,this.srcSampleRate=t,this.CLog("srcSampleRate: "+t+" set.sampleRate: "+n.sampleRate+(r?" 忽略"+r:""),r?3:0),this.engineCtx=0,this[n.type+"_start"]){var a=this.engineCtx=this[n.type+"_start"](n);a&&(a.pcmDatas=[],a.pcmSize=0)}},envResume:function(){this.envInFixTs=[]},envIn:function(e,t){var r=this,a=r.set,i=r.engineCtx,s=r.srcSampleRate,o=e.length,l=n.PowerLevel(t,o),c=r.buffers,f=c.length;c.push(e);var u=c,_=f,p=Date.now(),h=Math.round(o/s*1e3);r.envInLast=p,1==r.buffers.length&&(r.envInFirst=p-h);var d=r.envInFixTs;d.splice(0,0,{t:p,d:h});for(var v=p,m=0,b=0;b3e3){d.length=b;break}v=g.t,m+=g.d}var y=d[1],w=p-v;if(w-m>w/3&&(y&&w>1e3||d.length>=6)){var S=p-y.t-h;if(S>h/5){var x=!a.disableEnvInFix;if(r.CLog("["+p+"]"+(x?"":"未")+"补偿"+S+"ms",3),r.envInFix+=S,x){var k=new Int16Array(S*s/1e3);o+=k.length,c.push(k)}}}var A=r.recSize,M=o,R=A+M;if(r.recSize=R,i){var T=n.SampleData(c,s,a.sampleRate,i.chunkInfo);i.chunkInfo=T,R=(A=i.pcmSize)+(M=T.data.length),i.pcmSize=R,c=i.pcmDatas,f=c.length,c.push(T.data),s=T.sampleRate}var B=Math.round(R/s*1e3),E=c.length,C=u.length,P=function(){for(var e=O?0:-M,t=null==c[0],n=f;n10&&r.envInFirst-p>1e3&&r.CLog("rec.set.onProcess低性能,耗时"+L+"ms",3),!0===O){var I=0;for(b=f;b"+b.length+" 花:"+(Date.now()-a)+"ms"),setTimeout((function(){a=Date.now(),i[s.type](b,(function(e){u(e,v)}),(function(e){f(e)}))}))}else f("未加载"+s.type+"编码器");else f("音频buffers被释放");else f("未采集到录音")}},e[r]&&(c("重复引入"+r,3),e[r].Destroy()),e[r]=n;var p=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]},i=t.bytes.length,s=new Uint8Array(i+e.length);if(s.set(t.bytes),s.set(e,i),t.bytes=s,!t._ht){if(v(s,r),m(s,r),!h(v(s,r),[24,83,128,103]))return;for(v(s,r);r[0]1){var I=[];for(A=0;A=e.length)){var a=("0000000"+e[r].toString(2)).substr(-8),i=/^(0*1)(\d*)$/.exec(a);if(i){var s=i[1].length,o=[];if(!(r+s>e.length)){for(var l=0;le.length)return;for(var s=0;s0&&(u+=o.buffer.byteLength,c.push(o.buffer)),f+=57600,setTimeout(n)}else{var o;(o=l.flush()).length>0&&(u+=o.buffer.byteLength,c.push(o.buffer));var _=a.fn(c,u,s,r.sampleRate);i(_,r),t(new Blob(c,{type:"audio/mp3"}))}}()},Recorder.BindDestroy("mp3Worker",(function(){console.log("mp3Worker Destroy"),e&&e.terminate(),e=null})),Recorder.prototype.mp3_envCheck=function(e,t){var r="";return t.takeoffEncodeChunk&&(e.canProcess?n()||(r="当前浏览器版本太低,无法实时处理"):r=e.envName+"环境不支持实时处理"),r},Recorder.prototype.mp3_start=function(e){return n(e)};var t={id:0},n=function(n){var r=e;try{if(!r){var i=");wk_lame();var wk_ctxs={};self.onmessage="+function(e){var t=e.data,n=wk_ctxs[t.id];if("init"==t.action)wk_ctxs[t.id]={sampleRate:t.sampleRate,bitRate:t.bitRate,takeoff:t.takeoff,mp3Size:0,pcmSize:0,encArr:[],encObj:new wk_lame.Mp3Encoder(1,t.sampleRate,t.bitRate)};else if(!n)return;switch(t.action){case"stop":n.encObj=null,delete wk_ctxs[t.id];break;case"encode":n.pcmSize+=t.pcm.length,(r=n.encObj.encodeBuffer(t.pcm)).length>0&&(n.takeoff?self.postMessage({action:"takeoff",id:t.id,chunk:r}):(n.mp3Size+=r.buffer.byteLength,n.encArr.push(r.buffer)));break;case"complete":var r;(r=n.encObj.flush()).length>0&&(n.takeoff?self.postMessage({action:"takeoff",id:t.id,chunk:r}):(n.mp3Size+=r.buffer.byteLength,n.encArr.push(r.buffer)));var a=wk_mp3TrimFix.fn(n.encArr,n.mp3Size,n.pcmSize,n.sampleRate);self.postMessage({action:t.action,id:t.id,blob:new Blob(n.encArr,{type:"audio/mp3"}),meta:a})}};i+=";var wk_mp3TrimFix={rm:"+a.rm+",fn:"+a.fn+"}";var s=Recorder.lamejs.toString(),o=(window.URL||webkitURL).createObjectURL(new Blob(["var wk_lame=(",s,i],{type:"text/javascript"}));r=new Worker(o),setTimeout((function(){(window.URL||webkitURL).revokeObjectURL(o)}),1e4),r.onmessage=function(e){var n=e.data,r=t[n.id];r&&("takeoff"==n.action?r.set.takeoffEncodeChunk(new Uint8Array(n.chunk.buffer)):(r.call&&r.call(n),r.call=null))}}var l={worker:r,set:n,takeoffQueue:[]};return n?(l.id=++t.id,t[l.id]=l,r.postMessage({action:"init",id:l.id,sampleRate:n.sampleRate,bitRate:n.bitRate,takeoff:!!n.takeoffEncodeChunk,x:new Int16Array(5)})):r.postMessage({x:new Int16Array(5)}),e=r,l}catch(e){return r&&r.terminate(),console.error(e),null}};Recorder.prototype.mp3_stop=function(e){if(e&&e.worker){e.worker.postMessage({action:"stop",id:e.id}),e.worker=null,delete t[e.id];var n=-1;for(var r in t)n++;n&&console.warn("mp3 worker剩"+n+"个在串行等待")}},Recorder.prototype.mp3_encode=function(e,t){e&&e.worker&&e.worker.postMessage({action:"encode",id:e.id,pcm:t})},Recorder.prototype.mp3_complete=function(e,t,n,r){var a=this;e&&e.worker?(e.call=function(n){i(n.meta,e.set),t(n.blob),r&&a.mp3_stop(e)},e.worker.postMessage({action:"complete",id:e.id})):n("mp3编码器未打开")},Recorder.mp3ReadMeta=function(e,t){var n="object"==("undefined"==typeof window?"undefined":r(window))?window.parseInt:self.parseInt,a=new Uint8Array(e[0]||[]);if(a.length<4)return null;var i=function(e,t){return("0000000"+((t||a)[e]||0).toString(2)).substr(-8)},s=i(0)+i(1),o=i(2)+i(3);if(!/^1{11}/.test(s))return null;var l={"00":2.5,10:2,11:1}[s.substr(11,2)],c={"01":3}[s.substr(13,2)],f={1:[44100,48e3,32e3],2:[22050,24e3,16e3],2.5:[11025,12e3,8e3]}[l];f&&(f=f[n(o.substr(4,2),2)]);var u=[[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160],[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320]][1==l?1:0][n(o.substr(0,4),2)];if(!(l&&c&&u&&f))return null;for(var _=Math.round(8*t/u),p=1==c?384:2==c||1==l?1152:576,h=p/f*1e3,d=Math.floor(p*u/8/f*1e3),v=0,m=0,b=0;b=d+3){var y=new Uint8Array(g);v="1"==i(g.byteLength-(m-(d+3)+1),y).charAt(6);break}}return v&&d++,{version:l,layer:c,sampleRate:f,bitRate:u,duration:_,size:t,hasPadding:v,frameSize:d,frameDurationFloat:h}};var a={rm:Recorder.mp3ReadMeta,fn:function(e,t,n,r){var a=this.rm(e,t);if(!a)return{err:"mp3非预定格式"};var i=Math.round(n/r*1e3),s=Math.floor((a.duration-i)/a.frameDurationFloat);if(s>0){var o=s*a.frameSize-(a.hasPadding?1:0);t-=o;for(var l=0,c=[],f=0;f=u.byteLength?(o-=u.byteLength,c.push(u),e.splice(f,1),f--):(e[f]=u.slice(o),l=u,o=0)}if(!this.rm(e,t)){l&&(e[0]=l);for(f=0;f "+r.duration+"ms",r.remove>2&&(e.err=(e.err?e.err+", ":"")+"移除帧数过多")):n+=(e.duration||"-")+"ms",e.err?console.error(n,e.err,e):console.log(n,e)}}()},function(e,t,n){"use strict";!function(){function e(){var t=function(e){return Math.log(e)/Math.log(10)};function n(e){return new Int8Array(e)}function r(e){return new Int16Array(e)}function a(e){return new Int32Array(e)}function i(e){return new Float32Array(e)}function s(e){return new Float64Array(e)}function o(e){if(1==e.length)return i(e[0]);var t=e[0];e=e.slice(1);for(var n=[],r=0;r>=1;0!=e--;)a[i++]=s>n[r++]?0:1,a[i++]=s>n[r++]?0:1}function i(t,n,r,a,i,s){var o=(t>>=1)%2;for(t>>=1;0!=t--;){var l,c,f,u,_,p,h,d;l=r[a++]*n,c=r[a++]*n,_=0|l,f=r[a++]*n,p=0|c,u=r[a++]*n,h=0|f,l+=e.adj43[_],d=0|u,c+=e.adj43[p],i[s++]=0|l,f+=e.adj43[h],i[s++]=0|c,u+=e.adj43[d],i[s++]=0|f,i[s++]=0|u}0!=o&&(_=0|(l=r[a++]*n),p=0|(c=r[a++]*n),l+=e.adj43[_],c+=e.adj43[p],i[s++]=0|l,i[s++]=0|c)}var s=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function o(e,t,n,r){var a=function(e,t,n){var r=0,a=0;do{var i=e[t++],s=e[t++];r>=16)>i&&(o=i,r++),a.bits+=o,r}(e,t,n,s[a-1],r);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return function(e,t,n,r,a){var i=0,s=0,o=0,l=M.ht[r].xlen,c=M.ht[r].hlen,f=M.ht[r+1].hlen,u=M.ht[r+2].hlen;do{var _=e[t+0]*l+e[t+1];t+=2,i+=c[_],s+=f[_],o+=u[_]}while(ts&&(i=s,p++),i>o&&(i=o,p=r+2),a.bits+=i,p}(e,t,n,s[a-1],r);default:if(a>I.IXMAX_VAL)return r.bits=I.LARGE_BITS,-1;var i,o;for(a-=15,i=24;i<32&&!(M.ht[i].linmax>=a);i++);for(o=i-8;o<24&&!(M.ht[o].linmax>=a);o++);return function(e,t,n,r,a,i){var s,o=65536*M.ht[r].xlen+M.ht[a].xlen,l=0;do{var c=e[t++],f=e[t++];0!=c&&(c>14&&(c=15,l+=o),c*=16),0!=f&&(f>14&&(f=15,l+=o),c+=f),l+=M.largetbl[c]}while(t>=16)>s&&(l=s,r=a),i.bits+=l,r}(e,t,n,o,i,r)}}function l(e,n,r,a,i,s,l,c){for(var f=n.big_values,u=2;u=f)break;var p=i[u-2]+n.count1bits;if(r.part2_3_length<=p)break;var h=new t(p),d=o(a,_,f,h);p=h.bits,r.part2_3_length<=p||(r.assign(n),r.part2_3_length=p,r.region0_count=s[u-2],r.region1_count=u-2-s[u-2],r.table_select[0]=l[u-2],r.table_select[1]=c[u-2],r.table_select[2]=d)}}this.noquant_count_bits=function(e,n,r){var a=n.l3_enc,i=Math.min(576,n.max_nonzero_coeff+2>>1<<1);for(null!=r&&(r.sfb_count1=0);i>1&&0==(a[i-1]|a[i-2]);i-=2);n.count1=i;for(var s=0,l=0;i>3;i-=4){var c;if((2147483647&(a[i-1]|a[i-2]|a[i-3]|a[i-4]))>1)break;c=2*(2*(2*a[i-4]+a[i-3])+a[i-2])+a[i-1],s+=M.t32l[c],l+=M.t33l[c]}var f=s;if(n.count1table_select=0,s>l&&(f=l,n.count1table_select=1),n.count1bits=f,n.big_values=i,0==i)return f;if(n.block_type==F.SHORT_TYPE)(s=3*e.scalefac_band.s[3])>n.big_values&&(s=n.big_values),l=n.big_values;else if(n.block_type==F.NORM_TYPE){if(s=n.region0_count=e.bv_scf[i-2],l=n.region1_count=e.bv_scf[i-1],l=e.scalefac_band.l[s+l+2],s=e.scalefac_band.l[s+1],l(l=i)&&(s=l);if(s=Math.min(s,i),l=Math.min(l,i),0l)return I.LARGE_BITS;if(function(t,n,a,s,o){var l,c,f,_=0,p=0,h=0,d=0,v=n,m=0,b=v,g=0,y=t,w=0;for(f=null!=o&&s.global_gain==o.global_gain,c=s.block_type==F.SHORT_TYPE?38:21,l=0;l<=c;l++){var S=-1;if((f||s.block_type==F.NORM_TYPE)&&(S=s.global_gain-(s.scalefac[l]+(0!=s.preflag?e.pretab[l]:0)<s.max_nonzero_coeff)x=s.max_nonzero_coeff-_+1,u.fill(n,s.max_nonzero_coeff,576,0),(k=x)<0&&(k=0),l=c+1;if(0==p&&0==h&&(b=v,g=m,y=t,w=d),null!=o&&o.sfb_count1>0&&l>=o.sfb_count1&&o.step[l]>0&&S>=o.step[l]?(0!=p&&(i(p,a,y,w,b,g),p=0,b=v,g=m,y=t,w=d),h+=k):(0!=h&&(r(h,a,y,w,b,g),h=0,b=v,g=m,y=t,w=d),p+=k),k<=0){0!=h&&(r(h,a,y,w,b,g),h=0),0!=p&&(i(p,a,y,w,b,g),p=0);break}}l<=c&&(m+=s.width[l],d+=s.width[l],_+=s.width[l])}0!=p&&(i(p,a,y,w,b,g),p=0),0!=h&&(r(h,a,y,w,b,g),h=0)}(n,o,e.IPOW20(a.global_gain),a,s),0!=(2&t.substep_shaping))for(var c=0,f=a.global_gain+a.scalefac_scale,_=.634521682242439/e.IPOW20(f),p=0;p=_?o[h]:0}return this.noquant_count_bits(t,a,s)},this.best_huffman_divide=function(e,n){var r=new N,i=n.l3_enc,s=a(23),c=a(23),f=a(23),u=a(23);if(n.block_type!=F.SHORT_TYPE||1!=e.mode_gr){r.assign(n),n.block_type==F.NORM_TYPE&&(!function(e,n,r,a,i,s,l){for(var c=n.big_values,f=0;f<=22;f++)a[f]=I.LARGE_BITS;for(f=0;f<16;f++){var u=e.scalefac_band.l[f+1];if(u>=c)break;var _=0,p=new t(_),h=o(r,0,u,p);_=p.bits;for(var d=0;d<8;d++){var v=e.scalefac_band.l[f+d+2];if(v>=c)break;var m=_,b=o(r,u,v,p=new t(m));m=p.bits,a[f+d]>m&&(a[f+d]=m,i[f+d]=f,s[f+d]=h,l[f+d]=b)}}}(e,n,i,s,c,f,u),l(e,r,n,i,s,c,f,u));var _=r.big_values;if(!(0==_||(i[_-2]|i[_-1])>1||(_=n.count1+2)>576)){r.assign(n),r.count1=_;for(var p=0,h=0;_>r.big_values;_-=4){var d=2*(2*(2*i[_-4]+i[_-3])+i[_-2])+i[_-1];p+=M.t32l[d],h+=M.t33l[d]}if(r.big_values=_,r.count1table_select=0,p>h&&(p=h,r.count1table_select=1),r.count1bits=p,r.block_type==F.NORM_TYPE)l(e,r,n,i,s,c,f,u);else{if(r.part2_3_length=p,(p=e.scalefac_band.l[8])>_&&(p=_),p>0){var v=new t(r.part2_3_length);r.table_select[0]=o(i,0,p,v),r.part2_3_length=v.bits}if(_>p){v=new t(r.part2_3_length);r.table_select[1]=o(i,p,_,v),r.part2_3_length=v.bits}n.part2_3_length>r.part2_3_length&&n.assign(r)}}}};var c=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],f=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],p=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],h=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];g.slen1_tab=p,g.slen2_tab=h,this.best_scalefac_store=function(t,n,r,a){var i,s,o,l,u=a.tt[n][r],_=0;for(o=0,i=0;i0&&(v|=u.scalefac[i]);if(0==(1&v)&&0!=v){for(i=0;i0&&(u.scalefac[i]>>=1);u.scalefac_scale=_=1}}if(0==u.preflag&&u.block_type!=F.SHORT_TYPE&&2==t.mode_gr){for(i=11;i0&&(u.scalefac[i]-=e.pretab[i]);u.preflag=_=1}}for(s=0;s<4;s++)a.scfsi[r][s]=0;for(2==t.mode_gr&&1==n&&a.tt[0][r].block_type!=F.SHORT_TYPE&&a.tt[1][r].block_type!=F.SHORT_TYPE&&(!function(e,t){for(var n,r=t.tt[1][e],a=t.tt[0][e],i=0;i=0);n++);if(n==M.scfsi_band[i+1]){for(n=M.scfsi_band[i];n_&&(r.part2_length=_,r.scalefac_compress=i)}}(r,a),_=0),i=0;ia[n]&&(t.part2_length=a[n],t.scalefac_compress=n);return t.part2_length==I.LARGE_BITS};var b=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(t,n){var r,i,s,o,l,c,f,u,p=a(4),h=n.scalefac;for(r=0!=n.preflag?2:0,f=0;f<4;f++)p[f]=0;if(n.block_type==F.SHORT_TYPE){i=1;var d=e.nr_of_sfb_block[r][i];for(u=0,s=0;s<4;s++)for(o=d[s]/3,f=0;fp[s]&&(p[s]=h[3*u+l])}else{i=0;d=e.nr_of_sfb_block[r][i];for(u=0,s=0;s<4;s++)for(o=d[s],f=0;fp[s]&&(p[s]=h[u])}for(c=!1,s=0;s<4;s++)p[s]>b[r][s]&&(c=!0);if(!c){var v,m,g,w;for(n.sfb_partition_table=e.nr_of_sfb_block[r][i],s=0;s<4;s++)n.slen[s]=y[p[s]];switch(v=n.slen[0],m=n.slen[1],g=n.slen[2],w=n.slen[3],r){case 0:n.scalefac_compress=(5*v+m<<4)+(g<<2)+w;break;case 1:n.scalefac_compress=400+(5*v+m<<2)+g;break;case 2:n.scalefac_compress=500+3*v+m;break;default:_.err.printf("intensity stereo not implemented yet\n")}}if(!c)for(n.part2_length=0,s=0;s<4;s++)n.part2_length+=n.slen[s]*n.sfb_partition_table[s];return c};var y=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(e){for(var t=2;t<=576;t+=2){for(var r,a=0;e.scalefac_band.l[++a]t;)r--;for(r<0&&(r=n[a][0]),e.bv_scf[t-2]=r,r=n[a][1];e.scalefac_band.l[r+e.bv_scf[t-2]+2]>t;)r--;r<0&&(r=n[a][1]),e.bv_scf[t-1]=r}}}function y(){}function w(){function e(e,t,n,r,a,i,s,o,l,c,f,u,_,p,h){this.vbr_q=e,this.quant_comp=t,this.quant_comp_s=n,this.expY=r,this.st_lrm=a,this.st_s=i,this.masking_adj=s,this.masking_adj_short=o,this.ath_lower=l,this.ath_curve=c,this.ath_sensitivity=f,this.interch=u,this.safejoint=_,this.sfb21mod=p,this.msfix=h}function t(e,t,n,r,a,i,s,o,l,c,f,u,_,p){this.quant_comp=t,this.quant_comp_s=n,this.safejoint=r,this.nsmsfix=a,this.st_lrm=i,this.st_s=s,this.nsbass=o,this.scale=l,this.masking_adj=c,this.ath_lower=f,this.ath_curve=u,this.interch=_,this.sfscale=p}var n;this.setModules=function(e){n=e};var r=[new e(0,9,9,0,5.2,125,-4.2,-6.3,4.8,1,0,0,2,21,.97),new e(1,9,9,0,5.3,125,-3.6,-5.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,5.6,125,-2.2,-3.5,2.8,2,0,0,2,21,1.49),new e(3,9,9,1,5.8,130,-1.8,-2.8,2.6,3,-4,0,2,20,1.64),new e(4,9,9,1,6,135,-.7,-1.1,1.1,3.5,-8,0,2,0,1.79),new e(5,9,9,1,6.4,140,.5,.4,-7.5,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,6.6,145,.67,.65,-14.7,6.5,-19,4e-4,0,0,2.3),new e(7,9,9,1,6.6,145,.8,.75,-19.7,8,-22,6e-4,0,0,2.7),new e(8,9,9,1,6.6,145,1.2,1.15,-27.5,10,-23,7e-4,0,0,0),new e(9,9,9,1,6.6,145,1.6,1.6,-36,11,-25,8e-4,0,0,0),new e(10,9,9,1,6.6,145,2,2,-36,12,-25,8e-4,0,0,0)],a=[new e(0,9,9,0,4.2,25,-7,-4,7.5,1,0,0,2,26,.97),new e(1,9,9,0,4.2,25,-5.6,-3.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,4.2,25,-4.4,-1.8,2,2,0,0,2,18,1.49),new e(3,9,9,1,4.2,25,-3.4,-1.25,1.1,3,-4,0,2,15,1.64),new e(4,9,9,1,4.2,25,-2.2,.1,0,3.5,-8,0,2,0,1.79),new e(5,9,9,1,4.2,25,-1,1.65,-7.7,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,4.2,25,-0,2.47,-7.7,6.5,-19,4e-4,0,0,2),new e(7,9,9,1,4.2,25,.5,2,-14.5,8,-22,6e-4,0,0,2),new e(8,9,9,1,4.2,25,1,2.4,-22,10,-23,7e-4,0,0,2),new e(9,9,9,1,4.2,25,1.5,2.95,-30,11,-25,8e-4,0,0,2),new e(10,9,9,1,4.2,25,2,2.95,-36,12,-30,8e-4,0,0,2)];function i(e,t,n){var i=e.VBR==v.vbr_rh?r:a,s=e.VBR_q_frac,o=i[t],l=i[t+1],c=o;o.st_lrm=o.st_lrm+s*(l.st_lrm-o.st_lrm),o.st_s=o.st_s+s*(l.st_s-o.st_s),o.masking_adj=o.masking_adj+s*(l.masking_adj-o.masking_adj),o.masking_adj_short=o.masking_adj_short+s*(l.masking_adj_short-o.masking_adj_short),o.ath_lower=o.ath_lower+s*(l.ath_lower-o.ath_lower),o.ath_curve=o.ath_curve+s*(l.ath_curve-o.ath_curve),o.ath_sensitivity=o.ath_sensitivity+s*(l.ath_sensitivity-o.ath_sensitivity),o.interch=o.interch+s*(l.interch-o.interch),o.msfix=o.msfix+s*(l.msfix-o.msfix),function(e,t){var n=0;0>t&&(n=-1,t=0);90||(e.quant_comp=c.quant_comp),0!=n?e.quant_comp_short=c.quant_comp_s:Math.abs(e.quant_comp_short- -1)>0||(e.quant_comp_short=c.quant_comp_s),0!=c.expY&&(e.experimentalY=0!=c.expY),0!=n?e.internal_flags.nsPsy.attackthre=c.st_lrm:Math.abs(e.internal_flags.nsPsy.attackthre- -1)>0||(e.internal_flags.nsPsy.attackthre=c.st_lrm),0!=n?e.internal_flags.nsPsy.attackthre_s=c.st_s:Math.abs(e.internal_flags.nsPsy.attackthre_s- -1)>0||(e.internal_flags.nsPsy.attackthre_s=c.st_s),0!=n?e.maskingadjust=c.masking_adj:Math.abs(e.maskingadjust-0)>0||(e.maskingadjust=c.masking_adj),0!=n?e.maskingadjust_short=c.masking_adj_short:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=c.masking_adj_short),0!=n?e.ATHlower=-c.ath_lower/10:Math.abs(10*-e.ATHlower-0)>0||(e.ATHlower=-c.ath_lower/10),0!=n?e.ATHcurve=c.ath_curve:Math.abs(e.ATHcurve- -1)>0||(e.ATHcurve=c.ath_curve),0!=n?e.athaa_sensitivity=c.ath_sensitivity:Math.abs(e.athaa_sensitivity- -1)>0||(e.athaa_sensitivity=c.ath_sensitivity),c.interch>0&&(0!=n?e.interChRatio=c.interch:Math.abs(e.interChRatio- -1)>0||(e.interChRatio=c.interch)),c.safejoint>0&&(e.exp_nspsytune=e.exp_nspsytune|c.safejoint),c.sfb21mod>0&&(e.exp_nspsytune=e.exp_nspsytune|c.sfb21mod<<20),0!=n?e.msfix=c.msfix:Math.abs(e.msfix- -1)>0||(e.msfix=c.msfix),0==n&&(e.VBR_q=t,e.VBR_q_frac=s)}var s=[new t(8,9,9,0,0,6.6,145,0,.95,0,-30,11,.0012,1),new t(16,9,9,0,0,6.6,145,0,.95,0,-25,11,.001,1),new t(24,9,9,0,0,6.6,145,0,.95,0,-20,11,.001,1),new t(32,9,9,0,0,6.6,145,0,.95,0,-15,11,.001,1),new t(40,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new t(48,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new t(56,9,9,0,0,6.6,145,0,.95,0,-6,11,8e-4,1),new t(64,9,9,0,0,6.6,145,0,.95,0,-2,11,8e-4,1),new t(80,9,9,0,0,6.6,145,0,.95,0,0,8,7e-4,1),new t(96,9,9,0,2.5,6.6,145,0,.95,0,1,5.5,6e-4,1),new t(112,9,9,0,2.25,6.6,145,0,.95,0,2,4.5,5e-4,1),new t(128,9,9,0,1.95,6.4,140,0,.95,0,3,4,2e-4,1),new t(160,9,9,1,1.79,6,135,0,.95,-2,5,3.5,0,1),new t(192,9,9,1,1.49,5.6,125,0,.97,-4,7,3,0,0),new t(224,9,9,1,1.25,5.2,125,0,.98,-6,9,2,0,0),new t(256,9,9,1,.97,5.2,125,0,1,-8,10,1,0,0),new t(320,9,9,1,.9,5.2,125,0,1,-10,12,0,0,0)];function o(e,t,r){var a=t,i=n.nearestBitrateFullIndex(t);if(e.VBR=v.vbr_abr,e.VBR_mean_bitrate_kbps=a,e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,320),e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.brate=e.VBR_mean_bitrate_kbps,e.VBR_mean_bitrate_kbps>320&&(e.disable_reservoir=!0),s[i].safejoint>0&&(e.exp_nspsytune=2|e.exp_nspsytune),s[i].sfscale>0&&(e.internal_flags.noise_shaping=2),Math.abs(s[i].nsbass)>0){var o=int(4*s[i].nsbass);o<0&&(o+=64),e.exp_nspsytune=e.exp_nspsytune|o<<2}return 0!=r?e.quant_comp=s[i].quant_comp:Math.abs(e.quant_comp- -1)>0||(e.quant_comp=s[i].quant_comp),0!=r?e.quant_comp_short=s[i].quant_comp_s:Math.abs(e.quant_comp_short- -1)>0||(e.quant_comp_short=s[i].quant_comp_s),0!=r?e.msfix=s[i].nsmsfix:Math.abs(e.msfix- -1)>0||(e.msfix=s[i].nsmsfix),0!=r?e.internal_flags.nsPsy.attackthre=s[i].st_lrm:Math.abs(e.internal_flags.nsPsy.attackthre- -1)>0||(e.internal_flags.nsPsy.attackthre=s[i].st_lrm),0!=r?e.internal_flags.nsPsy.attackthre_s=s[i].st_s:Math.abs(e.internal_flags.nsPsy.attackthre_s- -1)>0||(e.internal_flags.nsPsy.attackthre_s=s[i].st_s),0!=r?e.scale=s[i].scale:Math.abs(e.scale- -1)>0||(e.scale=s[i].scale),0!=r?e.maskingadjust=s[i].masking_adj:Math.abs(e.maskingadjust-0)>0||(e.maskingadjust=s[i].masking_adj),s[i].masking_adj>0?0!=r?e.maskingadjust_short=.9*s[i].masking_adj:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=.9*s[i].masking_adj):0!=r?e.maskingadjust_short=1.1*s[i].masking_adj:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=1.1*s[i].masking_adj),0!=r?e.ATHlower=-s[i].ath_lower/10:Math.abs(10*-e.ATHlower-0)>0||(e.ATHlower=-s[i].ath_lower/10),0!=r?e.ATHcurve=s[i].ath_curve:Math.abs(e.ATHcurve- -1)>0||(e.ATHcurve=s[i].ath_curve),0!=r?e.interChRatio=s[i].interch:Math.abs(e.interChRatio- -1)>0||(e.interChRatio=s[i].interch),t}this.apply_preset=function(e,t,n){switch(t){case Z.R3MIX:t=Z.V3,e.VBR=v.vbr_mtrh;break;case Z.MEDIUM:t=Z.V4,e.VBR=v.vbr_rh;break;case Z.MEDIUM_FAST:t=Z.V4,e.VBR=v.vbr_mtrh;break;case Z.STANDARD:t=Z.V2,e.VBR=v.vbr_rh;break;case Z.STANDARD_FAST:t=Z.V2,e.VBR=v.vbr_mtrh;break;case Z.EXTREME:t=Z.V0,e.VBR=v.vbr_rh;break;case Z.EXTREME_FAST:t=Z.V0,e.VBR=v.vbr_mtrh;break;case Z.INSANE:return t=320,e.preset=t,o(e,t,n),e.VBR=v.vbr_off,t}switch(e.preset=t,t){case Z.V9:return i(e,9,n),t;case Z.V8:return i(e,8,n),t;case Z.V7:return i(e,7,n),t;case Z.V6:return i(e,6,n),t;case Z.V5:return i(e,5,n),t;case Z.V4:return i(e,4,n),t;case Z.V3:return i(e,3,n),t;case Z.V2:return i(e,2,n),t;case Z.V1:return i(e,1,n),t;case Z.V0:return i(e,0,n),t}return 8<=t&&t<=320?o(e,t,n):(e.preset=0,t)}}function S(){var e;this.setModules=function(t){e=t},this.ResvFrameBegin=function(t,n){var r,a=t.internal_flags,i=a.l3_side,s=e.getframebits(t);n.bits=(s-8*a.sideinfo_len)/a.mode_gr;var o=2048*a.mode_gr-8;t.brate>320?r=8*int(1e3*t.brate/(t.out_samplerate/1152)/8+.5):(r=11520,t.strict_ISO&&(r=8*int(32e4/(t.out_samplerate/1152)/8+.5))),a.ResvMax=r-s,a.ResvMax>o&&(a.ResvMax=o),(a.ResvMax<0||t.disable_reservoir)&&(a.ResvMax=0);var l=n.bits*a.mode_gr+Math.min(a.ResvSize,a.ResvMax);return l>r&&(l=r),i.resvDrain_pre=0,null!=a.pinfo&&(a.pinfo.mean_bits=n.bits/2,a.pinfo.resvsize=a.ResvSize),l},this.ResvMaxBits=function(e,t,n,r){var a,i=e.internal_flags,s=i.ResvSize,o=i.ResvMax;0!=r&&(s+=t),0!=(1&i.substep_shaping)&&(o*=.9),n.bits=t,10*s>9*o?(a=s-9*o/10,n.bits+=a,i.substep_shaping|=128):(a=0,i.substep_shaping&=127,e.disable_reservoir||0!=(1&i.substep_shaping)||(n.bits-=.1*t));var l=s<6*i.ResvMax/10?s:6*i.ResvMax/10;return(l-=a)<0&&(l=0),l},this.ResvAdjust=function(e,t){e.ResvSize-=t.part2_3_length+t.part2_length},this.ResvFrameEnd=function(e,t){var n,r=e.l3_side;e.ResvSize+=t*e.mode_gr;var a=0;r.resvDrain_post=0,r.resvDrain_pre=0,0!=(n=e.ResvSize%8)&&(a+=n),(n=e.ResvSize-a-e.ResvMax)>0&&(a+=n);var i=Math.min(8*r.main_data_begin,a)/8;r.resvDrain_pre+=8*i,a-=8*i,e.ResvSize-=8*i,r.main_data_begin-=i,r.resvDrain_post+=a,e.ResvSize-=a}}function x(){this.setModules=function(e,t,n){e,t,n};var e=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];function t(t,n){return n=n>>8^e[255&(n^t)]}this.updateMusicCRC=function(e,n,r,a){for(var i=0;i0;){var r;0==h&&(h=8,p++,e.header[e.w_ptr].write_timing==f&&d(e),c[p]=0),n-=r=Math.min(n,h),h-=r,c[p]|=t>>n<0;){var r;0==h&&(h=8,p++,c[p]=0),n-=r=Math.min(n,h),h-=r,c[p]|=t>>n<=8&&(v(r,76,8),t-=8),t>=8&&(v(r,65,8),t-=8),t>=8&&(v(r,77,8),t-=8),t>=8&&(v(r,69,8),t-=8),t>=32){var a=s.getLameShortVersion();if(t>=32)for(n=0;n=8;++n)t-=8,v(r,a.charCodeAt(n),8)}for(;t>=1;t-=1)v(r,r.ancillary_flag,1),r.ancillary_flag^=e.disable_reservoir?0:1}function w(e,t,n){for(var r=e.header[e.h_ptr].ptr;n>0;){var a=Math.min(n,8-(7&r));n-=a,e.header[e.h_ptr].buf[r>>3]|=t>>n<<8-(7&r)-a,r+=a}e.header[e.h_ptr].ptr=r}function S(e,t){e<<=8;for(var n=0;n<8;n++)0!=(65536&((t<<=1)^(e<<=1)))&&(t^=32773);return t}function x(e,t){var n,r=M.ht[t.count1table_select+32],a=0,i=t.big_values,s=t.big_values;for(n=(t.count1-t.big_values)/4;n>0;--n){var o=0,l=0;0!=t.l3_enc[i+0]&&(l+=8,t.xr[s+0]<0&&o++),0!=t.l3_enc[i+1]&&(l+=4,o*=2,t.xr[s+1]<0&&o++),0!=t.l3_enc[i+2]&&(l+=2,o*=2,t.xr[s+2]<0&&o++),0!=t.l3_enc[i+3]&&(l++,o*=2,t.xr[s+3]<0&&o++),i+=4,s+=4,v(e,o+r.table[l],r.hlen[l]),a+=r.hlen[l]}return a}function k(e,t,n,r,a){var i=M.ht[t],s=0;if(0==t)return s;for(var o=n;o15){if(p>14)_|=p-15<<1,c=f,p=15;if(h>14)_<<=f,_|=h-15,c+=f,h=15;u=16}0!=h&&(_<<=1,a.xr[o+1]<0&&_++,l--),p=p*u+h,c-=l,l+=i.hlen[p],v(e,i.table[p],l),v(e,_,c),s+=l+c}return s}function A(e,t){var n=3*e.scalefac_band.s[3];n>t.big_values&&(n=t.big_values);var r=k(e,t.table_select[0],0,n,t);return r+=k(e,t.table_select[1],n,t.big_values,t)}function R(e,t){var n,r,a,i;n=t.big_values;var s=t.region0_count+1;return a=e.scalefac_band.l[s],s+=t.region1_count+1,a>n&&(a=n),(i=e.scalefac_band.l[s])>n&&(i=n),r=k(e,t.table_select[0],0,a,t),r+=k(e,t.table_select[1],a,i,t),r+=k(e,t.table_select[2],i,n,t)}function T(){this.total=0}function B(t,n){var r,a,i,s,o,l=t.internal_flags;return o=l.w_ptr,-1==(s=l.h_ptr-1)&&(s=U.MAX_HEADER_BUF-1),r=l.header[s].write_timing-f,n.total=r,r>=0&&(a=1+s-o,s>8),t[5]=byte(255&n)},this.flush_bitstream=function(e){var n,a,i=e.internal_flags,s=i.h_ptr-1;if(-1==s&&(s=U.MAX_HEADER_BUF-1),n=i.l3_side,!((a=B(e,new T))<0)){if(b(e,a),i.ResvSize=0,n.main_data_begin=0,i.findReplayGain){var o=r.GetTitleGain(i.rgdata);i.RadioGain=0|Math.floor(10*o+.5)}i.findPeakSample&&(i.noclipGainChange=0|Math.ceil(20*t(i.PeakSample/32767)*10),i.noclipGainChange>0&&(EQ(e.scale,1)||EQ(e.scale,0))?i.noclipScale=Math.floor(32767/i.PeakSample*100)/100:i.noclipScale=-1)}},this.add_dummy_byte=function(e,t,n){for(var r,a=e.internal_flags;n-- >0;)for(m(0,t,8),r=0;r ResvSize"),8*t.main_data_begin!=n.ResvSize&&(_.err.printf("bit reservoir error: \nl3_side.main_data_begin: %d \nResvoir size: %d \nresv drain (post) %d \nresv drain (pre) %d \nheader and sideinfo: %d \ndata bits: %d \ntotal bits: %d (remainder: %d) \nbitsperframe: %d \n",8*t.main_data_begin,n.ResvSize,t.resvDrain_post,t.resvDrain_pre,8*n.sideinfo_len,a-t.resvDrain_post-8*n.sideinfo_len,a,a%8,r),_.err.println("This is a fatal error. It has several possible causes:"),_.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),_.err.println(" 9%% Your system is overclocked"),_.err.println(" 1%% bug in LAME encoding library"),n.ResvSize=8*t.main_data_begin),f>1e9){var i;for(i=0;is)return-1;if(_.arraycopy(c,0,t,n,u),p=-1,h=0,0!=f){var d=a(1);if(d[0]=e.nMusicCRC,l.updateMusicCRC(d,t,n,u),e.nMusicCRC=d[0],u>0&&(e.VBR_seek_table.nBytesWritten+=u),e.decode_on_the_fly)for(var v,m=o([2,1152]),b=u,g=-1;0!=g;)if(g=i.hip_decode1_unclipped(e.hip,t,n,b,m[0],m[1]),b=0,-1==g&&(g=0),g>0){if(e.findPeakSample){for(v=0;ve.PeakSample?e.PeakSample=m[0][v]:-m[0][v]>e.PeakSample&&(e.PeakSample=-m[0][v]);if(e.channels_out>1)for(v=0;ve.PeakSample?e.PeakSample=m[1][v]:-m[1][v]>e.PeakSample&&(e.PeakSample=-m[1][v])}if(e.findReplayGain&&r.AnalyzeSamples(e.rgdata,m[0],0,m[1],0,g,e.channels_out)==y.GAIN_ANALYSIS_ERROR)return-6}}return u},this.init_bit_stream_w=function(e){c=n(Z.LAME_MAXMP3BUFFER),e.h_ptr=e.w_ptr=0,e.header[e.h_ptr].write_timing=0,p=-1,h=0,f=0}}function A(e,t,n,r){this.xlen=e,this.linmax=t,this.table=n,this.hlen=r}m.STEREO=new m(0),m.JOINT_STEREO=new m(1),m.DUAL_CHANNEL=new m(2),m.MONO=new m(3),m.NOT_SET=new m(4),y.STEPS_per_dB=100,y.MAX_dB=120,y.GAIN_NOT_ENOUGH_SAMPLES=-24601,y.GAIN_ANALYSIS_ERROR=0,y.GAIN_ANALYSIS_OK=1,y.INIT_GAIN_ANALYSIS_ERROR=0,y.INIT_GAIN_ANALYSIS_OK=1,y.YULE_ORDER=10,y.MAX_ORDER=y.YULE_ORDER,y.MAX_SAMP_FREQ=48e3,y.RMS_WINDOW_TIME_NUMERATOR=1,y.RMS_WINDOW_TIME_DENOMINATOR=20,y.MAX_SAMPLES_PER_WINDOW=y.MAX_SAMP_FREQ*y.RMS_WINDOW_TIME_NUMERATOR/y.RMS_WINDOW_TIME_DENOMINATOR+1,x.NUMTOCENTRIES=100,x.MAXFRAMESIZE=2880,k.EQ=function(e,t){return Math.abs(e)>Math.abs(t)?Math.abs(e-t)<=1e-6*Math.abs(e):Math.abs(e-t)<=1e-6*Math.abs(t)},k.NEQ=function(e,t){return!k.EQ(e,t)};var M={};function R(e){this.bits=e}function T(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}function B(){this.setModules=function(e,t){e,t}}function E(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=i(F.SBMAX_l),this.s=i(F.SBMAX_s),this.psfb21=i(F.PSFB21),this.psfb12=i(F.PSFB12),this.cb_l=i(F.CBANDS),this.cb_s=i(F.CBANDS),this.eql_w=i(F.BLKSIZE/2)}function C(){this.class_id=0,this.num_samples=0,this.num_channels=0,this.in_samplerate=0,this.out_samplerate=0,this.scale=0,this.scale_left=0,this.scale_right=0,this.analysis=!1,this.bWriteVbrTag=!1,this.decode_only=!1,this.quality=0,this.mode=m.STEREO,this.force_ms=!1,this.free_format=!1,this.findReplayGain=!1,this.decode_on_the_fly=!1,this.write_id3tag_automatic=!1,this.brate=0,this.compression_ratio=0,this.copyright=0,this.original=0,this.extension=0,this.emphasis=0,this.error_protection=0,this.strict_ISO=!1,this.disable_reservoir=!1,this.quant_comp=0,this.quant_comp_short=0,this.experimentalY=!1,this.experimentalZ=0,this.exp_nspsytune=0,this.preset=0,this.VBR=null,this.VBR_q_frac=0,this.VBR_q=0,this.VBR_mean_bitrate_kbps=0,this.VBR_min_bitrate_kbps=0,this.VBR_max_bitrate_kbps=0,this.VBR_hard_min=0,this.lowpassfreq=0,this.highpassfreq=0,this.lowpasswidth=0,this.highpasswidth=0,this.maskingadjust=0,this.maskingadjust_short=0,this.ATHonly=!1,this.ATHshort=!1,this.noATH=!1,this.ATHtype=0,this.ATHcurve=0,this.ATHlower=0,this.athaa_type=0,this.athaa_loudapprox=0,this.athaa_sensitivity=0,this.short_blocks=null,this.useTemporal=!1,this.interChRatio=0,this.msfix=0,this.tune=!1,this.tune_value_a=0,this.version=0,this.encoder_delay=0,this.encoder_padding=0,this.framesize=0,this.frameNum=0,this.lame_allocated_gfp=0,this.internal_flags=null}function P(e){var t=e;this.quantize=t,this.iteration_loop=function(e,t,n,r){var s,o=e.internal_flags,l=i($.SFBMAX),c=i(576),f=a(2),u=0,_=o.l3_side,p=new R(u);this.quantize.rv.ResvFrameBegin(e,p),u=p.bits;for(var h=0;h>2&63)>=32&&(r-=64),c=Math.pow(10,r/4/10),(r=n.exp_nspsytune>>8&63)>=32&&(r-=64),p=Math.pow(10,r/4/10),(r=n.exp_nspsytune>>14&63)>=32&&(r-=64),v=Math.pow(10,r/4/10),(r=n.exp_nspsytune>>20&63)>=32&&(r-=64),b=v*Math.pow(10,r/4/10),r=0;rU.MAX_BITS_PER_GRANULE&&(d=U.MAX_BITS_PER_GRANULE),l=0,c=0;c3*i/4&&(_[c]=3*i/4),_[c]<0&&(_[c]=0),_[c]+r[c]>U.MAX_BITS_PER_CHANNEL&&(_[c]=Math.max(0,U.MAX_BITS_PER_CHANNEL-r[c])),l+=_[c];if(l>h)for(c=0;cU.MAX_BITS_PER_GRANULE){for(c=0;c.5&&(a=.5);var i=0|.5*a*(e[0]+e[1]);i>U.MAX_BITS_PER_CHANNEL-e[0]&&(i=U.MAX_BITS_PER_CHANNEL-e[0]),i<0&&(i=0),e[1]>=125&&(e[1]-i>125?(e[0]r&&(e[0]=r*e[0]/i,e[1]=r*e[1]/i)},this.athAdjust=function(e,t,n){var r=90.30873362,a=p.FAST_LOG10_X(t,10),i=e*e,s=0;return a-=n,i>1e-20&&(s=1+p.FAST_LOG10_X(i,10/r)),s<0&&(s=0),a*=s,a+=n+r-94.82444863,Math.pow(10,.1*a)},this.calc_xmin=function(e,t,n,r){var a,i=0,s=e.internal_flags,o=0,l=0,c=s.ATH,f=n.xr,u=e.VBR==v.vbr_mtrh?1:0,_=s.masking_lower;for(e.VBR!=v.vbr_mtrh&&e.VBR!=v.vbr_mt||(_=1),a=0;a>1,M=0;do{M+=T=f[o]*f[o],S+=T0);if(M>y&&l++,a==F.SBPSY_l)S<(A=y*s.nsPsy.longfact[a])&&(S=A);if(0!=u&&(y=S),!e.ATHonly)if((x=t.en.l[a])>0)A=M*t.thm.l[a]*_/x,0!=u&&(A*=s.nsPsy.longfact[a]),y>1;w=g/m,S=2220446049250313e-31;do{var T,B;M+=T=f[o]*f[o],S+=T0);if(M>g&&l++,d==F.SBPSY_s)S<(A=g*s.nsPsy.shortfact[d])&&(S=A);if(y=0!=u?S:g,!e.ATHonly&&!e.ATHshort)if((x=t.en.s[d][b])>0)A=M*t.thm.s[d][b]*_/x,0!=u&&(A*=s.nsPsy.shortfact[d]),yr[i-3+1]&&(r[i-3+1]+=(r[i-3]-r[i-3+1])*s.decay),r[i-3+1]>r[i-3+2]&&(r[i-3+2]+=(r[i-3+1]-r[i-3+2])*s.decay))}return l},this.calc_noise_core=function(e,t,n,r){var a=0,s=t.s,o=e.l3_enc;if(s>e.count1)for(;0!=n--;){c=e.xr[s],s++,a+=c*c,c=e.xr[s],s++,a+=c*c}else if(s>e.big_values){var l=i(2);for(l[0]=0,l[1]=r;0!=n--;){c=Math.abs(e.xr[s])-l[o[s]],s++,a+=c*c,c=Math.abs(e.xr[s])-l[o[s]],s++,a+=c*c}}else for(;0!=n--;){var c;c=Math.abs(e.xr[s])-_[o[s]]*r,s++,a+=c*c,c=Math.abs(e.xr[s])-_[o[s]]*r,s++,a+=c*c}return t.s=s,a},this.calc_noise=function(e,t,n,r,a){var i,s,o=0,l=0,u=0,_=0,h=0,d=-20,v=0,m=e.scalefac,g=0;for(r.over_SSD=0,i=0;i>1,v+e.width[i]>e.max_nonzero_coeff)s=(x=e.max_nonzero_coeff-v+1)>0?x>>1:0;var A=new b(v);S=this.calc_noise_core(e,A,s,k),v=A.s,null!=a&&(a.step[i]=w,a.noise[i]=S),S=n[o++]=S/t[l++],S=p.FAST_LOG10(Math.max(S,1e-20)),null!=a&&(a.noise_log[i]=S)}if(null!=a&&(a.global_gain=e.global_gain),h+=S,S>0)y=Math.max(0|10*S+.5,1),r.over_SSD+=y*y,u++,_+=S;d=Math.max(d,S)}return r.over_count=u,r.tot_noise=h,r.over_noise=_,r.max_noise=d,u},this.set_pinfo=function(e,t,n,r,a){var s,o,l,f,u,_=e.internal_flags,p=0==t.scalefac_scale?.5:1,h=t.scalefac,d=i($.SFBMAX),v=i($.SFBMAX),m=new T;calc_xmin(e,n,t,d),calc_noise(t,d,v,m,null);var b=0;for(o=t.sfb_lmax,t.block_type!=F.SHORT_TYPE&&0==t.mixed_block_flag&&(o=22),s=0;s0&&!e.ATHonly?f/=n.en.l[s]:f=0,_.pinfo.thr[r][a][s]=u*Math.max(f*n.thm.l[s],_.ATH.l[s]),_.pinfo.LAMEsfb[r][a][s]=0,0!=t.preflag&&s>=11&&(_.pinfo.LAMEsfb[r][a][s]=-p*c[s]),s0?f/=n.en.s[s][S]:f=0,(e.ATHonly||e.ATHshort)&&(f=0),_.pinfo.thr_s[r][a][3*s+S]=u*Math.max(f*n.thm.s[s][S],_.ATH.s[s]),_.pinfo.LAMEsfb_s[r][a][3*s+S]=-2*t.subblock_gain[S],s0?(i=n.over_SSD<=t.over_SSD,n.over_SSD==t.over_SSD&&(i=n.bits.2||n.max_noise<=0&&t.max_noise<0&&t.max_noise>n.max_noise-.2&&n.tot_noise0&&t.max_noise>n.max_noise-.2&&n.tot_noise0&&t.max_noise>-.05&&t.max_noise>n.max_noise-.1&&n.tot_noise+n.over_noise0&&t.max_noise>-.1&&t.max_noise>n.max_noise-.15&&n.tot_noise+n.over_noise+n.over_noise1?o=Math.pow(o,.5):o*=.95;break;case 0:default:o>1?o=1:o*=.95}var f=0;for(l=0;lt.xrpow_max&&(t.xrpow_max=r[f+u]);if(2==s.noise_shaping_amp)return}}}(e,t,a,i,s);var c=o(t);return!c&&(!(c=2==l.mode_gr?r.scale_bitcount(t):r.scale_bitcount_lsf(l,t))||(l.noise_shaping>1&&(u.fill(l.pseudohalf,0),0==t.scalefac_scale?(!function(e,t){for(var r=0,a=0;ae.xrpow_max&&(e.xrpow_max=t[r+o])}e.scalefac[a]=s>>1}e.preflag=0,e.scalefac_scale=1}(t,i),c=!1):t.block_type==F.SHORT_TYPE&&l.subblock_gain>0&&(c=function(e,t,r){var a,i=t.scalefac;for(a=0;a=16)return!0;for(var s=0;s<3;s++){var o=0,l=0;for(a=t.sfb_lmax+s;a=7)return!0;t.subblock_gain[s]++;var c=e.scalefac_band.l[t.sfb_lmax];for(a=t.sfb_lmax+s;a>t.scalefac_scale)>=0)i[a]=u,c+=3*f;else{i[a]=0;var _=210+(u<t.xrpow_max&&(t.xrpow_max=r[c+p]);c+=f*(3-s-1)}}var h=n.IPOW20(202);c+=t.width[a]*(s+1);for(p=-t.width[a];p<0;p++)r[c+p]*=h,r[c+p]>t.xrpow_max&&(t.xrpow_max=r[c+p])}}return!1}(l,t,i)||o(t))),c||(c=2==l.mode_gr?r.scale_bitcount(t):r.scale_bitcount_lsf(l,t)),!c))}this.setModules=function(i,s,o,l){e=i,t=s,this.rv=s,n=o,this.qupvt=o,r=l,a.setModules(n,r)},this.ms_convert=function(e,t){for(var n=0;n<576;++n){var r=e.tt[t][0].xr[n],a=e.tt[t][1].xr[n];e.tt[t][0].xr[n]=(r+a)*(.5*p.SQRT2),e.tt[t][1].xr[n]=(r-a)*(.5*p.SQRT2)}},this.init_xrpow=function(e,t,n){var r=0,a=0|t.max_nonzero_coeff;if(t.xrpow_max=0,u.fill(n,a,576,0),(r=function(e,t,n,r){r=0;for(var a=0;a<=n;++a){var i=Math.abs(e.xr[a]);r+=i,t[a]=Math.sqrt(i*Math.sqrt(i)),t[a]>e.xrpow_max&&(e.xrpow_max=t[a])}return r}(t,n,a,r))>1e-20){var i=0;0!=(2&e.substep_shaping)&&(i=1);for(var s=0;s=0&&!i;s--){var o=e.scalefac_band.psfb21[s],l=e.scalefac_band.psfb21[s+1],c=n.athAdjust(r.adjust,r.psfb21[s],r.floor);e.nsPsy.longfact[21]>1e-12&&(c*=e.nsPsy.longfact[21]);for(var f=l-1;f>=o;f--){if(!(Math.abs(a[f])=0&&!i;s--){l=(o=3*e.scalefac_band.s[12]+(e.scalefac_band.s[13]-e.scalefac_band.s[12])*u+(e.scalefac_band.psfb12[s]-e.scalefac_band.psfb12[0]))+(e.scalefac_band.psfb12[s+1]-e.scalefac_band.psfb12[s]);var _=n.athAdjust(r.adjust,r.psfb12[s],r.floor);e.nsPsy.shortfact[12]>1e-12&&(_*=e.nsPsy.shortfact[12]);for(f=l-1;f>=o;f--){if(!(Math.abs(a[f])<_)){i=!0;break}a[f]=0}}}(e,t)},s.BINSEARCH_NONE=new s(0),s.BINSEARCH_UP=new s(1),s.BINSEARCH_DOWN=new s(2),this.trancate_smallspectrums=function(e,t,a,s){var o=i($.SFBMAX);if((0!=(4&e.substep_shaping)||t.block_type!=F.SHORT_TYPE)&&0==(128&e.substep_shaping)){n.calc_noise(t,a,o,new T,null);for(var l=0;l<576;l++){var c=0;0!=t.l3_enc[l]&&(c=Math.abs(t.xr[l])),s[l]=c}l=0;var f=8;t.block_type==F.SHORT_TYPE&&(f=6);do{var _,p,h,d,v=t.width[f];if(l+=v,!(o[f]>=1||(u.sort(s,l-v,v),k.EQ(s[l-1],0)))){_=(1-o[f])*a[f],p=0,d=0;do{var m;for(h=1;d+h0)}}while(++fn?(u==s.BINSEARCH_DOWN&&(c=!0),c&&(l/=2),u=s.BINSEARCH_UP,_=l):(u==s.BINSEARCH_UP&&(c=!0),c&&(l/=2),u=s.BINSEARCH_DOWN,_=-l),t.global_gain+=_,t.global_gain<0&&(t.global_gain=0,c=!0),t.global_gain>255&&(t.global_gain=255,c=!0)}for(;o>n&&t.global_gain<255;)t.global_gain++,o=r.count_bits(e,i,t,null);e.CurrentStep[a]=f-t.global_gain>=4?4:2,e.OldValue[a]=t.global_gain,t.part2_3_length=o}(p,t,u,f,o),0==p.noise_shaping)return 100;n.calc_noise(t,a,m,b,g),b.bits=t.part2_3_length,h.assign(t);var k=0;for(_.arraycopy(o,0,d,0,576);!w;){do{var A,M=new T,R=255;if(A=0!=(2&p.substep_shaping)?20:3,p.sfb21_extra){if(m[h.sfbmax]>1)break;if(h.block_type==F.SHORT_TYPE&&(m[h.sfbmax+1]>1||m[h.sfbmax+2]>1))break}if(!c(e,h,m,o,S))break;0!=h.scalefac_scale&&(R=254);var B=u-h.part2_length;if(B<=0)break;for(;(h.part2_3_length=r.count_bits(p,o,h,g))>B&&h.global_gain<=R;)h.global_gain++;if(h.global_gain>R)break;if(0==b.over_count){for(;(h.part2_3_length=r.count_bits(p,o,h,g))>y&&h.global_gain<=R;)h.global_gain++;if(h.global_gain>R)break}if(n.calc_noise(h,a,m,M,g),M.bits=h.part2_3_length,0!=(l(t.block_type!=F.SHORT_TYPE?e.quant_comp:e.quant_comp_short,b,M,h,m)?1:0))y=t.part2_3_length,b=M,t.assign(h),k=0,_.arraycopy(o,0,d,0,576);else if(0==p.full_outer_loop){if(++k>A&&0==b.over_count)break;if(3==p.noise_shaping_amp&&S&&k>30)break;if(3==p.noise_shaping_amp&&S&&h.global_gain-x>15)break}}while(h.global_gain+h.scalefac_scale<255);3==p.noise_shaping_amp?S?w=!0:(h.assign(t),_.arraycopy(d,0,o,0,576),k=0,x=h.global_gain,S=!0):w=!0}return e.VBR==v.vbr_rh||e.VBR==v.vbr_mtrh?_.arraycopy(d,0,o,0,576):0!=(1&p.substep_shaping)&&trancate_smallspectrums(p,t,a,o),b.over_count},this.iteration_finish_one=function(e,n,a){var i=e.l3_side,s=i.tt[n][a];r.best_scalefac_store(e,n,a,i),1==e.use_best_huffman&&r.best_huffman_divide(e,s),t.ResvAdjust(e,s)},this.VBR_encode_granule=function(e,t,n,r,a,s,o){var l,c=e.internal_flags,f=new N,p=i(576),h=o,d=o+1,v=(o+s)/2,m=0,b=c.sfb21_extra;u.fill(f.l3_enc,0);do{c.sfb21_extra=!(v>h-42)&&b,outer_loop(e,t,n,r,a,v)<=0?(m=1,d=t.part2_3_length,f.assign(t),_.arraycopy(r,0,p,0,576),l=(o=d-32)-s,v=(o+s)/2):(l=o-(s=v+32),v=(o+s)/2,0!=m&&(m=2,t.assign(f),_.arraycopy(p,0,r,0,576)))}while(l>12);c.sfb21_extra=b,2==m&&_.arraycopy(f.l3_enc,0,t.l3_enc,0,576)},this.get_framebits=function(n,r){var a=n.internal_flags;a.bitrate_index=a.VBR_min_bitrate;var i=e.getframebits(n);a.bitrate_index=1,i=e.getframebits(n);for(var s=1;s<=a.VBR_max_bitrate;s++){a.bitrate_index=s;var o=new R(i);r[s]=t.ResvFrameBegin(n,o),i=o.bits}},this.VBR_old_prepare=function(e,r,a,i,s,o,l,c,f){var u,_=e.internal_flags,p=0,h=1,d=0;_.bitrate_index=_.VBR_max_bitrate;var v=t.ResvFrameBegin(e,new R(0))/_.mode_gr;get_framebits(e,o);for(var m=0;m<_.mode_gr;m++){var b=n.on_pe(e,r,c[m],v,m,0);_.mode_ext==F.MPG_MD_MS_LR&&(ms_convert(_.l3_side,m),n.reduce_side(c[m],a[m],v,b));for(var g=0;g<_.channels_out;++g){var y=_.l3_side.tt[m][g];y.block_type!=F.SHORT_TYPE?(p=1.28/(1+Math.exp(3.5-r[m][g]/300))-.05,u=_.PSY.mask_adjust-p):(p=2.56/(1+Math.exp(3.5-r[m][g]/300))-.14,u=_.PSY.mask_adjust_short-p),_.masking_lower=Math.pow(10,.1*u),init_outer_loop(_,y),f[m][g]=n.calc_xmin(e,i[m][g],y,s[m][g]),0!=f[m][g]&&(h=0),l[m][g]=126,d+=c[m][g]}}for(m=0;m<_.mode_gr;m++)for(g=0;g<_.channels_out;g++)d>o[_.VBR_max_bitrate]&&(c[m][g]*=o[_.VBR_max_bitrate],c[m][g]/=d),l[m][g]>c[m][g]&&(l[m][g]=c[m][g]);return h},this.bitpressure_strategy=function(e,t,n,r){for(var a=0;al&&(o[h][d]*=l,o[h][d]/=_);return f},this.calc_target_bits=function(r,a,i,s,o,l){var c,f,u,_,p=r.internal_flags,h=p.l3_side,d=0;p.bitrate_index=p.VBR_max_bitrate;var v=new R(d);for(l[0]=t.ResvFrameBegin(r,v),d=v.bits,p.bitrate_index=1,d=e.getframebits(r)-8*p.sideinfo_len,o[0]=d/(p.mode_gr*p.channels_out),d=r.VBR_mean_bitrate_kbps*r.framesize*1e3,0!=(1&p.substep_shaping)&&(d*=1.09),d/=r.out_samplerate,d-=8*p.sideinfo_len,d/=p.mode_gr*p.channels_out,(c=.93+.07*(11-r.compression_ratio)/5.5)<.9&&(c=.9),c>1&&(c=1),f=0;f700){var b=int((a[f][u]-700)/1.4),g=h.tt[f][u];s[f][u]=int(c*d),g.block_type==F.SHORT_TYPE&&b3*d/2?b=3*d/2:b<0&&(b=0),s[f][u]+=b}s[f][u]>U.MAX_BITS_PER_CHANNEL&&(s[f][u]=U.MAX_BITS_PER_CHANNEL),m+=s[f][u]}if(m>U.MAX_BITS_PER_GRANULE)for(u=0;uU.MAX_BITS_PER_CHANNEL&&(s[f][u]=U.MAX_BITS_PER_CHANNEL),_+=s[f][u];if(_>l[0])for(f=0;f=0;--z){var ee,te;ee=V[q+z]*a[20+z]+V[q+-1-z]*s[28+z],te=V[q+z]*s[28+z]-V[q+-1-z]*a[20+z],V[q+-1-z]=ee,V[q+z]=te}}}if(I=p,H=286,1==e.mode_gr)for(var ne=0;ne<18;ne++)_.arraycopy(e.sb_sample[N][1][ne],0,e.sb_sample[N][0][ne],0,32)}}}function V(){this.thm=new X,this.en=new X}function F(){var e=F.FFTOFFSET,t=F.MPG_MD_MS_LR,n=null;this.psy=null;var r=null,s=null,l=null;this.setModules=function(e,t,a,i){n=e,this.psy=t,r=t,s=i,l=a};var c=new j;this.lame_encode_mp3_frame=function(u,p,h,d,b,g){var y,w=f([2,2]);w[0][0]=new V,w[0][1]=new V,w[1][0]=new V,w[1][1]=new V;var S,x=f([2,2]);x[0][0]=new V,x[0][1]=new V,x[1][0]=new V,x[1][1]=new V;var k,A,M,R=[null,null],T=u.internal_flags,B=o([2,4]),E=[.5,.5],C=[[0,0],[0,0]],P=[[0,0],[0,0]];if(R[0]=p,R[1]=h,0==T.lame_encode_frame_init&&function(e,t){var n,r,a=e.internal_flags;if(0==a.lame_encode_frame_init){var s,o,l=i(2014),f=i(2014);for(a.lame_encode_frame_init=1,s=0,o=0;s<286+576*(1+a.mode_gr);++s)s<576*a.mode_gr?(l[s]=0,2==a.channels_out&&(f[s]=0)):(l[s]=t[0][o],2==a.channels_out&&(f[s]=t[1][o]),++o);for(r=0;r0&&(E[M]=B[M][3]/E[M])),A=0;A.03125)e.ATH.adjust>=1?e.ATH.adjust=1:e.ATH.adjust=r?(e.ATH.adjust*=.075*r+.925,e.ATH.adjust=r?e.ATH.adjust=r:e.ATH.adjust>1,d=(h=a<<1)+(_=a),a=h<<1,s=(i=t)+v;do{x=e[i+0]-e[i+_],S=e[i+0]+e[i+_],R=e[i+h]-e[i+d],A=e[i+h]+e[i+d],e[i+h]=S-A,e[i+0]=S+A,e[i+d]=x-R,e[i+_]=x+R,x=e[s+0]-e[s+_],S=e[s+0]+e[s+_],R=p.SQRT2*e[s+d],A=p.SQRT2*e[s+h],e[s+h]=S-A,e[s+0]=S+A,e[s+d]=x-R,e[s+_]=x+R,s+=a,i+=a}while(i=0);r(n[l],c,F.BLKSIZE_s/2)}},this.fft_long=function(t,n,i,s,o){var l=F.BLKSIZE/8-1,c=F.BLKSIZE/2;do{var f,u,_,p,h,d=255&a[l];u=(f=e[d]*s[i][o+d])-(h=e[d+512]*s[i][o+d+512]),f+=h,p=(_=e[d+256]*s[i][o+d+256])-(h=e[d+768]*s[i][o+d+768]),_+=h,n[(c-=4)+0]=f+_,n[c+2]=f-_,n[c+1]=u+p,n[c+3]=u-p,u=(f=e[d+1]*s[i][o+d+1])-(h=e[d+513]*s[i][o+d+513]),f+=h,p=(_=e[d+257]*s[i][o+d+257])-(h=e[d+769]*s[i][o+d+769]),_+=h,n[c+F.BLKSIZE/2+0]=f+_,n[c+F.BLKSIZE/2+2]=f-_,n[c+F.BLKSIZE/2+1]=u+p,n[c+F.BLKSIZE/2+3]=u-p}while(--l>=0);r(n,c,F.BLKSIZE/2)},this.init_fft=function(n){for(var r=0;r=0;--d){var v=i[s+0][d],m=i[s+1][d];i[s+0][d]=(v+m)*p.SQRT2*.5,i[s+1][d]=(v-m)*p.SQRT2*.5}for(var b=2;b>=0;--b)for(d=F.BLKSIZE_s-1;d>=0;--d){v=o[l+0][b][d],m=o[l+1][b][d];o[l+0][b][d]=(v+m)*p.SQRT2*.5,o[l+1][b][d]=(v-m)*p.SQRT2*.5}}n[0]=i[s+0][0],n[0]*=n[0];for(d=F.BLKSIZE/2-1;d>=0;--d){var g=i[s+0][F.BLKSIZE/2-d],y=i[s+0][F.BLKSIZE/2+d];n[F.BLKSIZE/2-d]=.5*(g*g+y*y)}for(b=2;b>=0;--b){a[b][0]=o[l+0][b][0],a[b][0]*=a[b][0];for(d=F.BLKSIZE_s/2-1;d>=0;--d){g=o[l+0][b][F.BLKSIZE_s/2-d],y=o[l+0][b][F.BLKSIZE_s/2+d];a[b][F.BLKSIZE_s/2-d]=.5*(g*g+y*y)}}var w=0;for(d=11;de){if(!(t=t*c)return e+t;s=e/t}if(e+=t,r+3<=6){if(s>=l)return e;var o=0|p.FAST_LOG10_X(s,16);return e*g[o]}var u,_;o=0|p.FAST_LOG10_X(s,16);return t=0!=i?a.ATH.cb_s[n]*a.ATH.adjust:a.ATH.cb_l[n]*a.ATH.adjust,et?(u=1,o<=13&&(u=y[o]),_=p.FAST_LOG10_X(e/t,10/15),e*((b[o]-u)*_+u)):o>13?e:e*y[o]:e*b[o]}var S=[1.7782755904,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.6999465924,1.22321*1.22321,1.3169398564,1];function x(e,t,n){var r;if(e<0&&(e=0),t<0&&(t=0),e<=0)return t;if(t<=0)return e;if(r=t>e?t/e:e/t,-2<=n&&n<=2){if(r>=l)return e+t;var a=0|p.FAST_LOG10_X(r,16);return(e+t)*S[a]}return r=f){++i;break}var _=e.PSY.bo_s_weight[i],p=1-_;o=_*t[s],l=_*n[s],e.en[r].s[i][a]+=o,e.thm[r].s[i][a]+=l,o=p*t[s],l=p*n[s]}for(;i=c){++a;break}var u=e.PSY.bo_l_weight[a],_=1-u;s=u*t[i],o=u*n[i],e.en[r].l[a]+=s,e.thm[r].l[a]+=o,s=_*t[i],o=_*n[i]}for(;a=1?e:n<=0?t:t>0?Math.pow(e/t,n)*t:0}var T=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function B(e,n){for(var r=309.07,a=0;a0){var o=s*n,l=e.en.s[a][i];l>o&&(r+=l>1e10*o?T[a]*(10*t):T[a]*p.FAST_LOG10(l/o))}}return r}var E=[6.8,5.8,5.8,6.4,6.5,9.9,12.1,14.4,15,18.9,21.6,26.9,34.2,40.2,46.8,56.5,60.7,73.9,85.7,93.4,126.1];function C(e,n){for(var r=281.0575,a=0;a0){var s=i*n,o=e.en.l[a];o>s&&(r+=o>1e10*s?E[a]*(10*t):E[a]*p.FAST_LOG10(o/s))}}return r}function P(e,t,n,r,a){var i,s;for(i=s=0;i0?((o=t[i])a&&(l=a),r[i]=l):r[i]=0;for(i=1;i0)(o=t[i-1])a&&(l=a),r[i]=l;else r[i]=0}(s=n[i-1]+n[i])>0?((o=t[i-1])a&&(l=a),r[i]=l):r[i]=0}var L=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function I(t,n,r,a,i,s,o,l){var c=t.internal_flags;if(a<2)e.fft_long(c,o[l],a,n,r);else if(2==a)for(var f=F.BLKSIZE-1;f>=0;--f){var u=o[l+0][f],_=o[l+1][f];o[l+0][f]=(u+_)*p.SQRT2*.5,o[l+1][f]=(u-_)*p.SQRT2*.5}s[0]=o[l+0][0],s[0]*=s[0];for(f=F.BLKSIZE/2-1;f>=0;--f){var h=o[l+0][F.BLKSIZE/2-f],d=o[l+0][F.BLKSIZE/2+f];s[F.BLKSIZE/2-f]=.5*(h*h+d*d)}var v=0;for(f=11;f=0;--f){var u=o[l+0][i][f],_=o[l+1][i][f];o[l+0][i][f]=(u+_)*p.SQRT2*.5,o[l+1][i][f]=(u-_)*p.SQRT2*.5}s[i][0]=o[l+0][i][0],s[i][0]*=s[i][0];for(f=F.BLKSIZE_s/2-1;f>=0;--f){var h=o[l+0][i][F.BLKSIZE_s/2-f],d=o[l+0][i][F.BLKSIZE_s/2+f];s[i][F.BLKSIZE_s/2-f]=.5*(h*h+d*d)}}function N(e,t,n,a){var i=e.internal_flags;2==e.athaa_loudapprox&&n<2&&(i.loudness_sq[t][n]=i.loudness_sq_save[n],i.loudness_sq_save[n]=r(a,i))}this.L3psycho_anal_ns=function(e,t,n,r,l,c,f,p,d,b){var g,y,S,x,T,E,I,H,N,$,D=e.internal_flags,j=o([2,F.BLKSIZE]),V=o([2,3,F.BLKSIZE_s]),q=i(F.CBANDS+1),Y=i(F.CBANDS+1),X=i(F.CBANDS+2),z=a(2),U=a(2),K=o([2,576]),W=a(F.CBANDS+2),Z=a(F.CBANDS+2);for(u.fill(Z,0),g=D.channels_out,e.mode==m.JOINT_STEREO&&(g=4),N=e.VBR==v.vbr_off?0==D.ResvMax?0:D.ResvSize/D.ResvMax*.5:e.VBR==v.vbr_rh||e.VBR==v.vbr_mtrh||e.VBR==v.vbr_mt?.6:1,y=0;y2&&(c[r][y].en.assign(D.en[y+2]),c[r][y].thm.assign(D.thm[y+2]))}for(y=0;yne[x+3-2]?ve/=ne[x+3-2]:ve=ne[x+3-2]>10*ve?ne[x+3-2]/(10*ve):0,ae[x+3]=ve}if(e.analysis){var me=ae[0];for(x=1;x<12;x++)mete&&(le[x/3]=x%3+1);for(x=1;x<4;x++){(re[x-1]>re[x]?re[x-1]/re[x]:re[x]/re[x-1])<1.7&&(le[x]=0,1==x&&(le[0]=0))}for(0!=le[0]&&0!=D.nsPsy.lastAttacks[y]&&(le[0]=0),3!=D.nsPsy.lastAttacks[y]&&le[0]+le[1]+le[2]+le[3]==0||(ie=0,0!=le[1]&&0!=le[0]&&(le[1]=0),0!=le[2]&&0!=le[1]&&(le[2]=0),0!=le[3]&&0!=le[2]&&(le[3]=0)),y<2?U[y]=ie:0==ie&&(U[0]=U[1]=0),d[y]=D.tot_ener[y],s(e,ce,fe,j,1&y,V,1&y,r,y,t,n),P(D,ce,q,se,oe),O(D,se,oe,W),H=0;H<3;H++){var be,ge;for(M(e,fe,Y,X,y,H),k(D,Y,X,y,H),I=0;I=2||1==le[H+1]){var ye=0!=H?H-1:2;ve=R(D.thm[y].s[I][ye],ge,.6*N);ge=Math.min(ge,ve)}if(1==le[H]){ye=0!=H?H-1:2,ve=R(D.thm[y].s[I][ye],ge,.3*N);ge=Math.min(ge,ve)}else if(0!=H&&3==le[H-1]||0==H&&3==D.nsPsy.lastAttacks[y]){ye=2!=H?H+1:0,ve=R(D.thm[y].s[I][ye],ge,.3*N);ge=Math.min(ge,ve)}be=ne[3*H+3]+ne[3*H+4]+ne[3*H+5],6*ne[3*H+5]0&&function(e,t){var n=e.internal_flags;if(n.channels_out>1){for(var r=0;r1.58*e.thm[1].l[t]||e.thm[1].l[t]>1.58*e.thm[0].l[t])){var n=e.mld_l[t]*e.en[3].l[t],r=Math.max(e.thm[2].l[t],Math.min(e.thm[3].l[t],n));n=e.mld_l[t]*e.en[2].l[t];var a=Math.max(e.thm[3].l[t],Math.min(e.thm[2].l[t],n));e.thm[2].l[t]=r,e.thm[3].l[t]=a}for(t=0;t1.58*e.thm[1].s[t][i]||e.thm[1].s[t][i]>1.58*e.thm[0].s[t][i])){n=e.mld_s[t]*e.en[3].s[t][i],r=Math.max(e.thm[2].s[t][i],Math.min(e.thm[3].s[t][i],n));n=e.mld_s[t]*e.en[2].s[t][i];a=Math.max(e.thm[3].s[t][i],Math.min(e.thm[2].s[t][i],n));e.thm[2].s[t][i]=r,e.thm[3].s[t][i]=a}}(D),$=e.msfix,Math.abs($)>0&&function(e,t,n){var r=t,a=Math.pow(10,n);t*=2,r*=2;for(var i=0;i1?(ke=p,Re=-2,Ae=F.NORM_TYPE,b[0]!=F.SHORT_TYPE&&b[1]!=F.SHORT_TYPE||(Ae=F.SHORT_TYPE),Me=c[r][y-2]):(ke=f,Re=0,Ae=b[y],Me=l[r][y]),Ae==F.SHORT_TYPE?ke[Re+y]=B(Me,D.masking_lower):ke[Re+y]=C(Me,D.masking_lower),e.analysis&&(D.pinfo.pe[r][y]=ke[Re+y])}return 0};var $=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function D(e,t,n){if(0==n)for(var r=0;r0?((o=t[i])a&&(l=a),r[i]=l):r[i]=0,i=1;i0)(o=t[i-1])a&&(l=a),r[i]=l;else r[i]=0}(s=n[i-1]+n[i])>0?((o=t[i-1])a&&(l=a),r[i]=l):r[i]=0}(f,u,p,h),l=c=0;cw&&(r[c]=w),f.masking_lower>1&&(r[c]*=f.masking_lower),r[c]>n[c]&&(r[c]=n[c]),f.masking_lower<1&&(r[c]*=f.masking_lower)}for(;c0?Math.min(h,y):Math.min(h,.3*n[o])}else{var w=16*e.nb_2[s][o],S=2*e.nb_1[s][o];w<=0&&(w=h),S<=0&&(S=h),y=e.blocktype_old[1&s]==F.NORM_TYPE?Math.min(S,w):S,r[o]=Math.min(h,y)}e.nb_2[s][o]=e.nb_1[s][o],e.nb_1[s][o]=h,p=l[o],p*=e.minval_l[o],p*=d,r[o]>p&&(r[o]=p),e.masking_lower>1&&(r[o]*=e.masking_lower),r[o]>n[o]&&(r[o]=n[o]),e.masking_lower<1&&(r[o]*=e.masking_lower)}for(;o0?Math.pow(10,a):1,u=0;u0){var y,w,S=r[u]*f;if(y=Math.min(Math.max(h,S),Math.max(d,S)),(w=(v=Math.max(l,S))+(m=Math.max(o,S)))>0&&y*c_&&(l=_),o>p&&(o=p),t[2][u]=l,t[3][u]=o}}function X(e,t){var n;return(n=e>=0?27*-e:e*t)<=-72?0:Math.exp(.2302585093*n)}function z(e){var t,n,r=0;for(r=0;X(r,e)>1e-20;r-=1);for(a=r,i=0;Math.abs(i-a)>1e-12;)X(r=(i+a)/2,e)>0?i=r:a=r;t=a;var a,i;r=0;for(r=0;X(r,e)>1e-20;r+=1);for(a=0,i=r;Math.abs(i-a)>1e-12;)X(r=(i+a)/2,e)>0?a=r:i=r;n=i;var s,o=0,l=1e3;for(s=0;s<=l;++s){o+=X(r=t+s*(n-t)/l,e)}return 1001/(o*(n-t))}function U(e){return e<0&&(e=0),e*=.001,13*Math.atan(.76*e)+3.5*Math.atan(e*e/56.25)}function W(e,t,n,r,s,o,l,c,f,u,_,p){var h,d=i(F.CBANDS+1),v=c/(p>15?1152:384),m=a(F.HBLKSIZE);c/=f;var b=0,g=0;for(h=0;hf/2){b=f/2,++h;break}}d[h]=c*b;for(var w=0;wf/2&&(x=f/2),n[w]=(m[S]+m[x])/2,t[w]=m[x];var R=v*A;l[w]=(R-d[t[w]])/(d[t[w]+1]-d[t[w]]),l[w]<0?l[w]=0:l[w]>1&&(l[w]=1),M=U(c*u[w]*_),M=Math.min(M,15.5)/15.5,o[w]=Math.pow(10,1.25*(1-Math.cos(Math.PI*M))-2.5)}b=0;for(var T=0;T=0?3:1.5)>=.5&&f<=2.5?8*((p=f-.5)*p-2*p):0,((_=15.811389+7.5*(f+=.474)-17.5*Math.sqrt(1+f*f))<=-60?0:(f=Math.exp(.2302585093*(u+_)),f/=.6609193))*r[l]);h[v][l]=m*a[v]}else for(l=0;l0);l++);for(e[v][0]=l,l=t-1;l>0&&!(h[v][l]>0);l--);e[v][1]=l,d+=e[v][1]-e[v][0]+1}var y=i(d),w=0;for(v=0;v2&&(s[r][v].en.assign(p.en[v+2]),s[r][v].thm.assign(p.thm[v+2]))}for(v=0;v0;++g,--S){var E=_[0][g],C=_[1][g];_[0][g]=E+C,_[1][g]=E-C}for(g=0;g<3;g++)k[g]=p.nsPsy.last_en_subshort[v][g+6],x[g]=k[g]/p.nsPsy.last_en_subshort[v][g+4],A[0]+=k[g];for(g=0;g<9;g++){for(var P=R+64,O=1;Rk[g+3-2]?O/=k[g+3-2]:O=k[g+3-2]>10*O?k[g+3-2]/(10*O):0,x[g+3]=O}for(g=0;g<3;++g){var L=k[3*g+3]+k[3*g+4]+k[3*g+5],I=1;6*k[3*g+5]T&&(f[v][g/3]=g%3+1);for(g=1;g<4;g++){var N=A[g-1],D=A[g];Math.max(N,D)<4e4&&N<1.7*D&&D<1.7*N&&(1==g&&f[v][0]<=f[v][g]&&(f[v][0]=0),f[v][g]=0)}f[v][0]<=p.nsPsy.lastAttacks[v]&&(f[v][0]=0),3!=p.nsPsy.lastAttacks[v]&&f[v][0]+f[v][1]+f[v][2]+f[v][3]==0||(B=0,0!=f[v][1]&&0!=f[v][0]&&(f[v][1]=0),0!=f[v][2]&&0!=f[v][1]&&(f[v][2]=0),0!=f[v][3]&&0!=f[v][2]&&(f[v][3]=0)),v<2?u[v]=B:0==B&&(u[0]=u[1]=0),l[v]=p.tot_ener[v]}}(e,t,n,r,s,l,u,S,x,M),function(e,t){var n=e.internal_flags;e.short_blocks!=h.short_block_coupled||0!=t[0]&&0!=t[1]||(t[0]=t[1]=0);for(var r=0;r=2||1==x[E][P+1]){var U=0!=P?P-1:2,K=R(p.thm[E].s[L][U],z,.36);z=Math.min(z,K)}else if(1==x[E][P]){U=0!=P?P-1:2,K=R(p.thm[E].s[L][U],z,.18);z=Math.min(z,K)}else if(0!=P&&3==x[E][P-1]||0==P&&3==p.nsPsy.lastAttacks[E]){U=2!=P?P+1:0,K=R(p.thm[E].s[L][U],z,.18);z=Math.min(z,K)}z*=S[E][P],X[P]=z}for(P=0;P<3;P++)p.thm[E].s[L][P]=X[P]}}for(E=0;E1?(W=f,Z=-2,G=F.NORM_TYPE,_[0]!=F.SHORT_TYPE&&_[1]!=F.SHORT_TYPE||(G=F.SHORT_TYPE),Q=l[r][E-2]):(W=c,Z=0,G=_[E],Q=s[r][E]),G==F.SHORT_TYPE?W[Z+E]=B(Q,p.masking_lower):W[Z+E]=C(Q,p.masking_lower),e.analysis&&(p.pinfo.pe[r][E]=W[Z+E])}return 0},this.psymodel_init=function(n){var r,a=n.internal_flags,s=!0,o=13,u=0,_=0,p=-8.25,h=-4.5,m=i(F.CBANDS),b=i(F.CBANDS),g=i(F.CBANDS),y=n.out_samplerate;switch(n.experimentalZ){default:case 0:s=!0;break;case 1:s=n.VBR!=v.vbr_mtrh&&n.VBR!=v.vbr_mt;break;case 2:s=!1;break;case 3:o=8,u=-1.75,_=-.0125,p=-8.25,h=-2.25}for(a.ms_ener_ratio_old=.25,a.blocktype_old[0]=a.blocktype_old[1]=F.NORM_TYPE,r=0;r<4;++r){for(var w=0;w=o&&(x=_*(m[r]-o)/(24-o)+u*(24-m[r])/(24-o)),g[r]=Math.pow(10,x/10),a.numlines_l[r]>0?a.rnumlines_l[r]=1/a.numlines_l[r]:a.rnumlines_l[r]=0}a.s3_ll=Z(a.s3ind,a.npart_l,m,b,g,s);var k;w=0;for(r=0;r(T*=a.numlines_l[r])&&(R=T)}a.ATH.cb_l[r]=R,(R=20*m[r]/10-20)>6&&(R=100),R<-15&&(R=-15),R-=8,a.minval_l[r]=Math.pow(10,R/10)*a.numlines_l[r]}for(a.npart_s=W(a.numlines_s,a.bo_s,a.bm_s,m,b,a.mld_s,a.PSY.bo_s_weight,y,F.BLKSIZE_s,a.scalefac_band.s,F.BLKSIZE_s/384,F.SBMAX_s),w=0,r=0;r=o&&(x=h*(m[r]-o)/(24-o)+p*(24-m[r])/(24-o)),g[r]=Math.pow(10,x/10),R=d.MAX_VALUE;for(A=0;A(T*=a.numlines_s[r])&&(R=T)}a.ATH.cb_s[r]=R,R=7*m[r]/12-7,m[r]>12&&(R*=1+3.1*Math.log(1+R)),m[r]<12&&(R*=1+2.3*Math.log(1-R)),R<-15&&(R=-15),R-=8,a.minval_s[r]=Math.pow(10,R/10)*a.numlines_s[r]}a.s3_ss=Z(a.s3ind_s,a.npart_s,m,b,g,s),l=Math.pow(10,9/16),c=Math.pow(10,1.5),f=Math.pow(10,1.5),e.init_fft(a),a.decay=Math.exp(-1*t/(.01*y/192)),k=3.5,0!=(2&n.exp_nspsytune)&&(k=1),Math.abs(n.msfix)>0&&(k=n.msfix),n.msfix=k;for(var B=0;Ba.npart_l-1&&(a.s3ind[B][1]=a.npart_l-1);var E=576*a.mode_gr/y;if(a.ATH.decay=Math.pow(10,-1.2*E),a.ATH.adjust=.01,a.ATH.adjustLimit=1,-1!=n.ATHtype){var C=n.out_samplerate/F.BLKSIZE,P=0;for(M=0,r=0;r=0;)a.ATH.eql_w[r]*=P}for(B=w=0;B1?0:e<=0?1:Math.cos(Math.PI/2*e)}function S(e,t){switch(e){case 44100:return t.version=1,0;case 48e3:return t.version=1,1;case 32e3:return t.version=1,2;case 22050:return t.version=0,0;case 24e3:return t.version=0,1;case 16e3:return t.version=0,2;case 11025:return t.version=0,0;case 12e3:return t.version=0,1;case 8e3:return t.version=0,2;default:return t.version=0,-1}}function x(e,t,n){n<16e3&&(t=2);for(var r=M.bitrate_table[t][1],a=2;a<=14;a++)M.bitrate_table[t][a]>0&&Math.abs(M.bitrate_table[t][a]-e)0&&M.bitrate_table[t][r]==e)return r;return-1}function R(t,n){var r=[new g(8,2e3),new g(16,3700),new g(24,3900),new g(32,5500),new g(40,7e3),new g(48,7500),new g(56,1e4),new g(64,11e3),new g(80,13500),new g(96,15100),new g(112,15600),new g(128,17e3),new g(160,17500),new g(192,18600),new g(224,19400),new g(256,19700),new g(320,20500)],a=e.nearestBitrateFullIndex(n);t.lowerlimit=r[a].lowpass}function T(e){var t=F.BLKSIZE+e.framesize-F.FFTOFFSET;return t=Math.max(t,512+e.framesize-32)}function B(t,n,r,a,i,s){var o=e.enc.lame_encode_mp3_frame(t,n,r,a,i,s);return t.frameNum++,o}function L(){this.n_in=0,this.n_out=0}function I(){this.num_used=0}function H(e,t,n){var r=Math.PI*t;(e/=n)<0&&(e=0),e>1&&(e=1);var a=e-.5,i=.42-.5*Math.cos(2*e*Math.PI)+.08*Math.cos(4*e*Math.PI);return Math.abs(a)<1e-9?r/Math.PI:i*Math.sin(n*r*a)/(Math.PI*n*a)}function N(e,t,n,r,a,s,o,l,c){var f,u,_=e.internal_flags,p=0,h=e.out_samplerate/function e(t,n){return 0!=n?e(n,t%n):t}(e.out_samplerate,e.in_samplerate);h>U.BPC&&(h=U.BPC);var d=Math.abs(_.resample_ratio-Math.floor(.5+_.resample_ratio))<1e-4?1:0,v=1/_.resample_ratio;v>1&&(v=1);var m=31;0==m%2&&--m;var b=(m+=d)+1;if(0==_.fill_buffer_resample_init){for(_.inbuf_old[0]=i(b),_.inbuf_old[1]=i(b),f=0;f<=2*h;++f)_.blackfilt[f]=i(b);for(_.itime[0]=0,_.itime[1]=0,p=0;p<=2*h;p++){var g=0,y=(p-h)/(2*h);for(f=0;f<=m;f++)g+=_.blackfilt[p][f]=H(f-y,v,m);for(f=0;f<=m;f++)_.blackfilt[p][f]/=g}_.fill_buffer_resample_init=1}var w=_.inbuf_old[c];for(u=0;u=o)break;y=S-_.itime[c]-(p+m%2*.5);x=0|Math.floor(2*y*h+h+.5);var k=0;for(f=0;f<=m;++f){var A=f+p-m/2;k+=(A<0?w[b+A]:a[s+A])*_.blackfilt[x][f]}t[n+u]=k}if(l.num_used=Math.min(o,m+p-m/2),_.itime[c]+=l.num_used-u*_.resample_ratio,l.num_used>=b)for(f=0;f1.0001)for(var o=0;oe-r?n:a},this.lame_init_params=function(e){var i,c,g,T=e.internal_flags;if(T.Class_ID=0,null==T.ATH&&(T.ATH=new E),null==T.PSY&&(T.PSY=new d),null==T.rgdata&&(T.rgdata=new O),T.channels_in=e.num_channels,1==T.channels_in&&(e.mode=m.MONO),T.channels_out=e.mode==m.MONO?1:2,T.mode_ext=F.MPG_MD_MS_LR,e.mode==m.MONO&&(e.force_ms=!1),e.VBR==v.vbr_off&&128!=e.VBR_mean_bitrate_kbps&&0==e.brate&&(e.brate=e.VBR_mean_bitrate_kbps),e.VBR==v.vbr_off||e.VBR==v.vbr_mtrh||e.VBR==v.vbr_mt||(e.free_format=!1),e.VBR==v.vbr_off&&0==e.brate&&k.EQ(e.compression_ratio,0)&&(e.compression_ratio=11.025),e.VBR==v.vbr_off&&e.compression_ratio>0&&(0==e.out_samplerate&&(e.out_samplerate=map2MP3Frequency(int(.97*e.in_samplerate))),e.brate=0|16*e.out_samplerate*T.channels_out/(1e3*e.compression_ratio),T.samplerate_index=S(e.out_samplerate,e),e.free_format||(e.brate=x(e.brate,e.version,e.out_samplerate))),0!=e.out_samplerate&&(e.out_samplerate<16e3?(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,64)):e.out_samplerate<32e3?(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,160)):(e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,32),e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,320))),0==e.lowpassfreq){var B=16e3;switch(e.VBR){case v.vbr_off:R(C=new b,e.brate),B=C.lowerlimit;break;case v.vbr_abr:var C;R(C=new b,e.VBR_mean_bitrate_kbps),B=C.lowerlimit;break;case v.vbr_rh:var L=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=e.VBR_q&&e.VBR_q<=9){var I=L[e.VBR_q],H=L[e.VBR_q+1],N=e.VBR_q_frac;B=linear_int(I,H,N)}else B=19500;break;default:L=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=e.VBR_q&&e.VBR_q<=9){I=L[e.VBR_q],H=L[e.VBR_q+1],N=e.VBR_q_frac;B=linear_int(I,H,N)}else B=19500}e.mode!=m.MONO||e.VBR!=v.vbr_off&&e.VBR!=v.vbr_abr||(B*=1.5),e.lowpassfreq=0|B}if(0==e.out_samplerate&&(2*e.lowpassfreq>e.in_samplerate&&(e.lowpassfreq=e.in_samplerate/2),e.out_samplerate=(i=0|e.lowpassfreq,c=e.in_samplerate,g=44100,c>=48e3?g=48e3:c>=44100?g=44100:c>=32e3?g=32e3:c>=24e3?g=24e3:c>=22050?g=22050:c>=16e3?g=16e3:c>=12e3?g=12e3:c>=11025?g=11025:c>=8e3&&(g=8e3),-1==i?g:(i<=15960&&(g=44100),i<=15250&&(g=32e3),i<=11220&&(g=24e3),i<=9970&&(g=22050),i<=7230&&(g=16e3),i<=5420&&(g=12e3),i<=4510&&(g=11025),i<=3970&&(g=8e3),c44100?48e3:c>32e3?44100:c>24e3?32e3:c>22050?24e3:c>16e3?22050:c>12e3?16e3:c>11025?12e3:c>8e3?11025:8e3:g))),e.lowpassfreq=Math.min(20500,e.lowpassfreq),e.lowpassfreq=Math.min(e.out_samplerate/2,e.lowpassfreq),e.VBR==v.vbr_off&&(e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.brate)),e.VBR==v.vbr_abr&&(e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.VBR_mean_bitrate_kbps)),e.bWriteVbrTag||(e.findReplayGain=!1,e.decode_on_the_fly=!1,T.findPeakSample=!1),T.findReplayGain=e.findReplayGain,T.decode_on_the_fly=e.decode_on_the_fly,T.decode_on_the_fly&&(T.findPeakSample=!0),T.findReplayGain&&t.InitGainAnalysis(T.rgdata,e.out_samplerate)==y.INIT_GAIN_ANALYSIS_ERROR)return e.internal_flags=null,-6;switch(T.decode_on_the_fly&&!e.decode_only&&(null!=T.hip&&u.hip_decode_exit(T.hip),T.hip=u.hip_decode_init()),T.mode_gr=e.out_samplerate<=24e3?1:2,e.framesize=576*T.mode_gr,e.encoder_delay=F.ENCDELAY,T.resample_ratio=e.in_samplerate/e.out_samplerate,e.VBR){case v.vbr_mt:case v.vbr_rh:case v.vbr_mtrh:e.compression_ratio=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5][e.VBR_q];break;case v.vbr_abr:e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.VBR_mean_bitrate_kbps);break;default:e.compression_ratio=16*e.out_samplerate*T.channels_out/(1e3*e.brate)}if(e.mode==m.NOT_SET&&(e.mode=m.JOINT_STEREO),e.highpassfreq>0?(T.highpass1=2*e.highpassfreq,e.highpasswidth>=0?T.highpass2=2*(e.highpassfreq+e.highpasswidth):T.highpass2=2*e.highpassfreq,T.highpass1/=e.out_samplerate,T.highpass2/=e.out_samplerate):(T.highpass1=0,T.highpass2=0),e.lowpassfreq>0?(T.lowpass2=2*e.lowpassfreq,e.lowpasswidth>=0?(T.lowpass1=2*(e.lowpassfreq-e.lowpasswidth),T.lowpass1<0&&(T.lowpass1=0)):T.lowpass1=2*e.lowpassfreq,T.lowpass1/=e.out_samplerate,T.lowpass2/=e.out_samplerate):(T.lowpass1=0,T.lowpass2=0),function(e){var t=e.internal_flags,n=32,r=-1;if(t.lowpass1>0){for(var a=999,i=0;i<=31;i++){(c=i/31)>=t.lowpass2&&(n=Math.min(n,i)),t.lowpass10&&t.highpass2<.75/31*.9&&(t.highpass1=0,t.highpass2=0,_.err.println("Warning: highpass filter disabled. highpass frequency too small\n")),t.highpass2>0){var s=-1;for(i=0;i<=31;i++){(c=i/31)<=t.highpass1&&(r=Math.max(r,i)),t.highpass1t.highpass1?w((t.highpass2-c)/(t.highpass2-t.highpass1+1e-20)):1,l=t.lowpass2>t.lowpass1?w((c-t.lowpass1)/(t.lowpass2-t.lowpass1+1e-20)):1,t.amp_filter[i]=o*l}}(e),T.samplerate_index=S(e.out_samplerate,e),T.samplerate_index<0)return e.internal_flags=null,-1;if(e.VBR==v.vbr_off){if(e.free_format)T.bitrate_index=0;else if(e.brate=x(e.brate,e.version,e.out_samplerate),T.bitrate_index=A(e.brate,e.version,e.out_samplerate),T.bitrate_index<=0)return e.internal_flags=null,-1}else T.bitrate_index=1;e.analysis&&(e.bWriteVbrTag=!1),null!=T.pinfo&&(e.bWriteVbrTag=!1),n.init_bit_stream_w(T);for(var $,D=T.samplerate_index+3*e.version+6*(e.out_samplerate<16e3?1:0),j=0;j5&&(e.quality=5),T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,e.experimentalY?T.sfb21_extra=!1:T.sfb21_extra=e.out_samplerate>44e3,T.iteration_loop=new VBRNewIterationLoop(s);break;case v.vbr_rh:r.apply_preset(e,500-10*e.VBR_q,0),T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,e.experimentalY?T.sfb21_extra=!1:T.sfb21_extra=e.out_samplerate>44e3,e.quality>6&&(e.quality=6),e.quality<0&&(e.quality=LAME_DEFAULT_QUALITY),T.iteration_loop=new VBROldIterationLoop(s);break;default:var Y;T.sfb21_extra=!1,e.quality<0&&(e.quality=LAME_DEFAULT_QUALITY),(Y=e.VBR)==v.vbr_off&&(e.VBR_mean_bitrate_kbps=e.brate),r.apply_preset(e,e.VBR_mean_bitrate_kbps,0),e.VBR=Y,T.PSY.mask_adjust=e.maskingadjust,T.PSY.mask_adjust_short=e.maskingadjust_short,Y==v.vbr_off?T.iteration_loop=new P(s):T.iteration_loop=new ABRIterationLoop(s)}if(e.VBR!=v.vbr_off){if(T.VBR_min_bitrate=1,T.VBR_max_bitrate=14,e.out_samplerate<16e3&&(T.VBR_max_bitrate=8),0!=e.VBR_min_bitrate_kbps&&(e.VBR_min_bitrate_kbps=x(e.VBR_min_bitrate_kbps,e.version,e.out_samplerate),T.VBR_min_bitrate=A(e.VBR_min_bitrate_kbps,e.version,e.out_samplerate),T.VBR_min_bitrate<0))return-1;if(0!=e.VBR_max_bitrate_kbps&&(e.VBR_max_bitrate_kbps=x(e.VBR_max_bitrate_kbps,e.version,e.out_samplerate),T.VBR_max_bitrate=A(e.VBR_max_bitrate_kbps,e.version,e.out_samplerate),T.VBR_max_bitrate<0))return-1;e.VBR_min_bitrate_kbps=M.bitrate_table[e.version][T.VBR_min_bitrate],e.VBR_max_bitrate_kbps=M.bitrate_table[e.version][T.VBR_max_bitrate],e.VBR_mean_bitrate_kbps=Math.min(M.bitrate_table[e.version][T.VBR_max_bitrate],e.VBR_mean_bitrate_kbps),e.VBR_mean_bitrate_kbps=Math.max(M.bitrate_table[e.version][T.VBR_min_bitrate],e.VBR_mean_bitrate_kbps)}return e.tune&&(T.PSY.mask_adjust+=e.tune_value_a,T.PSY.mask_adjust_short+=e.tune_value_a),function(e){var t=e.internal_flags;switch(e.quality){default:case 9:t.psymodel=0,t.noise_shaping=0,t.noise_shaping_amp=0,t.noise_shaping_stop=0,t.use_best_huffman=0,t.full_outer_loop=0;break;case 8:e.quality=7;case 7:t.psymodel=1,t.noise_shaping=0,t.noise_shaping_amp=0,t.noise_shaping_stop=0,t.use_best_huffman=0,t.full_outer_loop=0;break;case 6:case 5:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=0,t.noise_shaping_stop=0,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=0,t.full_outer_loop=0;break;case 4:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=0,t.noise_shaping_stop=0,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 3:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),t.noise_shaping_amp=1,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 2:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),0==t.substep_shaping&&(t.substep_shaping=2),t.noise_shaping_amp=1,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0;break;case 1:case 0:t.psymodel=1,0==t.noise_shaping&&(t.noise_shaping=1),0==t.substep_shaping&&(t.substep_shaping=2),t.noise_shaping_amp=2,t.noise_shaping_stop=1,-1==t.subblock_gain&&(t.subblock_gain=1),t.use_best_huffman=1,t.full_outer_loop=0}}(e),e.athaa_type<0?T.ATH.useAdjust=3:T.ATH.useAdjust=e.athaa_type,T.ATH.aaSensitivityP=Math.pow(10,e.athaa_sensitivity/-10),null==e.short_blocks&&(e.short_blocks=h.short_block_allowed),e.short_blocks!=h.short_block_allowed||e.mode!=m.JOINT_STEREO&&e.mode!=m.STEREO||(e.short_blocks=h.short_block_coupled),e.quant_comp<0&&(e.quant_comp=1),e.quant_comp_short<0&&(e.quant_comp_short=0),e.msfix<0&&(e.msfix=0),e.exp_nspsytune=1|e.exp_nspsytune,e.internal_flags.nsPsy.attackthre<0&&(e.internal_flags.nsPsy.attackthre=W.NSATTACKTHRE),e.internal_flags.nsPsy.attackthre_s<0&&(e.internal_flags.nsPsy.attackthre_s=W.NSATTACKTHRE_S),e.scale<0&&(e.scale=1),e.ATHtype<0&&(e.ATHtype=4),e.ATHcurve<0&&(e.ATHcurve=4),e.athaa_loudapprox<0&&(e.athaa_loudapprox=2),e.interChRatio<0&&(e.interChRatio=0),null==e.useTemporal&&(e.useTemporal=!0),T.slot_lag=T.frac_SpF=0,e.VBR==v.vbr_off&&(T.slot_lag=T.frac_SpF=72e3*(e.version+1)*e.brate%e.out_samplerate|0),a.iteration_init(e),p.psymodel_init(e),0},this.lame_encode_flush=function(e,t,r,a){var i,s,o,l,u=e.internal_flags,_=c([2,1152]),p=0,h=u.mf_samples_to_encode-F.POSTDELAY,d=T(e);if(u.mf_samples_to_encode<1)return 0;for(i=0,e.in_samplerate!=e.out_samplerate&&(h+=16*e.out_samplerate/e.in_samplerate),(o=e.framesize-h%e.framesize)<576&&(o+=e.framesize),e.encoder_padding=o,l=(h+o)/e.framesize;l>0&&p>=0;){var v=d-u.mf_size,m=e.frameNum;v*=e.in_samplerate,(v/=e.out_samplerate)>1152&&(v=1152),v<1&&(v=1),s=a-i,0==a&&(s=0),r+=p=this.lame_encode_buffer(e,_[0],_[1],v,t,r,s),i+=p,l-=m!=e.frameNum?1:0}if(u.mf_samples_to_encode=0,p<0)return p;if(s=a-i,0==a&&(s=0),n.flush_bitstream(e),(p=n.copy_buffer(u,t,r,s,1))<0)return p;if(r+=p,s=a-(i+=p),0==a&&(s=0),e.write_id3tag_automatic){if(f.id3tag_write_v1(e),(p=n.copy_buffer(u,t,r,s,0))<0)return p;i+=p}return i},this.lame_encode_buffer=function(e,r,a,s,o,l,c){var f=e.internal_flags,u=[null,null];if(4294479419!=f.Class_ID)return-3;if(0==s)return 0;!function(e,t){(null==e.in_buffer_0||e.in_buffer_nsamples1&&(u[1][_]=a[_]);return function(e,r,a,i,s,o,l){var c,f,u,_,p,h=e.internal_flags,d=0,v=[null,null],m=[null,null];if(4294479419!=h.Class_ID)return-3;if(0==i)return 0;if((p=n.copy_buffer(h,s,o,l,0))<0)return p;if(o+=p,d+=p,m[0]=r,m[1]=a,k.NEQ(e.scale,0)&&k.NEQ(e.scale,1))for(f=0;f0;){var g,w,S=[null,null];S[0]=m[0],S[1]=m[1];var x=new L;if($(e,v,S,b,i,x),g=x.n_in,w=x.n_out,h.findReplayGain&&!h.decode_on_the_fly&&t.AnalyzeSamples(h.rgdata,v[0],h.mf_size,v[1],h.mf_size,w,h.channels_out)==y.GAIN_ANALYSIS_ERROR)return-6;if(i-=g,b+=g,h.channels_out,h.mf_size+=w,h.mf_samples_to_encode<1&&(h.mf_samples_to_encode=F.ENCDELAY+F.POSTDELAY),h.mf_samples_to_encode+=w,h.mf_size>=_){var A=l-d;if(0==l&&(A=0),(c=B(e,v[0],v[1],s,o,A))<0)return c;for(o+=c,d+=c,h.mf_size-=e.framesize,h.mf_samples_to_encode-=e.framesize,u=0;uR&&(R=t.length,B=n(T=0|1.25*R+7200));var i=a.lame_encode_buffer(M,t,r,t.length,B,0,T);return new Int8Array(B.subarray(0,i))},this.flush=function(){var e=a.lame_encode_flush(M,B,0,T);return new Int8Array(B.subarray(0,e))}}}e(),Recorder.lamejs=e}()},function(e,t,n){"use strict";var r,a;r=function(e){return new a(e)},(a=function(e){var t={scale:2,speed:9,phase:21.8,fps:20,keep:!0,lineWidth:3,linear1:[0,"rgba(150,96,238,1)",.2,"rgba(170,79,249,1)",1,"rgba(53,199,253,1)"],linear2:[0,"rgba(209,130,255,0.6)",1,"rgba(53,199,255,0.6)"],linearBg:[0,"rgba(255,255,255,0.2)",1,"rgba(54,197,252,0.2)"]};for(var n in e)t[n]=e[n];this.set=e=t;var r=e.elem;r&&("string"==typeof r?r=document.querySelector(r):r.length&&(r=r[0])),r&&(e.width=r.offsetWidth,e.height=r.offsetHeight);var a=e.scale,i=e.width*a,s=e.height*a;if(!i||!s)throw new Error("WaveView无宽高");var o=this.elem=document.createElement("div"),l=["","transform-origin:0 0;","transform:scale("+1/a+");"];o.innerHTML='
';var c=this.canvas=o.querySelector("canvas"),f=this.ctx=c.getContext("2d");c.width=i,c.height=s,this.linear1=this.genLinear(f,i,e.linear1),this.linear2=this.genLinear(f,i,e.linear2),this.linearBg=this.genLinear(f,s,e.linearBg,!0),r&&(r.innerHTML="",r.appendChild(o)),this._phase=0}).prototype=r.prototype={genLinear:function(e,t,n,r){for(var a=e.createLinearGradient(0,0,r?0:t,r?t:0),i=0;i1300&&(clearInterval(e.timer),e.timer=0)}},draw:function(e){var t=this.set,n=this.ctx,r=t.scale,a=t.width*r,i=t.height*r,s=t.speed/t.fps,o=this._phase-=s,l=o+s*t.phase,c=e/100,f=this.genPath(2,c,o),u=this.genPath(1.8,c,l);n.clearRect(0,0,a,i),n.beginPath();for(var _=0,p=0;p=0;_--,p-=r)n.lineTo(p,u[_]);n.closePath(),n.fillStyle=this.linearBg,n.fill(),this.drawPath(u,this.linear2),this.drawPath(f,this.linear1)},drawPath:function(e,t){var n=this.set,r=this.ctx,a=n.scale,i=n.width*a;r.beginPath();for(var s=0,o=0;o
- - + + + + - - - - +}; + +window.onerror=function(message, url, lineNo, columnNo, error){ + //https://www.cnblogs.com/xianyulaodi/p/6201829.html + vue_main.reclog('【Uncaught Error】'+message+'
'+"at:"+lineNo+":"+columnNo+" url:"+url+"\n"+(error&&error.stack||"不能获得错误堆栈")+'
'); +}; + + + + + + \ No newline at end of file diff --git a/assets/demo-vue/index.js b/assets/demo-vue/index.js index f6a913c..00adad5 100644 --- a/assets/demo-vue/index.js +++ b/assets/demo-vue/index.js @@ -43,28 +43,8 @@ var root=new Vue({ }); - - - -//皮一下,这种难看调用逻辑验证 -var mainRef=root.$refs.mainView; -mainRef.reclog('RecordApp[即将废弃] 除Recorder支持的外,支持Hybrid App,低版本IOS上支持微信网页和小程序web-view'+unescape("%uD83C%uDF89")+""); -mainRef.reclog('Recorder H5使用简单,功能丰富,支持PC、Android、IOS 14.3+'+unescape("%uD83D%uDCAA")+""); - -mainRef.reclog(`绿油油的一大片,真有食欲${unescape('%uD83D%uDE02')} 当前浏览器支持录音':'red">不支持录音'}`); - -var logMeta=function(n,v){ - mainRef.reclog(''+n+": "+v+""); -}; -logMeta(`本页面修改时间(有可能修改了忘改)`,'2022-03-03 21:52:39'); -logMeta(`Recorder库修改时间(有可能修改了忘改)`,mainRef.Rec.LM); -logMeta(`UA`,navigator.userAgent); -logMeta(`URL`,location.href.replace(/#.*/g,"")); -logMeta(`Vue`,Vue.version); -mainRef.reclog("点击打开录音,然后再点击开始录音",2); - - +window.vue_vue=Vue; window.vue_root=root; -window.vue_main=mainRef; +window.vue_main=root.$refs.mainView; console.log("Vue",Vue); -console.log("Recorder",mainRef.Rec); \ No newline at end of file +console.log("Recorder",vue_main.Rec); \ No newline at end of file diff --git a/assets/npm-home/hash-history.txt b/assets/npm-home/hash-history.txt index 4aed40c..e9ad3a9 100644 --- a/assets/npm-home/hash-history.txt +++ b/assets/npm-home/hash-history.txt @@ -1,4 +1,8 @@ [ + { + "sha1": "820a2fe65d47fd2b2a88d7bfd5456266dbb39005", + "time": "2022-8-7 18:51:17" + }, { "sha1": "40d86b5656875a4f856d652bc3d4839464d8fe2d", "time": "2022-6-28 09:44:33" @@ -14,9 +18,5 @@ { "sha1": "57c7f5b7d61da7a427bb536215f20ae691fd9d62", "time": "2022-3-5 01:22:47" - }, - { - "sha1": "da5d36f2d737a399132ff0dce78f4848f575b6d0", - "time": "2021-8-8 18:32:10" } ] \ No newline at end of file diff --git a/assets/runtime-codes/lib.transform.mp32other.js b/assets/runtime-codes/lib.transform.mp32other.js index 32b727d..9807c41 100644 --- a/assets/runtime-codes/lib.transform.mp32other.js +++ b/assets/runtime-codes/lib.transform.mp32other.js @@ -1,12 +1,16 @@ /****************** -《【Demo库】【格式转换】-mp3格式转成其他格式》 +《【Demo库】【格式转换】-mp3等格式解码转成其他格式》 作者:高坚果 时间:2019-10-22 15:20:57 +【原理】mp3格式转换成其他格式,只是简单的调用AudioContext的decodeAudioData解码音频得到pcm格式数据,然后再将pcm通过Recorder的mock方法转换成其他格式。 + +【其他格式】由于decodeAudioData方法只支持当前浏览器能播放的音频格式,因此除了mp3外,其他能播放的格式一般也是能解码转换的,比如ogg,webm格式,通过 document.createElement("audio").canPlayType("audio/ogg") 来判断某一格式是否支持解码(mp3一定能解码,其他不一定)。 + 文档: Recorder.Mp32Other(newSet,mp3Blob,True,False) newSet:Recorder的set参数,用来生成新格式,注意:要先加载好新格式的编码引擎 - mp3Blob:mp3二进制数据 + mp3Blob:mp3或其他格式音频的二进制数据 True: fn(blob,duration,mockRec) 和Recorder的stop函数参数一致,mockRec为转码时用到的Recorder对象引用 False: fn(errMsg) 和Recorder的stop函数参数一致 ******************/ @@ -109,8 +113,8 @@ Runtime.Ctrls([ ,{choiceFile:{ multiple:false - ,name:"mp3" - ,mime:"audio/mp3" + ,name:"音频" + ,mime:"audio/*" ,process:function(fileName,arrayBuffer,filesCount,fileIdx,endCall){ test(new Blob([arrayBuffer])); endCall(); @@ -143,13 +147,15 @@ function recStart(){ }); }; function recStop(){ + if(!rec){ + Runtime.Log("未开始录音",1); + return; + } rec.stop(function(blob,duration){ - rec.close();//释放录音资源 - Runtime.LogAudio(blob,duration,rec); test(blob); },function(msg){ Runtime.Log("录音失败:"+msg, 1); - }); + },true); }; diff --git a/assets/runtime-codes/test.webm.extract_audio.js b/assets/runtime-codes/test.webm.extract_audio.js new file mode 100644 index 0000000..a6483bc --- /dev/null +++ b/assets/runtime-codes/test.webm.extract_audio.js @@ -0,0 +1,581 @@ +/****************** +《【测试】WebM格式解析并提取音频》 +作者:高坚果 +时间:2022-08-03 20:28 + +Matroska开源多媒体容器标准,WebM格式(.webm、.weba)使用此标准,另外还有常见的.mkv视频格式也是使用此标准,惊不惊喜意不意外。 + +编写本测试代码的意图是验证从webm片段数据中提取pcm数据的可行性,结果:只要浏览器支持录pcm编码的webm,就能很容易提取出pcm数据。 + +Matroska封装格式官方文档: + https://www.matroska.org/index.html +参考文章: + webM文件解析--基于Matroska和EBML + https://blog.csdn.net/newchenxf/article/details/112567406 + 多媒体封装格式详解---MKV【1】【2】【3】 + http://blog.csdn.net/tx3344/article/details/8162656 + http://blog.csdn.net/tx3344/article/details/8176288 + http://blog.csdn.net/tx3344/article/details/8203260 + Matroska文件解析之SimpleBlock + https://blog.csdn.net/weixin_30500289/article/details/97829650 + +==================================================== +WebM文件分解(16进制显示): + - 数据统一套娃格式:EBML_ID+数据长度+数据,ID和长度均为VINT格式 + - VINT:可变长Int,首字节2进制下左侧 `0000001`开头的长度,就代表有几个字节,0可能有0-7个,值为1后面的所有2进制内容 + - SimpleBlock 另外有格式定义 + +1A45DFA3 9F //【EBML Header】 Header+Segment【Array】可存在多个 + 4286 81 01 + 42F7 81 01 + 42F2 81 04 + 42F3 81 08 + 4282 84 7765626D //webm + 4287 81 04 + 4285 81 02 +18538067 01FFFFFFFFFFFFFF //【Segment】 + 1549A966 99 //【Segment Information】 + 2AD7B1 83 0F4240 //1000000 int + 4D80 86 4368726F6D65 //Chrome + 5741 86 4368726F6D65 + 1654AE6B EA //【Track】轨道信息 + AE BD //【TrackEntry】【Array】 TrackEntry是数组,出现一次就代表一条轨道 + D7 81 01 //Track Number: 1 + 73C5 87 DF91DCD55C648E + 83 81 02 //TrackType 1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control + 86 86 415F4F505553 //A_OPUS + 63A2 93 4F707573486561640101000080BB0000000000 + E1 8D //【Audio】 + B5 84 473B8000 //48000.0hz + 9F 81 01 //1声道 + 6264 81 20 //32位 + AE A9 //【TrackEntry】【Array】 + D7 81 02 + 73C5 87 FCE6B23D2C8F28 + 83 81 01 + 55EE 81 01 + 86 85 565F565038 //V_VP8 + E0 8C //【Video】 + B0 82 0280 //视频宽度 640 + BA 82 01E0 //视频高度 480 + 53C0 81 01 + 1F43B675 01FFFFFFFFFFFFFF //【Cluster】【Array】 Cluster是数组,会出现多次 + E7 81 00 //Cluster的时间偏移量 0ms + A3 206733 //【SimpleBlock】【Array】 一条数据,会出现多次 + 82 //Track Number: 2,对应的轨道是视频 + 0000 //时间偏移量 0ms+0ms + 80 //the Block contains only keyframes + ... 剩余0x6733-4字节视频数据... + A3 414E //【SimpleBlock】【Array】 + 81 0000 80 //轨道1,对应的轨道是音频,时间偏移量 0ms+0ms + ... 剩余0x14E-4字节音频频数据... + A3 4148 //【SimpleBlock】【Array】 + 81 003B 80 //轨道1,对应的轨道是音频,时间偏移量 0ms+59ms + ... 剩余0x148-4字节音频频数据... + 1F43B675 01FFFFFFFFFFFFFF //【Cluster】【Array】 + E7 82 3137 //Cluster的时间偏移量 12599ms + A3 41B3 //【SimpleBlock】【Array】 + 81 0000 80 //轨道1,对应的轨道是音频,时间偏移量 12599ms+0ms + ......到文件结尾...... +******************/ + +//=====WebM格式解析并提取音频 核心函数========== +Recorder.WebM_Extract_Audio=function(webmBlob,True,False){ + True=True||function(){}; + False=False||function(){}; + + var HeaderEID=[0x1A,0x45,0xDF,0xA3]; + var SegmentEID=[0x18,0x53,0x80,0x67]; + var ClusterEID=[0x1F,0x43,0xB6,0x75]; + + var reader=new FileReader(); + reader.onloadend=function(){ + try{ + var fileBytes=new Uint8Array(reader.result); + var multiHeader=0,tracks={},audioTrackIdx=0,audioTrack0={}; + var duration=[0],duration2=[0]; + var rawData=[],playData=[],isPcm=0; + var position=[0]; + + //循环读取 Header+Segment + HeaderLoop:while(true){ + if(position[0]>=fileBytes.length)break; + +//EBML Header +var eid=readMatroskaVInt(fileBytes, position); +if(!BytesEq(eid, HeaderEID)){ + return False("未识别到此WebM文件Header"); +}; +multiHeader++; +//跳过EBML Header内容 +readMatroskaBlock(fileBytes, position); + +//Segment +var eid=readMatroskaVInt(fileBytes, position); +if(!BytesEq(eid, SegmentEID)){ + return False("未识别到此WebM文件Segment"); +}; +//跳过Segment长度值 +readMatroskaVInt(fileBytes, position); + +//循环读取Cluster +while(true){ + if(position[0]>=fileBytes.length)break; + var eid0=readMatroskaVInt(fileBytes, position); + + //Cluster + if(BytesEq(eid0, ClusterEID)){ + //跳过Cluster长度值 + readMatroskaVInt(fileBytes, position); + + var ablockIdx=0; + var bytes0=fileBytes; + var pos0=position; + var bytesTime0=[]; + + //循环读取SimpleBlock + while(true){ + if(pos0[0]>=bytes0.length)break; + var eid1=readMatroskaVInt(bytes0, pos0); + if(BytesEq(eid1, HeaderEID)){//下一个Header+Segment + position[0]-=HeaderEID.length;//退回一下 + continue HeaderLoop; + }; + if(BytesEq(eid1, ClusterEID)){//下一个Cluster + position[0]-=ClusterEID.length;//退回一下 + break; + }; + + var pos0_=pos0[0]; + var bytes1Len=[]; + var bytes1=readMatroskaBlock(bytes0, pos0, bytes1Len); + var pos1=[0]; + if(BytesEq(eid1, [0xE7])){//Cluster 的当前时间 + bytesTime0=[0xE7]; + for(var i=pos0_;i0 && track.bitDepth==32){ + //pcm数据转换成16位播放 + isPcm=true; + var floatArr=new Float32Array(uint8.buffer); + for(var i=0;i>8)&0xff); + + i+=track.channels; + } + }else{ + //非pcm就用webm重新封装一下播放 + if(playData.length==0){ + Hex2Bytes( +'1A45DFA3 9F 4286 81 01\ + 42F7 81 01 42F2 81 04 42F3 81 08 4282 84 7765626D 4287 81 04 4285 81 02\ +18538067 01FFFFFFFFFFFFFF\ + 1549A966 99 2AD7B1 83 0F4240 4D80 86 4368726F6D65 5741 86 4368726F6D65 1654AE6B', playData); + playData.push(parseInt("1"+("0000000"+track.srcBytes.length.toString(2)).substr(-7),2)); + for(var i=0;i=bytes0.length)break; + var eid1=readMatroskaVInt(bytes0, pos0); + var bytes1Len=[]; + var bytes1=readMatroskaBlock(bytes0, pos0, bytes1Len); + var pos1=[0]; + //TrackEntry + if(BytesEq(eid1, [0xAE])){ + var track={}; + while(true){ + if(pos1[0]>=bytes1.length)break; + var eid2=readMatroskaVInt(bytes1, pos1); + var bytes2=readMatroskaBlock(bytes1, pos1); + var pos2=[0]; + if(BytesEq(eid2, [0xD7])){//Track Number + var val=BytesInt(bytes2); + track.number=val; + if(multiHeader==1){ + tracks[val]=track; + }; + }else if(BytesEq(eid2, [0x83])){//Track Type + var val=BytesInt(bytes2); + if(val==1) track.type="video"; + else if(val==2) { + track.type="audio"; + if(multiHeader==1){ + track.audioTrackIdx=audioTrackIdx++; + if(track.audioTrackIdx==0){ + audioTrack0=track; + } + } + + track.srcBytes=[0xAE]; + [].push.apply(track.srcBytes, bytes1Len); + [].push.apply(track.srcBytes, bytes1); + } else track.type="Type-"+val; + }else if(BytesEq(eid2, [0x86])){//Track Codec + track.codec=BytesStr(bytes2); + }else if(BytesEq(eid2, [0xE0]) || BytesEq(eid2, [0xE1])){ + //循环读取 Video 或 Audio 属性 + while(true){ + if(pos2[0]>=bytes2.length)break; + var eid3=readMatroskaVInt(bytes2, pos2); + var bytes3=readMatroskaBlock(bytes2, pos2); + //采样率、位数、声道数 + if(BytesEq(eid3, [0xB5])) track.sampleRate=Math.round(BytesFloat(bytes3)); + else if(BytesEq(eid3, [0x62,0x64])) track.bitDepth=BytesInt(bytes3); + else if(BytesEq(eid3, [0x9F])) track.channels=BytesInt(bytes3); + //宽高 + else if(BytesEq(eid3, [0xB0])) track.width=BytesInt(bytes3); + else if(BytesEq(eid3, [0xBA])) track.height=BytesInt(bytes3); + } + } + } + if(multiHeader>1){//多个Header时,不支不同持轨道参数 + var tk=tracks[track.number]; + if(!tk || tk.type!=track.type || tk.codec!=track.codec + || tk.sampleRate!=track.sampleRate + || tk.bitDepth!=track.bitDepth + || tk.channels!=track.channels){ + console.log(tk, track); + throw new Error("WebM中有多个header时,不支持不一致的轨道参数"); + } + } + continue; + } + //End TrackEntry + //不认识的,忽略 + } + continue; + } + //End Track + + //不认识的,忽略 +}; +//End Cluster + } + //End Header+Segment + }catch(e){ + console.error(e); + return False("解析WebM文件提取音频异常:"+e.message); + } + if(!rawData.length){ + return False("未提取到此WebM文件的音频数据"); + } + + var dur=0; + for(var i=1;i<=multiHeader;i++){ + dur+=duration[i]||0; + dur+=duration2[i]||0; + } + True({ + rawData:new Uint8Array(rawData) + ,rawTrack:audioTrack0 + + ,playBlob:new Blob([new Uint8Array(playData).buffer],{type:isPcm?"audio/pcm":"audio/webm"}) + ,playType:isPcm?"pcm":"webm" + ,playSampleRate:audioTrack0.sampleRate||0 + ,playBitRate:isPcm?16:0 + + ,webmTracks:tracks + ,multiHeader:multiHeader + ,duration:dur + }); + }; + reader.readAsArrayBuffer(webmBlob); +}; +//两个字节数组内容是否相同 +var BytesEq=function(bytes1,bytes2){ + if(bytes2.length==1){ + if(bytes1.length==1){ + return bytes1[0]==bytes2[0]; + } + return false; + } + if(bytes1.length!=bytes2.length){ + return false; + } + for(var i=0;i用videojs测试浏览器兼容性 - - - + @@ -17,9 +13,60 @@
+
+
国外的玩意,除了好看就是容易误操作,上面如果是空白,代表:加载很慢↑↑↑↑ (也有可能是他们更新了页面,但这个测试html还未及时同步更新)
显示出录音界面后,点击大麦克风按钮打开录音,再点击左下角圆点按钮开始录音,再点按钮结束录音,录完后点左下角的播放箭头播放
+
+ 这个录出来的音频格式完全不可控,可能是webm、wav;但可以注入代码强制修改,录音时日志里面显示的“Using recorderType: xxx”决定了录音类型,替换GetRecorderType函数即可: +
wav:
+
webm:
+
未知:
+
+ +
@@ -46,6 +93,17 @@
+ +
@@ -110,20 +181,20 @@ - - - + + + - - - - - + + + + + - + - + - + - +
@@ -217,7 +218,8 @@ | Gitee 更多Demo : Demo列表(可编辑) - | H5 vue + | H5 vue + | H5 ts
QuickStart : @@ -318,7 +320,7 @@
- +
@@ -327,25 +329,23 @@ 切换麦克风 : 从未请求过录音权限时,可能无法正常拉取设备列表,打开一次录音后可尝试 - +
noiseSuppression : - 降噪配置开关 + 降噪配置开关(默认禁用)
echoCancellation : - 回声消除配置开关 + 回声消除配置开关(默认禁用)
autoGainControl : @@ -357,24 +357,33 @@ 自动增益配置开关
- 以上参数设置后需重新打开录音;均为set中的audioTrackSet高级配置,会直接传递给浏览器的getUserMedia方法,不同浏览器的支持程度不同,并不一定会生效 -
- -
- Destroy : - - Destroy会关闭所有的全局资源,包括AudioContext,当录音出现问题时,可尝试Destroy一下重试 + 以上参数设置后需重新打开录音;均为set中的audioTrackSet高级配置,会直接传递给浏览器的getUserMedia方法,不同浏览器的支持程度不同,并不一定会生效; + 移动端打开降噪、回声消除可能会表现的很怪异(包括系统播放声音变小),所以默认禁用,使用原声录制(高音甜、中音准、低音沉,总之一句话就是通透),如需降噪、回声消除请测试好后再开启
+ 启用MediaRecorder : + + +
音频采集连接方式:启用时尝试使用MediaRecorder.WebM.PCM,默认启用,未启用或者不支持时使用AudioWorklet或ScriptProcessor;通过设置Recorder.ConnectEnableWebM=false禁用。
+
+ 使用MediaRecorder采集到的音频数据比其他方式更好,几乎不存在丢帧现象,所以音质明显会好很多,建议保持开启; + 有些浏览器不支持录制PCM编码的WebM,如FireFox、低版本的Chrome,将依旧使用AudioWorklet或ScriptProcessor来连接采集。 +
+ + +
启用AudioWorklet : -
音频采集连接方式:未启用时使用ScriptProcessor(默认),启用时使用AudioWorklet;通过设置Recorder.ConnectEnableWorklet=true启用。
+
音频采集连接方式:启用时尝试使用AudioWorklet,默认禁用,未启用或者不支持时使用ScriptProcessor;通过设置Recorder.ConnectEnableWorklet=true启用。
已知:AudioWorklet在一定条件下会导致某些浏览器崩溃 测试 @@ -383,6 +392,12 @@
+
+
+ 如需录音功能定制开发,网站、App、小程序、前端后端开发等需求,请加QQ群:①群 781036591、②群 748359095,口令recorder,联系群主(即作者),谢谢~ +
+
+
变速变调 : @@ -429,6 +444,17 @@
以上参数设置后需重新打开录音;这些参数仅供调试用,未来会被删除。
+
+ Destroy : + + Destroy会关闭所有的全局资源,包括AudioContext,当录音出现问题时,可尝试Destroy一下重试 +
+ +
+ 阻止自动锁屏 : + + 手机锁屏后是否能录音不可控,直接简单粗暴的调用wakeLock接口 或 静音+循环播放视频来阻止锁屏,就是有点费电 +
暴力测试 : @@ -465,7 +491,7 @@
测试App : - IOS Demo App:下载源码 自行编译 + iOS Demo App:下载源码 自行编译 ,Android Demo App:下载APK (40kb,删除.zip后缀,源码)
@@ -483,17 +509,22 @@ - Audio对录音的影响测试(issues#34);IOS Safari如果未开始过录音并且播放了音乐,然后后续录音将会有问题;再现方法(test apple developer forums):刷新页面后首先先播放音乐,然后开始测试录音,会发现波形显示掉帧或者保持直线。另测试浏览器对音频的支持情况。 + Audio对录音的影响测试(issues#34);iOS Safari如果未开始过录音并且播放了音乐,然后后续录音将会有问题;再现方法(test apple developer forums):刷新页面后首先先播放音乐,然后开始测试录音,会发现波形显示掉帧或者保持直线。另测试浏览器对音频的支持情况。
视频播放测试 : - + + - Video对录音的影响测试(issues#84);IOS Safari可能出现先播放视频,然后再开始录音,会自动播放视频的声音,但并未再现。 + Video对录音的影响测试(issues#84);iOS Safari可能出现先播放视频,然后再开始录音,会自动播放视频的声音,但并未再现。 + +
@@ -512,6 +543,9 @@ }} AudioContext.audioWorklet:{{"audioWorklet" in (Recorder.Ctx||{})}} AudioWorkletNode:${"AudioWorkletNode" in window} +MediaRecorder:${"MediaRecorder" in window} +MediaRecorder.ondataavailable:${"MediaRecorder" in window && "ondataavailable" in MediaRecorder.prototype} +MediaRecorder.WebM.PCM:${"MediaRecorder" in window && MediaRecorder.isTypeSupported("audio/webm; codecs=pcm")} URL:${location.href.replace(/#.+/g,"")} UA:${navigator.userAgent} @@ -564,10 +598,16 @@ reclog("已禁用设备卡顿时音频输入丢失补偿,可以通过别的程序大量占用CPU来模拟设备卡顿,然后录音听听未补偿时的播放效果,然后再试试不禁用的效果"); }; + var enableWebM=$(".enableWebMSet")[0].checked; + Recorder.ConnectEnableWebM=enableWebM; + if(!enableWebM){ + reclog("已禁用MediaRecorder.WebM.PCM","#aaa"); + } + var enableWorklet=$(".enableWorkletSet")[0].checked; Recorder.ConnectEnableWorklet=enableWorklet; if(enableWorklet){ - reclog("已启用AudioWorklet,"+workletTips,"#f60"); + reclog("已启用AudioWorklet"+(enableWebM?"(同时启用了MediaRecorder,AudioWorklet只会在MediaRecorder未生效时采用)":"")+","+workletTips,"#f60"); } var debugSet_D220626=$(".debugSet_D220626")[0].checked; @@ -581,7 +621,7 @@ var trackSet_noise=$(".trackSet_noise").val(); var trackSet_aec=$(".trackSet_aec").val(); var trackSet_gain=$(".trackSet_gain").val(); - if(trackSet_device || trackSet_noise || trackSet_aec || trackSet_gain){ + if(trackSet_device || trackSet_noise==1 || trackSet_aec==1 || trackSet_gain){ audioTrackSet={}; if(trackSet_device){ var device=DeviceList[+trackSet_device]; @@ -713,13 +753,17 @@ var callDestroy=function(){ Recorder.Destroy(); reclog("已执行Recorder.Destroy()"); + scrollToEl(".reclog"); }; //拉取麦克风设备列表 var DeviceList=[]; -var trackSetQueryDeviceList=function(){ +var trackSetQueryDeviceList=function(click){ var end=function(list,err){ DeviceList=list; + if(click){ + console.log("DeviceList: ", JSON.parse(JSON.stringify(DeviceList))); + } var opts=['']; for(var i=0;i恢复锁屏'); + window.wakeUnLockClick=function(btn){ + lock.release().then(function(){ + wakeLockObj=null; $(btn).remove(); + reclog("已恢复自动锁屏"); + }); + }; + scrollToEl(".reclog"); + })['catch'](function(e){ + console.error("wakeLock错误:"+e.message); + fail(); + }); + }else{ + fail(); + } +}; + + //实时传输数据模拟开关 $(".realTimeSendSet").bind("change",function(e){ var open=e.target.checked; diff --git a/recorder.mp3.min.js b/recorder.mp3.min.js index 24f34d3..c69007b 100644 --- a/recorder.mp3.min.js +++ b/recorder.mp3.min.js @@ -3,4 +3,4 @@ https://github.com/xiangyuecn/Recorder src: recorder-core.js,engine/mp3.js,engine/mp3-engine.js */ -!function(w){"use strict";var m=function(){},O=function(e){return new t(e)};O.LM="2022-06-26 18:37";var R="Recorder";O.IsOpen=function(){var e=O.Stream;if(e){var t=e.getTracks&&e.getTracks()||e.audioTracks||[],a=t[0];if(a){var s=a.readyState;return"live"==s||s==a.LIVE}}return!1},O.BufferSize=4096,O.Destroy=function(){for(var e in k(R+" Destroy"),b(),a)a[e]()};var a={};O.BindDestroy=function(e,t){a[e]=t},O.Support=function(){var e=w.AudioContext;if(e||(e=w.webkitAudioContext),!e)return!1;var t=navigator.mediaDevices||{};return t.getUserMedia||(t=navigator).getUserMedia||(t.getUserMedia=t.webkitGetUserMedia||t.mozGetUserMedia||t.msGetUserMedia),!!t.getUserMedia&&(O.Scope=t,O.Ctx&&"closed"!=O.Ctx.state||(O.Ctx=new e,O.BindDestroy("Ctx",function(){var e=O.Ctx;e&&e.close&&(e.close(),O.Ctx=0)})),!0)};var B="ConnectEnableWorklet";O[B]=!1;var p=function(e){var s=(e=e||O).BufferSize||O.BufferSize,n=O.Ctx,r=e.Stream,i=r._m=n.createMediaStreamSource(r),_=n.destination,t="createMediaStreamDestination";n[t]&&(_=n[t]());var l=r._call,o=function(e,t){if(!t||v)for(var a in l){for(var s=e.length,n=new Int16Array(s),r=0,i=0;i"+l,3);for(var f=0,c=r;c"+p.length+" 花:"+(Date.now()-s)+"ms"),setTimeout(function(){s=Date.now(),n[r.type](p,function(e){o(e,u)},function(e){_(e)})})}else _("未加载"+r.type+"编码器");else _("音频buffers被释放");else _("未采集到录音")}},w[R]&&(k("重复引入"+R,3),w[R].Destroy()),(w[R]=O).TrafficImgUrl="//ia.51.la/go1?id=20469973&pvFlag=1";var r=O.Traffic=function(e){e=e?"/"+R+"/Report/"+e:"";var t=O.TrafficImgUrl;if(t){var a=O.Traffic,s=/^(https?:..[^\/#]*\/?)[^#]*/i.exec(location.href)||[],n=s[1]||"http://file/",r=(s[0]||n)+e;if(0==t.indexOf("//")&&(t=/^https:/i.test(r)?"https:"+t:"http:"+t),e&&(t=t+"&cu="+encodeURIComponent(n+e)),!a[r]){a[r]=1;var i=new Image;i.src=t,k("Traffic Analysis Image: "+(e||R+".TrafficImgUrl="+O.TrafficImgUrl))}}}}(window),"function"==typeof define&&define.amd&&define(function(){return Recorder}),"object"==typeof module&&module.exports&&(module.exports=Recorder),function(){"use strict";var i;Recorder.prototype.enc_mp3={stable:!0,testmsg:"采样率范围48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000"},Recorder.prototype.mp3=function(a,s,e){var n=this.set,r=a.length,t=this.mp3_start(n);if(t)return this.mp3_encode(t,a),void this.mp3_complete(t,s,e,1);var i=new Recorder.lamejs.Mp3Encoder(1,n.sampleRate,n.bitRate),_=[],o=0,l=0,f=function(){if(o=c.byteLength?(_-=c.byteLength,l.push(c),e.splice(f,1),f--):(e[f]=c.slice(_),o=c,_=0)}if(!this.rm(e,t)){o&&(e[0]=o);for(f=0;f "+s.duration+"ms",2>=1;0!=e--;)n[r++]=i>a[s++]?0:1,n[r++]=i>a[s++]?0:1}function R(e,t,a,s,n,r){var i=(e>>=1)%2;for(e>>=1;0!=e--;){var _,o,l,f,c,h,u,m;_=a[s++]*t,o=a[s++]*t,c=0|_,l=a[s++]*t,h=0|o,f=a[s++]*t,u=0|l,_+=M.adj43[c],m=0|f,o+=M.adj43[h],n[r++]=0|_,l+=M.adj43[u],n[r++]=0|o,f+=M.adj43[m],n[r++]=0|l,n[r++]=0|f}0!=i&&(c=0|(_=a[s++]*t),h=0|(o=a[s++]*t),_+=M.adj43[c],o+=M.adj43[h],n[r++]=0|_,n[r++]=0|o)}var _=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function d(e,t,a,s){var n=function(e,t,a){var s=0,n=0;do{var r=e[t++],i=e[t++];s>=16)&&(_=r,s++),n.bits+=_,s}(e,t,a,_[n-1],s);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return function(e,t,a,s,n){var r=0,i=0,_=0,o=F.ht[s].xlen,l=F.ht[s].hlen,f=F.ht[s+1].hlen,c=F.ht[s+2].hlen;do{var h=e[t+0]*o+e[t+1];t+=2,r+=l[h],i+=f[h],_+=c[h]}while(t=n);r++);for(i=r-8;i<24&&!(F.ht[i].linmax>=n);i++);return function(e,t,a,s,n,r){var i,_=65536*F.ht[s].xlen+F.ht[n].xlen,o=0;do{var l=e[t++],f=e[t++];0!=l&&(14>=16)&&(o=i,s=n),r.bits+=o,s}(e,t,a,i,r,s)}}function u(e,t,a,s,n,r,i,_){for(var o=t.big_values,l=2;l>1<<1);for(null!=a&&(a.sfb_count1=0);1t.big_values&&(r=t.big_values),i=t.big_values;else if(t.block_type==Pe.NORM_TYPE){if(r=t.region0_count=e.bv_scf[n-2],i=t.region1_count=e.bv_scf[n-1],i=e.scalefac_band.l[r+i+2],r=e.scalefac_band.l[r+1],ir)return y.LARGE_BITS;if(function(e,t,a,s,n){var r,i,_,o=0,l=0,f=0,c=0,h=t,u=0,m=h,p=0,b=e,v=0;for(_=null!=n&&s.global_gain==n.global_gain,i=s.block_type==Pe.SHORT_TYPE?38:21,r=0;r<=i;r++){var d=-1;if((_||s.block_type==Pe.NORM_TYPE)&&(d=s.global_gain-(s.scalefac[r]+(0!=s.preflag?M.pretab[r]:0)<s.max_nonzero_coeff&&(g=s.max_nonzero_coeff-o+1,Te.fill(t,s.max_nonzero_coeff,576,0),(S=g)<0&&(S=0),r=i+1),0==l&&0==f&&(m=h,p=u,b=e,v=c),null!=n&&0=n.sfb_count1&&0=n.step[r]?(0!=l&&(R(l,a,b,v,m,p),l=0,m=h,p=u,b=e,v=c),f+=S):(0!=f&&(w(f,a,b,v,m,p),f=0,m=h,p=u,b=e,v=c),l+=S),S<=0){0!=f&&(w(f,a,b,v,m,p),f=0),0!=l&&(R(l,a,b,v,m,p),l=0);break}}r<=i&&(u+=s.width[r],c+=s.width[r],o+=s.width[r])}0!=l&&(R(l,a,b,v,m,p),l=0),0!=f&&(w(f,a,b,v,m,p),f=0)}(t,n,M.IPOW20(a.global_gain),a,s),0!=(2&e.substep_shaping))for(var i=0,_=a.global_gain+a.scalefac_scale,o=.634521682242439/M.IPOW20(_),l=0;l=o?n[f]:0}return this.noquant_count_bits(e,a,s)},this.best_huffman_divide=function(e,t){var a=new x,s=t.l3_enc,n=Be(23),r=Be(23),i=Be(23),_=Be(23);if(t.block_type!=Pe.SHORT_TYPE||1!=e.mode_gr){a.assign(t),t.block_type==Pe.NORM_TYPE&&(!function(e,t,a,s,n,r,i){for(var _=t.big_values,o=0;o<=22;o++)s[o]=y.LARGE_BITS;for(o=0;o<16;o++){var l=e.scalefac_band.l[o+1];if(_<=l)break;var f=0,c=new v(f),h=d(a,0,l,c);f=c.bits;for(var u=0;u<8;u++){var m=e.scalefac_band.l[o+u+2];if(_<=m)break;var p=f,b=d(a,l,m,c=new v(p));p=c.bits,s[o+u]>p&&(s[o+u]=p,r[(n[o+u]=o)+u]=h,i[o+u]=b)}}}(e,t,s,n,r,i,_),u(e,a,t,s,n,r,i,_));var o=a.big_values;if(!(0==o||1<(s[o-2]|s[o-1])||576<(o=t.count1+2))){a.assign(t),a.count1=o;for(var l=0,f=0;o>a.big_values;o-=4){var c=2*(2*(2*s[o-4]+s[o-3])+s[o-2])+s[o-1];l+=F.t32l[c],f+=F.t33l[c]}if(a.big_values=o,a.count1table_select=0,fa.part2_3_length&&t.assign(a)}}}};var h=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],m=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],p=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],b=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];k.slen1_tab=p,k.slen2_tab=b,this.best_scalefac_store=function(e,t,a,s){var n,r,i,_,o=s.tt[t][a],l=0;for(n=i=0;n>=1);o.scalefac_scale=l=1}}if(0==o.preflag&&o.block_type!=Pe.SHORT_TYPE&&2==e.mode_gr){for(n=11;nf&&(s.part2_length=f,s.scalefac_compress=r)}}(a,s),l=0),n=0;ns[t]&&(e.part2_length=s[t],e.scalefac_compress=t);return e.part2_length==y.LARGE_BITS};var g=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(e,t){var a,s,n,r,i,_,o,l,f=Be(4),c=t.scalefac;for(a=0!=t.preflag?2:0,o=0;o<4;o++)f[o]=0;if(t.block_type==Pe.SHORT_TYPE){s=1;var h=M.nr_of_sfb_block[a][s];for(n=l=0;n<4;n++)for(r=h[n]/3,o=0;of[n]&&(f[n]=c[3*l+i])}else{s=0;h=M.nr_of_sfb_block[a][s];for(n=l=0;n<4;n++)for(r=h[n],o=0;of[n]&&(f[n]=c[l])}for(_=!1,n=0;n<4;n++)f[n]>g[a][n]&&(_=!0);if(!_){var u,m,p,b;for(t.sfb_partition_table=M.nr_of_sfb_block[a][s],n=0;n<4;n++)t.slen[n]=S[f[n]];switch(u=t.slen[0],m=t.slen[1],p=t.slen[2],b=t.slen[3],a){case 0:t.scalefac_compress=(5*u+m<<4)+(p<<2)+b;break;case 1:t.scalefac_compress=400+(5*u+m<<2)+p;break;case 2:t.scalefac_compress=500+3*u+m;break;default:$.err.printf("intensity stereo not implemented yet\n")}}if(!_)for(n=t.part2_length=0;n<4;n++)t.part2_length+=t.slen[n]*t.sfb_partition_table[n];return _};var S=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(e){for(var t=2;t<=576;t+=2){for(var a,s=0;e.scalefac_band.l[++s]t;)a--;for(a<0&&(a=n[s][0]),e.bv_scf[t-2]=a,a=n[s][1];e.scalefac_band.l[a+e.bv_scf[t-2]+2]>t;)a--;a<0&&(a=n[s][1]),e.bv_scf[t-1]=a}}}function X(){}function M(){this.setModules=function(e,t,a){e,t,a};var _=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];this.updateMusicCRC=function(e,t,a,s){for(var n=0;n>8^_[255&(i^r)]);var r,i}}function q(){var o=this,s=32773,c=null,h=null,r=null,u=null;this.setModules=function(e,t,a,s){c=e,h=t,r=a,u=s};var m=null,l=0,p=0,b=0;function v(e,t,a){for(;0>a<>a<>3]|=t>>a<<8-(7&s)-n,s+=n}e.header[e.h_ptr].ptr=s}function n(e,t){e<<=8;for(var a=0;a<8;a++)0!=(65536&((t<<=1)^(e<<=1)))&&(t^=s);return t}function d(e,t){var a,s=F.ht[t.count1table_select+32],n=0,r=t.big_values,i=t.big_values;for(a=(t.count1-t.big_values)/4;0t.big_values&&(a=t.big_values);var s=g(e,t.table_select[0],0,a,t);return s+=g(e,t.table_select[1],a,t.big_values,t)}function M(e,t){var a,s,n,r;a=t.big_values;var i=t.region0_count+1;return n=e.scalefac_band.l[i],i+=t.region1_count+1,a>8),t[5]=byte(255&a)},this.flush_bitstream=function(e){var t,a,s=e.internal_flags,n=s.h_ptr-1;if(-1==n&&(n=Z.MAX_HEADER_BUF-1),t=s.l3_side,!((a=R(e,new w))<0)){if(_(e,a),s.ResvSize=0,t.main_data_begin=0,s.findReplayGain){var r=c.GetTitleGain(s.rgdata);s.RadioGain=0|Math.floor(10*r+.5)}s.findPeakSample&&(s.noclipGainChange=0|Math.ceil(20*A(s.PeakSample/32767)*10),0 ResvSize"),8*t.main_data_begin!=a.ResvSize&&($.err.printf("bit reservoir error: \nl3_side.main_data_begin: %d \nResvoir size: %d \nresv drain (post) %d \nresv drain (pre) %d \nheader and sideinfo: %d \ndata bits: %d \ntotal bits: %d (remainder: %d) \nbitsperframe: %d \n",8*t.main_data_begin,a.ResvSize,t.resvDrain_post,t.resvDrain_pre,8*a.sideinfo_len,n-t.resvDrain_post-8*a.sideinfo_len,n,n%8,s),$.err.println("This is a fatal error. It has several possible causes:"),$.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),$.err.println(" 9%% Your system is overclocked"),$.err.println(" 1%% bug in LAME encoding library"),a.ResvSize=8*t.main_data_begin),1e9e.PeakSample?e.PeakSample=o[0][_]:-o[0][_]>e.PeakSample&&(e.PeakSample=-o[0][_]);if(1e.PeakSample?e.PeakSample=o[1][_]:-o[1][_]>e.PeakSample&&(e.PeakSample=-o[1][_])}if(e.findReplayGain&&c.AnalyzeSamples(e.rgdata,o[0],0,o[1],0,f,e.channels_out)==X.GAIN_ANALYSIS_ERROR)return-6}}return r},this.init_bit_stream_w=function(e){m=B(U.LAME_MAXMP3BUFFER),e.h_ptr=e.w_ptr=0,e.header[e.h_ptr].write_timing=0,p=-1,l=b=0}}function e(e,t,a,s){this.xlen=e,this.linmax=t,this.table=a,this.hlen=s}Ee.STEREO=new Ee(0),Ee.JOINT_STEREO=new Ee(1),Ee.DUAL_CHANNEL=new Ee(2),Ee.MONO=new Ee(3),Ee.NOT_SET=new Ee(4),X.STEPS_per_dB=100,X.MAX_dB=120,X.GAIN_NOT_ENOUGH_SAMPLES=-24601,X.GAIN_ANALYSIS_ERROR=0,X.GAIN_ANALYSIS_OK=1,X.INIT_GAIN_ANALYSIS_ERROR=0,X.INIT_GAIN_ANALYSIS_OK=1,X.MAX_ORDER=X.YULE_ORDER=10,X.MAX_SAMPLES_PER_WINDOW=(X.MAX_SAMP_FREQ=48e3)*(X.RMS_WINDOW_TIME_NUMERATOR=1)/(X.RMS_WINDOW_TIME_DENOMINATOR=20)+1,M.NUMTOCENTRIES=100,M.MAXFRAMESIZE=2880,q.EQ=function(e,t){return Math.abs(e)>Math.abs(t)?Math.abs(e-t)<=1e-6*Math.abs(e):Math.abs(e-t)<=1e-6*Math.abs(t)},q.NEQ=function(e,t){return!q.EQ(e,t)};var F={};function j(e){this.bits=e}function T(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}function r(e,t,a,s){this.l=Be(1+Pe.SBMAX_l),this.s=Be(1+Pe.SBMAX_s),this.psfb21=Be(1+Pe.PSFB21),this.psfb12=Be(1+Pe.PSFB12);var n=this.l,r=this.s;4==arguments.length&&(this.arrL=e,this.arrS=t,this.arr21=a,this.arr12=s,$.arraycopy(this.arrL,0,n,0,Math.min(this.arrL.length,this.l.length)),$.arraycopy(this.arrS,0,r,0,Math.min(this.arrS.length,this.s.length)),$.arraycopy(this.arr21,0,this.psfb21,0,Math.min(this.arr21.length,this.psfb21.length)),$.arraycopy(this.arr12,0,this.psfb12,0,Math.min(this.arr12.length,this.psfb12.length)))}function y(){var l=null,m=null,s=null;this.setModules=function(e,t,a){l=e,m=t,s=a},this.IPOW20=function(e){return u[e]};var x=2.220446049250313e-16,f=y.IXMAX_VAL+2,c=y.Q_MAX,h=y.Q_MAX2,n=100;this.nr_of_sfb_block=[[[6,5,5,5],[9,9,9,9],[6,9,9,9]],[[6,5,7,3],[9,9,12,6],[6,9,12,6]],[[11,10,0,0],[18,18,0,0],[15,18,0,0]],[[7,7,7,0],[12,12,12,0],[6,15,12,0]],[[6,6,6,3],[12,9,9,6],[6,12,9,6]],[[8,8,5,0],[15,12,9,0],[6,18,9,0]]];var w=[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0];this.pretab=w,this.sfBandIndex=[new r([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,24,32,42,56,74,100,132,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,332,394,464,540,576],[0,4,8,12,18,26,36,48,62,80,104,136,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576],[0,4,8,12,16,22,30,40,52,66,84,106,136,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576],[0,4,8,12,16,22,28,38,50,64,80,100,126,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576],[0,4,8,12,16,22,30,42,58,78,104,138,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576],[0,8,16,24,36,52,72,96,124,160,162,164,166,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0])];var R=Ae(c+h+1),u=Ae(c),p=Ae(f),b=Ae(f);function v(e,t){var a=s.ATHformula(t,e);return a-=n,a=Math.pow(10,a/10+e.ATHlower)}function B(e){this.s=e}this.adj43=b,this.iteration_init=function(e){var t,a=e.internal_flags,s=a.l3_side;if(0==a.iteration_init_init){for(a.iteration_init_init=1,s.main_data_begin=0,function(e){for(var t=e.internal_flags.ATH.l,a=e.internal_flags.ATH.psfb21,s=e.internal_flags.ATH.s,n=e.internal_flags.ATH.psfb12,r=e.internal_flags,i=e.out_samplerate,_=0;_>2&63)&&(t-=64),n=Math.pow(10,t/4/10),32<=(t=e.exp_nspsytune>>8&63)&&(t-=64),r=Math.pow(10,t/4/10),32<=(t=e.exp_nspsytune>>14&63)&&(t-=64),i=Math.pow(10,t/4/10),32<=(t=e.exp_nspsytune>>20&63)&&(t-=64),_=i*Math.pow(10,t/4/10),t=0;t3*s/4&&(f[_]=3*s/4),f[_]<0&&(f[_]=0),f[_]+a[_]>Z.MAX_BITS_PER_CHANNEL&&(f[_]=Math.max(0,Z.MAX_BITS_PER_CHANNEL-a[_])),i+=f[_];if(hZ.MAX_BITS_PER_CHANNEL-e[0]&&(r=Z.MAX_BITS_PER_CHANNEL-e[0]),r<0&&(r=0),125<=e[1]&&(125>1,B=0;do{B+=k=f[_]*f[_],M+=k>1;S=d/b,M=x;do{var k,T;B+=k=f[_]*f[_],M+=ks[r-3+1]&&(s[r-3+1]+=(s[r-3]-s[r-3+1])*i.decay),s[r-3+1]>s[r-3+2]&&(s[r-3+2]+=(s[r-3+1]-s[r-3+2])*i.decay))}return o},this.calc_noise_core=function(e,t,a,s){var n=0,r=t.s,i=e.l3_enc;if(r>e.count1)for(;0!=a--;){o=e.xr[r],r++,n+=o*o,o=e.xr[r],r++,n+=o*o}else if(r>e.big_values){var _=Ae(2);for(_[0]=0,_[1]=s;0!=a--;){o=Math.abs(e.xr[r])-_[i[r]],r++,n+=o*o,o=Math.abs(e.xr[r])-_[i[r]],r++,n+=o*o}}else for(;0!=a--;){var o;o=Math.abs(e.xr[r])-p[i[r]]*s,r++,n+=o*o,o=Math.abs(e.xr[r])-p[i[r]]*s,r++,n+=o*o}return t.s=r,n},this.calc_noise=function(e,t,a,s,n){var r,i,_=0,o=0,l=0,f=0,c=0,h=-20,u=0,m=e.scalefac,p=0;for(r=s.over_SSD=0;r>1,u+e.width[r]>e.max_nonzero_coeff)i=0<(g=e.max_nonzero_coeff-u+1)?g>>1:0;var M=new B(u);d=this.calc_noise_core(e,M,i,S),u=M.s,null!=n&&(n.step[r]=v,n.noise[r]=d),d=a[_++]=d/t[o++],d=ee.FAST_LOG10(Math.max(d,1e-20)),null!=n&&(n.noise_log[r]=d)}if(null!=n&&(n.global_gain=e.global_gain),c+=d,0a.max_noise-.2&&a.tot_noisea.max_noise-.2&&a.tot_noisea.max_noise-.1&&a.tot_noise+a.over_noisea.max_noise-.15&&a.tot_noise+a.over_noise+a.over_noiset.xrpow_max&&(t.xrpow_max=s[f+c]);if(2==i.noise_shaping_amp)return}}}(e,t,a,s,n);var i=_(t);return!i&&(!(i=2==r.mode_gr?w.scale_bitcount(t):w.scale_bitcount_lsf(r,t))||(1e.xrpow_max&&(e.xrpow_max=t[a+i])}e.scalefac[s]=r>>1}e.preflag=0,e.scalefac_scale=1}(t,s),i=!1):t.block_type==Pe.SHORT_TYPE&&0>t.scalefac_scale))n[s]=f,o+=3*l;else{n[s]=0;var c=210+(f<t.xrpow_max&&(t.xrpow_max=a[o+h]);o+=l*(3-r-1)}}var u=M.IPOW20(202);for(o+=t.width[s]*(r+1),h=-t.width[s];h<0;h++)a[o+h]*=u,a[o+h]>t.xrpow_max&&(t.xrpow_max=a[o+h])}}return!1}(r,t,s)||_(t))),i||(i=2==r.mode_gr?w.scale_bitcount(t):w.scale_bitcount_lsf(r,t)),!i))}this.setModules=function(e,t,a,s){v=e,g=t,this.rv=t,M=a,this.qupvt=a,w=s,n.setModules(M,w)},this.ms_convert=function(e,t){for(var a=0;a<576;++a){var s=e.tt[t][0].xr[a],n=e.tt[t][1].xr[a];e.tt[t][0].xr[a]=(s+n)*(.5*ee.SQRT2),e.tt[t][1].xr[a]=(s-n)*(.5*ee.SQRT2)}},this.init_xrpow=function(e,t,a){var s=0,n=0|t.max_nonzero_coeff;if(t.xrpow_max=0,Te.fill(a,n,576,0),1e-20<(s=function(e,t,a,s){for(var n=s=0;n<=a;++n){var r=Math.abs(e.xr[n]);s+=r,t[n]=Math.sqrt(r*Math.sqrt(r)),t[n]>e.xrpow_max&&(e.xrpow_max=t[n])}return s}(t,a,n,s))){var r=0;0!=(2&e.substep_shaping)&&(r=1);for(var i=0;iS&&_.global_gain<=g;)_.global_gain++;if(_.global_gain>g)break;if(0==f.over_count){for(;(_.part2_3_length=w.count_bits(i,s,_,c))>h&&_.global_gain<=g;)_.global_gain++;if(_.global_gain>g)break}if(M.calc_noise(_,a,l,d,c),d.bits=_.part2_3_length,0!=(B(t.block_type!=Pe.SHORT_TYPE?e.quant_comp:e.quant_comp_short,f,d,_,l)?1:0))h=t.part2_3_length,f=d,t.assign(_),b=0,$.arraycopy(s,0,o,0,576);else if(0==i.full_outer_loop){if(++b>v&&0==f.over_count)break;if(3==i.noise_shaping_amp&&m&&30r[f.VBR_max_bitrate]&&(_[p][v]*=r[f.VBR_max_bitrate],_[p][v]/=u),i[p][v]>_[p][v]&&(i[p][v]=_[p][v]);return h},this.bitpressure_strategy=function(e,t,a,s){for(var n=0;nZ.MAX_BITS_PER_CHANNEL&&(s[_][o]=Z.MAX_BITS_PER_CHANNEL),m+=s[_][o]}if(Z.MAX_BITS_PER_GRANULEZ.MAX_BITS_PER_CHANNEL&&(s[_][o]=Z.MAX_BITS_PER_CHANNEL),l+=s[_][o];if(l>r[0])for(_=0;_=s?(e.ATH.adjust*=.075*s+.925,e.ATH.adjust=s?e.ATH.adjust=s:e.ATH.adjust>1,u=(h=(c=s)<<1)+c,s=h<<1,r=(n=t)+m;M=e[n+0]-e[n+c],S=e[n+0]+e[n+c],A=e[n+h]-e[n+u],R=e[n+h]+e[n+u],e[n+h]=S-R,e[n+0]=S+R,e[n+u]=M-A,e[n+c]=M+A,M=e[r+0]-e[r+c],S=e[r+0]+e[r+c],A=ee.SQRT2*e[r+u],R=ee.SQRT2*e[r+h],e[r+h]=S-R,e[r+0]=S+R,e[r+u]=M-A,e[r+c]=M+A,r+=s,(n+=s)<_;);for(l=T[i+0],o=T[i+1],f=1;fO[u+3-2]?Q/=O[u+3-2]:Q=O[u+3-2]>10*Q?O[u+3-2]/(10*Q):0,C[u+3]=Q}if(e.analysis){var W=C[0];for(u=1;u<12;u++)WV&&(q[u/3]=u%3+1);for(u=1;u<4;u++){(N[u-1]>N[u]?N[u-1]/N[u]:N[u]/N[u-1])<1.7&&(q[u]=0,1==u&&(q[0]=0))}for(0!=q[0]&&0!=S.nsPsy.lastAttacks[c]&&(q[0]=0),3!=S.nsPsy.lastAttacks[c]&&q[0]+q[1]+q[2]+q[3]==0||((D=0)!=q[1]&&0!=q[0]&&(q[1]=0),0!=q[2]&&0!=q[1]&&(q[2]=0),0!=q[3]&&0!=q[2]&&(q[3]=0)),c<2?T[c]=D:0==D&&(T[0]=T[1]=0),o[c]=S.tot_ener[c],he(e,F,j,M,1&c,w,1&c,s,c,t,a),Me(S,F,R,Y,X),we(S,Y,X,y),v=0;v<3;v++){var J,$;for(ve(e,j,B,A,c,v),pe(S,B,A,c,v),b=0;b1.58*e.thm[1].l[t]||e.thm[1].l[t]>1.58*e.thm[0].l[t])){var a=e.mld_l[t]*e.en[3].l[t],s=Math.max(e.thm[2].l[t],Math.min(e.thm[3].l[t],a));a=e.mld_l[t]*e.en[2].l[t];var n=Math.max(e.thm[3].l[t],Math.min(e.thm[2].l[t],a));e.thm[2].l[t]=s,e.thm[3].l[t]=n}for(t=0;t1.58*e.thm[1].s[t][r]||e.thm[1].s[t][r]>1.58*e.thm[0].s[t][r]||(a=e.mld_s[t]*e.en[3].s[t][r],s=Math.max(e.thm[2].s[t][r],Math.min(e.thm[3].s[t][r],a)),a=e.mld_s[t]*e.en[2].s[t][r],n=Math.max(e.thm[3].s[t][r],Math.min(e.thm[2].s[t][r],a)),e.thm[2].s[t][r]=s,e.thm[3].s[t][r]=n)}(S),g=e.msfix,0g&&(s[o]=g),1a[o]&&(s[o]=a[o]),l.masking_lower<1&&(s[o]*=l.masking_lower)}for(;of&&(s[r]=f),1a[r]&&(s[r]=a[r]),e.masking_lower<1&&(s[r]*=e.masking_lower)}for(;rM[b+3-2]?E/=M[b+3-2]:E=M[b+3-2]>10*E?M[b+3-2]/(10*E):0,S[b+3]=E}for(b=0;b<3;++b){var P=M[3*b+3]+M[3*b+4]+M[3*b+5],I=1;6*M[3*b+5]A&&(o[m][b/3]=b%3+1);for(b=1;b<4;b++){var L=w[b-1],V=w[b];Math.max(L,V)<4e4&&L<1.7*V&&V<1.7*L&&(1==b&&o[m][0]<=o[m][b]&&(o[m][0]=0),o[m][b]=0)}o[m][0]<=c.nsPsy.lastAttacks[m]&&(o[m][0]=0),3!=c.nsPsy.lastAttacks[m]&&o[m][0]+o[m][1]+o[m][2]+o[m][3]==0||((k=0)!=o[m][1]&&0!=o[m][0]&&(o[m][1]=0),0!=o[m][2]&&0!=o[m][1]&&(o[m][2]=0),0!=o[m][3]&&0!=o[m][2]&&(o[m][3]=0)),m<2?l[m]=k:0==k&&(l[0]=l[1]=0),i[m]=c.tot_ener[m]}}(e,t,a,s,n,r,o,w,R,B),function(e,t){var a=e.internal_flags;e.short_blocks!=xe.short_block_coupled||0!=t[0]&&0!=t[1]||(t[0]=t[1]=0);for(var s=0;s=n&&(p=i*(l[t]-n)/(24-n)+r*(24-l[t])/(24-n)),c[t]=Math.pow(10,p/10),0=n&&(p=o*(l[t]-n)/(24-n)+_*(24-l[t])/(24-n)),c[t]=Math.pow(10,p/10),g=K.MAX_VALUE;for(v=0;va.npart_l-1&&(a.s3ind[M][1]=a.npart_l-1);var w=576*a.mode_gr/h;if(a.ATH.decay=Math.pow(10,-1.2*w),a.ATH.adjust=.01,-(a.ATH.adjustLimit=1)!=e.ATHtype){var R=e.out_samplerate/Pe.BLKSIZE,B=0;for(t=d=0;t=v)for(l=0;le.in_samplerate&&(e.lowpassfreq=e.in_samplerate/2),e.out_samplerate=(t=0|e.lowpassfreq,a=e.in_samplerate,s=44100,48e3<=a?s=48e3:44100<=a?s=44100:32e3<=a?s=32e3:24e3<=a?s=24e3:22050<=a?s=22050:16e3<=a?s=16e3:12e3<=a?s=12e3:11025<=a?s=11025:8e3<=a&&(s=8e3),-1==t?s:(t<=15960&&(s=44100),t<=15250&&(s=32e3),t<=11220&&(s=24e3),t<=9970&&(s=22050),t<=7230&&(s=16e3),t<=5420&&(s=12e3),t<=4510&&(s=11025),t<=3970&&(s=8e3),a=t.lowpass2&&(a=Math.min(a,r)),t.lowpass1t.highpass1?E((t.highpass2-l)/(t.highpass2-t.highpass1+1e-20)):1,o=t.lowpass2>t.lowpass1?E((l-t.lowpass1)/(t.lowpass2-t.lowpass1+1e-20)):1,t.amp_filter[r]=_*o}}(e),n.samplerate_index=P(e.out_samplerate,e),n.samplerate_index<0)return e.internal_flags=null,-1;if(e.VBR==ye.vbr_off){if(e.free_format)n.bitrate_index=0;else if(e.brate=I(e.brate,e.version,e.out_samplerate),n.bitrate_index=H(e.brate,e.version,e.out_samplerate),n.bitrate_index<=0)return e.internal_flags=null,-1}else n.bitrate_index=1;e.analysis&&(e.bWriteVbrTag=!1),null!=n.pinfo&&(e.bWriteVbrTag=!1),R.init_bit_stream_w(n);for(var c,h,u,m=n.samplerate_index+3*e.version+6*(e.out_samplerate<16e3?1:0),p=0;p=f){var M=i-u;if(0==i&&(M=0),(_=O(e,m[0],m[1],n,r,M))<0)return _;for(r+=_,u+=_,h.mf_size-=e.framesize,h.mf_samples_to_encode-=e.framesize,l=0;li&&(s.ResvMax=i),(s.ResvMax<0||e.disable_reservoir)&&(s.ResvMax=0);var _=t.bits*s.mode_gr+Math.min(s.ResvSize,s.ResvMax);return a<_&&(_=a),n.resvDrain_pre=0,null!=s.pinfo&&(s.pinfo.mean_bits=t.bits/2,s.pinfo.resvsize=s.ResvSize),_},this.ResvMaxBits=function(e,t,a,s){var n,r=e.internal_flags,i=r.ResvSize,_=r.ResvMax;0!=s&&(i+=t),0!=(1&r.substep_shaping)&&(_*=.9),a.bits=t,9*_<10*i?(n=i-9*_/10,a.bits+=n,r.substep_shaping|=128):(n=0,r.substep_shaping&=127,e.disable_reservoir||0!=(1&r.substep_shaping)||(a.bits-=.1*t));var o=i<6*r.ResvMax/10?i:6*r.ResvMax/10;return(o-=n)<0&&(o=0),o},this.ResvAdjust=function(e,t){e.ResvSize-=t.part2_3_length+t.part2_length},this.ResvFrameEnd=function(e,t){var a,s=e.l3_side;e.ResvSize+=t*e.mode_gr;var n=0;s.resvDrain_post=0,(s.resvDrain_pre=0)!=(a=e.ResvSize%8)&&(n+=a),0<(a=e.ResvSize-n-e.ResvMax)&&(n+=a);var r=Math.min(8*s.main_data_begin,n)/8;s.resvDrain_pre+=8*r,n-=8*r,e.ResvSize-=8*r,s.main_data_begin-=r,s.resvDrain_post+=n,e.ResvSize-=n}},m=new k,p=new function(){this.setModules=function(e,t,a){}},b=new function(){};n.setModules(r,i,_,o,l,f,c,h,b),i.setModules(r,b,c,f),h.setModules(i,c),_.setModules(n),l.setModules(i,u,o,m),o.setModules(m,u,n.enc.psy),u.setModules(i),m.setModules(o),f.setModules(n,i,c),a.setModules(p,b),p.setModules(c,h,_);var v=n.lame_init();v.num_channels=s,v.in_samplerate=e,v.out_samplerate=e,v.brate=t,v.mode=Ee.STEREO,v.quality=3,v.bWriteVbrTag=!1,v.disable_reservoir=!0,v.write_id3tag_automatic=!1,n.lame_init_params(v);var d=1152,g=0|1.25*d+7200,S=B(g);this.encodeBuffer=function(e,t){1==s&&(t=e),e.length>d&&(d=e.length,S=B(g=0|1.25*d+7200));var a=n.lame_encode_buffer(v,e,t,e.length,S,0,g);return new Int8Array(S.subarray(0,a))},this.flush=function(){var e=n.lame_encode_flush(v,S,0,g);return new Int8Array(S.subarray(0,e))}}}t(),Recorder.lamejs=t}(); \ No newline at end of file +!function(y){"use strict";var v=function(){},O=function(e){return new t(e)};O.LM="2022-08-06 20:51";var T="Recorder",d="getUserMedia",C="srcSampleRate",N="sampleRate";O.IsOpen=function(){var e=O.Stream;if(e){var t=e.getTracks&&e.getTracks()||e.audioTracks||[],a=t[0];if(a){var s=a.readyState;return"live"==s||s==a.LIVE}}return!1},O.BufferSize=4096,O.Destroy=function(){for(var e in H(T+" Destroy"),S(),a)a[e]()};var a={};O.BindDestroy=function(e,t){a[e]=t},O.Support=function(){var e=y.AudioContext;if(e||(e=y.webkitAudioContext),!e)return!1;var t=navigator.mediaDevices||{};return t[d]||(t=navigator)[d]||(t[d]=t.webkitGetUserMedia||t.mozGetUserMedia||t.msGetUserMedia),!!t[d]&&(O.Scope=t,O.Ctx&&"closed"!=O.Ctx.state||(O.Ctx=new e,O.BindDestroy("Ctx",function(){var e=O.Ctx;e&&e.close&&(e.close(),O.Ctx=0)})),!0)};var x="ConnectEnableWebM";O[x]=!0;var E="ConnectEnableWorklet";O[E]=!1;var g=function(e,o){var l,i,f,c=e.BufferSize||O.BufferSize,h=O.Ctx,u=e.Stream,_=function(e){var t=u._m=h.createMediaStreamSource(u),a=h.destination,s="createMediaStreamDestination";h[s]&&(a=h[s]()),t.connect(e),e.connect(a)},m="",p=u._call,b=function(e){for(var t in p){for(var a=e.length,s=new Int16Array(a),n=0,r=0;r"+l,3);for(var f=0,c=r;c"+v.length+" 花:"+(Date.now()-s)+"ms"),setTimeout(function(){s=Date.now(),n[r.type](v,function(e){f(e,p)},function(e){l(e)})})}else l("未加载"+r.type+"编码器");else l("音频buffers被释放");else l("未采集到录音")}},y[T]&&(H("重复引入"+T,3),y[T].Destroy()),y[T]=O;var L=function(e,t){t.pos||(t.pos=[0],t.tracks={},t.bytes=[]);var a=t.tracks,s=[t.pos[0]],n=function(){t.pos[0]=s[0]},r=t.bytes.length,i=new Uint8Array(r+e.length);if(i.set(t.bytes),i.set(e,r),t.bytes=i,!t._ht){if(Y(i,s),X(i,s),!V(Y(i,s),[24,83,128,103]))return;for(Y(i,s);s[0]=e.length)){var n=e[s],r=("0000000"+n.toString(2)).substr(-8),i=/^(0*1)(\d*)$/.exec(r);if(i){var _=i[1].length,o=[];if(!(s+_>e.length)){for(var l=0;l<_;l++)o[l]=e[s],s++;return a&&(o[0]=parseInt(i[2]||"0",2)),t[0]=s,o}}}},X=function(e,t){var a=Y(e,t,1);if(a){var s=D(a),n=t[0],r=[];if(s<2147483647){if(n+s>e.length)return;for(var i=0;i=c.byteLength?(_-=c.byteLength,l.push(c),e.splice(f,1),f--):(e[f]=c.slice(_),o=c,_=0)}if(!this.rm(e,t)){o&&(e[0]=o);for(f=0;f "+s.duration+"ms",2>=1;0!=e--;)n[r++]=i>a[s++]?0:1,n[r++]=i>a[s++]?0:1}function R(e,t,a,s,n,r){var i=(e>>=1)%2;for(e>>=1;0!=e--;){var _,o,l,f,c,h,u,m;_=a[s++]*t,o=a[s++]*t,c=0|_,l=a[s++]*t,h=0|o,f=a[s++]*t,u=0|l,_+=M.adj43[c],m=0|f,o+=M.adj43[h],n[r++]=0|_,l+=M.adj43[u],n[r++]=0|o,f+=M.adj43[m],n[r++]=0|l,n[r++]=0|f}0!=i&&(c=0|(_=a[s++]*t),h=0|(o=a[s++]*t),_+=M.adj43[c],o+=M.adj43[h],n[r++]=0|_,n[r++]=0|o)}var _=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function d(e,t,a,s){var n=function(e,t,a){var s=0,n=0;do{var r=e[t++],i=e[t++];s>=16)&&(_=r,s++),n.bits+=_,s}(e,t,a,_[n-1],s);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return function(e,t,a,s,n){var r=0,i=0,_=0,o=F.ht[s].xlen,l=F.ht[s].hlen,f=F.ht[s+1].hlen,c=F.ht[s+2].hlen;do{var h=e[t+0]*o+e[t+1];t+=2,r+=l[h],i+=f[h],_+=c[h]}while(t=n);r++);for(i=r-8;i<24&&!(F.ht[i].linmax>=n);i++);return function(e,t,a,s,n,r){var i,_=65536*F.ht[s].xlen+F.ht[n].xlen,o=0;do{var l=e[t++],f=e[t++];0!=l&&(14>=16)&&(o=i,s=n),r.bits+=o,s}(e,t,a,i,r,s)}}function u(e,t,a,s,n,r,i,_){for(var o=t.big_values,l=2;l>1<<1);for(null!=a&&(a.sfb_count1=0);1t.big_values&&(r=t.big_values),i=t.big_values;else if(t.block_type==Pe.NORM_TYPE){if(r=t.region0_count=e.bv_scf[n-2],i=t.region1_count=e.bv_scf[n-1],i=e.scalefac_band.l[r+i+2],r=e.scalefac_band.l[r+1],ir)return x.LARGE_BITS;if(function(e,t,a,s,n){var r,i,_,o=0,l=0,f=0,c=0,h=t,u=0,m=h,p=0,b=e,v=0;for(_=null!=n&&s.global_gain==n.global_gain,i=s.block_type==Pe.SHORT_TYPE?38:21,r=0;r<=i;r++){var d=-1;if((_||s.block_type==Pe.NORM_TYPE)&&(d=s.global_gain-(s.scalefac[r]+(0!=s.preflag?M.pretab[r]:0)<s.max_nonzero_coeff&&(g=s.max_nonzero_coeff-o+1,ye.fill(t,s.max_nonzero_coeff,576,0),(S=g)<0&&(S=0),r=i+1),0==l&&0==f&&(m=h,p=u,b=e,v=c),null!=n&&0=n.sfb_count1&&0=n.step[r]?(0!=l&&(R(l,a,b,v,m,p),l=0,m=h,p=u,b=e,v=c),f+=S):(0!=f&&(w(f,a,b,v,m,p),f=0,m=h,p=u,b=e,v=c),l+=S),S<=0){0!=f&&(w(f,a,b,v,m,p),f=0),0!=l&&(R(l,a,b,v,m,p),l=0);break}}r<=i&&(u+=s.width[r],c+=s.width[r],o+=s.width[r])}0!=l&&(R(l,a,b,v,m,p),l=0),0!=f&&(w(f,a,b,v,m,p),f=0)}(t,n,M.IPOW20(a.global_gain),a,s),0!=(2&e.substep_shaping))for(var i=0,_=a.global_gain+a.scalefac_scale,o=.634521682242439/M.IPOW20(_),l=0;l=o?n[f]:0}return this.noquant_count_bits(e,a,s)},this.best_huffman_divide=function(e,t){var a=new T,s=t.l3_enc,n=Ae(23),r=Ae(23),i=Ae(23),_=Ae(23);if(t.block_type!=Pe.SHORT_TYPE||1!=e.mode_gr){a.assign(t),t.block_type==Pe.NORM_TYPE&&(!function(e,t,a,s,n,r,i){for(var _=t.big_values,o=0;o<=22;o++)s[o]=x.LARGE_BITS;for(o=0;o<16;o++){var l=e.scalefac_band.l[o+1];if(_<=l)break;var f=0,c=new v(f),h=d(a,0,l,c);f=c.bits;for(var u=0;u<8;u++){var m=e.scalefac_band.l[o+u+2];if(_<=m)break;var p=f,b=d(a,l,m,c=new v(p));p=c.bits,s[o+u]>p&&(s[o+u]=p,r[(n[o+u]=o)+u]=h,i[o+u]=b)}}}(e,t,s,n,r,i,_),u(e,a,t,s,n,r,i,_));var o=a.big_values;if(!(0==o||1<(s[o-2]|s[o-1])||576<(o=t.count1+2))){a.assign(t),a.count1=o;for(var l=0,f=0;o>a.big_values;o-=4){var c=2*(2*(2*s[o-4]+s[o-3])+s[o-2])+s[o-1];l+=F.t32l[c],f+=F.t33l[c]}if(a.big_values=o,a.count1table_select=0,fa.part2_3_length&&t.assign(a)}}}};var h=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],m=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],p=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],b=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];k.slen1_tab=p,k.slen2_tab=b,this.best_scalefac_store=function(e,t,a,s){var n,r,i,_,o=s.tt[t][a],l=0;for(n=i=0;n>=1);o.scalefac_scale=l=1}}if(0==o.preflag&&o.block_type!=Pe.SHORT_TYPE&&2==e.mode_gr){for(n=11;nf&&(s.part2_length=f,s.scalefac_compress=r)}}(a,s),l=0),n=0;ns[t]&&(e.part2_length=s[t],e.scalefac_compress=t);return e.part2_length==x.LARGE_BITS};var g=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(e,t){var a,s,n,r,i,_,o,l,f=Ae(4),c=t.scalefac;for(a=0!=t.preflag?2:0,o=0;o<4;o++)f[o]=0;if(t.block_type==Pe.SHORT_TYPE){s=1;var h=M.nr_of_sfb_block[a][s];for(n=l=0;n<4;n++)for(r=h[n]/3,o=0;of[n]&&(f[n]=c[3*l+i])}else{s=0;h=M.nr_of_sfb_block[a][s];for(n=l=0;n<4;n++)for(r=h[n],o=0;of[n]&&(f[n]=c[l])}for(_=!1,n=0;n<4;n++)f[n]>g[a][n]&&(_=!0);if(!_){var u,m,p,b;for(t.sfb_partition_table=M.nr_of_sfb_block[a][s],n=0;n<4;n++)t.slen[n]=S[f[n]];switch(u=t.slen[0],m=t.slen[1],p=t.slen[2],b=t.slen[3],a){case 0:t.scalefac_compress=(5*u+m<<4)+(p<<2)+b;break;case 1:t.scalefac_compress=400+(5*u+m<<2)+p;break;case 2:t.scalefac_compress=500+3*u+m;break;default:$.err.printf("intensity stereo not implemented yet\n")}}if(!_)for(n=t.part2_length=0;n<4;n++)t.part2_length+=t.slen[n]*t.sfb_partition_table[n];return _};var S=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(e){for(var t=2;t<=576;t+=2){for(var a,s=0;e.scalefac_band.l[++s]t;)a--;for(a<0&&(a=n[s][0]),e.bv_scf[t-2]=a,a=n[s][1];e.scalefac_band.l[a+e.bv_scf[t-2]+2]>t;)a--;a<0&&(a=n[s][1]),e.bv_scf[t-1]=a}}}function X(){}function M(){this.setModules=function(e,t,a){e,t,a};var _=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];this.updateMusicCRC=function(e,t,a,s){for(var n=0;n>8^_[255&(i^r)]);var r,i}}function q(){var o=this,s=32773,c=null,h=null,r=null,u=null;this.setModules=function(e,t,a,s){c=e,h=t,r=a,u=s};var m=null,l=0,p=0,b=0;function v(e,t,a){for(;0>a<>a<>3]|=t>>a<<8-(7&s)-n,s+=n}e.header[e.h_ptr].ptr=s}function n(e,t){e<<=8;for(var a=0;a<8;a++)0!=(65536&((t<<=1)^(e<<=1)))&&(t^=s);return t}function d(e,t){var a,s=F.ht[t.count1table_select+32],n=0,r=t.big_values,i=t.big_values;for(a=(t.count1-t.big_values)/4;0t.big_values&&(a=t.big_values);var s=g(e,t.table_select[0],0,a,t);return s+=g(e,t.table_select[1],a,t.big_values,t)}function M(e,t){var a,s,n,r;a=t.big_values;var i=t.region0_count+1;return n=e.scalefac_band.l[i],i+=t.region1_count+1,a>8),t[5]=byte(255&a)},this.flush_bitstream=function(e){var t,a,s=e.internal_flags,n=s.h_ptr-1;if(-1==n&&(n=Z.MAX_HEADER_BUF-1),t=s.l3_side,!((a=R(e,new w))<0)){if(_(e,a),s.ResvSize=0,t.main_data_begin=0,s.findReplayGain){var r=c.GetTitleGain(s.rgdata);s.RadioGain=0|Math.floor(10*r+.5)}s.findPeakSample&&(s.noclipGainChange=0|Math.ceil(20*B(s.PeakSample/32767)*10),0 ResvSize"),8*t.main_data_begin!=a.ResvSize&&($.err.printf("bit reservoir error: \nl3_side.main_data_begin: %d \nResvoir size: %d \nresv drain (post) %d \nresv drain (pre) %d \nheader and sideinfo: %d \ndata bits: %d \ntotal bits: %d (remainder: %d) \nbitsperframe: %d \n",8*t.main_data_begin,a.ResvSize,t.resvDrain_post,t.resvDrain_pre,8*a.sideinfo_len,n-t.resvDrain_post-8*a.sideinfo_len,n,n%8,s),$.err.println("This is a fatal error. It has several possible causes:"),$.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),$.err.println(" 9%% Your system is overclocked"),$.err.println(" 1%% bug in LAME encoding library"),a.ResvSize=8*t.main_data_begin),1e9e.PeakSample?e.PeakSample=o[0][_]:-o[0][_]>e.PeakSample&&(e.PeakSample=-o[0][_]);if(1e.PeakSample?e.PeakSample=o[1][_]:-o[1][_]>e.PeakSample&&(e.PeakSample=-o[1][_])}if(e.findReplayGain&&c.AnalyzeSamples(e.rgdata,o[0],0,o[1],0,f,e.channels_out)==X.GAIN_ANALYSIS_ERROR)return-6}}return r},this.init_bit_stream_w=function(e){m=A(G.LAME_MAXMP3BUFFER),e.h_ptr=e.w_ptr=0,e.header[e.h_ptr].write_timing=0,p=-1,l=b=0}}function e(e,t,a,s){this.xlen=e,this.linmax=t,this.table=a,this.hlen=s}Ee.STEREO=new Ee(0),Ee.JOINT_STEREO=new Ee(1),Ee.DUAL_CHANNEL=new Ee(2),Ee.MONO=new Ee(3),Ee.NOT_SET=new Ee(4),X.STEPS_per_dB=100,X.MAX_dB=120,X.GAIN_NOT_ENOUGH_SAMPLES=-24601,X.GAIN_ANALYSIS_ERROR=0,X.GAIN_ANALYSIS_OK=1,X.INIT_GAIN_ANALYSIS_ERROR=0,X.INIT_GAIN_ANALYSIS_OK=1,X.MAX_ORDER=X.YULE_ORDER=10,X.MAX_SAMPLES_PER_WINDOW=(X.MAX_SAMP_FREQ=48e3)*(X.RMS_WINDOW_TIME_NUMERATOR=1)/(X.RMS_WINDOW_TIME_DENOMINATOR=20)+1,M.NUMTOCENTRIES=100,M.MAXFRAMESIZE=2880,q.EQ=function(e,t){return Math.abs(e)>Math.abs(t)?Math.abs(e-t)<=1e-6*Math.abs(e):Math.abs(e-t)<=1e-6*Math.abs(t)},q.NEQ=function(e,t){return!q.EQ(e,t)};var F={};function j(e){this.bits=e}function y(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}function r(e,t,a,s){this.l=Ae(1+Pe.SBMAX_l),this.s=Ae(1+Pe.SBMAX_s),this.psfb21=Ae(1+Pe.PSFB21),this.psfb12=Ae(1+Pe.PSFB12);var n=this.l,r=this.s;4==arguments.length&&(this.arrL=e,this.arrS=t,this.arr21=a,this.arr12=s,$.arraycopy(this.arrL,0,n,0,Math.min(this.arrL.length,this.l.length)),$.arraycopy(this.arrS,0,r,0,Math.min(this.arrS.length,this.s.length)),$.arraycopy(this.arr21,0,this.psfb21,0,Math.min(this.arr21.length,this.psfb21.length)),$.arraycopy(this.arr12,0,this.psfb12,0,Math.min(this.arr12.length,this.psfb12.length)))}function x(){var l=null,m=null,s=null;this.setModules=function(e,t,a){l=e,m=t,s=a},this.IPOW20=function(e){return u[e]};var T=2.220446049250313e-16,f=x.IXMAX_VAL+2,c=x.Q_MAX,h=x.Q_MAX2,n=100;this.nr_of_sfb_block=[[[6,5,5,5],[9,9,9,9],[6,9,9,9]],[[6,5,7,3],[9,9,12,6],[6,9,12,6]],[[11,10,0,0],[18,18,0,0],[15,18,0,0]],[[7,7,7,0],[12,12,12,0],[6,15,12,0]],[[6,6,6,3],[12,9,9,6],[6,12,9,6]],[[8,8,5,0],[15,12,9,0],[6,18,9,0]]];var w=[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0];this.pretab=w,this.sfBandIndex=[new r([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,24,32,42,56,74,100,132,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,332,394,464,540,576],[0,4,8,12,18,26,36,48,62,80,104,136,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576],[0,4,8,12,16,22,30,40,52,66,84,106,136,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576],[0,4,8,12,16,22,28,38,50,64,80,100,126,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576],[0,4,8,12,16,22,30,42,58,78,104,138,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new r([0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576],[0,8,16,24,36,52,72,96,124,160,162,164,166,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0])];var R=Be(c+h+1),u=Be(c),p=Be(f),b=Be(f);function v(e,t){var a=s.ATHformula(t,e);return a-=n,a=Math.pow(10,a/10+e.ATHlower)}function A(e){this.s=e}this.adj43=b,this.iteration_init=function(e){var t,a=e.internal_flags,s=a.l3_side;if(0==a.iteration_init_init){for(a.iteration_init_init=1,s.main_data_begin=0,function(e){for(var t=e.internal_flags.ATH.l,a=e.internal_flags.ATH.psfb21,s=e.internal_flags.ATH.s,n=e.internal_flags.ATH.psfb12,r=e.internal_flags,i=e.out_samplerate,_=0;_>2&63)&&(t-=64),n=Math.pow(10,t/4/10),32<=(t=e.exp_nspsytune>>8&63)&&(t-=64),r=Math.pow(10,t/4/10),32<=(t=e.exp_nspsytune>>14&63)&&(t-=64),i=Math.pow(10,t/4/10),32<=(t=e.exp_nspsytune>>20&63)&&(t-=64),_=i*Math.pow(10,t/4/10),t=0;t3*s/4&&(f[_]=3*s/4),f[_]<0&&(f[_]=0),f[_]+a[_]>Z.MAX_BITS_PER_CHANNEL&&(f[_]=Math.max(0,Z.MAX_BITS_PER_CHANNEL-a[_])),i+=f[_];if(hZ.MAX_BITS_PER_CHANNEL-e[0]&&(r=Z.MAX_BITS_PER_CHANNEL-e[0]),r<0&&(r=0),125<=e[1]&&(125>1,A=0;do{A+=k=f[_]*f[_],M+=k>1;S=d/b,M=T;do{var k,y;A+=k=f[_]*f[_],M+=ks[r-3+1]&&(s[r-3+1]+=(s[r-3]-s[r-3+1])*i.decay),s[r-3+1]>s[r-3+2]&&(s[r-3+2]+=(s[r-3+1]-s[r-3+2])*i.decay))}return o},this.calc_noise_core=function(e,t,a,s){var n=0,r=t.s,i=e.l3_enc;if(r>e.count1)for(;0!=a--;){o=e.xr[r],r++,n+=o*o,o=e.xr[r],r++,n+=o*o}else if(r>e.big_values){var _=Be(2);for(_[0]=0,_[1]=s;0!=a--;){o=Math.abs(e.xr[r])-_[i[r]],r++,n+=o*o,o=Math.abs(e.xr[r])-_[i[r]],r++,n+=o*o}}else for(;0!=a--;){var o;o=Math.abs(e.xr[r])-p[i[r]]*s,r++,n+=o*o,o=Math.abs(e.xr[r])-p[i[r]]*s,r++,n+=o*o}return t.s=r,n},this.calc_noise=function(e,t,a,s,n){var r,i,_=0,o=0,l=0,f=0,c=0,h=-20,u=0,m=e.scalefac,p=0;for(r=s.over_SSD=0;r>1,u+e.width[r]>e.max_nonzero_coeff)i=0<(g=e.max_nonzero_coeff-u+1)?g>>1:0;var M=new A(u);d=this.calc_noise_core(e,M,i,S),u=M.s,null!=n&&(n.step[r]=v,n.noise[r]=d),d=a[_++]=d/t[o++],d=ee.FAST_LOG10(Math.max(d,1e-20)),null!=n&&(n.noise_log[r]=d)}if(null!=n&&(n.global_gain=e.global_gain),c+=d,0a.max_noise-.2&&a.tot_noisea.max_noise-.2&&a.tot_noisea.max_noise-.1&&a.tot_noise+a.over_noisea.max_noise-.15&&a.tot_noise+a.over_noise+a.over_noiset.xrpow_max&&(t.xrpow_max=s[f+c]);if(2==i.noise_shaping_amp)return}}}(e,t,a,s,n);var i=_(t);return!i&&(!(i=2==r.mode_gr?w.scale_bitcount(t):w.scale_bitcount_lsf(r,t))||(1e.xrpow_max&&(e.xrpow_max=t[a+i])}e.scalefac[s]=r>>1}e.preflag=0,e.scalefac_scale=1}(t,s),i=!1):t.block_type==Pe.SHORT_TYPE&&0>t.scalefac_scale))n[s]=f,o+=3*l;else{n[s]=0;var c=210+(f<t.xrpow_max&&(t.xrpow_max=a[o+h]);o+=l*(3-r-1)}}var u=M.IPOW20(202);for(o+=t.width[s]*(r+1),h=-t.width[s];h<0;h++)a[o+h]*=u,a[o+h]>t.xrpow_max&&(t.xrpow_max=a[o+h])}}return!1}(r,t,s)||_(t))),i||(i=2==r.mode_gr?w.scale_bitcount(t):w.scale_bitcount_lsf(r,t)),!i))}this.setModules=function(e,t,a,s){v=e,g=t,this.rv=t,M=a,this.qupvt=a,w=s,n.setModules(M,w)},this.ms_convert=function(e,t){for(var a=0;a<576;++a){var s=e.tt[t][0].xr[a],n=e.tt[t][1].xr[a];e.tt[t][0].xr[a]=(s+n)*(.5*ee.SQRT2),e.tt[t][1].xr[a]=(s-n)*(.5*ee.SQRT2)}},this.init_xrpow=function(e,t,a){var s=0,n=0|t.max_nonzero_coeff;if(t.xrpow_max=0,ye.fill(a,n,576,0),1e-20<(s=function(e,t,a,s){for(var n=s=0;n<=a;++n){var r=Math.abs(e.xr[n]);s+=r,t[n]=Math.sqrt(r*Math.sqrt(r)),t[n]>e.xrpow_max&&(e.xrpow_max=t[n])}return s}(t,a,n,s))){var r=0;0!=(2&e.substep_shaping)&&(r=1);for(var i=0;iS&&_.global_gain<=g;)_.global_gain++;if(_.global_gain>g)break;if(0==f.over_count){for(;(_.part2_3_length=w.count_bits(i,s,_,c))>h&&_.global_gain<=g;)_.global_gain++;if(_.global_gain>g)break}if(M.calc_noise(_,a,l,d,c),d.bits=_.part2_3_length,0!=(A(t.block_type!=Pe.SHORT_TYPE?e.quant_comp:e.quant_comp_short,f,d,_,l)?1:0))h=t.part2_3_length,f=d,t.assign(_),b=0,$.arraycopy(s,0,o,0,576);else if(0==i.full_outer_loop){if(++b>v&&0==f.over_count)break;if(3==i.noise_shaping_amp&&m&&30r[f.VBR_max_bitrate]&&(_[p][v]*=r[f.VBR_max_bitrate],_[p][v]/=u),i[p][v]>_[p][v]&&(i[p][v]=_[p][v]);return h},this.bitpressure_strategy=function(e,t,a,s){for(var n=0;nZ.MAX_BITS_PER_CHANNEL&&(s[_][o]=Z.MAX_BITS_PER_CHANNEL),m+=s[_][o]}if(Z.MAX_BITS_PER_GRANULEZ.MAX_BITS_PER_CHANNEL&&(s[_][o]=Z.MAX_BITS_PER_CHANNEL),l+=s[_][o];if(l>r[0])for(_=0;_=s?(e.ATH.adjust*=.075*s+.925,e.ATH.adjust=s?e.ATH.adjust=s:e.ATH.adjust>1,u=(h=(c=s)<<1)+c,s=h<<1,r=(n=t)+m;M=e[n+0]-e[n+c],S=e[n+0]+e[n+c],B=e[n+h]-e[n+u],R=e[n+h]+e[n+u],e[n+h]=S-R,e[n+0]=S+R,e[n+u]=M-B,e[n+c]=M+B,M=e[r+0]-e[r+c],S=e[r+0]+e[r+c],B=ee.SQRT2*e[r+u],R=ee.SQRT2*e[r+h],e[r+h]=S-R,e[r+0]=S+R,e[r+u]=M-B,e[r+c]=M+B,r+=s,(n+=s)<_;);for(l=y[i+0],o=y[i+1],f=1;fO[u+3-2]?Q/=O[u+3-2]:Q=O[u+3-2]>10*Q?O[u+3-2]/(10*Q):0,N[u+3]=Q}if(e.analysis){var W=N[0];for(u=1;u<12;u++)WV&&(q[u/3]=u%3+1);for(u=1;u<4;u++){(C[u-1]>C[u]?C[u-1]/C[u]:C[u]/C[u-1])<1.7&&(q[u]=0,1==u&&(q[0]=0))}for(0!=q[0]&&0!=S.nsPsy.lastAttacks[c]&&(q[0]=0),3!=S.nsPsy.lastAttacks[c]&&q[0]+q[1]+q[2]+q[3]==0||((D=0)!=q[1]&&0!=q[0]&&(q[1]=0),0!=q[2]&&0!=q[1]&&(q[2]=0),0!=q[3]&&0!=q[2]&&(q[3]=0)),c<2?y[c]=D:0==D&&(y[0]=y[1]=0),o[c]=S.tot_ener[c],he(e,F,j,M,1&c,w,1&c,s,c,t,a),Me(S,F,R,Y,X),we(S,Y,X,x),v=0;v<3;v++){var J,$;for(ve(e,j,A,B,c,v),pe(S,A,B,c,v),b=0;b1.58*e.thm[1].l[t]||e.thm[1].l[t]>1.58*e.thm[0].l[t])){var a=e.mld_l[t]*e.en[3].l[t],s=Math.max(e.thm[2].l[t],Math.min(e.thm[3].l[t],a));a=e.mld_l[t]*e.en[2].l[t];var n=Math.max(e.thm[3].l[t],Math.min(e.thm[2].l[t],a));e.thm[2].l[t]=s,e.thm[3].l[t]=n}for(t=0;t1.58*e.thm[1].s[t][r]||e.thm[1].s[t][r]>1.58*e.thm[0].s[t][r]||(a=e.mld_s[t]*e.en[3].s[t][r],s=Math.max(e.thm[2].s[t][r],Math.min(e.thm[3].s[t][r],a)),a=e.mld_s[t]*e.en[2].s[t][r],n=Math.max(e.thm[3].s[t][r],Math.min(e.thm[2].s[t][r],a)),e.thm[2].s[t][r]=s,e.thm[3].s[t][r]=n)}(S),g=e.msfix,0g&&(s[o]=g),1a[o]&&(s[o]=a[o]),l.masking_lower<1&&(s[o]*=l.masking_lower)}for(;of&&(s[r]=f),1a[r]&&(s[r]=a[r]),e.masking_lower<1&&(s[r]*=e.masking_lower)}for(;rM[b+3-2]?E/=M[b+3-2]:E=M[b+3-2]>10*E?M[b+3-2]/(10*E):0,S[b+3]=E}for(b=0;b<3;++b){var P=M[3*b+3]+M[3*b+4]+M[3*b+5],I=1;6*M[3*b+5]B&&(o[m][b/3]=b%3+1);for(b=1;b<4;b++){var L=w[b-1],V=w[b];Math.max(L,V)<4e4&&L<1.7*V&&V<1.7*L&&(1==b&&o[m][0]<=o[m][b]&&(o[m][0]=0),o[m][b]=0)}o[m][0]<=c.nsPsy.lastAttacks[m]&&(o[m][0]=0),3!=c.nsPsy.lastAttacks[m]&&o[m][0]+o[m][1]+o[m][2]+o[m][3]==0||((k=0)!=o[m][1]&&0!=o[m][0]&&(o[m][1]=0),0!=o[m][2]&&0!=o[m][1]&&(o[m][2]=0),0!=o[m][3]&&0!=o[m][2]&&(o[m][3]=0)),m<2?l[m]=k:0==k&&(l[0]=l[1]=0),i[m]=c.tot_ener[m]}}(e,t,a,s,n,r,o,w,R,A),function(e,t){var a=e.internal_flags;e.short_blocks!=Te.short_block_coupled||0!=t[0]&&0!=t[1]||(t[0]=t[1]=0);for(var s=0;s=n&&(p=i*(l[t]-n)/(24-n)+r*(24-l[t])/(24-n)),c[t]=Math.pow(10,p/10),0=n&&(p=o*(l[t]-n)/(24-n)+_*(24-l[t])/(24-n)),c[t]=Math.pow(10,p/10),g=K.MAX_VALUE;for(v=0;va.npart_l-1&&(a.s3ind[M][1]=a.npart_l-1);var w=576*a.mode_gr/h;if(a.ATH.decay=Math.pow(10,-1.2*w),a.ATH.adjust=.01,-(a.ATH.adjustLimit=1)!=e.ATHtype){var R=e.out_samplerate/Pe.BLKSIZE,A=0;for(t=d=0;t=v)for(l=0;le.in_samplerate&&(e.lowpassfreq=e.in_samplerate/2),e.out_samplerate=(t=0|e.lowpassfreq,a=e.in_samplerate,s=44100,48e3<=a?s=48e3:44100<=a?s=44100:32e3<=a?s=32e3:24e3<=a?s=24e3:22050<=a?s=22050:16e3<=a?s=16e3:12e3<=a?s=12e3:11025<=a?s=11025:8e3<=a&&(s=8e3),-1==t?s:(t<=15960&&(s=44100),t<=15250&&(s=32e3),t<=11220&&(s=24e3),t<=9970&&(s=22050),t<=7230&&(s=16e3),t<=5420&&(s=12e3),t<=4510&&(s=11025),t<=3970&&(s=8e3),a=t.lowpass2&&(a=Math.min(a,r)),t.lowpass1t.highpass1?E((t.highpass2-l)/(t.highpass2-t.highpass1+1e-20)):1,o=t.lowpass2>t.lowpass1?E((l-t.lowpass1)/(t.lowpass2-t.lowpass1+1e-20)):1,t.amp_filter[r]=_*o}}(e),n.samplerate_index=P(e.out_samplerate,e),n.samplerate_index<0)return e.internal_flags=null,-1;if(e.VBR==xe.vbr_off){if(e.free_format)n.bitrate_index=0;else if(e.brate=I(e.brate,e.version,e.out_samplerate),n.bitrate_index=H(e.brate,e.version,e.out_samplerate),n.bitrate_index<=0)return e.internal_flags=null,-1}else n.bitrate_index=1;e.analysis&&(e.bWriteVbrTag=!1),null!=n.pinfo&&(e.bWriteVbrTag=!1),R.init_bit_stream_w(n);for(var c,h,u,m=n.samplerate_index+3*e.version+6*(e.out_samplerate<16e3?1:0),p=0;p=f){var M=i-u;if(0==i&&(M=0),(_=O(e,m[0],m[1],n,r,M))<0)return _;for(r+=_,u+=_,h.mf_size-=e.framesize,h.mf_samples_to_encode-=e.framesize,l=0;li&&(s.ResvMax=i),(s.ResvMax<0||e.disable_reservoir)&&(s.ResvMax=0);var _=t.bits*s.mode_gr+Math.min(s.ResvSize,s.ResvMax);return a<_&&(_=a),n.resvDrain_pre=0,null!=s.pinfo&&(s.pinfo.mean_bits=t.bits/2,s.pinfo.resvsize=s.ResvSize),_},this.ResvMaxBits=function(e,t,a,s){var n,r=e.internal_flags,i=r.ResvSize,_=r.ResvMax;0!=s&&(i+=t),0!=(1&r.substep_shaping)&&(_*=.9),a.bits=t,9*_<10*i?(n=i-9*_/10,a.bits+=n,r.substep_shaping|=128):(n=0,r.substep_shaping&=127,e.disable_reservoir||0!=(1&r.substep_shaping)||(a.bits-=.1*t));var o=i<6*r.ResvMax/10?i:6*r.ResvMax/10;return(o-=n)<0&&(o=0),o},this.ResvAdjust=function(e,t){e.ResvSize-=t.part2_3_length+t.part2_length},this.ResvFrameEnd=function(e,t){var a,s=e.l3_side;e.ResvSize+=t*e.mode_gr;var n=0;s.resvDrain_post=0,(s.resvDrain_pre=0)!=(a=e.ResvSize%8)&&(n+=a),0<(a=e.ResvSize-n-e.ResvMax)&&(n+=a);var r=Math.min(8*s.main_data_begin,n)/8;s.resvDrain_pre+=8*r,n-=8*r,e.ResvSize-=8*r,s.main_data_begin-=r,s.resvDrain_post+=n,e.ResvSize-=n}},m=new k,p=new function(){this.setModules=function(e,t,a){}},b=new function(){};n.setModules(r,i,_,o,l,f,c,h,b),i.setModules(r,b,c,f),h.setModules(i,c),_.setModules(n),l.setModules(i,u,o,m),o.setModules(m,u,n.enc.psy),u.setModules(i),m.setModules(o),f.setModules(n,i,c),a.setModules(p,b),p.setModules(c,h,_);var v=n.lame_init();v.num_channels=s,v.in_samplerate=e,v.out_samplerate=e,v.brate=t,v.mode=Ee.STEREO,v.quality=3,v.bWriteVbrTag=!1,v.disable_reservoir=!0,v.write_id3tag_automatic=!1,n.lame_init_params(v);var d=1152,g=0|1.25*d+7200,S=A(g);this.encodeBuffer=function(e,t){1==s&&(t=e),e.length>d&&(d=e.length,S=A(g=0|1.25*d+7200));var a=n.lame_encode_buffer(v,e,t,e.length,S,0,g);return new Int8Array(S.subarray(0,a))},this.flush=function(){var e=n.lame_encode_flush(v,S,0,g);return new Int8Array(S.subarray(0,e))}}}t(),Recorder.lamejs=t}(); \ No newline at end of file diff --git a/recorder.wav.min.js b/recorder.wav.min.js index b0d7de3..accac60 100644 --- a/recorder.wav.min.js +++ b/recorder.wav.min.js @@ -3,4 +3,4 @@ https://github.com/xiangyuecn/Recorder src: recorder-core.js,engine/wav.js */ -!function(k){"use strict";var m=function(){},F=function(e){return new t(e)};F.LM="2022-06-26 18:37";var I="Recorder";F.IsOpen=function(){var e=F.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},F.BufferSize=4096,F.Destroy=function(){for(var e in x(I+" Destroy"),d(),n)n[e]()};var n={};F.BindDestroy=function(e,t){n[e]=t},F.Support=function(){var e=k.AudioContext;if(e||(e=k.webkitAudioContext),!e)return!1;var t=navigator.mediaDevices||{};return t.getUserMedia||(t=navigator).getUserMedia||(t.getUserMedia=t.webkitGetUserMedia||t.mozGetUserMedia||t.msGetUserMedia),!!t.getUserMedia&&(F.Scope=t,F.Ctx&&"closed"!=F.Ctx.state||(F.Ctx=new e,F.BindDestroy("Ctx",function(){var e=F.Ctx;e&&e.close&&(e.close(),F.Ctx=0)})),!0)};var M="ConnectEnableWorklet";F[M]=!1;var h=function(e){var r=(e=e||F).BufferSize||F.BufferSize,a=F.Ctx,o=e.Stream,s=o._m=a.createMediaStreamSource(o),i=a.destination,t="createMediaStreamDestination";a[t]&&(i=a[t]());var f=o._call,c=function(e,t){if(!t||g)for(var n in f){for(var r=e.length,a=new Int16Array(r),o=0,s=0;s"+f,3);for(var u=0,l=o;l"+h.length+" 花:"+(Date.now()-r)+"ms"),setTimeout(function(){r=Date.now(),a[o.type](h,function(e){c(e,p)},function(e){i(e)})})}else i("未加载"+o.type+"编码器");else i("音频buffers被释放");else i("未采集到录音")}},k[I]&&(x("重复引入"+I,3),k[I].Destroy()),(k[I]=F).TrafficImgUrl="//ia.51.la/go1?id=20469973&pvFlag=1";var o=F.Traffic=function(e){e=e?"/"+I+"/Report/"+e:"";var t=F.TrafficImgUrl;if(t){var n=F.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 s=new Image;s.src=t,x("Traffic Analysis Image: "+(e||I+".TrafficImgUrl="+F.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,s=8==r.bitRate?8:16,i=a*(s/8),c=new ArrayBuffer(44+i),f=new DataView(c),u=0,l=function(e){for(var t=0;t>8);f.setInt8(u,h,!0)}else for(m=0;m"+f,3);for(var u=0,l=o;l"+m.length+" 花:"+(Date.now()-n)+"ms"),setTimeout(function(){n=Date.now(),a[o.type](m,function(e){u(e,g)},function(e){f(e)})})}else f("未加载"+o.type+"编码器");else f("音频buffers被释放");else f("未采集到录音")}},x[A]&&(F("重复引入"+A,3),x[A].Destroy()),x[A]=U;var O=function(e,t){t.pos||(t.pos=[0],t.tracks={},t.bytes=[]);var r=t.tracks,n=[t.pos[0]],a=function(){t.pos[0]=n[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(B(i,n),N(i,n),!z(B(i,n),[24,83,128,103]))return;for(B(i,n);n[0]=e.length)){var a=e[n],o=("0000000"+a.toString(2)).substr(-8),i=/^(0*1)(\d*)$/.exec(o);if(i){var s=i[1].length,c=[];if(!(n+s>e.length)){for(var f=0;fe.length)return;for(var i=0;i>8);f.setInt8(u,g,!0)}else for(h=0;h1300){ + //超时没有输入,干掉定时器 + clearInterval(This.timer); + This.timer=0; + } + } + ,draw:function(powerLevel){ var This=this,set=This.set; var ctx=This.ctx; var scale=set.scale; var width=set.width*scale; var height=set.height*scale; - var speedx=set.speed*pcmData.length/sampleRate; + var speedx=set.speed/set.fps; var phase=This._phase-=speedx;//位移速度 + var phase2=phase+speedx*set.phase; var amplitude=powerLevel/100; var path1=This.genPath(2,amplitude,phase); - var path2=This.genPath(1.8,amplitude,phase+speedx*5); + var path2=This.genPath(1.8,amplitude,phase2); //开始绘制图形 ctx.clearRect(0,0,width,height); @@ -150,7 +206,7 @@ fn.prototype=WaveView.prototype={ ctx.stroke(); } }; -Recorder.WaveView=WaveView; +Recorder[ViewTxt]=WaveView; })(); \ No newline at end of file diff --git a/src/package-build.js b/src/package-build.js index 27a8553..f280b28 100644 --- a/src/package-build.js +++ b/src/package-build.js @@ -233,6 +233,18 @@ function Run_npm(){ }); }); + + var writeDTS=function(path,val){ + fs.writeFileSync(npmFiles+path,val); + console.log("已生成"+npmFiles+path); + }; + var recDTS='declare let Recorder : any;\nexport default Recorder;'; + writeDTS("/index.d.ts", recDTS); + writeDTS("/recorder.mp3.min.d.ts", recDTS); + writeDTS("/recorder.wav.min.d.ts", recDTS); + writeDTS("/src/app-support/app.d.ts", 'declare let RecordApp : any;\nexport default RecordApp;'); + + //记录代码是否有变更 var sha1=sha1Obj.digest("hex"); var hashArr=JSON.parse(hashHistory||"[]"); diff --git a/src/recorder-core.js b/src/recorder-core.js index 94f20fb..35605b2 100644 --- a/src/recorder-core.js +++ b/src/recorder-core.js @@ -21,8 +21,11 @@ var NOOP=function(){}; var Recorder=function(set){ return new initFn(set); }; -Recorder.LM="2022-06-26 18:37"; +Recorder.LM="2022-08-06 20:51"; var RecTxt="Recorder"; +var getUserMediaTxt="getUserMedia"; +var srcSampleRateTxt="srcSampleRate"; +var sampleRateTxt="sampleRate"; //是否已经打开了全局的麦克风录音,所有工作都已经准备好了,就等接收音频数据了 @@ -68,11 +71,11 @@ Recorder.Support=function(){ return false; }; var scope=navigator.mediaDevices||{}; - if(!scope.getUserMedia){ + if(!scope[getUserMediaTxt]){ scope=navigator; - scope.getUserMedia||(scope.getUserMedia=scope.webkitGetUserMedia||scope.mozGetUserMedia||scope.msGetUserMedia); + scope[getUserMediaTxt]||(scope[getUserMediaTxt]=scope.webkitGetUserMedia||scope.mozGetUserMedia||scope.msGetUserMedia); }; - if(!scope.getUserMedia){ + if(!scope[getUserMediaTxt]){ return false; }; @@ -93,29 +96,33 @@ Recorder.Support=function(){ }; -/*是否启用AudioWorklet特性来进行音频采集连接(如果浏览器支持的话),默认禁用,禁用后将使用过时的ScriptProcessor来连接(如果方法还在的话),当前AudioWorklet的实现在移动端没有ScriptProcessor稳健*/ +/*是否启用MediaRecorder.WebM.PCM来进行音频采集连接(如果浏览器支持的话),默认启用,禁用或者不支持时将使用AudioWorklet或ScriptProcessor来连接;MediaRecorder采集到的音频数据比其他方式更好,几乎不存在丢帧现象,所以音质明显会好很多,建议保持开启*/ +var ConnectEnableWebM="ConnectEnableWebM"; +Recorder[ConnectEnableWebM]=true; + +/*是否启用AudioWorklet特性来进行音频采集连接(如果浏览器支持的话),默认禁用,禁用或不支持时将使用过时的ScriptProcessor来连接(如果方法还在的话),当前AudioWorklet的实现在移动端没有ScriptProcessor稳健;ConnectEnableWebM如果启用并且有效时,本参数将不起作用*/ var ConnectEnableWorklet="ConnectEnableWorklet"; Recorder[ConnectEnableWorklet]=false; /*初始化H5音频采集连接。如果自行提供了sourceStream将只进行一次简单的连接处理。如果是普通麦克风录音,此时的Stream是全局的,Safari上断开后就无法再次进行连接使用,表现为静音,因此使用全部使用全局处理避免调用到disconnect;全局处理也有利于屏蔽底层细节,start时无需再调用底层接口,提升兼容、可靠性。*/ -var Connect=function(streamStore){ - streamStore=streamStore||Recorder; +var Connect=function(streamStore,isUserMedia){ var bufferSize=streamStore.BufferSize||Recorder.BufferSize; var ctx=Recorder.Ctx,stream=streamStore.Stream; - var media=stream._m=ctx.createMediaStreamSource(stream); - var ctxDest=ctx.destination,cmsdTxt="createMediaStreamDestination"; - if(ctx[cmsdTxt]){ - ctxDest=ctx[cmsdTxt](); - }; + var mediaConn=function(node){ + var media=stream._m=ctx.createMediaStreamSource(stream); + var ctxDest=ctx.destination,cmsdTxt="createMediaStreamDestination"; + if(ctx[cmsdTxt]){ + ctxDest=ctx[cmsdTxt](); + }; + media.connect(node); + node.connect(ctxDest); + } + var isWebM,isWorklet,badInt,webMTips=""; var calls=stream._call; //浏览器回传的音频数据处理 - var onReceive=function(float32Arr,fromWorklet){ - if(fromWorklet && !isWorklet){ - CLog(audioWorklet+"多余回调",3); - return; - }; + var onReceive=function(float32Arr){ for(var k0 in calls){//has item var size=float32Arr.length; @@ -140,19 +147,21 @@ var Connect=function(streamStore){ var audioWorklet="audioWorklet"; var recAudioWorklet=RecTxt+" "+audioWorklet; var RecProc="RecProc"; - + var MediaRecorderTxt="MediaRecorder"; + var MRWebMPCM=MediaRecorderTxt+".WebM.PCM"; + + +//===================连接方式三========================= //古董级别的 ScriptProcessor 处理,目前所有浏览器均兼容,虽然是过时的方法,但更稳健,移动端性能比AudioWorklet强 var oldFn=ctx.createScriptProcessor||ctx.createJavaScriptNode; var oldIsBest="。由于"+audioWorklet+"内部1秒375次回调,在移动端可能会有性能问题导致回调丢失录音变短,PC端无影响,暂不建议开启"+audioWorklet+"。"; var oldScript=function(){ isWorklet=stream.isWorklet=false; _Disconn_n(stream); - CLog("Connect采用老的"+scriptProcessor+","+(Recorder[ConnectEnableWorklet]?"但已":"可")+"设置"+RecTxt+"."+ConnectEnableWorklet+"=true尝试启用"+audioWorklet+oldIsBest,3); + CLog("Connect采用老的"+scriptProcessor+","+(Recorder[ConnectEnableWorklet]?"但已":"可")+"设置"+RecTxt+"."+ConnectEnableWorklet+"=true尝试启用"+audioWorklet+webMTips+oldIsBest,3); var process=stream._p=oldFn.call(ctx,bufferSize,1,1);//单声道,省的数据处理复杂 - - media.connect(process); - process.connect(ctxDest); + mediaConn(process); var _DsetTxt="_D220626",_Dset=Recorder[_DsetTxt];if(_Dset)CLog("Use "+RecTxt+"."+_DsetTxt,3); process.onaudioprocess=function(e){ @@ -165,9 +174,15 @@ var Connect=function(streamStore){ }; }; }; - + + +//===================连接方式二========================= +var connWorklet=function(){ //尝试开启AudioWorklet处理 - var isWorklet=stream.isWorklet=!oldFn || Recorder[ConnectEnableWorklet]; + isWebM=stream.isWebM=false; + _Disconn_r(stream); + + isWorklet=stream.isWorklet=!oldFn || Recorder[ConnectEnableWorklet]; var AwNode=window.AudioWorkletNode; if(!(isWorklet && ctx[audioWorklet] && AwNode)){ oldScript();//被禁用 或 不支持,直接使用老的 @@ -227,7 +242,6 @@ var Connect=function(streamStore){ var awNext=function(){//可以继续,没有调用断开 return isWorklet && stream._na; }; - var badInt; var nodeAlive=stream._na=function(){ //start时会调用,只要没有收到数据就断定AudioWorklet有问题,恢复用老的 if(badInt!==""){//没有回调过数据 @@ -246,15 +260,18 @@ var Connect=function(streamStore){ var node=stream._n=new AwNode(ctx, RecProc, { processorOptions:{bufferSize:bufferSize} }); - media.connect(node); - node.connect(ctxDest);//老版本浏览器必须连接 + mediaConn(node); node.port.onmessage=function(e){ if(badInt){ clearTimeout(badInt);badInt=""; }; - onReceive(e.data.val,1); + if(awNext()){ + onReceive(e.data.val); + }else if(!isWorklet){ + CLog(audioWorklet+"多余回调",3); + }; }; - CLog("Connect采用"+audioWorklet+"方式,设置"+RecTxt+"."+ConnectEnableWorklet+"=false可恢复老式"+scriptProcessor+oldIsBest,3); + CLog("Connect采用"+audioWorklet+",设置"+RecTxt+"."+ConnectEnableWorklet+"=false可恢复老式"+scriptProcessor+webMTips+oldIsBest,3); }; //如果start时的resume和下面的构造node同时进行,将会导致部分浏览器崩溃,源码assets中 ztest_chrome_bug_AudioWorkletNode.html 可测试。所以,将所有代码套到resume里面(不管catch),避免出现这个问题 @@ -278,12 +295,74 @@ var Connect=function(streamStore){ }); }); }; -var ConnAlive=function(streamStore){ - var stream=(streamStore||Recorder).Stream; + + +//===================连接方式一========================= +var connWebM=function(){ + //尝试开启MediaRecorder录制webm+pcm处理 + var MR=window[MediaRecorderTxt]; + var onData="ondataavailable"; + var webmType="audio/webm; codecs=pcm"; + isWebM=stream.isWebM=Recorder[ConnectEnableWebM]; + + var supportMR=MR && (onData in MR.prototype) && MR.isTypeSupported(webmType); + webMTips=supportMR?"":"(此浏览器不支持"+MRWebMPCM+")"; + if(!isUserMedia || !isWebM || !supportMR){ + connWorklet(); //非麦克风录音(MediaRecorder采样率不可控) 或 被禁用 或 不支持MediaRecorder 或 不支持webm+pcm + return; + } - if(stream._na){//检查AudioWorklet连接是否有效,无效就回滚到老的ScriptProcessor - stream._na(); + var mrNext=function(){//可以继续,没有调用断开 + return isWebM && stream._ra; + }; + var mrAlive=stream._ra=function(){ + //start时会调用,只要没有收到数据就断定MediaRecorder有问题,降级处理 + if(badInt!==""){//没有回调过数据 + clearTimeout(badInt); + badInt=setTimeout(function(){ + //badInt=0; 保留给nodeAlive继续判断 + if(mrNext()){ + CLog(MediaRecorderTxt+"未返回任何音频,降级使用"+audioWorklet,3); + connWorklet(); + }; + },500); + }; + }; + + var mrSet=Object.assign({mimeType:webmType}, Recorder.ConnectWebMOptions); + var mr=stream._r=new MR(stream, mrSet); + var webmData=stream._rd={sampleRate:ctx[sampleRateTxt]}; + mr[onData]=function(e){ + //提取webm中的pcm数据,提取失败就等着badInt超时降级处理 + var reader=new FileReader(); + reader.onloadend=function(){ + if(mrNext()){ + var f32arr=WebM_Extract(new Uint8Array(reader.result),webmData); + if(!f32arr)return; + if(f32arr==-1){//无法提取,立即降级 + connWorklet(); + return; + }; + + if(badInt){ + clearTimeout(badInt);badInt=""; + }; + onReceive(f32arr); + }else if(!isWebM){ + CLog(MediaRecorderTxt+"多余回调",3); + }; + }; + reader.readAsArrayBuffer(e.data); }; + mr.start(~~(bufferSize/48));//按48k时的回调间隔 + CLog("Connect采用"+MRWebMPCM+",设置"+RecTxt+"."+ConnectEnableWebM+"=false可恢复使用"+audioWorklet+"或老式"+scriptProcessor); +}; + + connWebM(); +}; +var ConnAlive=function(stream){ + if(stream._na) stream._na(); //检查AudioWorklet连接是否有效,无效就回滚到老的ScriptProcessor + if(stream._ra) stream._ra(); //检查MediaRecorder连接是否有效,无效就降级处理 }; var _Disconn_n=function(stream){ stream._na=null; @@ -293,6 +372,13 @@ var _Disconn_n=function(stream){ stream._n=null; }; }; +var _Disconn_r=function(stream){ + stream._ra=null; + if(stream._r){ + stream._r.stop(); + stream._r=null; + }; +}; var Disconnect=function(streamStore){ streamStore=streamStore||Recorder; var isGlobal=streamStore==Recorder; @@ -308,6 +394,7 @@ var Disconnect=function(streamStore){ stream._p.onaudioprocess=stream._p=null; }; _Disconn_n(stream); + _Disconn_r(stream); if(isGlobal){//全局的时候,要把流关掉(麦克风),直接提供的流不处理 var tracks=stream.getTracks&&stream.getTracks()||stream.audioTracks||[]; @@ -660,7 +747,7 @@ Recorder.prototype=initFn.prototype={ if(Recorder.IsOpen()){ if(oldStream)This.CLog("发现同时多次调用open",1); - Connect(); + Connect(streamStore,1); ok(); }else{ failCall("录音功能无效:无音频流"); @@ -673,7 +760,21 @@ Recorder.prototype=initFn.prototype={ codeFail(code,"无法录音:"+code); }; - var pro=Recorder.Scope.getUserMedia({audio:This.set.audioTrackSet||true},f1,f2); + + var trackSet={ + noiseSuppression:false //默认禁用降噪,原声录制,免得移动端表现怪异(包括系统播放声音变小) + ,echoCancellation:false //回声消除 + }; + var trackSet2=This.set.audioTrackSet; + for(var k in trackSet2)trackSet[k]=trackSet2[k]; + trackSet.sampleRate=Recorder.Ctx.sampleRate;//必须指明采样率,不然手机上MediaRecorder采样率16k + + try{ + var pro=Recorder.Scope[getUserMediaTxt]({audio:trackSet},f1,f2); + }catch(e){//不能设置trackSet就算了 + This.CLog(getUserMediaTxt,3,e); + pro=Recorder.Scope[getUserMediaTxt]({audio:true},f1,f2); + }; if(pro&&pro.then){ pro.then(f1)[True&&"catch"](f2); //fix 关键字,保证catch压缩时保持字符串形式 }; @@ -714,7 +815,7 @@ Recorder.prototype=initFn.prototype={ This.mockEnvInfo=null; This.buffers=[pcmData]; This.recSize=pcmData.length; - This.srcSampleRate=pcmSampleRate; + This[srcSampleRateTxt]=pcmSampleRate; return This; } ,envCheck:function(envInfo){//平台环境下的可用性检查,任何时候都可以调用检查,返回errMsg:""正常,"失败原因" @@ -723,7 +824,7 @@ Recorder.prototype=initFn.prototype={ //检测CPU的数字字节序,TypedArray字节序是个迷,直接拒绝罕见的大端模式,因为找不到这种CPU进行测试 var tag="CPU_BE"; - if(!errMsg && !Recorder[tag] && !new Int8Array(new Int32Array([1]).buffer)[0]){ + if(!errMsg && !Recorder[tag] && window.Int8Array && !new Int8Array(new Int32Array([1]).buffer)[0]){ Traffic(tag); //如果开启了流量统计,这里将发送一个图片请求 errMsg="不支持"+tag+"架构"; }; @@ -754,8 +855,13 @@ Recorder.prototype=initFn.prototype={ This.envInFix=0;//补偿的总时间 This.envInFixTs=[];//补偿计数列表 - set.sampleRate=Math.min(sampleRate,set.sampleRate);//engineCtx需要提前确定最终的采样率 - This.srcSampleRate=sampleRate; + //engineCtx需要提前确定最终的采样率 + var setSr=set[sampleRateTxt]; + if(setSr>sampleRate){ + set[sampleRateTxt]=sampleRate; + }else{ setSr=0 } + This[srcSampleRateTxt]=sampleRate; + This.CLog(srcSampleRateTxt+": "+sampleRate+" set."+sampleRateTxt+": "+set[sampleRateTxt]+(setSr?" 忽略"+setSr:""), setSr?3:0); This.engineCtx=0; //此类型有边录边转码(Worker)支持 @@ -773,7 +879,7 @@ Recorder.prototype=initFn.prototype={ } ,envIn:function(pcm,sum){//和平台环境无关的pcm[Int16]输入 var This=this,set=This.set,engineCtx=This.engineCtx; - var bufferSampleRate=This.srcSampleRate; + var bufferSampleRate=This[srcSampleRateTxt]; var size=pcm.length; var powerLevel=Recorder.PowerLevel(sum,size); @@ -835,7 +941,7 @@ Recorder.prototype=initFn.prototype={ //此类型有边录边转码(Worker)支持,开启实时转码 if(engineCtx){ //转换成set的采样率 - var chunkInfo=Recorder.SampleData(buffers,bufferSampleRate,set.sampleRate,engineCtx.chunkInfo); + var chunkInfo=Recorder.SampleData(buffers,bufferSampleRate,set[sampleRateTxt],engineCtx.chunkInfo); engineCtx.chunkInfo=chunkInfo; sizeOld=engineCtx.pcmSize; @@ -846,7 +952,7 @@ Recorder.prototype=initFn.prototype={ buffers=engineCtx.pcmDatas; bufferFirstIdx=buffers.length; buffers.push(chunkInfo.data); - bufferSampleRate=chunkInfo.sampleRate; + bufferSampleRate=chunkInfo[sampleRateTxt]; }; var duration=Math.round(bufferSize/bufferSampleRate*1000); @@ -957,8 +1063,8 @@ Recorder.prototype=initFn.prototype={ This.CLog("开始录音"); This._stop(); - This.state=0;//0未录音 1录音中 2暂停 3等待ctx激活 - This.envStart(null,ctx.sampleRate); + This.state=3;//0未录音 1录音中 2暂停 3等待ctx激活 + This.envStart(null, ctx[sampleRateTxt]); //检查open过程中stop是否已经调用过 if(This._SO&&This._SO+1!=This._S){//上面调用过一次 _stop @@ -969,17 +1075,16 @@ Recorder.prototype=initFn.prototype={ This._SO=0; var end=function(){ - This.state=1; - This.resume(); + if(This.state==3){ + This.state=1; + This.resume(); + } }; if(ctx.state=="suspended"){ This.CLog("wait ctx resume..."); - This.state=3;//此状态下 不管其他切换动作对state的改变 ctx.resume().then(function(){ This.CLog("ctx resume"); - if(This.state==3){ - end(); - }; + end(); }); }else{ end(); @@ -1002,13 +1107,13 @@ Recorder.prototype=initFn.prototype={ This.CLog("resume"); This.envResume(); - var store=This._streamStore(); - store.Stream._call[This.id]=function(pcm,sum){ + var stream=This._streamStore().Stream; + stream._call[This.id]=function(pcm,sum){ if(This.state==1){ This.envIn(pcm,sum); }; }; - ConnAlive(store);//AudioWorklet只会在ctx激活后运行 + ConnAlive(stream);//AudioWorklet只会在ctx激活后运行 }; } @@ -1038,7 +1143,8 @@ Recorder.prototype=initFn.prototype={ */ ,stop:function(True,False,autoClose){ var This=this,set=This.set,t1; - This.CLog("stop 和start时差"+(This.envInLast?This.envInLast-This.envInFirst+"ms 补偿"+This.envInFix+"ms":"-")); + var envInMS=This.envInLast-This.envInFirst, envInLen=envInMS&&This.buffers.length; //可能未start + This.CLog("stop 和start时差"+(envInMS?envInMS+"ms 补偿"+This.envInFix+"ms"+" envIn:"+envInLen+" fps:"+(envInLen/envInMS*1000).toFixed(1):"-")); var end=function(){ This._stop();//彻底关掉engineCtx @@ -1096,7 +1202,7 @@ Recorder.prototype=initFn.prototype={ //此类型有边录边转码(Worker)支持 var engineCtx=This.engineCtx; if(This[set.type+"_complete"]&&engineCtx){ - var duration=Math.round(engineCtx.pcmSize/set.sampleRate*1000);//采用后的数据长度和buffers的长度可能微小的不一致,是采样率连续转换的精度问题 + var duration=Math.round(engineCtx.pcmSize/set[sampleRateTxt]*1000);//采用后的数据长度和buffers的长度可能微小的不一致,是采样率连续转换的精度问题 t1=Date.now(); This[set.type+"_complete"](engineCtx,function(blob){ @@ -1107,11 +1213,11 @@ Recorder.prototype=initFn.prototype={ //标准UI线程转码,调整采样率 t1=Date.now(); - var chunk=Recorder.SampleData(This.buffers,This.srcSampleRate,set.sampleRate); + var chunk=Recorder.SampleData(This.buffers,This[srcSampleRateTxt],set[sampleRateTxt]); - set.sampleRate=chunk.sampleRate; + set[sampleRateTxt]=chunk[sampleRateTxt]; var res=chunk.data; - var duration=Math.round(res.length/set.sampleRate*1000); + var duration=Math.round(res.length/set[sampleRateTxt]*1000); This.CLog("采样"+size+"->"+res.length+" 花:"+(Date.now()-t1)+"ms"); @@ -1135,6 +1241,193 @@ window[RecTxt]=Recorder; + +//=======从WebM字节流中提取pcm数据,提取成功返回Float32Array,失败返回null||-1===== +var WebM_Extract=function(inBytes, scope){ + if(!scope.pos){ + scope.pos=[0]; scope.tracks={}; scope.bytes=[]; + }; + var tracks=scope.tracks, position=[scope.pos[0]]; + var endPos=function(){ scope.pos[0]=position[0] }; + + var sBL=scope.bytes.length; + var bytes=new Uint8Array(sBL+inBytes.length); + bytes.set(scope.bytes); bytes.set(inBytes,sBL); + scope.bytes=bytes; + + //先读取文件头和Track信息 + if(!scope._ht){ + readMatroskaVInt(bytes, position);//EBML Header + readMatroskaBlock(bytes, position);//跳过EBML Header内容 + if(!BytesEq(readMatroskaVInt(bytes, position), [0x18,0x53,0x80,0x67])){ + return;//未识别到Segment + } + readMatroskaVInt(bytes, position);//跳过Segment长度值 + while(position[0]1){//多声道,提取一个声道 + var arr2=[]; + for(var i=0;i=arr.length)return; + var b0=arr[i],b2=("0000000"+b0.toString(2)).substr(-8); + var m=/^(0*1)(\d*)$/.exec(b2); + if(!m)return; + var len=m[1].length, val=[]; + if(i+len>arr.length)return; + for(var i2=0;i2arr.length)return; + for(var i2=0;i2