AlkantarClanX12

Your IP : 3.144.42.233


Current Path : /opt/alt/python312/lib64/python3.12/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/__pycache__/sndhdr.cpython-312.opt-1.pyc

�

�Q�f���dZddlZejed��ddgZddlmZedd	�Zd
ej_dej_dej_d
ej_dej_d�Z
d�ZgZd�Zej#e�d�Zej#e�d�Zej#e�d�Zej#e�d�Zej#e�d�Zej#e�d�Zej#e�d�Zej#e�d�Zd�Zd�Zd�Zd�Zd�Zedk(re�yy) a�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, 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.
�N)��
)�remove�what�whathdr)�
namedtuple�
SndHeadersz.filetype framerate nchannels nframes sampwidthz�The 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.c��t|�}|S)zGuess the type of a sound file.)r)�filename�ress  �-/opt/alt/python312/lib64/python3.12/sndhdr.pyrr8s��
�(�
�C��J�c��t|d�5}|jd�}tD] }|||�}|s�t|�ccddd�S	ddd�y#1swYyxYw)zRecognize sound headers.�rbiN)�open�read�testsr	)r�f�h�tfrs     r
rr>s\��	
�h��	��
�F�F�3�K���B��Q��(�C��!�3�'�'�����
��	�	�s�&A�	A�A�Ac���tj�5tjdt��ddl}ddd�|jd�sy|dddk(rd	}n|ddd
k(rd}ny|j
d�	j|d�}||j�|j�|j�d|j�zfS#1swY��xYw#tjf$rYywxYw)
zAIFC and AIFF files�ignore)�categoryrN�FORM��sAIFC�aifcsAIFF�aiff�r)�warnings�catch_warnings�simplefilter�DeprecationWarningr�
startswith�seekr�EOFError�Error�getframerate�getnchannels�
getnframes�getsampwidth)rrr�fmt�as     r
�	test_aifcr.Os���	�	 �	 �	"����h�1C�D��
#�
�<�<�� ����2�w�'����	
�1�R��G�	�����F�F�1�I���I�I�a����
����!�1�>�>�#3�
�L�L�N�A���� 0�0�2�2�!
#�	"��
�d�j�j�!����s� C�8C�C�C0�/C0c�*�|jd�rt}n|dddvrt}nyd}||dd�}||dd�}||dd�}||dd	�}||d	d
�}d}	|dk(rd}
n|d
k(rd}
n|dk(rd}
d
}	nd}
|	|z}|r||z}nd}|||||
fS)zAU and SND filess.sndN�)sds.sdns.�aurr�����U�r�?���)r$�get_long_be�get_long_le)
rr�func�filetype�hdr_size�	data_size�encoding�rate�	nchannels�sample_size�sample_bits�
frame_size�nframes
             r
