ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/wave.cpython-311.pyc

�

�f:U����dZddlmZddlZddlZddlZgd�ZGd�de��ZdZ	dZ
ed	d
��Zd�ZGd�d
��Z
Gd�d��ZGd�d��Zdd�ZdS)a%
Stuff to parse WAVE files.

Usage.

Reading WAVE files:
      f = wave.open(file, 'r')
where file is either the name of a file or an open file pointer.
The open file pointer must have methods read(), seek(), and close().
When the setpos() and rewind() methods are not used, the seek()
method is not  necessary.

This returns an instance of a class with the following public methods:
      getnchannels()  -- returns number of audio channels (1 for
                         mono, 2 for stereo)
      getsampwidth()  -- returns sample width in bytes
      getframerate()  -- returns sampling frequency
      getnframes()    -- returns number of audio frames
      getcomptype()   -- returns compression type ('NONE' for linear samples)
      getcompname()   -- returns human-readable version of
                         compression type ('not compressed' linear samples)
      getparams()     -- returns a namedtuple consisting of all of the
                         above in the above order
      getmarkers()    -- returns None (for compatibility with the
                         aifc module)
      getmark(id)     -- raises an error since the mark does not
                         exist (for compatibility with the aifc module)
      readframes(n)   -- returns at most n frames of audio
      rewind()        -- rewind to the beginning of the audio stream
      setpos(pos)     -- seek to the specified position
      tell()          -- return the current position
      close()         -- close the instance (make it unusable)
The position returned by tell() and the position given to setpos()
are compatible and have nothing to do with the actual position in the
file.
The close() method is called automatically when the class instance
is destroyed.

Writing WAVE files:
      f = wave.open(file, 'w')
where file is either the name of a file or an open file pointer.
The open file pointer must have methods write(), tell(), seek(), and
close().

This returns an instance of a class with the following public methods:
      setnchannels(n) -- set the number of channels
      setsampwidth(n) -- set the sample width
      setframerate(n) -- set the frame rate
      setnframes(n)   -- set the number of frames
      setcomptype(type, name)
                      -- set the compression type and the
                         human-readable compression type
      setparams(tuple)
                      -- set all parameters at once
      tell()          -- return current position in output file
      writeframesraw(data)
                      -- write audio frames without patching up the
                         file header
      writeframes(data)
                      -- write audio frames and patch up the file header
      close()         -- patch up the file header and close the
                         output file
You should set the parameters before the first writeframesraw or
writeframes.  The total number of frames does not need to be set,
but when it is set to the correct value, the header does not have to
be patched up.
It is best to first set all parameters, perhaps possibly the
compression type, and then write audio frames using writeframesraw.
When all frames have been written, either call writeframes(b'') or
close() to patch up the sizes in the header.
The close() method is called automatically when the class instance
is destroyed.
�)�
namedtupleN)�open�Error�	Wave_read�
Wave_writec��eZdZdS)rN)�__name__�
__module__�__qualname__���+/opt/alt/python311/lib64/python3.11/wave.pyrrRs�������Dr
r�)N�b�hN�i�_wave_paramsz7nchannels sampwidth framerate nframes comptype compnamec���tt|����}tdt|��|��D]+}t|��D]}|||z|||zdz
|z
<��,t|��S)Nrr)�	bytearray�len�range�bytes)�data�width�swapped_datar�js     r�	_byteswapr]s����S��Y�Y�'�'�L�
�1�c�$�i�i��
'�
'�:�:���u���	:�	:�A�.2�1�q�5�k�L��U��Q���*�+�+�	:�����r
c�>�eZdZd
d�Zd�Zd�Zdd�Zd�Zdd
�Zd�Z	dS)�_ChunkTFc��d|_||_|rd}nd}||_|�d��|_t|j��dkrt�	tj|dz|�d����d|_	n#tj
$r	td�wxYw|r|j	dz
|_	d|_	|j���|_
d|_dS#tt f$rd|_YdSwxYw)	NF�>�<��Lr�T)�closed�align�file�read�	chunknamer�EOFError�struct�unpack_from�	chunksize�error�	size_read�tell�offset�seekable�AttributeError�OSError)�selfr(r'�	bigendian�
inclheader�strflags      r�__init__z_Chunk.__init__hs�������
��	��G�G��G���	����1������t�~����"�"��N�	%�#�/����T�Y�Y�q�\�\�J�J�1�M�D�N�N���|�	%�	%�	%���$�	%�����	0�!�^�a�/�D�N����	!��)�.�.�*�*�D�K�!�D�M�M�M����(�	"�	"�	"�!�D�M�M�M�M�	"���s�6B�B&�C)�)D�Dc��|jS)z*Return the name (ID) of the current chunk.)r*�r6s r�getnamez_Chunk.getname�s
���~�r
c�h�|js*	|���d|_dS#d|_wxYwdS)NT)r&�skipr<s r�closez_Chunk.close�sF���{�	#�
#��	�	����"������d���"�"�"�"�		#�	#s�&�	/rc�$�|jrtd���|jstd���|dkr||jz}n|dkr
||jz}|dks||jkrt�|j�|j	|zd��||_dS)z�Seek to specified position into the chunk.
        Default position is 0 (start of chunk).
        If the file is not seekable, this will result in an error.
        �I/O operation on closed filezcannot seekr�rN)
