PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  lY@svdZddgZddlmZeddZddZddZgZd d Zej ed d Z ej e d dZ ej e ddZ ej e ddZ ej e ddZej eddZej eddZej eddZddZddZdd Zd!d"Zd#d$Zed%krred&S)'aRoutines to help recognizing sound files. Function whathdr() recognizes various types of sound file headers. It understands almost all headers that SOX can decode. The return tuple contains the following items, in this order: - file type (as SOX understands it) - sampling rate (0 if unknown or hard to decode) - number of channels (0 if unknown or hard to decode) - number of frames in the file (-1 if unknown or hard to decode) - number of bits/sample, or 'U' for U-LAW, or 'A' for A-LAW If the file doesn't have a recognizable type, it returns None. If the file can't be opened, OSError is raised. To compute the total time, divide the number of frames by the sampling rate (a frame contains a sample for each channel). Function what() calls whathdr(). (It used to also use some heuristics for raw data, but this doesn't work very well.) Finally, the function test() is a simple main program that calls what() for all files mentioned on the argument list. For directory arguments it calls what() for all files in that directory. Default argument is "." (testing all files in the current directory). The option -r tells it to recurse down directories found inside explicitly given directories. whatwhathdr) namedtuple SndHeadersz.filetype framerate nchannels nframes sampwidthcCst|}|S)zGuess the type of a sound file.)r)filenameresr%/opt/python35/lib/python3.5/sndhdr.pyr(s c Cs`t|dJ}|jd}x-tD]%}|||}|r(t|Sq(WdSWdQRXdS)zRecognize sound headers.rbiN)openreadtestsr)rfhZtfrrrr r.s cCsddl}|jdsdS|dddkr>d}n#|dddkr]d}ndS|jdy|j|d }Wnt|jfk rdSYnX||j|j|jd|j fS) NrsFORM sAIFCaifcsAIFFZaiffr) r startswithseekr EOFErrorError getframerate getnchannels getnframes getsampwidth)rrrfmtarrr test_aifc?s     rc Cs6|jdrt}n#|dddkr7t}ndSd}||dd}||dd}||dd}||dd }||d d }d } |d krd } n6|d krd} n!|dkrd} d } nd} | |} | r|| } nd} |||| | fS)Ns.sndds.dns.ZaurrU?)r r!)r get_long_be get_long_le) rrfuncZfiletypeZhdr_sizeZ data_sizeencodingrateZ nchannelsZ sample_sizeZ sample_bits frame_sizeZnframerrr test_auTs2          r1cCsr|dddks,|dddkr0dSt|dd}|rYd |}nd }d |d dd fS)NAEsFSSDsHCOMi"VrZhcomr%rr*)r+)rrZdivisorr/rrr test_hcomus, r8cCs|jdsdSt|dd}d}d|koFdknr||dkrd||d}|rtd |}d |dd d fS) NsCreative Voice Filer#rir%rg.AZvocrr*)r get_short_leint)rrZsbseekr/Zratecoderrr test_vocs,r=cCsddl}|jd sH|dddksH|dddkrLdS|jdy|j|d}Wnt|jfk rdSYnXd |j|j|jd|j fS) NrsRIFFrrsWAVEr"sfmt rZwav) waverrZopenfprrrrrr)rrr>wrrr test_wavs <  r@cCs.|jd s&|dddkr*dSdS) NsFORMrrs8SVX8svxrr%)rArr%rr)r)rrrrr test_8svxs&rBcCsR|jdrNt|dd}t|dd}d|d|dfSdS)NsSOUNDrrr#r9Zsndtr%)rr,r;)rrZnsamplesr/rrr test_sndtsrCcCsX|jdrTt|dd}d|ko<dknrTd|dd dfSdS) Nsr'riiaZsndrr%rr*)rr;)rrr/rrr test_sndrsrDcCs,|dd>|dd>B|dd>B|dBS)Nrr$r%r"r'rr(r)brrr r+sr+cCs,|dd>|dd>B|dd>B|dBS)Nr(r$r'r"r%rrr)rErrr r,sr,cCs|dd>|dBS)Nrrr%r)rErrr get_short_besrFcCs|dd>|dBS)Nr%rrr)rErrr r;sr;c Csddl}d}|jddrN|jddkrN|jdd=d}yJ|jddrt|jdd|dntdg|dWn/tk r|jjd|jdYnXdS)Nrr%z-rr'.z [Interrupted] )sysargvtestallKeyboardInterruptstderrwriteexit)rH recursiverrr tests &  rPc Csddl}ddl}x|D]}|jj|rt|ddd|sW|rtdddl}|j|jj|d}t||dqtdqt|ddd|jj ytt |Wqt k rtd YqXqWdS) Nrz/:end zrecursing down:*z*** directory (use -r) ***:z*** not found ***) rHospathisdirprintglobjoinrJstdoutflushrOSError)listrOZtoplevelrHrUrrYnamesrrr rJs"         rJ__main__N)__doc____all__ collectionsrrrrr rappendr1r8r=r@rBrCrDr+r,rFr;rPrJ__name__rrrr s>