0;++y,--x){var C=_[0][y],O=_[1][y];_[0][y]=C+O,_[1][y]=C-O}for(y=0;y<3;y++)M[y]=p.nsPsy.last_en_subshort[v][y+6],A[y]=M[y]/p.nsPsy.last_en_subshort[v][y+4],k[0]+=M[y];for(y=0;y<9;y++){for(var P=R+64,I=1;RM[y+3-2]?I/=M[y+3-2]:I=M[y+3-2]>10*I?M[y+3-2]/(10*I):0,A[y+3]=I}for(y=0;y<3;++y){var L=M[3*y+3]+M[3*y+4]+M[3*y+5],H=1;6*M[3*y+5]B&&(f[v][y/3]=y%3+1);for(y=1;y<4;y++){var $=k[y-1],D=k[y];Math.max($,D)<4e4&&$<1.7*D&&D<1.7*$&&(1==y&&f[v][0]<=f[v][y]&&(f[v][0]=0),f[v][y]=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||(E=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]=E:0==E&&(u[0]=u[1]=0),l[v]=p.tot_ener[v]}}(e,t,n,r,s,l,u,A,M,k),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==M[R][B+1]){var I=0!=B?B-1:2,N=$(d.thm[R].s[C][I],P,.36);P=Math.min(P,N)}else if(1==M[R][B]){I=0!=B?B-1:2,N=$(d.thm[R].s[C][I],P,.6*_);P=Math.min(P,N)}else if(0!=B&&3==M[R][B-1]||0==B&&3==d.nsPsy.lastAttacks[R]){I=2!=B?B+1:0,N=$(d.thm[R].s[C][I],P,.6*_);P=Math.min(P,N)}P*=A[R][B],O[B]=P}for(B=0;B<3;B++)d.thm[R].s[C][B]=O[B]}}for(R=0;R1?(D=f,V=-2,Y=F.NORM_TYPE,p[0]!=F.SHORT_TYPE&&p[1]!=F.SHORT_TYPE||(Y=F.SHORT_TYPE),X=l[r][R-2]):(D=c,V=0,Y=p[R],X=s[r][R]),Y==F.SHORT_TYPE?D[V+R]=j(X,d.masking_lower):D[V+R]=q(X,d.masking_lower),e.analysis&&(d.pinfo.pe[r][R]=D[V+R])}return 0},this.psymodel_init=function(n){var r,a=n.internal_flags,s=!0,o=13,l=0,c=0,f=-8.25,u=-4.5,_=i(F.CBANDS),p=i(F.CBANDS),h=i(F.CBANDS),m=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,l=-1.75,c=-.0125,f=-8.25,u=-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 b=0;b=o&&(y=c*(_[r]-o)/(24-o)+l*(24-_[r])/(24-o)),h[r]=Math.pow(10,y/10),a.numlines_l[r]>0?a.rnumlines_l[r]=1/a.numlines_l[r]:a.rnumlines_l[r]=0}a.s3_ll=oe(a.s3ind,a.npart_l,_,p,h,s);var w;b=0;for(r=0;r(C*=a.numlines_l[r])&&(E=C)}a.ATH.cb_l[r]=E,(E=20*_[r]/10-20)>6&&(E=100),E<-15&&(E=-15),E-=8,a.minval_l[r]=Math.pow(10,E/10)*a.numlines_l[r]}for(a.npart_s=se(a.numlines_s,a.bo_s,a.bm_s,_,p,a.mld_s,a.PSY.bo_s_weight,m,F.BLKSIZE_s,a.scalefac_band.s,F.BLKSIZE_s/384,F.SBMAX_s),b=0,r=0;r=o&&(y=u*(_[r]-o)/(24-o)+f*(24-_[r])/(24-o)),h[r]=Math.pow(10,y/10),E=d.MAX_VALUE;for(R=0;R(C*=a.numlines_s[r])&&(E=C)}a.ATH.cb_s[r]=E,E=7*_[r]/12-7,_[r]>12&&(E*=1+3.1*Math.log(1+E)),_[r]<12&&(E*=1+2.3*Math.log(1-E)),E<-15&&(E=-15),E-=8,a.minval_s[r]=Math.pow(10,E/10)*a.numlines_s[r]}a.s3_ss=oe(a.s3ind_s,a.npart_s,_,p,h,s),S=Math.pow(10,(M+1)/16),x=Math.pow(10,(k+1)/16),A=Math.pow(10,T/10),e.init_fft(a),a.decay=Math.exp(-1*t/(.01*m/192)),w=3.5,0!=(2&n.exp_nspsytune)&&(w=1),Math.abs(n.msfix)>0&&(w=n.msfix),n.msfix=w;for(var O=0;Oa.npart_l-1&&(a.s3ind[O][1]=a.npart_l-1);var P=576*a.mode_gr/m;if(a.ATH.decay=Math.pow(10,-1.2*P),a.ATH.adjust=.01,a.ATH.adjustLimit=1,-1!=n.ATHtype){var I=n.out_samplerate/F.BLKSIZE,L=0;for(B=0,r=0;r=0;)a.ATH.eql_w[r]*=L}for(O=b=0;O1?0:e<=0?1:Math.cos(Math.PI/2*e)}function x(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 M(e,t,n){n<16e3&&(t=2);for(var r=k.bitrate_table[t][1],a=2;a<=14;a++)k.bitrate_table[t][a]>0&&Math.abs(k.bitrate_table[t][a]-e)0&&k.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 B(e){var t=F.BLKSIZE+e.framesize-F.FFTOFFSET;return t=Math.max(t,512+e.framesize-32)}function I(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 H(){this.num_used=0}function N(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 $(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]=N(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 A=0;for(f=0;f<=m;++f){var M=f+p-m/2;A+=(M<0?w[b+M]:a[s+M])*_.blackfilt[x][f]}t[n+u]=A}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,B=e.internal_flags;if(B.Class_ID=0,null==B.ATH&&(B.ATH=new E),null==B.PSY&&(B.PSY=new d),null==B.rgdata&&(B.rgdata=new P),B.channels_in=e.num_channels,1==B.channels_in&&(e.mode=m.MONO),B.channels_out=e.mode==m.MONO?1:2,B.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&&A.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*B.channels_out/(1e3*e.compression_ratio),B.samplerate_index=x(e.out_samplerate,e),e.free_format||(e.brate=M(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 C=16e3;switch(e.VBR){case v.vbr_off:R(I=new b,e.brate),C=I.lowerlimit;break;case v.vbr_abr:var I;R(I=new b,e.VBR_mean_bitrate_kbps),C=I.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 H=L[e.VBR_q],N=L[e.VBR_q+1],$=e.VBR_q_frac;C=linear_int(H,N,$)}else C=19500;break;default:L=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=e.VBR_q&&e.VBR_q<=9){H=L[e.VBR_q],N=L[e.VBR_q+1],$=e.VBR_q_frac;C=linear_int(H,N,$)}else C=19500}e.mode!=m.MONO||e.VBR!=v.vbr_off&&e.VBR!=v.vbr_abr||(C*=1.5),e.lowpassfreq=0|C}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*B.channels_out/(1e3*e.brate)),e.VBR==v.vbr_abr&&(e.compression_ratio=16*e.out_samplerate*B.channels_out/(1e3*e.VBR_mean_bitrate_kbps)),e.bWriteVbrTag||(e.findReplayGain=!1,e.decode_on_the_fly=!1,B.findPeakSample=!1),B.findReplayGain=e.findReplayGain,B.decode_on_the_fly=e.decode_on_the_fly,B.decode_on_the_fly&&(B.findPeakSample=!0),B.findReplayGain&&t.InitGainAnalysis(B.rgdata,e.out_samplerate)==y.INIT_GAIN_ANALYSIS_ERROR)return e.internal_flags=null,-6;switch(B.decode_on_the_fly&&!e.decode_only&&(null!=B.hip&&u.hip_decode_exit(B.hip),B.hip=u.hip_decode_init()),B.mode_gr=e.out_samplerate<=24e3?1:2,e.framesize=576*B.mode_gr,e.encoder_delay=F.ENCDELAY,B.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*B.channels_out/(1e3*e.VBR_mean_bitrate_kbps);break;default:e.compression_ratio=16*e.out_samplerate*B.channels_out/(1e3*e.brate)}if(e.mode==m.NOT_SET&&(e.mode=m.JOINT_STEREO),e.highpassfreq>0?(B.highpass1=2*e.highpassfreq,e.highpasswidth>=0?B.highpass2=2*(e.highpassfreq+e.highpasswidth):B.highpass2=2*e.highpassfreq,B.highpass1/=e.out_samplerate,B.highpass2/=e.out_samplerate):(B.highpass1=0,B.highpass2=0),e.lowpassfreq>0?(B.lowpass2=2*e.lowpassfreq,e.lowpasswidth>=0?(B.lowpass1=2*(e.lowpassfreq-e.lowpasswidth),B.lowpass1<0&&(B.lowpass1=0)):B.lowpass1=2*e.lowpassfreq,B.lowpass1/=e.out_samplerate,B.lowpass2/=e.out_samplerate):(B.lowpass1=0,B.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?S((t.highpass2-c)/(t.highpass2-t.highpass1+1e-20)):1,l=t.lowpass2>t.lowpass1?S((c-t.lowpass1)/(t.lowpass2-t.lowpass1+1e-20)):1,t.amp_filter[i]=o*l}}(e),B.samplerate_index=x(e.out_samplerate,e),B.samplerate_index<0)return e.internal_flags=null,-1;if(e.VBR==v.vbr_off){if(e.free_format)B.bitrate_index=0;else if(e.brate=M(e.brate,e.version,e.out_samplerate),B.bitrate_index=T(e.brate,e.version,e.out_samplerate),B.bitrate_index<=0)return e.internal_flags=null,-1}else B.bitrate_index=1;e.analysis&&(e.bWriteVbrTag=!1),null!=B.pinfo&&(e.bWriteVbrTag=!1),n.init_bit_stream_w(B);for(var D,j=B.samplerate_index+3*e.version+6*(e.out_samplerate<16e3?1:0),V=0;V5&&(e.quality=5),B.PSY.mask_adjust=e.maskingadjust,B.PSY.mask_adjust_short=e.maskingadjust_short,e.experimentalY?B.sfb21_extra=!1:B.sfb21_extra=e.out_samplerate>44e3,B.iteration_loop=new VBRNewIterationLoop(s);break;case v.vbr_rh:r.apply_preset(e,500-10*e.VBR_q,0),B.PSY.mask_adjust=e.maskingadjust,B.PSY.mask_adjust_short=e.maskingadjust_short,e.experimentalY?B.sfb21_extra=!1:B.sfb21_extra=e.out_samplerate>44e3,e.quality>6&&(e.quality=6),e.quality<0&&(e.quality=LAME_DEFAULT_QUALITY),B.iteration_loop=new VBROldIterationLoop(s);break;default:var X;B.sfb21_extra=!1,e.quality<0&&(e.quality=LAME_DEFAULT_QUALITY),(X=e.VBR)==v.vbr_off&&(e.VBR_mean_bitrate_kbps=e.brate),r.apply_preset(e,e.VBR_mean_bitrate_kbps,0),e.VBR=X,B.PSY.mask_adjust=e.maskingadjust,B.PSY.mask_adjust_short=e.maskingadjust_short,X==v.vbr_off?B.iteration_loop=new O(s):B.iteration_loop=new ABRIterationLoop(s)}if(e.VBR!=v.vbr_off){if(B.VBR_min_bitrate=1,B.VBR_max_bitrate=14,e.out_samplerate<16e3&&(B.VBR_max_bitrate=8),0!=e.VBR_min_bitrate_kbps&&(e.VBR_min_bitrate_kbps=M(e.VBR_min_bitrate_kbps,e.version,e.out_samplerate),B.VBR_min_bitrate=T(e.VBR_min_bitrate_kbps,e.version,e.out_samplerate),B.VBR_min_bitrate<0))return-1;if(0!=e.VBR_max_bitrate_kbps&&(e.VBR_max_bitrate_kbps=M(e.VBR_max_bitrate_kbps,e.version,e.out_samplerate),B.VBR_max_bitrate=T(e.VBR_max_bitrate_kbps,e.version,e.out_samplerate),B.VBR_max_bitrate<0))return-1;e.VBR_min_bitrate_kbps=k.bitrate_table[e.version][B.VBR_min_bitrate],e.VBR_max_bitrate_kbps=k.bitrate_table[e.version][B.VBR_max_bitrate],e.VBR_mean_bitrate_kbps=Math.min(k.bitrate_table[e.version][B.VBR_max_bitrate],e.VBR_mean_bitrate_kbps),e.VBR_mean_bitrate_kbps=Math.max(k.bitrate_table[e.version][B.VBR_min_bitrate],e.VBR_mean_bitrate_kbps)}return e.tune&&(B.PSY.mask_adjust+=e.tune_value_a,B.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?B.ATH.useAdjust=3:B.ATH.useAdjust=e.athaa_type,B.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),B.slot_lag=B.frac_SpF=0,e.VBR==v.vbr_off&&(B.slot_lag=B.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=B(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(f.Class_ID!=w)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(h.Class_ID!=w)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,A.NEQ(e.scale,0)&&A.NEQ(e.scale,1))for(f=0;f0;){var g,S,x=[null,null];x[0]=m[0],x[1]=m[1];var M=new L;if(D(e,v,x,b,i,M),g=M.n_in,S=M.n_out,h.findReplayGain&&!h.decode_on_the_fly&&t.AnalyzeSamples(h.rgdata,v[0],h.mf_size,v[1],h.mf_size,S,h.channels_out)==y.GAIN_ANALYSIS_ERROR)return-6;if(i-=g,b+=g,h.channels_out,h.mf_size+=S,h.mf_samples_to_encode<1&&(h.mf_samples_to_encode=F.ENCDELAY+F.POSTDELAY),h.mf_samples_to_encode+=S,h.mf_size>=_){var k=l-d;if(0==l&&(k=0),(c=I(e,v[0],v[1],s,o,k))<0)return c;for(o+=c,d+=c,h.mf_size-=e.framesize,h.mf_samples_to_encode-=e.framesize,u=0;uT&&(T=t.length,B=n(R=0|1.25*T+7200));var i=a.lame_encode_buffer(k,t,r,t.length,B,0,R);return new Int8Array(B.subarray(0,i))},this.flush=function(){var e=a.lame_encode_flush(k,B,0,R);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: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.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",[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",[n("button",{staticClass:"mainBtn ctrlBtn",on:{click:e.recOpen}},[e._v("打开录音,请求权限")]),e._v(" "),n("button",{staticClass:"mainBtn ctrlBtn",on:{click:e.recStart}},[e._v("开始录音")]),e._v(" "),n("button",{staticClass:"mainBtn ctrlBtn",on:{click:e.recStop}},[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(e){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};!function(e){var t=function(){},n=function(e){return new i(e)};n.IsOpen=function(){var e=n.Stream;if(e){var t=(e.getTracks&&e.getTracks()||e.audioTracks||[])[0];if(t){var r=t.readyState;return"live"==r||r==t.LIVE}}return!1},n.BufferSize=4096,n.Destroy=function(){for(var e in console.log("Recorder Destroy"),r)r[e]()};var r={};n.BindDestroy=function(e,t){r[e]=t},n.Support=function(){var t=e.AudioContext;if(t||(t=e.webkitAudioContext),!t)return!1;var r=navigator.mediaDevices||{};return r.getUserMedia||(r=navigator).getUserMedia||(r.getUserMedia=r.webkitGetUserMedia||r.mozGetUserMedia||r.msGetUserMedia),!!r.getUserMedia&&(n.Scope=r,n.Ctx&&"closed"!=n.Ctx.state||(n.Ctx=new t,n.BindDestroy("Ctx",(function(){var e=n.Ctx;e&&e.close&&e.close()}))),!0)},n.SampleData=function(e,t,n,r,a){r||(r={});var i=r.index||0,s=r.offset||0,o=r.frameNext||[];a||(a={});var l=a.frameSize||1;a.frameType&&(l="mp3"==a.frameType?1152:1);for(var c=0,f=i;f1?c=Math.floor(c/u):(u=1,n=t),c+=o.length;var _=new Int16Array(c),p=0;for(f=0;f0){var w=2*(_.length-y);o=new Int16Array(_.buffer.slice(w)),_=new Int16Array(_.buffer.slice(0,w))}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 a=0;function i(e){this.id=++a,n.Traffic&&n.Traffic();var r={type:"mp3",bitRate:16,sampleRate:16e3,onProcess:t};for(var i in e)r[i]=e[i];this.set=r,this._S=9}n.Sync={O:9,C:9},n.prototype=i.prototype={open:function(r,a){var i=this;r=r||t,a=a||t;var s=function(){r(),i._SO=0},o=function(t,n){/Permission|Allow/i.test(t)?a("用户拒绝了录音权限",!0):!1===e.isSecureContext?a("无权录音(需https)"):/Found/i.test(t)?a(n+",无可用麦克风"):a(n)},l=n.Sync,c=++l.O,f=l.C;i._O=i._O_=c,i._SO=i._S;var u=function(){if(f!=l.C||!i._O){var e="open被取消";return c==l.O?i.close():e="open被中断",a(e),!0}};if(n.IsOpen())s();else if(n.Support()){var _=i.envCheck({envName:"H5",canProcess:!0});if(_)a("不能录音:"+_);else{var p=function(e){n.Stream=e,e._call={},u()||setTimeout((function(){u()||(n.IsOpen()?(function(){var e=n.Ctx,t=n.Stream,r=t._m=e.createMediaStreamSource(t),a=t._p=(e.createScriptProcessor||e.createJavaScriptNode).call(e,n.BufferSize,1,1);r.connect(a),a.connect(e.destination);var i=t._call;a.onaudioprocess=function(e){for(var t in i){for(var n=e.inputBuffer.getChannelData(0),r=n.length,a=new Int16Array(r),s=0,o=0;o3e3){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(console.warn("["+p+"]"+(x?"":"未")+"补偿"+S+"ms"),r.envInFix+=S,x){var k=new Int16Array(S*s/1e3);o+=k.length,c.push(k)}}}var A=r.recSize,M=o,T=A+M;if(r.recSize=T,i){var R=n.SampleData(c,s,a.sampleRate,i.chunkInfo);i.chunkInfo=R,T=(A=i.pcmSize)+(M=R.data.length),i.pcmSize=T,c=i.pcmDatas,f=c.length,c.push(R.data),s=R.sampleRate}var B=Math.round(T/s*1e3),E=c.length,C=u.length,O=function(){for(var e=P?0:-M,t=null==c[0],n=f;n"+d.length+" 花:"+(Date.now()-a)+"ms"),setTimeout((function(){a=Date.now(),i[s.type](d,(function(e){c(e,p)}),(function(e){l(e)}))}))}else l("未加载"+s.type+"编码器");else l("音频被释放");else l("未采集到录音")}},e.Recorder&&e.Recorder.Destroy(),e.Recorder=n,n.LM="2020-5-17 08:21:54",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,console.log("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(8)(e))},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=s(n(5));n(9),n(10),n(11);var a=s(n(12)),i=s(n(16));function s(e){return e&&e.__esModule?e:{default:e}}var o=new a.default({el:".rootView",data:{Rec:r.default},components:{MainView:i.default},template:'\n\n \n \n
Recorder vue+webpack测试\n
GitHub >>\n
\n \n\n \n \n
\n \n
源码修改后测试方法:\n
\n> cnpm install\n> npm run build-dev\n
\n 然后就可以打开index.html查看效果了。
\n
\n \n\n '}),l=o.$refs.mainView;l.reclog('绿油油的一大片,真有食欲'+unescape("%uD83D%uDE02")+' 当前浏览器支持录音':'red">不支持录音')+"");var c=function(e,t){l.reclog(''+e+": "+t+"")};c("Vue",a.default.version),c("UA",navigator.userAgent),c("URL",location.href.replace(/#.*/g,"")),l.reclog("点击打开录音,然后再点击开始录音",2),window.vue_root=o,window.vue_main=l,console.log("Vue",a.default),console.log("Recorder",r.default)},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";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>L.IXMAX_VAL)return r.bits=L.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 L.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 H,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]=L.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==L.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 T(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 R(){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 R))<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 T(e){this.bits=e}function R(){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 O(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 T(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+=R=f[o]*f[o],S+=R0);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 R,B;M+=R=f[o]*f[o],S+=R0);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 R;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 R,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 R,T=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&&(T=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<=T;)h.global_gain++;if(h.global_gain>T)break;if(0==b.over_count){for(;(h.part2_3_length=r.count_bits(p,o,h,g))>y&&h.global_gain<=T;)h.global_gain++;if(h.global_gain>T)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 H,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 T(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 T(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 T(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(L=p,N=286,1==e.mode_gr)for(var ne=0;ne<18;ne++)_.arraycopy(e.sb_sample[H][1][ne],0,e.sb_sample[H][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,T=[null,null],R=u.internal_flags,B=o([2,4]),E=[.5,.5],C=[[0,0],[0,0]],O=[[0,0],[0,0]];if(T[0]=p,T[1]=h,0==R.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+_],T=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-T,e[i+_]=x+T,x=e[s+0]-e[s+_],S=e[s+0]+e[s+_],T=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-T,e[s+_]=x+T,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 R=[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?R[a]*(10*t):R[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 O(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 I=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function L(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 H(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,R,E,L,N,H,$,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),H=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),O(D,ce,q,se,oe),P(D,se,oe,Z),N=0;N<3;N++){var be,ge;for(M(e,fe,Y,X,y,N),k(D,Y,X,y,N),L=0;L=2||1==le[N+1]){var ye=0!=N?N-1:2;ve=T(D.thm[y].s[L][ye],ge,.6*H);ge=Math.min(ge,ve)}if(1==le[N]){ye=0!=N?N-1:2,ve=T(D.thm[y].s[L][ye],ge,.3*H);ge=Math.min(ge,ve)}else if(0!=N&&3==le[N-1]||0==N&&3==D.nsPsy.lastAttacks[y]){ye=2!=N?N+1:0,ve=T(D.thm[y].s[L][ye],ge,.3*H);ge=Math.min(ge,ve)}be=ne[3*N+3]+ne[3*N+4]+ne[3*N+5],6*ne[3*N+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,Te=-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,Te=0,Ae=b[y],Me=l[r][y]),Ae==F.SHORT_TYPE?ke[Te+y]=B(Me,D.masking_lower):ke[Te+y]=C(Me,D.masking_lower),e.analysis&&(D.pinfo.pe[r][y]=ke[Te+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 T=v*A;l[w]=(T-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 R=0;R