�test_aurGgs����|�|�G����	
�2�A��%�	%�����H��A�a��F�|�H��Q�q��W�
�I��A�b��H�~�H���"�R��>�D��Q�r�"�X��I��K��1�}���	�Q����	�Q���������y�(�J���Z�'�����T�9�f�k�9�9rc�b�|dddk7s|dddk7ryt|dd	�}|rd
|z}nd}d|d
ddfS)z	HCOM file�A�EsFSSD��sHCOMN��i"Vr�hcomr5r9r)r:)rr�divisorrAs    r
�	test_hcomrQ�sR����B�x�7��a��C�j�G�3���!�C��*�%�G���w������4��B��!�!rc��|jd�syt|dd�}d}d|cxkrdkr&nn#||dk(rd||d	zz
}|rtd
|z�}d|ddd
fS)zVOC filesCreative Voice FileNr3�ri�r5�r0g��.A�vocr9r)r$�get_short_le�int)rr�sbseekrA�ratecodes     r
�test_vocrZ�ss���<�<�2�3��
�!�B�r�(�
#�F��D��F��S��Q�v�Y�!�^���6�!�8��$����y�8�+�,�D��$��2�q� � rc�P�ddl}|jd�r|dddk7s|dddk7ry|jd�	|j|d	�}d
|j
�|j�|j�d|j�zfS#t|j
f$rYywxYw)zWAV filerNsRIFFrrsWAVEr2sfmt r�wav)
�waver$r%rr&r'r(r)r*r+)rrr]�ws    r
�test_wavr_�s�����<�<�� �A�a��G�w�$6�!�B�r�(�g�:M���F�F�1�I���I�I�a����
�1�>�>�#�Q�^�^�%5��<�<�>�1�Q�^�^�%5�#5�7�7��
�d�j�j�!����s�B
�
B%�$B%c�8�|jd�r|dddk7ryy)z	8SVX filerrrs8SVXN)�8svxrr5rr)r$)rrs  r
�	test_8svxrb�s!���<�<�� �A�a��G�w�$6��rc�l�|jd�r#t|dd�}t|dd�}d|d|dfSy)	z	SNDT filesSOUNDrrr3rS�sndtr5N)r$r;rV)rr�nsamplesrAs    r
�	test_sndtrf�sD���|�|�H���q��2�w�'���A�b��H�%���t�Q��!�+�+�rc�n�|jd�r$t|dd�}d|cxkrdkr
ny
d|ddd	fSy
y
)z	SNDR filesr7r0i�i�a�sndrr5r9rN)r$rV)rrrAs   r
�	test_sndrri�sF���|�|�G���A�a��F�#���4� �5� ��4��B��)�)�!�rc�B�|ddz|ddzz|ddzz|dzS)Nrr4r5r2r7rr���bs r
r:r:��3��
�a�D�B�J�1�Q�4�2�:�&�!�A�$�!�)�4�q��t�;�;rc�B�|ddz|ddzz|ddzz|dzS)Nrr4r7r2r5rrrkrls r
r;r;�rnrc��|ddz|dzS)Nrrr5rkrls r
�get_short_berq����
�a�D�A�I��1���rc��|ddz|dzS)Nr5rrrkrls r
rVrV�rrrc�\�ddl}d}|jddr#|jddk(r|jdd�=d}	|jddrt|jdd|d�ytdg|d�y#t$r/|jjd�|j
d�YywxYw)Nrr5z-rr7�.z
[Interrupted]
)�sys�argv�testall�KeyboardInterrupt�stderr�write�exit)rv�	recursives  r
�testr~�s�����I�
�x�x���|������t�+��H�H�Q�q�S�M��	���8�8�A�B�<��C�H�H�Q�R�L�)�Q�/��S�E�9�a�(�����
�
���,�-�������s�)A3�$A3�35B+�*B+c��ddl}ddl}|D]�}|jj|�rwt	|dzd��|s|rWt	d�ddl}|j|jj
|j|�d��}t||d���t	d���t	|dzd��|jj�	t	t|����y#t$rt	d	�Y��wxYw)
Nrz/:� )�endzrecursing down:�*z*** directory (use -r) ***�:z*** not found ***)
rv�os�path�isdir�print�glob�join�escaperx�stdout�flushr�OSError)�listr}�toplevelrvr�rr��namess        r
rxrx�s����
���
�7�7�=�=��"��(�T�/�s�+��H��'�(���	�	�"�'�'�,�,�t�{�{�8�/D�c�"J�K����y�!�,��2�3��(�S�.�c�*��J�J����
+��d�8�n�%����
+��)�*�
+�s�C"�"C9�8C9�__main__)�__doc__r �_deprecated�__name__�__all__�collectionsrr	r=�	frameraterB�nframes�	sampwidthrrrr.�appendrGrQrZr_rbrfrir:r;rqrVr~rxrkrr
�<module>r�sk���:�����X�g�.�
�9�
��"�
��H�J�
� >�
����!1�
����!6�
�����
����!#�
������	��2�*���Y��:�>���W��	"����Y��
!����X��7����X������Y��,����Y��*����Y��<�<���
�+�*�z���F�r