AlkantarClanX12

Your IP : 18.227.0.255


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/wave.cpython-35.opt-2.pyc



���]E�@s�ddlZdddgZGdd�de�ZdZdZddlZddlZddlZdd
l	m
Z
ddlmZedd
�Z
Gdd�d�ZGdd�d�Zddd�ZeZdS)�N�open�openfp�Errorc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�)/opt/alt/python35/lib64/python3.5/wave.pyrNs��b�h�i)�Chunk)�
namedtuple�_wave_paramsz7nchannels sampwidth framerate nframes comptype compnamec@seZdZdd�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),�	Wave_readcCscd|_d|_t|dd�|_|jj�dkrHtd��|jjd�dkrltd��d|_d|_x�d|_	yt|jdd�}Wnt
k
r�PYnX|j�}|d	kr�|j|�d|_nG|d
kr1|jstd��||_|j|j
|_d|_	P|j�q�W|jsS|jr_td��dS)
NrZ	bigendiansRIFFz file does not start with RIFF id�sWAVEznot a WAVE filer
sfmt sdatazdata 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_chunk�	chunksize�
_framesize�_nframes�skip)�self�file�chunkZ	chunknamerrr	�initfp}s:					

			zWave_read.initfpc	Csid|_t|t�r3tj|d�}||_y|j|�Wn|jr]|j��YnXdS)N�rb)�_i_opened_the_file�
isinstance�str�builtinsrr"�close)r�frrr	�__init__�s			
zWave_read.__init__cCs|j�dS)N)r()rrrr	�__del__�szWave_read.__del__cCs|S)Nr)rrrr	�	__enter__�szWave_read.__enter__cGs|j�dS)N)r()r�argsrrr	�__exit__�szWave_read.__exit__cCs|jS)N)r)rrrr	�getfp�szWave_read.getfpcCsd|_d|_dS)Nr
r)rr)rrrr	�rewind�s	zWave_read.rewindcCs/d|_|j}|r+d|_|j�dS)N)rr$r()rr rrr	r(�s
			zWave_read.closecCs|jS)N)r)rrrr	�tell�szWave_read.tellcCs|jS)N)�
_nchannels)rrrr	�getnchannels�szWave_read.getnchannelscCs|jS)N)r)rrrr	�
getnframes�szWave_read.getnframescCs|jS)N)�
_sampwidth)rrrr	�getsampwidth�szWave_read.getsampwidthcCs|jS)N)�
_framerate)rrrr	�getframerate�szWave_read.getframeratecCs|jS)N)�	_comptype)rrrr	�getcomptype�szWave_read.getcomptypecCs|jS)N)�	_compname)rrrr	�getcompname�szWave_read.getcompnamecCs=t|j�|j�|j�|j�|j�|j��S)N)rr3r6r8r4r:r<)rrrr	�	getparams�szWave_read.getparamscCsdS)Nr)rrrr	�
getmarkers�szWave_read.getmarkerscCstd��dS)Nzno marks)r)r�idrrr	�getmark�szWave_read.getmarkcCs=|dks||jkr'td��||_d|_dS)Nrzposition not in ranger
)rrrr)r�posrrr	�setpos�s	zWave_read.setposcCs�|jrN|jjdd�|j|j}|rE|jj|d�d|_|dkr^dS|jj||j�}|jdkr�tjdkr�t	j
||j�}|jr�|r�|j|�}|jt|�|j
|j|_|S)Nr�r
�big)rr�seekrrrr5�sys�	byteorder�audioop�byteswapr�lenr2)r�nframesrA�datarrr	�
readframes�s		$zWave_read.readframescCs�tjd|jd��\}|_|_}}|tkrotjd|jd��d}|dd|_ntd|f��|j|j|_d	|_	d
|_
dS)Nz<HHLLH�z<H�r��zunknown format: %r�NONEznot compressed)�struct�unpack_fromrr2r7�WAVE_FORMAT_PCMr5rrr9r;)rr!Z
wFormatTagZdwAvgBytesPerSecZwBlockAlign�	sampwidthrrr	r�s0	zWave_read._read_fmt_chunkN)rrrr"r*r+r,r.r/r0r(r1r3r4r6r8r:r<r=r>r@rBrMrrrrr	r^s*
rc@s`eZdZdd�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):�
Wave_writec	Csid|_t|t�r3tj|d�}||_y|j|�Wn|jr]|j��YnXdS)N�wb)r$r%r&r'rr"r()rr)rrr	r*#s			
zWave_write.__init__cCs^||_d|_d|_d|_d|_d|_d|_d|_d|_d|_	dS)NrF)
rrr2r5r7r�_nframeswritten�_datawritten�_datalength�_headerwritten)rr rrr	r"/s									zWave_write.initfpcCs|j�dS)N)r()rrrr	r+;szWave_write.__del__cCs|S)Nr)rrrr	r,>szWave_write.__enter__cGs|j�dS)N)r()rr-rrr	r.AszWave_write.__exit__cCs:|jrtd��|dkr-td��||_dS)Nz0cannot change parameters after starting to writer
zbad # of channels)rZrr2)r�	nchannelsrrr	�setnchannelsGs
	zWave_write.setnchannelscCs|jstd��|jS)Nznumber of channels not set)r2r)rrrr	r3Ns	zWave_write.getnchannelscCsF|jrtd��|dks-|dkr9td��||_dS)Nz0cannot change parameters after starting to writer
rzbad sample width)rZrr5)rrVrrr	�setsampwidthSs
	zWave_write.setsampwidthcCs|jstd��|jS)Nzsample width not set)r5r)rrrr	r6Zs	zWave_write.getsampwidthcCsF|jrtd��|dkr-td��tt|��|_dS)Nz0cannot change parameters after starting to writerzbad frame rate)rZr�int�roundr7)r�	frameraterrr	�setframerate_s
	zWave_write.setframeratecCs|jstd��|jS)Nzframe rate not set)r7r)rrrr	r8fs	zWave_write.getframeratecCs"|jrtd��||_dS)Nz0cannot change parameters after starting to write)rZrr)rrKrrr	�
setnframesks	zWave_write.setnframescCs|jS)N)rY)rrrr	r4pszWave_write.getnframescCsC|jrtd��|dkr-td��||_||_dS)Nz0cannot change parameters after starting to writerRzunsupported compression type)rR)rZrr9r;)r�comptype�compnamerrr	�setcomptypess		zWave_write.setcomptypecCs|jS)N)r9)rrrr	r:{szWave_write.getcomptypecCs|jS)N)r;)rrrr	r<~szWave_write.getcompnamecCsu|\}}}}}}|jr-td��|j|�|j|�|j|�|j|�|j||�dS)Nz0cannot change parameters after starting to write)rZrr^r_rcrdrg)r�paramsr]rVrbrKrerfrrr	�	setparams�s	



zWave_write.setparamscCsU|js|js|jr*td��t|j|j|j|j|j|j�S)Nznot all parameters set)r2r5r7rrrr9r;)rrrr	r=�szWave_write.getparamscCstd��dS)Nzsetmark() not supported)r)rr?rA�namerrr	�setmark�szWave_write.setmarkcCstd��dS)Nzno marks)r)rr?rrr	r@�szWave_write.getmarkcCsdS)Nr)rrrr	r>�szWave_write.getmarkerscCs|jS)N)rY)rrrr	r1�szWave_write.tellcCs�t|ttf�s*t|�jd�}|jt|��t|�|j|j}|j	ro|j	|�}|jdkr�t
jdkr�tj
||j�}|jj|�|jt|�7_|j||_dS)N�Br
rD)r%�bytes�	bytearray�
memoryview�cast�_ensure_header_writtenrJr5r2rrFrGrHrIr�writerZrY)rrLrKrrr	�writeframesraw�s	zWave_write.writeframesrawcCs-|j|�|j|jkr)|j�dS)N)rsr[rZ�_patchheader)rrLrrr	�writeframes�s
zWave_write.writeframescCsvzC|jrB|jd�|j|jkr5|j�|jj�Wdd|_|j}|rqd|_|j�XdS)Nr)rrqr[rZrt�flushr$r()rr rrr	r(�s	

			zWave_write.closecCsY|jsU|jstd��|js3td��|jsHtd��|j|�dS)Nz# channels not specifiedzsample width not specifiedzsampling rate not specified)r\r2rr5r7�
_write_header)rZdatasizerrr	rq�s				z!Wave_write._ensure_header_writtencCs:|jjd�|js0||j|j|_|j|j|j|_y|jj�|_Wn!tt	fk
r�d|_YnX|jjt
jdd|jdddt|j|j
|j|j
|j|j|j|jdd��|jdk	r|jj�|_|jjt
jd	|j��d
|_dS)NsRIFFz<L4s4sLHHLLHH4s�$sWAVEsfmt �rQsdataz<LT)rrrrr2r5r[r1�_form_length_pos�AttributeError�OSErrorrS�packrUr7�_data_length_posr\)rZ
initlengthrrr	rw�s$	
zWave_write._write_headercCs�|j|jkrdS|jj�}|jj|jd�|jjtjdd|j��|jj|j	d�|jjtjd|j��|jj|d�|j|_dS)Nrz<Lrx)
rZr[rr1rErzrrrSr}r~)rZcurposrrr	rt�s#zWave_write._patchheaderN)rrrr*r"r+r,r.r^r3r_r6rcr8rdr4rgr:r<rir=rkr@r>r1rsrur(rqrwrtrrrr	rW	s8


rWcCsi|dkr-t|d�r'|j}nd}|dkrCt|�S|dkrYt|�Std��dS)	N�moder#�r�wrXz$mode must be 'r', 'rb', 'w', or 'wb')r�r#)r�rX)�hasattrrrrWr)r)rrrr	r�s

)NrrNr
)r'�__all__�	ExceptionrrUZ_array_fmtsrHrSrFr!r�collectionsrrrrWrrrrrr	�<module>Js	��