r&�
ValueErrorr3r5r0r.�RuntimeErrorr(�seekr2)r6�pos�whences   rrFz_Chunk.seek�s����;�	=��;�<�<�<��}�	)��-�(�(�(��Q�;�;����&�C�C�
�q�[�[����&�C���7�7�c�D�N�*�*����	���t�{�S�(�!�,�,�,�����r
c�<�|jrtd���|jS)NrB)r&rDr0r<s rr1z_Chunk.tell�s#���;�	=��;�<�<�<��~�r
���c���|jrtd���|j|jkrdS|dkr|j|jz
}||j|jz
kr|j|jz
}|j�|��}|jt
|��z|_|j|jkrG|jr@|jdzr6|j�d��}|jt
|��z|_|S)z�Read at most size bytes from the chunk.
        If size is omitted or negative, read until the end
        of the chunk.
        rBr
rr)r&rDr0r.r(r)rr')r6�sizer�dummys    rr)z_Chunk.read�s����;�	=��;�<�<�<��>�T�^�+�+��3��!�8�8��>�D�N�2�D��$�.�4�>�1�1�1��>�D�N�2�D��y�~�~�d�#�#����#�d�)�)�3����>�T�^�+�+��:�,��N�Q��,��I�N�N�1�%�%�E�!�^�c�%�j�j�8�D�N��r
c��|jrtd���|jrb	|j|jz
}|jr|jdzr|dz}|j�|d��|j|z|_dS#t$rYnwxYw|j|jkrMtd|j|jz
��}|�
|��}|st�|j|jk�KdSdS)z�Skip the rest of the chunk.
        If you are not interested in the contents of the chunk,
        this method should be called so that the file points to
        the start of the next chunk.
        rBrNi )r&rDr3r.r0r'r(rFr5�minr)r+)r6�nrMs   rr?z_Chunk.skip�s���;�	=��;�<�<�<��=�
	�	
��N�T�^�3���:��4�>�A�#5���A��A��	���q�!�$�$�$�!%��!�!3�������
�
�
���
�����n�t�~�-�-��D�$�.�4�>�9�:�:�A��I�I�a�L�L�E��
���	�n�t�~�-�-�-�-�-�-s�AA0�0
A=�<A=N)TTF)r)rJ)
r	r
rr:r=r@rFr1r)r?rr
rrrgs�������!�!�!�!�2���#�#�#�����&���
����.����r
rc��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)raPVariables used in this class:

    These variables are available to the user though appropriate
    methods of this class:
    _file -- the open file with methods read(), close(), and seek()
              set through the __init__() method
    _nchannels -- the number of audio channels
              available through the getnchannels() method
    _nframes -- the number of audio frames
              available through the getnframes() method
    _sampwidth -- the number of bytes per audio sample
              available through the getsampwidth() method
    _framerate -- the sampling frequency
              available through the getframerate() method
    _comptype -- the AIFF-C compression type ('NONE' if AIFF)
              available through the getcomptype() method
    _compname -- the human-readable AIFF-C compression type
              available through the getcomptype() method
    _soundpos -- the position in the audio stream
              available through the tell() method, set through the
              setpos() method

    These variables are used internally only:
    _fmt_chunk_read -- 1 iff the FMT chunk has been read
    _data_seek_needed -- 1 iff positioned correctly in audio
              file for readframes()
    _data_chunk -- instantiation of a chunk class for the DATA chunk
    _framesize -- size of one frame in the file
    c���d|_d|_t|d���|_|j���dkrtd���|j�d��dkrtd���d|_d|_	d|_		t|jd���}n#t$rYn�wxYw|���}|d	kr|�|��d|_n?|d
