AlkantarClanX12

Your IP : 3.142.156.58


Current Path : /opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/__pycache__/wave.cpython-33.pyo

�
��f�Hc@s�dZddlZdddgZGdd�de�ZdZdZddlZddl	Z	ddl
mZdd
�ZGdd�d�Z
Gdd�d�Zddd�ZeZdS(u
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 tuple 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 pathing 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('') or
close() to patch up the sizes in the header.
The close() method is called automatically when the class instance
is destroyed.
iNuopenuopenfpuErrorcBs|EeZdZdS(uErrorN(u__name__u
__module__u__qualname__(u
__locals__((u)/opt/alt/python33/lib64/python3.3/wave.pyuErrorNsiubuhui(uChunkcCsVt|�}|ddd�|ddd�<|ddd�|ddd�<t|�S(Nii(u	bytearrayubytes(udatauba((u)/opt/alt/python33/lib64/python3.3/wave.pyu
_byteswap3Ys  u
_byteswap3cBs�|EeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(S()u	Wave_readuPVariables 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
    cCsqd|_d|_t|dd�|_|jj�dkrKtd��n|jjd�dkrrtd��nd|_d|_	x�d|_
yt|jdd�}Wntk
r�PYnX|j�}|d	kr�|j|�d|_nM|d
kr=|jstd��n||_	|j
|j|_d|_
Pn|j�q�|js^|j	rmtd��ndS(
Niu	bigendiansRIFFu file does not start with RIFF idisWAVEunot a WAVE fileisfmt sdataudata chunk before fmt chunku#fmt chunk and/or data chunk missing(uNoneu_convertu	_soundposuChunku_fileugetnameuErrorureadu_fmt_chunk_readu_data_chunku_data_seek_neededuEOFErroru_read_fmt_chunku	chunksizeu
_framesizeu_nframesuskip(uselfufileuchunku	chunkname((u)/opt/alt/python33/lib64/python3.3/wave.pyuinitfp~s:					

			
uWave_read.initfpc	Csod|_t|t�r6tj|d�}||_ny|j|�Wn!|jrc|j�n�YnXdS(Nurb(uNoneu_i_opened_the_fileu
isinstanceustrubuiltinsuopenuinitfpuclose(uselfuf((u)/opt/alt/python33/lib64/python3.3/wave.pyu__init__�s		
uWave_read.__init__cCs|j�dS(N(uclose(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyu__del__�suWave_read.__del__cCs|jS(N(u_file(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetfp�suWave_read.getfpcCsd|_d|_dS(Nii(u_data_seek_neededu	_soundpos(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyurewind�s	uWave_read.rewindcCs/|jr"|jj�d|_nd|_dS(N(u_i_opened_the_fileucloseuNoneu_file(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyuclose�s	
uWave_read.closecCs|jS(N(u	_soundpos(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyutell�suWave_read.tellcCs|jS(N(u
_nchannels(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetnchannels�suWave_read.getnchannelscCs|jS(N(u_nframes(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyu
getnframes�suWave_read.getnframescCs|jS(N(u
_sampwidth(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetsampwidth�suWave_read.getsampwidthcCs|jS(N(u
_framerate(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetframerate�suWave_read.getframeratecCs|jS(N(u	_comptype(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetcomptype�suWave_read.getcomptypecCs|jS(N(u	_compname(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetcompname�suWave_read.getcompnamecCs:|j�|j�|j�|j�|j�|j�fS(N(ugetnchannelsugetsampwidthugetframerateu
getnframesugetcomptypeugetcompname(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyu	getparams�suWave_read.getparamscCsdS(N(uNone(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyu
getmarkers�suWave_read.getmarkerscCstd��dS(Nuno marks(uError(uselfuid((u)/opt/alt/python33/lib64/python3.3/wave.pyugetmark�suWave_read.getmarkcCs@|dks||jkr*td��n||_d|_dS(Niuposition not in rangei(u_nframesuErroru	_soundposu_data_seek_needed(uselfupos((u)/opt/alt/python33/lib64/python3.3/wave.pyusetpos�s	uWave_read.setposcCs�|jrT|jjdd�|j|j}|rH|jj|d�nd|_n|dkrddS|jdkrWtjdkrWddl}|j}|jt	|j�}||j
}||j|j|jkr�|j|j|j}n|j
|jj|�|j||j|_|j}|j||j|_|j�|j�}nF|jj||j�}|jdkr�tjdkr�t|�}n|jr�|r�|j|�}n|jt|�|j
|j|_|S(Nisiiubigi(ii(u_data_seek_neededu_data_chunkuseeku	_soundposu
_framesizeu
_sampwidthusysu	byteorderuarrayu_array_fmtsu
_nchannelsu	chunksizeu	size_readufromfileufileubyteswaputobytesureadu
_byteswap3u_convertulen(uselfunframesuposuarrayuchunkudataunitems((u)/opt/alt/python33/lib64/python3.3/wave.pyu
readframes�s8		
	
$uWave_read.readframescCs�tjd|jd��\}|_|_}}|tkrotjd|jd��d}|dd|_ntd|f��|j|j|_d	|_	d
|_
dS(Nu<HHLLHiu<Hiiiiuunknown format: %ruNONEunot compressed(ustructuunpack_fromureadu
_nchannelsu
_framerateuWAVE_FORMAT_PCMu
_sampwidthuErroru
_framesizeu	_comptypeu	_compname(uselfuchunku
wFormatTagudwAvgBytesPerSecuwBlockAlignu	sampwidth((u)/opt/alt/python33/lib64/python3.3/wave.pyu_read_fmt_chunks0	uWave_read._read_fmt_chunkN(u__name__u
__module__u__qualname__u__doc__uinitfpu__init__u__del__ugetfpurewinducloseutellugetnchannelsu
getnframesugetsampwidthugetframerateugetcomptypeugetcompnameu	getparamsu
getmarkersugetmarkusetposu
readframesu_read_fmt_chunk(u
__locals__((u)/opt/alt/python33/lib64/python3.3/wave.pyu	Wave_read_s(
)u	Wave_readcBsR|EeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�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.d/�Zd0d1�Zd2d3�Zd4d5�Zd6S(7u
Wave_writeu�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	Csod|_t|t�r6tj|d�}||_ny|j|�Wn!|jrc|j�n�YnXdS(Nuwb(uNoneu_i_opened_the_fileu
isinstanceustrubuiltinsuopenuinitfpuclose(uselfuf((u)/opt/alt/python33/lib64/python3.3/wave.pyu__init__0s		
uWave_write.__init__cCs^||_d|_d|_d|_d|_d|_d|_d|_d|_	d|_dS(NiF(u_fileuNoneu_convertu
_nchannelsu
_sampwidthu
_framerateu_nframesu_nframeswrittenu_datawrittenu_datalengthuFalseu_headerwritten(uselfufile((u)/opt/alt/python33/lib64/python3.3/wave.pyuinitfp<s									uWave_write.initfpcCs|j�dS(N(uclose(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyu__del__HsuWave_write.__del__cCs@|jrtd��n|dkr3td��n||_dS(Nu0cannot change parameters after starting to writeiubad # of channels(u_datawrittenuErroru
_nchannels(uselfu	nchannels((u)/opt/alt/python33/lib64/python3.3/wave.pyusetnchannelsNs
	uWave_write.setnchannelscCs|jstd��n|jS(Nunumber of channels not set(u
_nchannelsuError(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetnchannelsUs	uWave_write.getnchannelscCsL|jrtd��n|dks0|dkr?td��n||_dS(Nu0cannot change parameters after starting to writeiiubad sample width(u_datawrittenuErroru
_sampwidth(uselfu	sampwidth((u)/opt/alt/python33/lib64/python3.3/wave.pyusetsampwidthZs
	uWave_write.setsampwidthcCs|jstd��n|jS(Nusample width not set(u
_sampwidthuError(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetsampwidthas	uWave_write.getsampwidthcCsL|jrtd��n|dkr3td��ntt|��|_dS(Nu0cannot change parameters after starting to writeiubad frame rate(u_datawrittenuErroruinturoundu
_framerate(uselfu	framerate((u)/opt/alt/python33/lib64/python3.3/wave.pyusetframeratefs
	uWave_write.setframeratecCs|jstd��n|jS(Nuframe rate not set(u
_framerateuError(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetframeratems	uWave_write.getframeratecCs%|jrtd��n||_dS(Nu0cannot change parameters after starting to write(u_datawrittenuErroru_nframes(uselfunframes((u)/opt/alt/python33/lib64/python3.3/wave.pyu
setnframesrs	uWave_write.setnframescCs|jS(N(u_nframeswritten(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyu
getnframeswsuWave_write.getnframescCsI|jrtd��n|dkr3td��n||_||_dS(Nu0cannot change parameters after starting to writeuNONEuunsupported compression type(uNONE(u_datawrittenuErroru	_comptypeu	_compname(uselfucomptypeucompname((u)/opt/alt/python33/lib64/python3.3/wave.pyusetcomptypezs		uWave_write.setcomptypecCs|jS(N(u	_comptype(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetcomptype�suWave_write.getcomptypecCs|jS(N(u	_compname(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyugetcompname�suWave_write.getcompnamecCsx|\}}}}}}|jr0td��n|j|�|j|�|j|�|j|�|j||�dS(Nu0cannot change parameters after starting to write(u_datawrittenuErrorusetnchannelsusetsampwidthusetframerateu
setnframesusetcomptype(uselfuparamsu	nchannelsu	sampwidthu	framerateunframesucomptypeucompname((u)/opt/alt/python33/lib64/python3.3/wave.pyu	setparams�s	



uWave_write.setparamscCsU|js|js|jr-td��n|j|j|j|j|j|jfS(Nunot all parameters set(u
_nchannelsu
_sampwidthu
_framerateuErroru_nframesu	_comptypeu	_compname(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyu	getparams�suWave_write.getparamscCstd��dS(Nusetmark() not supported(uError(uselfuiduposuname((u)/opt/alt/python33/lib64/python3.3/wave.pyusetmark�suWave_write.setmarkcCstd��dS(Nuno marks(uError(uselfuid((u)/opt/alt/python33/lib64/python3.3/wave.pyugetmark�suWave_write.getmarkcCsdS(N(uNone(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyu
getmarkers�suWave_write.getmarkerscCs|jS(N(u_nframeswritten(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyutell�suWave_write.tellcCs<|jt|��t|�|j|j}|jrH|j|�}n|jdkr�tjdkr�ddl}|jt|j�}|j	|�|}|j
�|j|j�|j
t|�|j|_
nS|jdkrtjdkrt|�}n|jj|�|j
t|�|_
|j||_dS(Niiubigii(ii(u_ensure_header_writtenulenu
_sampwidthu
_nchannelsu_convertusysu	byteorderuarrayu_array_fmtsu	frombytesubyteswaputofileu_fileu_datawrittenu
_byteswap3uwriteu_nframeswritten(uselfudataunframesuarrayua((u)/opt/alt/python33/lib64/python3.3/wave.pyuwriteframesraw�s"	

 uWave_write.writeframesrawcCs0|j|�|j|jkr,|j�ndS(N(uwriteframesrawu_datalengthu_datawrittenu_patchheader(uselfudata((u)/opt/alt/python33/lib64/python3.3/wave.pyuwriteframes�s
uWave_write.writeframescCs||jrVz=|jd�|j|jkr8|j�n|jj�Wdd|_Xn|jrx|jj�d|_ndS(Ni(	u_fileu_ensure_header_writtenu_datalengthu_datawrittenu_patchheaderuflushuNoneu_i_opened_the_fileuclose(uself((u)/opt/alt/python33/lib64/python3.3/wave.pyuclose�s	


	
uWave_write.closecCse|jsa|js!td��n|js9td��n|jsQtd��n|j|�ndS(Nu# channels not specifiedusample width not specifiedusampling rate not specified(u_headerwrittenu
_nchannelsuErroru
_sampwidthu
_framerateu
_write_header(uselfudatasize((u)/opt/alt/python33/lib64/python3.3/wave.pyu_ensure_header_written�s				u!Wave_write._ensure_header_writtencCs|jjd�|js3||j|j|_n|j|j|j|_|jj�|_|jjtj	dd|jdddt
|j|j|j|j|j|j|j|jdd��|jj�|_|jjtj	d	|j��d
|_dS(NsRIFFu<L4s4sLHHLLHH4si$sWAVEsfmt iisdatau<LT(u_fileuwriteu_nframesu
_nchannelsu
_sampwidthu_datalengthutellu_form_length_posustructupackuWAVE_FORMAT_PCMu
_framerateu_data_length_posuTrueu_headerwritten(uselfu
initlength((u)/opt/alt/python33/lib64/python3.3/wave.pyu
_write_header�s	
uWave_write._write_headercCs�|j|jkrdS|jj�}|jj|jd�|jjtjdd|j��|jj|j	d�|jjtjd|j��|jj|d�|j|_dS(Niu<Li$(
u_datawrittenu_datalengthu_fileutelluseeku_form_length_posuwriteustructupacku_data_length_pos(uselfucurpos((u)/opt/alt/python33/lib64/python3.3/wave.pyu_patchheader�s#uWave_write._patchheaderN(u__name__u
__module__u__qualname__u__doc__u__init__uinitfpu__del__usetnchannelsugetnchannelsusetsampwidthugetsampwidthusetframerateugetframerateu
setnframesu
getnframesusetcomptypeugetcomptypeugetcompnameu	setparamsu	getparamsusetmarkugetmarku
getmarkersutelluwriteframesrawuwriteframesucloseu_ensure_header_writtenu
_write_headeru_patchheader(u
__locals__((u)/opt/alt/python33/lib64/python3.3/wave.pyu
Wave_writes6

u
Wave_writecCsl|dkr0t|d�r'|j}q0d}n|dkrFt|�S|dkr\t|�Std��dS(	Numodeurburuwuwbu$mode must be 'r', 'rb', 'w', or 'wb'(ururb(uwuwb(uNoneuhasattrumodeu	Wave_readu
Wave_writeuError(ufumode((u)/opt/alt/python33/lib64/python3.3/wave.pyuopen�s	

(NubuhNui(u__doc__ubuiltinsu__all__u	ExceptionuErroruWAVE_FORMAT_PCMuNoneu_array_fmtsustructusysuchunkuChunku
_byteswap3u	Wave_readu
Wave_writeuopenuopenfp(((u)/opt/alt/python33/lib64/python3.3/wave.pyu<module>Hs��