AlkantarClanX12

Your IP : 18.216.42.225


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/wave.cpython-310.opt-2.pyc

o

6��fTF�@s�	ddlmZddlmZddlZddlZddlZddlZgd�ZGdd�de	�Z
dZdZed	d
�Z
Gdd�d�ZGd
d�d�Zddd�ZdS)�)�Chunk)�
namedtupleN)�open�Error�	Wave_read�
Wave_writec@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�+/opt/alt/python310/lib64/python3.10/wave.pyrTsr�)N�b�hN�i�_wave_paramsz7nchannels sampwidth framerate nframes comptype compnamec@s�eZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+S),rcCs�d|_d|_t|dd�|_|j��dkrtd��|j�d�dkr$td��d|_d|_	d|_	z	t|jdd�}Wn	t
y@Yn0w|��}|d	krR|�|�d|_n|d
krk|js]td��||_|j|j
|_d|_	n|��q+|jrv|jsztd��dS)
Nr)Z	bigendian�RIFFz file does not start with RIFF id��WAVEznot a WAVE filer
�fmt �datazdata chunk before fmt chunkz#fmt chunk and/or data chunk missing)�_convert�	_soundposr�_fileZgetnamer�readZ_fmt_chunk_read�_data_chunk�_data_seek_needed�EOFError�_read_fmt_chunkZ	chunksize�
_framesize�_nframes�skip)�self�file�chunkZ	chunknamerrr�initfp}s@�
��zWave_read.initfpcC�Jd|_t|t�rt�|d�}||_z|�|�WdS|jr$|���)N�rb��_i_opened_the_file�
isinstance�str�builtinsrr%�close�r"�frrr�__init__�s
zWave_read.__init__cC�|��dS�N�r-�r"rrr�__del__��zWave_read.__del__cC�|Sr2rr4rrr�	__enter__��zWave_read.__enter__cGr1r2r3�r"�argsrrr�__exit__�r6zWave_read.__exit__cC�|jSr2)rr4rrr�getfp��zWave_read.getfpcCsd|_d|_dS)Nr
r)rrr4rrr�rewind�s
zWave_read.rewindcCs&d|_|j}|rd|_|��dSdSr2)rr)r-�r"r#rrrr-�s�zWave_read.closecCr=r2)rr4rrr�tell�r?zWave_read.tellcCr=r2)�
_nchannelsr4rrr�getnchannels�r?zWave_read.getnchannelscCr=r2)r r4rrr�
getnframes�r?zWave_read.getnframescCr=r2)�
_sampwidthr4rrr�getsampwidth�r?zWave_read.getsampwidthcCr=r2)�
_framerater4rrr�getframerate�r?zWave_read.getframeratecCr=r2��	_comptyper4rrr�getcomptype�r?zWave_read.getcomptypecCr=r2��	_compnamer4rrr�getcompname�r?zWave_read.getcompnamecCs*t|��|��|��|��|��|���Sr2)rrDrGrIrErLrOr4rrr�	getparams�s�zWave_read.getparamscC�dSr2rr4rrr�
getmarkers�r9zWave_read.getmarkerscC�td���Nzno marks�r�r"�idrrr�getmark��zWave_read.getmarkcCs*|dks	||jkr
td��||_d|_dS)Nrzposition not in ranger
)r rrr)r"�posrrr�setpos�s
zWave_read.setposcCs�|jr|j�dd�|j|j}|r|j�|d�d|_|dkr"dS|j�||j�}|jdkr<tjdkr<t	�
||j�}|jrF|rF|�|�}|jt|�|j
|j|_|S)Nr�r
�big)rr�seekrrrrF�sys�	byteorder�audioop�byteswapr�lenrC)r"�nframesrZ�datarrr�
readframes�s

zWave_read.readframescCs�zt�d|�d��\}|_|_}}Wntjytd�w|tkrJz
t�d|�d��d}Wntjy:td�w|dd|_|jsIt	d��nt	d	|f��|jsXt	d
��|j|j|_
d|_d|_dS)
Nz<HHLLH�z<H�r���bad sample widthzunknown format: %r�bad # of channels�NONEznot compressed)
�structZunpack_fromrrCrH�errorr�WAVE_FORMAT_PCMrFrrrKrN)r"r$Z
wFormatTagZdwAvgBytesPerSecZwBlockAlign�	sampwidthrrrr�s*$���
zWave_read._read_fmt_chunkN)rr	r
r%r0r5r8r<r>r@r-rBrDrErGrIrLrOrPrRrXr[rfrrrrrr^s.
rc@s�eZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9S):rcCr&)N�wbr(r.rrrr0-s
zWave_write.__init__cCs@||_d|_d|_d|_d|_d|_d|_d|_d|_d|_	dS)NrF)
rrrCrFrHr �_nframeswritten�_datawritten�_datalength�_headerwrittenrArrrr%9s
zWave_write.initfpcCr1r2r3r4rrrr5Er6zWave_write.__del__cCr7r2rr4rrrr8Hr9zWave_write.__enter__cGr1r2r3r:rrrr<Kr6zWave_write.__exit__cCs(|jrtd��|dkrtd��||_dS)N�0cannot change parameters after starting to writer
rl)rtrrC)r"�	nchannelsrrr�setnchannelsQs