kr9|jstd���||_|j|j
z|_d|_	n|�����|jr|jstd���dS)
Nr)r7�RIFFz file does not start with RIFF idr#�WAVEznot a WAVE filer�fmt �datazdata chunk before fmt chunkz#fmt chunk and/or data chunk missing)�_convert�	_soundposr�_filer=rr)�_fmt_chunk_read�_data_chunk�_data_seek_neededr+�_read_fmt_chunkr.�
_framesize�_nframesr?)r6r(�chunkr*s    r�initfpzWave_read.initfp�s�����
�����D�a�0�0�0��
��:�����7�*�*��:�;�;�;��:�?�?�1����(�(��)�*�*�*� ������	�%&�D�"�
��t�z�q�9�9�9�����
�
�
���
�����
�
���I��G�#�#��$�$�U�+�+�+�'(��$�$��g�%�%��+�?�� =�>�>�>�#(�� � %��4�?� B��
�)*��&���J�J�L�L�L�#	�$�#�	?�4�+;�	?��=�>�>�>�	?�	?s�B,�,
B9�8B9c���d|_t|t��rtj|d��}||_	|�|��dS#|jr|����xYw)N�rb��_i_opened_the_file�
isinstance�str�builtinsrrar@�r6�fs  rr:zWave_read.__init__sq��"&����a����	(��
�a��&�&�A�&'�D�#�	��K�K��N�N�N�N�N��	��&�
����	�	�	������A�A/c�.�|���dS�N�r@r<s r�__del__zWave_read.__del__!����
�
�����r
c��|Srmrr<s r�	__enter__zWave_read.__enter__$����r
c�.�|���dSrmrn�r6�argss  r�__exit__zWave_read.__exit__'rpr
c��|jSrm)rYr<s r�getfpzWave_read.getfp-s
���z�r
c�"�d|_d|_dS)Nrr)r\rXr<s r�rewindzWave_read.rewind0s��!"�������r
c�`�d|_|j}|rd|_|���dSdSrm)rYrer@�r6r(s  rr@zWave_read.close4s<����
��&���	�&*�D�#��J�J�L�L�L�L�L�	�	r
c��|jSrm)rXr<s rr1zWave_read.tell;�
���~�r
c��|jSrm)�
_nchannelsr<s r�getnchannelszWave_read.getnchannels>�
����r
c��|jSrm)r_r<s r�
getnframeszWave_read.getnframesAs
���}�r
c��|jSrm)�
_sampwidthr<s r�getsampwidthzWave_read.getsampwidthDr�r
c��|jSrm)�
_framerater<s r�getframeratezWave_read.getframerateGr�r
c��|jSrm��	_comptyper<s r�getcomptypezWave_read.getcomptypeJrr
c��|jSrm��	_compnamer<s r�getcompnamezWave_read.getcompnameMrr
c	��t|���|���|���|���|���|�����Srm)rr�r�r�r�r�r�r<s r�	getparamszWave_read.getparamsPsh���D�-�-�/�/��1B�1B�1D�1D��(�(�*�*�D�O�O�,=�,=��'�'�)�)�4�+;�+;�+=�+=�?�?�	?r
c��dSrmrr<s r�
getmarkerszWave_read.getmarkersU����tr
c� �td����Nzno marks�r�r6�ids  r�getmarkzWave_read.getmarkX����J���r
c�b�|dks||jkrtd���||_d|_dS)Nrzposition not in ranger)r_rrXr\)r6rGs  r�setposzWave_read.setpos[s;����7�7�c�D�M�)�)��/�0�0�0����!"����r
c��|jrN|j�dd��|j|jz}|r|j�|d��d|_|dkrdS|j�||jz��}|jdkr%tjdkrt||j��}|j
r|r|�
|��}|jt|��|j|jzzz|_|S)Nrr
r�big)
r\r[rFrXr^r)r��sys�	byteorderrrWrr�)r6�nframesrGrs    r�
readframeszWave_read.readframesas����!�	'���!�!�!�Q�'�'�'��.�4�?�2�C��
.�� �%�%�c�1�-�-�-�%&�D�"��a�<�<��3���$�$�W�t��%>�?�?���?�a���C�M�U�$:�$:��T�4�?�3�3�D��=�	'�T�	'��=�=��&�&�D���#�d�)�)���$�/�8Y�*Z�Z����r
c�8�	tjd|�d����\}|_|_}}n#tj$r	td�wxYw|tkro	tjd|�d����d}n#tj$r	td�wxYw|dzdz|_|jstd���ntd	|�����|jstd
���|j|jz|_
d|_d|_dS)
Nz<HHLLH�z<HrCr�r%�bad sample widthzunknown format: �bad # of channels�NONEznot compressed)
r,r-r)r�r�r/r+�WAVE_FORMAT_PCMr�rr^r�r�)r6r`�
wFormatTag�dwAvgBytesPerSec�wBlockAlign�	sampwidths      rr]zWave_read._read_fmt_chunkvsU��	%�Z`�Zl�mu�w|�xB�xB�CE�xF�xF�[G�[G�W�J�����:J�K�K���|�	%�	%�	%���$�	%������(�(�
)�"�.�t�U�Z�Z��]�]�C�C�A�F�	�	���<�
)�
)�
)��D�(�
)����(�1�}��2�D�O��?�
0��.�/�/�/�
0��%�
�
�<�=�=�=���	-��+�,�,�,��/�D�O�;������)����s�8;�A�".B�B)N)r	r
r�__doc__rar:rorrrwryr{r@r1r�r�r�r�r�r�r�r�r�r�r�r]rr
rrr�sY��������<?�?�?�>������������������������������������������?�?�?�
��� � � �#�#�#����**�*�*�*�*r
rc��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)ra�Variables used in this class:

    These variables are user settable through appropriate methods
    of this class:
    _file -- the open file with methods write(), close(), tell(), seek()
              set through the __init__() method
    _comptype -- the AIFF-C compression type ('NONE' in AIFF)
              set through the setcomptype() or setparams() method
    _compname -- the human-readable AIFF-C compression type
              set through the setcomptype() or setparams() method
    _nchannels -- the number of audio channels
              set through the setnchannels() or setparams() method
    _sampwidth -- the number of bytes per audio sample
              set through the setsampwidth() or setparams() method
    _framerate -- the sampling frequency
              set through the setframerate() or setparams() method
    _nframes -- the number of audio frames written to the header
              set through the setnframes() or setparams() method

    These variables are used internally only:
    _datalength -- the size of the audio samples written to the header
    _nframeswritten -- the number of frames actually written
    _datawritten -- the size of the audio samples actually written
    c���d|_t|t��rtj|d��}||_	|�|��dS#|jr|����xYw)N�wbrdris  rr:zWave_write.__init__�sq��"&����a����	(��
�a��&�&�A�&'�D�#�	��K�K��N�N�N�N�N��	��&�
����	�	�	����rkc��||_d|_d|_d|_d|_d|_d|_d|_d|_d|_	dS)NrF)
rYrWr�r�r�r_�_nframeswritten�_datawritten�_datalength�_headerwrittenr}s  rrazWave_write.initfp�sR����
���
������������
� ���������#����r
c�.�|���dSrmrnr<s rrozWave_write.__del__�rpr
c��|Srmrr<s rrrzWave_write.__enter__�rsr
c�.�|���dSrmrnrus  rrwzWave_write.__exit__�rpr
c�j�|jrtd���|dkrtd���||_dS)N�0cannot change parameters after starting to writerr�)r�rr�)r6�	nchannelss  r�setnchannelszWave_write.setnchannels�s@����	L��J�K�K�K��q�=�=��+�,�,�,�#����r
c�<�|jstd���|jS)Nznumber of channels not set)r�rr<s rr�zWave_write.getnchannels�s#����	6��4�5�5�5���r
c�v�|jrtd���|dks|dkrtd���||_dS)Nr�rr#r�)r�rr�)r6r�s  r�setsampwidthzWave_write.setsampwidth�sH����	L��J�K�K�K��q�=�=�I��M�M��*�+�+�+�#����r
c�<�|jstd���|jS)Nzsample width not set)r�rr<s rr�zWave_write.getsampwidth�s#����	0��.�/�/�/���r
c��|jrtd���|dkrtd���tt|����|_dS)Nr�rzbad frame rate)r�r�int�roundr�)r6�	framerates  r�setframeratezWave_write.setframerate�sP����	L��J�K�K�K���>�>��(�)�)�)��e�I�.�.�/�/����r
c�<�|jstd���|jS)Nzframe rate not set)r�rr<s rr�zWave_write.getframerate�s#����	.��,�-�-�-���r
c�@�|jrtd���||_dS�Nr�)r�rr_)r6r�s  r�
setnframeszWave_write.setnframes�s(����	L��J�K�K�K���
�
�
r
c��|jSrm�r�r<s rr�zWave_write.getnframes�����#�#r
c�t�|jrtd���|dvrtd���||_||_dS)Nr�)r�zunsupported compression type)r�rr�r�)r6�comptype�compnames   r�setcomptypezWave_write.setcomptype�sI����	L��J�K�K�K��9�$�$��6�7�7�7�!���!����r
c��|jSrmr�r<s rr�zWave_write.getcomptype�rr
c��|jSrmr�r<s rr�zWave_write.getcompnamerr
c��|\}}}}}}|jrtd���|�|��|�|��|�|��|�|��|�||��dSr�)r�rr�r�r�r�r�)r6�paramsr�r�r�r�r�r�s        r�	setparamszWave_write.setparamss���GM�D�	�9�i��(�H���	L��J�K�K�K����)�$�$�$����)�$�$�$����)�$�$�$����� � � �����8�,�,�,�,�,r
c��|jr|jr|jstd���t	|j|j|j|j|j|j��S)Nznot all parameters set)r�r�r�rrr_r�r�r<s rr�zWave_write.getparamssX����	2�d�o�	2�T�_�	2��0�1�1�1��D�O�T�_�d�o��m�T�^�T�^�=�=�	=r
c� �td���)Nzsetmark() not supportedr�)r6r�rG�names    r�setmarkzWave_write.setmarks���-�.�.�.r
c� �td���r�r�r�s  rr�zWave_write.getmarkr�r
c��dSrmrr<s rr�zWave_write.getmarkersr�r
c��|jSrmr�r<s rr1zWave_write.tellr�r
c�(�t|ttf��s"t|���d��}|�t
|����t
|��|j|jzz}|j	r|�	|��}|jdkr%tjdkrt||j��}|j
�|��|xjt
|��z
c_|j|z|_dS)N�Brr�)rfrr�
memoryview�cast�_ensure_header_writtenrr�r�rWr�r�rrY�writer�r�)r6rr�s   r�writeframesrawzWave_write.writeframesraw s����$��	� 2�3�3�	.��d�#�#�(�(��-�-�D��#�#�C��I�I�.�.�.��d�)�)���$�/� A�B���=�	'��=�=��&�&�D��?�a���C�M�U�$:�$:��T�4�?�3�3�D��
����������S��Y�Y�&���#�3�g�=����r
c�|�|�|��|j|jkr|���dSdSrm)r�r�r��_patchheader)r6rs  r�writeframeszWave_write.writeframes-sG�����D�!�!�!���t�0�0�0���������1�0r
c�v�	|jrR|�d��|j|jkr|���|j���d|_|j}|rd|_|���dSdS#d|_|j}|rd|_|���wwxYw)Nr)rYr�r�r�r��flushrer@r}s  rr@zWave_write.close2s���	��z�
#��+�+�A�.�.�.��#�t�'8�8�8��%�%�'�'�'��
� � �"�"�"��D�J��*�D��
�*.��'��
�
������
�
���D�J��*�D��
�*.��'��
�
�����
���s�AB
�
.B8c���|jsY|jstd���|jstd���|jstd���|�|��dSdS)Nz# channels not specifiedzsample width not specifiedzsampling rate not specified)r�r�rr�r��
_write_header)r6�datasizes  rr�z!Wave_write._ensure_header_writtenDs|���"�	)��?�
8��6�7�7�7��?�
:��8�9�9�9��?�
;��9�:�:�:����x�(�(�(�(�(�	)�	)r
c���|jrJ�|j�d��|js||j|jzz|_|j|jz|jz|_	|j���|_n#ttf$r
d|_YnwxYw|j�tjdd|jzdddt|j|j|j|jz|jz|j|jz|jdzd����|j�|j���|_|j�tjd	|j����d
|_dS)NrSz<L4s4sLHHLLHH4s�$rTrU�r%rV�<LT)r�rYr�r_r�r�r�r1�_form_length_posr4r5r,�packr�r��_data_length_pos)r6�
initlengths  rr�zWave_write._write_headerNsm���&�&�&�&��
����!�!�!��}�	N�&�4�?�T�_�+L�M�D�M��=�4�?�:�T�_�L���	)�$(�J�O�O�$5�$5�D�!�!����(�	)�	)�	)�$(�D�!�!�!�	)�����
�����%6���!�!�7�G�R��T�_�d�o��O�d�o�-���?��O�d�o�-��O�a���*�*�	+�	+�	+�� �,�$(�J�O�O�$5�$5�D�!��
�����T�4�+;�<�<�=�=�=�"����s�A>�>B�Bc�
�|jsJ�|j|jkrdS|j���}|j�|jd��|j�tj	dd|jz����|j�|j
d��|j�tj	d|j����|j�|d��|j|_dS)Nrr�r�)r�r�r�rYr1rFr�r�r,r�r�)r6�curposs  rr�zWave_write._patchheadercs����"�"�"�"���� 0�0�0��F�����"�"���
����-�q�1�1�1��
�����T�2��0A�+A�B�B�C�C�C��
����-�q�1�1�1��
�����T�4�+<�=�=�>�>�>��
�����"�"�"��,����r
N) r	r
rr�r:rarorrrwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r1r�r�r@r�r�r�rr
rrr�s���������2
�
�
�
$�
$�
$����������$�$�$����
$�$�$����
0�0�0����
 � � �
$�$�$�"�"�"�������-�-�-�=�=�=�/�/�/� � � ����$�$�$�>�>�>� � � �
���$)�)�)�#�#�#�*
-�
-�
-�
-�
-r
rc��|�t|d��r|j}nd}|dvrt|��S|dvrt|��St	d���)N�moderc)�rrc)�wr�z$mode must be 'r', 'rb', 'w', or 'wb')�hasattrr�rrr)rjr�s  rrrpsd���|��1�f���	��6�D�D��D��{�����|�|��	
��	�	��!�}�}���:�;�;�;r
rm)r��collectionsrrhr,r��__all__�	Exceptionrr��_array_fmtsrrrrrrrr
r�<module>rs\��G�G�R#�"�"�"�"�"�����
�
�
�
�
�
�
�
�7�
6�
6��	�	�	�	�	�I�	�	�	���'���z�.�N�P�P�����l�l�l�l�l�l�l�l�^s*�s*�s*�s*�s*�s*�s*�s*�la-�a-�a-�a-�a-�a-�a-�a-�H<�<�<�<�<�<r

Zerion Mini Shell 1.0