Your IP : 18.188.86.189
�
��fKc@sZdZddgZdd�Zdd�ZgZdd�Zeje�dd�Zeje�d d
�Zeje�dd�Z eje �d
d�Z
eje
�dd�Zeje�dd�Zeje�dd�Z
eje
�dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zed!krVe�nd"S(#u�Routines 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, IOError 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.
uwhatuwhathdrcCst|�}|S(uGuess the type of a sound file.(uwhathdr(ufilenameures((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyuwhat#scCsYt|d��D}|jd�}x'tD]}|||�}|r(|Sq(WdSWdQXdS(uRecognize sound headers.urbiN(uopenureadutestsuNone(ufilenameufuhutfures((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyuwhathdr)s
cCs�ddl}|jd�sdS|dd�dkr>d}n#|dd�dkr]d}ndS|jd�y|j|d �}Wnt|jfk
r�dSYnX||j�|j�|j �d|j
�fS(
NisFORMiisAIFCuaifcsAIFFuaiffur(uaifcu
startswithuNoneuseekuopenuEOFErroruErrorugetframerateugetnchannelsu
getnframesugetsampwidth(uhufuaifcufmtua((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyu test_aifc:s
u test_aifcc
Cs6|jd�rt}n#|dd�dkr7t}ndSd}||dd��}||dd��}||dd��}||dd ��}||d d
��}d} |dkr�d}
n6|d
kr�d}
n!|dkr�d}
d
} nd}
| |}|r||}nd}|||||
fS(Ns.sndisds.sdns.uauiiiiiiuUiiu?(sds.sdns.i����(u
startswithuget_long_beuget_long_leuNone(
uhufufuncufiletypeuhdr_sizeu data_sizeuencodingurateu nchannelsusample_sizeusample_bitsu
frame_sizeunframe((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyutest_auOs2
utest_aucCsr|dd�dks,|dd�dkr0dSt|dd��}|rYd |}nd
}d|ddd
fS(NiAiEsFSSDi�i�sHCOMi�i�i"Viuhcomiii����(uNoneuget_long_be(uhufudivisorurate((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyu test_hcomps,
u test_hcomcCs�|jd�sdSt|dd��}d}d|koFdknr�||dkr�d||d}|r�td |�}q�nd
|dddfS(
NsCreative Voice Fileiiii�iiig��.Auvocii����(u
startswithuNoneuget_short_leuint(uhufusbseekurateuratecode((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyutest_voc}s,utest_voccCs�|jd�s<|dd�dks<|dd�dkr@dSt|dd��}t|dd ��}t|d d
��}t|dd��}d
||d|fS(NsRIFFiisWAVEisfmt iiiii"i$uwavii����(u
startswithuNoneuget_short_leuget_long_le(uhufustyleu nchannelsurateusample_bits((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyutest_wav�s<utest_wavcCs.|jd�s&|dd�dkr*dSdS( NsFORMiis8SVXu8svxii(u8svxiiii(u
startswithuNone(uhuf((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyu test_8svx�s&u test_8svxcCsR|jd�rNt|dd��}t|dd��}d|d|dfSdS(NsSOUNDiiiiusndti(u
startswithuget_long_leuget_short_le(uhufunsamplesurate((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyu test_sndt�su test_sndtcCs[|jd�rWt|dd��}d|ko<dknrWd|dd dfSndS(
Nsiii�i�ausndriii����(u
startswithuget_short_le(uhufurate((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyu test_sndr�su test_sndrcCs,|dd>|dd>B|dd>B|dBS(Niiiiiii((ub((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyuget_long_be�suget_long_becCs,|dd>|dd>B|dd>B|dBS(Niiiiiii((ub((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyuget_long_le�suget_long_lecCs|dd>|dBS(Niii((ub((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyuget_short_be�suget_short_becCs|dd>|dBS(Niii((ub((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyuget_short_le�suget_short_lecCs�ddl}d}|jdd�rQ|jddkrQ|jdd�=d}nyJ|jdd�r�t|jdd�|d�ntdg|d�Wn/tk
r�|jjd�|jd�YnXdS(Niiu-riu.u
[Interrupted]
(usysuargvutestalluKeyboardInterruptustderruwriteuexit(usysu recursive((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyutest�s&
utestcCsddl}ddl}x�|D]�}|jj|�r�t|ddd�|sW|r�td�ddl}|j|jj|d��}t||d�q�td�qt|ddd�|jj �ytt
|��Wqtk
r�td �YqXqWdS(
Niu/:uendu urecursing down:u*u*** directory (use -r) ***u:u*** not found ***(usysuosupathuisdiruprintuglobujoinutestallustdoutuflushuwhatuIOError(ulistu recursiveutoplevelusysuosufilenameuglobunames((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyutestall�s"
utestallu__main__N(u__doc__u__all__uwhatuwhathdrutestsu test_aifcuappendutest_auu test_hcomutest_vocutest_wavu test_8svxu test_sndtu test_sndruget_long_beuget_long_leuget_short_beuget_short_leutestutestallu__name__(((u+/opt/alt/python33/lib64/python3.3/sndhdr.pyu<module>s8
?>