B P|@s.ddgZddlmZeddZdej_dej_dej_d ej_d ej _d dZ d dZ gZ d dZ e e ddZe eddZe eddZe eddZe eddZe eddZe eddZe eddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zed)kr*ed*S)+whatwhathdr) namedtuple SndHeadersz.filetype framerate nchannels nframes sampwidthzThe value for type indicates the data type and will be one of the strings 'aifc', 'aiff', 'au','hcom', 'sndr', 'sndt', 'voc', 'wav', '8svx', 'sb', 'ub', or 'ul'.zYThe sampling_rate will be either the actual value or 0 if unknown or difficult to decode.z^The number of channels or 0 if it cannot be determined or if the value is difficult to decode.z?The value for frames will be either the number of frames or -1.zAEither the sample size in bits or 'A' for A-LAW or 'U' for u-LAW.cCs t|}|S)N)r)filenameresr)/opt/alt/python37/lib/python3.7/sndhdr.pyr4sc CsHt|d4}|d}x"tD]}|||}|rt|SqWdSQRXdS)Nrbi)openreadtestsr)rfhZtfrrrr r:s     c Csddl}|dsdS|dddkr,d}n|dddkrBd}ndS|dy||d }Wnt|jfk rzdSX||||d| fS) NrsFORM sAIFCaifcsAIFFZaiffr) r startswithseekr EOFErrorError getframerate getnchannels getnframes getsampwidth)rrrZfmtarrr test_aifcKs  rc Cs|drt}n|dddkr&t}ndSd}||dd}||dd}||dd}||dd}||dd }d } |d krd } n$|d krd} n|d krd} d } nd} | |} | r|| } nd} |||| | fS)Ns.snd)sds.sdns.ZaurrU?)r get_long_be get_long_le) rrfuncfiletypeZhdr_sizeZ data_sizeencodingrate nchannelsZ sample_sizeZ sample_bitsZ frame_sizeZnframerrr test_au`s2  r/cCsT|dddks |dddkr$dSt|dd}|rBd |}nd }d |d d dfS)NAEsFSSDsHCOMi"VrZhcomr"r'r)r()rrZdivisorr-rrr test_hcoms  r6cCst|dsdSt|dd}d}d|kr6dkrfnn,||dkrfd||d}|rftd |}d |dd d fS) NsCreative Voice Filer rir"rg.AZvocr'r)r get_short_leint)rrZsbseekr-Zratecoderrr test_vocs $ r;c Csddl}|dr2|dddks2|dddkr6dS|dy||d}Wnt|jfk rjdSXd |||d| fS) NrsRIFFrrsWAVErsfmt rZwav) waverrr rrrrrr)rrr<wrrr test_wavs* r>cCs"|dr|dddkrdSdS)NsFORMrrs8SVX)Z8svxrr"rr)r)rrrrr test_8svxsr?cCs<|dr8t|dd}t|dd}d|d|dfSdS)NsSOUNDrrr r7Zsndtr")rr)r9)rrZnsamplesr-rrr test_sndts r@cCsD|dr@t|dd}d|kr.dkr@nnd|ddd fSdS) Nsr$riiaZsndrr"r'r)rr9)rrr-rrr test_sndrs rAcCs,|dd>|dd>B|dd>B|dBS)Nrr!r"rr$rr%r)brrr r(sr(cCs,|dd>|dd>B|dd>B|dBS)Nr%r!r$rr"rrr)rBrrr r)sr)cCs|dd>|dBS)Nrrr"r)rBrrr get_short_besrCcCs|dd>|dBS)Nr"rrr)rBrrr r9sr9cCsddl}d}|jddr8|jddkr8|jdd=d}y8|jddr`t|jdd|dntdg|dWn*tk r|jd|dYnXdS)Nrr"z-rr$.z [Interrupted] )sysargvtestallKeyboardInterruptstderrwriteexit)rE recursiverrr tests  rMc Csddl}ddl}x|D]}|j|rzt|ddd|s>|rptdddl}||j|d}t||dqtdqt|ddd|j ytt |Wqt k rtd YqXqWdS) Nrz/: )endzrecursing down:*z*** directory (use -r) ***:z*** not found ***) rEospathisdirprintglobjoinrGstdoutflushrOSError)listrLZtoplevelrErRrrVnamesrrr rGs"    rG__main__N)__all__ collectionsrrr+__doc__Z framerater.ZnframesZ sampwidthrrr rappendr/r6r;r>r?r@rAr(r)rCr9rMrG__name__rrrr !sF