zWave_write.setnchannelscC�|jstd��|jS)Nznumber of channels not set)rCrr4rrrrDX�zWave_write.getnchannelscCs0|jrtd��|dks|dkrtd��||_dS)Nrwr
rrk)rtrrF)r"rqrrr�setsampwidth]s

zWave_write.setsampwidthcCrz)Nzsample width not set)rFrr4rrrrGdr{zWave_write.getsampwidthcCs0|jrtd��|dkrtd��tt|��|_dS)Nrwrzbad frame rate)rtr�int�roundrH)r"�	frameraterrr�setframerateis
zWave_write.setframeratecCrz)Nzframe rate not set)rHrr4rrrrIpr{zWave_write.getframeratecCs|jrtd��||_dS�Nrw)rtrr )r"rdrrr�
setnframesus
zWave_write.setnframescCr=r2�rsr4rrrrEzr?zWave_write.getnframescCs.|jrtd��|dvrtd��||_||_dS)Nrw)rmzunsupported compression type)rtrrKrN)r"�comptype�compnamerrr�setcomptype}s
zWave_write.setcomptypecCr=r2rJr4rrrrL�r?zWave_write.getcomptypecCr=r2rMr4rrrrO�r?zWave_write.getcompnamecCsV|\}}}}}}|jrtd��|�|�|�|�|�|�|�|�|�||�dSr�)rtrryr|r�r�r�)r"�paramsrxrqrrdr�r�rrr�	setparams�s



zWave_write.setparamscCs8|jr	|jr	|js
td��t|j|j|j|j|j|j�S)Nznot all parameters set)rCrFrHrrr rKrNr4rrrrP�s
�zWave_write.getparamscCrS)Nzsetmark() not supportedrU)r"rWrZ�namerrr�setmark�rYzWave_write.setmarkcCrSrTrUrVrrrrX�rYzWave_write.getmarkcCrQr2rr4rrrrR�r9zWave_write.getmarkerscCr=r2r�r4rrrrB�r?zWave_write.tellcCs�t|ttf�st|��d�}|�t|��t|�|j|j}|j	r'|�	|�}|jdkr8t
jdkr8t�
||j�}|j�|�|jt|�7_|j||_dS)N�Br
r])r*�bytes�	bytearray�
memoryview�cast�_ensure_header_writtenrcrFrCrr_r`rarbr�writertrs)r"rerdrrr�writeframesraw�s
zWave_write.writeframesrawcCs&|�|�|j|jkr|��dSdSr2)r�rurt�_patchheader)r"rerrr�writeframes�s
�zWave_write.writeframescCszz+|jr|�d�|j|jkr|��|j��Wd|_|j}|r*d|_|��dSdSd|_|j}|r<d|_|��ww)Nr)rr�rurtr��flushr)r-rArrrr-�s&

���
�zWave_write.closecCsB|js|js
td��|jstd��|jstd��|�|�dSdS)Nz# channels not specifiedzsample width not specifiedzsampling rate not specified)rvrCrrFrH�
_write_header)r"Zdatasizerrrr��s�z!Wave_write._ensure_header_writtencCs�|j�d�|js||j|j|_|j|j|j|_z|j��|_Wntt	fy2d|_Ynw|j�t
�dd|jdddt|j|j
|j|j
|j|j|j|jdd��|jdure|j��|_|j�t
�d	|j��d
|_dS)Nrz<L4s4sLHHLLHH4s�$rr�rjr�<LT)rr�r rCrFrurB�_form_length_pos�AttributeError�OSErrorrn�packrprH�_data_length_posrv)r"Z
initlengthrrrr��s(
�


�

zWave_write._write_headercCs�|j|jkrdS|j��}|j�|jd�|j�t�dd|j��|j�|j	d�|j�t�d|j��|j�|d�|j|_dS)Nrr�r�)
rtrurrBr^r�r�rnr�r�)r"Zcurposrrrr��s
zWave_write._patchheaderN)rr	r
r0r%r5r8r<ryrDr|rGr�rIr�rEr�rLrOr�rPr�rXrRrBr�r�r-r�r�r�rrrrrs<


rcCsF|durt|d�r
|j}nd}|dvrt|�S|dvrt|�Std��)N�moder')�rr')�wrrz$mode must be 'r', 'rb', 'w', or 'wb')�hasattrr�rrr)r/r�rrrr�s
rr2)r$r�collectionsrrar,rnr_�__all__�	ExceptionrrpZ_array_fmtsrrrrrrrr�<module>s&I�6d