Your IP : 3.137.200.56


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

�
��fNyc@s�dZddlZddlZddlZdddgZGdd�de�ZdZdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdZ
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zdd!lmZGd"d#�d#�ZGd$d%�d%�Zed&d�ZeZed'kr�ddlZejd(d�ruejjd)�nejd(Z ee d*�Z!ze"d+e �e"d,e!j#��e"d-e!j$��e"d.e!j%��e"d/e!j&��e"d0e!j'��e"d1e!j(��ejd2d�r�ejd2Z)e"d3e)�ee)d4�Z*zDe*j+e!j,��x*e!j-d5�Z.e.r�Pne*j/e.�qhWde*j0�Xe"d6�nWde!j0�XndS(7uDStuff to parse AIFF-C and AIFF files.

Unless explicitly stated otherwise, the description below is true
both for AIFF-C files and AIFF files.

An AIFF-C file has the following structure.

  +-----------------+
  | FORM            |
  +-----------------+
  | <size>          |
  +----+------------+
  |    | AIFC       |
  |    +------------+
  |    | <chunks>   |
  |    |    .       |
  |    |    .       |
  |    |    .       |
  +----+------------+

An AIFF file has the string "AIFF" instead of "AIFC".

A chunk consists of an identifier (4 bytes) followed by a size (4 bytes,
big endian order), followed by the data.  The size field does not include
the size of the 8 byte header.

The following chunk types are recognized.

  FVER
      <version number of AIFF-C defining document> (AIFF-C only).
  MARK
      <# of markers> (2 bytes)
      list of markers:
          <marker ID> (2 bytes, must be > 0)
          <position> (4 bytes)
          <marker name> ("pstring")
  COMM
      <# of channels> (2 bytes)
      <# of sound frames> (4 bytes)
      <size of the samples> (2 bytes)
      <sampling frequency> (10 bytes, IEEE 80-bit extended
          floating point)
      in AIFF-C files only:
      <compression type> (4 bytes)
      <human-readable version of compression type> ("pstring")
  SSND
      <offset> (4 bytes, not used by this program)
      <blocksize> (4 bytes, not used by this program)
      <sound data>

A pstring consists of 1 byte length, a string of characters, and 0 or 1
byte pad to make the total length even.

Usage.

Reading AIFF files:
  f = aifc.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().
In some types of audio files, if the setpos() method is 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 AIFF files)
  getcompname()   -- returns human-readable version of
             compression type ('not compressed' for AIFF files)
  getparams() -- returns a tuple consisting of all of the
             above in the above order
  getmarkers()    -- get the list of marks in the audio file or None
             if there are no marks
  getmark(id) -- get mark with the specified id (raises an error
             if the mark does not exist)
  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(), the position given to setpos() and
the position of marks are all 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 AIFF files:
  f = aifc.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:
  aiff()      -- create an AIFF file (AIFF-C default)
  aifc()      -- create an AIFF-C file
  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
  setmark(id, pos, name)
          -- add specified mark to the list of marks
  tell()      -- return current position in output file (useful
             in combination with setmark())
  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.
Marks can be added anytime.  If there are any marks, you must call
close() after all frames have been written.
The close() method is called automatically when the class instance
is destroyed.

When a file is opened with the extension '.aiff', an AIFF file is
written, otherwise an AIFF-C file is written.  This default can be
changed by calling aiff() or aifc() before the first writeframes or
writeframesraw.
iNuErroruopenuopenfpcBs|EeZdZdS(uErrorN(u__name__u
__module__u__qualname__(u
__locals__((u)/opt/alt/python33/lib64/python3.3/aifc.pyuError�sl@QEcCsCy!tjd|jd��dSWntjk
r>t�YnXdS(Nu>lii(ustructuunpackureaduerroruEOFError(ufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
_read_long�s!u
_read_longcCsCy!tjd|jd��dSWntjk
r>t�YnXdS(Nu>Lii(ustructuunpackureaduerroruEOFError(ufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_read_ulong�s!u_read_ulongcCsCy!tjd|jd��dSWntjk
r>t�YnXdS(Nu>hii(ustructuunpackureaduerroruEOFError(ufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_read_short�s!u_read_shortcCsCy!tjd|jd��dSWntjk
r>t�YnXdS(Nu>Hii(ustructuunpackureaduerroruEOFError(ufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_read_ushort�s!u_read_ushortcCs_t|jd��}|dkr*d}n|j|�}|d@dkr[|jd�}n|S(Niis(uorduread(ufileulengthudataudummy((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_read_string�s	u_read_stringg�����cCs�t|�}d}|dkr1d
}|d}nt|�}t|�}||kok|kokdknryd}n>|dkr�t}n)|d}|d|td|d	�}||S(Niii�gi�i�?lg@i?i����(u_read_shortu_read_ulongu	_HUGE_VALupow(ufuexponusignuhimantulomant((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_read_float�s
'		
u_read_floatcCs|jtjd|��dS(Nu>h(uwriteustructupack(ufux((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_write_short�su_write_shortcCs|jtjd|��dS(Nu>H(uwriteustructupack(ufux((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
_write_ushort�su
_write_ushortcCs|jtjd|��dS(Nu>l(uwriteustructupack(ufux((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_write_long�su_write_longcCs|jtjd|��dS(Nu>L(uwriteustructupack(ufux((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_write_ulong�su_write_ulongcCswt|�dkr!td��n|jtjdt|���|j|�t|�d@dkrs|jd�ndS(Ni�u%string exceeds maximum pstring lengthuBiis(ulenu
ValueErroruwriteustructupack(ufus((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
_write_string�s
u
_write_stringc	Cshddl}|dkr+d}|d}nd}|dkrRd}d}d}n�|j|�\}}|dks�|dks�||kr�|dB}d}d}n�|d}|dkr�|j||�}d}n||B}|j|d�}|j|�}t|�}|j||d�}|j|�}t|�}t||�t||�t||�dS(	Nii�ii@i�i�?i i����(umathufrexpuldexpuflooruintu
_write_ushortu_write_ulong(	ufuxumathusignuexponuhimantulomantufmantufsmant((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_write_float�s8
	$
	
	


u_write_float(uChunkcBs|EeZdZdd�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-S(.u	Aifc_readcCs�d|_d|_g|_d|_||_t|�}|j�dkrZtd��n|j	d�}|dkr�d|_
n$|dkr�d|_
ntd��d|_x�d|_yt|j�}Wnt
k
r�PYnX|j�}|d	kr|j|�d|_nj|d
krD||_|j	d�}d|_n:|dkrbt|�|_n|d
kr~|j|�n|j�q�|js�|jr�td��ndS(NisFORMu file does not start with FORM idisAIFFsAIFCiunot an AIFF or AIFF-C filesCOMMsSSNDisFVERsMARKu$COMM chunk and/or SSND chunk missing(u_versionuNoneu_convertu_markersu	_soundposu_fileuChunkugetnameuErrorureadu_aifcu_comm_chunk_readu_ssnd_seek_neededuEOFErroru_read_comm_chunku_ssnd_chunku_read_ulongu	_readmarkuskip(uselfufileuchunkuformdatau	chunknameudummy((u)/opt/alt/python33/lib64/python3.3/aifc.pyuinitfp$sH							

	
uAifc_read.initfpcCs5t|t�r$tj|d�}n|j|�dS(Nurb(u
isinstanceustrubuiltinsuopenuinitfp(uselfuf((u)/opt/alt/python33/lib64/python3.3/aifc.pyu__init__KsuAifc_read.__init__cCs|jS(N(u_file(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetfpTsuAifc_read.getfpcCsd|_d|_dS(Nii(u_ssnd_seek_neededu	_soundpos(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyurewindWs	uAifc_read.rewindcCs|jj�dS(N(u_fileuclose(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyuclose[suAifc_read.closecCs|jS(N(u	_soundpos(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyutell^suAifc_read.tellcCs|jS(N(u
_nchannels(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetnchannelsasuAifc_read.getnchannelscCs|jS(N(u_nframes(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
getnframesdsuAifc_read.getnframescCs|jS(N(u
_sampwidth(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetsampwidthgsuAifc_read.getsampwidthcCs|jS(N(u
_framerate(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetframeratejsuAifc_read.getframeratecCs|jS(N(u	_comptype(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetcomptypemsuAifc_read.getcomptypecCs|jS(N(u	_compname(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetcompnamepsuAifc_read.getcompnamecCs:|j�|j�|j�|j�|j�|j�fS(N(ugetnchannelsugetsampwidthugetframerateu
getnframesugetcomptypeugetcompname(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu	getparamsvsuAifc_read.getparamscCs t|j�dkrdS|jS(Ni(ulenu_markersuNone(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
getmarkers{suAifc_read.getmarkerscCsAx%|jD]}||dkr
|Sq
Wtdj|���dS(Niumarker {0!r} does not exist(u_markersuErroruformat(uselfuidumarker((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetmark�suAifc_read.getmarkcCs@|dks||jkr*td��n||_d|_dS(Niuposition not in rangei(u_nframesuErroru	_soundposu_ssnd_seek_needed(uselfupos((u)/opt/alt/python33/lib64/python3.3/aifc.pyusetpos�s	uAifc_read.setposcCs�|jrd|jjd�|jjd�}|j|j}|rX|jj|d�nd|_n|dkrtdS|jj||j�}|jr�|r�|j|�}n|jt|�|j|j	|_|S(Niis(
u_ssnd_seek_neededu_ssnd_chunkuseekureadu	_soundposu
_framesizeu_convertulenu
_nchannelsu
_sampwidth(uselfunframesudummyuposudata((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
readframes�s	uAifc_read.readframescCsddl}|j|d�S(Nii(uaudioopualaw2lin(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu	_alaw2lin�suAifc_read._alaw2lincCsddl}|j|d�S(Nii(uaudioopuulaw2lin(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu	_ulaw2lin�suAifc_read._ulaw2lincCsLddl}t|d�s'd|_n|j|d|j�\}|_|S(Niu_adpcmstatei(uaudioopuhasattruNoneu_adpcmstateu	adpcm2lin(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
_adpcm2lin�s
!uAifc_read._adpcm2lincCs�t|�|_t|�|_t|�dd|_tt|��|_|j|j|_|j	r�d}|j
dkr�d}tjd�d|_
n|j
d�|_|r
t|jj
d��}|d@dkr�|d}n|j
||_
|jjdd�nt|�|_|jd	kr�|jd
krI|j|_nH|jdkrg|j|_n*|jdkr�|j|_ntd��d|_q�nd	|_d|_dS(NiiiiiuWarning: bad COMM chunk sizeiisNONEsG722sulawsULAWsalawsALAWuunsupported compression typeisnot compressedi����(sulawsULAW(salawsALAW(u_read_shortu
_nchannelsu
_read_longu_nframesu
_sampwidthuintu_read_floatu
_framerateu
_framesizeu_aifcu	chunksizeuwarningsuwarnureadu	_comptypeuordufileuseeku_read_stringu	_compnameu
_adpcm2linu_convertu	_ulaw2linu	_alaw2linuError(uselfuchunkukludgeulength((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_read_comm_chunk�s<	

	uAifc_read._read_comm_chunkcCs�t|�}ygx`t|�D]R}t|�}t|�}t|�}|sR|r|jj|||f�qqWWnVtk
r�dt|j�t|j�dkr�dnd|f}tj	|�YnXdS(Nu;Warning: MARK chunk contains only %s marker%s instead of %siuus(
u_read_shorturangeu
_read_longu_read_stringu_markersuappenduEOFErrorulenuwarningsuwarn(uselfuchunkunmarkersuiuiduposunameuw((u)/opt/alt/python33/lib64/python3.3/aifc.pyu	_readmark�s$
*
uAifc_read._readmarkN(u__name__u
__module__u__qualname__uinitfpu__init__ugetfpurewinducloseutellugetnchannelsu
getnframesugetsampwidthugetframerateugetcomptypeugetcompnameu	getparamsu
getmarkersugetmarkusetposu
readframesu	_alaw2linu	_ulaw2linu
_adpcm2linu_read_comm_chunku	_readmark(u
__locals__((u)/opt/alt/python33/lib64/python3.3/aifc.pyu	Aifc_reads,$'	&u	Aifc_readcBs�|EeZdZdd�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�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dES(Fu
Aifc_writecCslt|t�r*|}tj|d�}nd}|j|�|dd�dkr_d|_n	d|_dS(Nuwbu???iu.aiffiii����(u
isinstanceustrubuiltinsuopenuinitfpu_aifc(uselfufufilename((u)/opt/alt/python33/lib64/python3.3/aifc.pyu__init__	s
uAifc_write.__init__cCs�||_t|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
g|_d|_d|_dS(NsNONEsnot compressedii(u_fileu
_AIFC_versionu_versionu	_comptypeu	_compnameuNoneu_convertu
_nchannelsu
_sampwidthu
_framerateu_nframesu_nframeswrittenu_datawrittenu_datalengthu_markersu_marklengthu_aifc(uselfufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyuinitfps														uAifc_write.initfpcCs|j�dS(N(uclose(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu__del__'suAifc_write.__del__cCs%|jrtd��nd|_dS(Nu0cannot change parameters after starting to writei(u_nframeswrittenuErroru_aifc(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyuaiff-s	uAifc_write.aiffcCs%|jrtd��nd|_dS(Nu0cannot change parameters after starting to writei(u_nframeswrittenuErroru_aifc(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyuaifc2s	uAifc_write.aifccCs@|jrtd��n|dkr3td��n||_dS(Nu0cannot change parameters after starting to writeiubad # of channels(u_nframeswrittenuErroru
_nchannels(uselfu	nchannels((u)/opt/alt/python33/lib64/python3.3/aifc.pyusetnchannels7s
	uAifc_write.setnchannelscCs|jstd��n|jS(Nunumber of channels not set(u
_nchannelsuError(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetnchannels>s	uAifc_write.getnchannelscCsL|jrtd��n|dks0|dkr?td��n||_dS(Nu0cannot change parameters after starting to writeiiubad sample width(u_nframeswrittenuErroru
_sampwidth(uselfu	sampwidth((u)/opt/alt/python33/lib64/python3.3/aifc.pyusetsampwidthCs
	uAifc_write.setsampwidthcCs|jstd��n|jS(Nusample width not set(u
_sampwidthuError(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetsampwidthJs	uAifc_write.getsampwidthcCs@|jrtd��n|dkr3td��n||_dS(Nu0cannot change parameters after starting to writeiubad frame rate(u_nframeswrittenuErroru
_framerate(uselfu	framerate((u)/opt/alt/python33/lib64/python3.3/aifc.pyusetframerateOs
	uAifc_write.setframeratecCs|jstd��n|jS(Nuframe rate not set(u
_framerateuError(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetframerateVs	uAifc_write.getframeratecCs%|jrtd��n||_dS(Nu0cannot change parameters after starting to write(u_nframeswrittenuErroru_nframes(uselfunframes((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
setnframes[s	uAifc_write.setnframescCs|jS(N(u_nframeswritten(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
getnframes`suAifc_write.getnframescCsI|jrtd��n|d	kr3td��n||_||_dS(
Nu0cannot change parameters after starting to writesNONEsulawsULAWsalawsALAWsG722uunsupported compression type(sNONEsulawsULAWsalawsALAWsG722(u_nframeswrittenuErroru	_comptypeu	_compname(uselfucomptypeucompname((u)/opt/alt/python33/lib64/python3.3/aifc.pyusetcomptypecs			uAifc_write.setcomptypecCs|jS(N(u	_comptype(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetcomptypelsuAifc_write.getcomptypecCs|jS(N(u	_compname(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetcompnameosuAifc_write.getcompnamecCs�|\}}}}}}|jr0td��n|d	krKtd��n|j|�|j|�|j|�|j|�|j||�dS(
Nu0cannot change parameters after starting to writesNONEsulawsULAWsalawsALAWsG722uunsupported compression type(sNONEsulawsULAWsalawsALAWsG722(u_nframeswrittenuErrorusetnchannelsusetsampwidthusetframerateu
setnframesusetcomptype(uselfuparamsu	nchannelsu	sampwidthu	framerateunframesucomptypeucompname((u)/opt/alt/python33/lib64/python3.3/aifc.pyu	setparamsws		



uAifc_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/aifc.pyu	getparams�suAifc_write.getparamscCs�|dkrtd��n|dkr6td��nt|t�sTtd��nxNtt|j��D]7}||j|dkrj|||f|j|<dSqjW|jj|||f�dS(Niumarker ID must be > 0umarker position must be >= 0umarker name must be bytes(uErroru
isinstanceubytesurangeulenu_markersuappend(uselfuiduposunameui((u)/opt/alt/python33/lib64/python3.3/aifc.pyusetmark�suAifc_write.setmarkcCsAx%|jD]}||dkr
|Sq
Wtdj|���dS(Niumarker {0!r} does not exist(u_markersuErroruformat(uselfuidumarker((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetmark�suAifc_write.getmarkcCs t|j�dkrdS|jS(Ni(ulenu_markersuNone(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
getmarkers�suAifc_write.getmarkerscCs|jS(N(u_nframeswritten(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyutell�suAifc_write.tellcCs�|jt|��t|�|j|j}|jrH|j|�}n|jj|�|j||_|jt|�|_dS(N(	u_ensure_header_writtenulenu
_sampwidthu
_nchannelsu_convertu_fileuwriteu_nframeswrittenu_datawritten(uselfudataunframes((u)/opt/alt/python33/lib64/python3.3/aifc.pyuwriteframesraw�s	uAifc_write.writeframesrawcCsB|j|�|j|jks1|j|jkr>|j�ndS(N(uwriteframesrawu_nframeswrittenu_nframesu_datalengthu_datawrittenu_patchheader(uselfudata((u)/opt/alt/python33/lib64/python3.3/aifc.pyuwriteframes�s
uAifc_write.writeframescCs�|jdkrdSz�|jd�|jd@rS|jjd�|jd|_n|j�|j|jks�|j|jks�|j	r�|j
�nWdd|_|j}d|_|j�XdS(Niis(
u_fileuNoneu_ensure_header_writtenu_datawrittenuwriteu
_writemarkersu_nframeswrittenu_nframesu_datalengthu_marklengthu_patchheaderu_convertuclose(uselfuf((u)/opt/alt/python33/lib64/python3.3/aifc.pyuclose�s 


				uAifc_write.closecCsddl}|j|d�S(Nii(uaudioopulin2alaw(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu	_lin2alaw�suAifc_write._lin2alawcCsddl}|j|d�S(Nii(uaudioopulin2ulaw(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu	_lin2ulaw�suAifc_write._lin2ulawcCsLddl}t|d�s'd|_n|j|d|j�\}|_|S(Niu_adpcmstatei(uaudioopuhasattruNoneu_adpcmstateu	lin2adpcm(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
_lin2adpcm�s
!uAifc_write._lin2adpcmcCs�|js�|jdkrN|js-d|_n|jdkrNtd��qNn|jsftd��n|js~td	��n|js�td
��n|j|�ndS(NsULAWsulawsALAWsalawsG722iuRsample width must be 2 when compressing with ulaw/ULAW, alaw/ALAW or G7.22 (ADPCM)u# channels not specifiedusample width not specifiedusampling rate not specified(sULAWsulawsALAWsalawsG722(u_nframeswrittenu	_comptypeu
_sampwidthuErroru
_nchannelsu
_framerateu
_write_header(uselfudatasize((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_ensure_header_written�s					u!Aifc_write._ensure_header_writtencCs^|jdkr|j|_n<|jdkr<|j|_n|jdkrZ|j|_ndS(NsG722sulawsULAWsalawsALAW(sulawsULAW(salawsALAW(u	_comptypeu
_lin2adpcmu_convertu	_lin2ulawu	_lin2alaw(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_init_compression�suAifc_write._init_compressioncCs(|jr%|jdkr%|j�n|jjd�|jsX||j|j|_n|j|j|j|_|jd@r�|jd|_n|jr&|jdkr�|jd|_|jd@r#|jd|_q#q&|jd	kr&|jd
d|_|jd@r#|jd|_q#q&ny|jj	�|_
Wn!ttfk
r_d|_
YnX|j|j�}|jr�|jjd�|jjd
�t|jd�t|j|j�n|jjd�|jjd�t|j|�t|j|j�|j
dk	r(|jj	�|_nt|j|j�|jdkr]t|jd�nt|j|jd�t|j|j�|jr�|jj|j�t|j|j�n|jjd�|j
dk	r�|jj	�|_nt|j|jd�t|jd�t|jd�dS(NsNONEsFORMisulawsULAWsalawsALAWisG722iisAIFCsFVERsAIFFsCOMMisSSNDi(sulawsULAWsalawsALAW(sULAWsulawsALAWsalawsG722(u_aifcu	_comptypeu_init_compressionu_fileuwriteu_nframesu
_nchannelsu
_sampwidthu_datalengthutellu_form_length_posuAttributeErroruOSErroruNoneu_write_form_lengthu_write_ulongu_versionu_write_shortu_nframes_posu_write_floatu
_framerateu
_write_stringu	_compnameu_ssnd_length_pos(uselfu
initlengthu
commlength((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
_write_header�s^
	
	

		uAifc_write._write_headercCsw|jr<d	t|j�}|d@r3|d}nd}nd}d}t|jd||jd|d|�|S(
Niiiiiiiii(u_aifculenu	_compnameu_write_ulongu_fileu_marklength(uselfu
datalengthu
commlengthu
verslength((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_write_form_length's	

		"uAifc_write._write_form_lengthcCs0|jj�}|jd@r<|jd}|jjd�n	|j}||jkr�|j|jkr�|jdkr�|jj|d�dS|jj|j	d�|j
|�}|jj|jd�t|j|j�|jj|j
d�t|j|d�|jj|d�|j|_||_dS(Nisii(u_fileutellu_datawrittenuwriteu_datalengthu_nframesu_nframeswrittenu_marklengthuseeku_form_length_posu_write_form_lengthu_nframes_posu_write_ulongu_ssnd_length_pos(uselfucurposu
datalengthudummy((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_patchheader4s&

	uAifc_write._patchheadercCst|j�dkrdS|jjd�d}x[|jD]P}|\}}}|t|�dd}t|�d@dkr9|d}q9q9Wt|j|�|d|_t|jt|j��xP|jD]E}|\}}}t|j|�t|j|�t|j|�q�WdS(NisMARKiiii(ulenu_markersu_fileuwriteu_write_ulongu_marklengthu_write_shortu
_write_string(uselfulengthumarkeruiduposuname((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
_writemarkersJs"
uAifc_write._writemarkersN(%u__name__u
__module__u__qualname__u__init__uinitfpu__del__uaiffuaifcusetnchannelsugetnchannelsusetsampwidthugetsampwidthusetframerateugetframerateu
setnframesu
getnframesusetcomptypeugetcomptypeugetcompnameu	setparamsu	getparamsusetmarkugetmarku
getmarkersutelluwriteframesrawuwriteframesucloseu	_lin2alawu	_lin2ulawu
_lin2adpcmu_ensure_header_writtenu_init_compressionu
_write_headeru_write_form_lengthu_patchheaderu
_writemarkers(u
__locals__((u)/opt/alt/python33/lib64/python3.3/aifc.pyu
Aifc_write�sD
	

	3
u
Aifc_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	Aifc_readu
Aifc_writeuError(ufumode((u)/opt/alt/python33/lib64/python3.3/aifc.pyuopen]s	

u__main__iu/usr/demos/data/audio/bach.aiffuruReadingunchannels =unframes   =usampwidth =uframerate =ucomptype  =ucompname  =iuWritinguwiuDone.(1u__doc__ustructubuiltinsuwarningsu__all__u	ExceptionuErroru
_AIFC_versionu
_read_longu_read_ulongu_read_shortu_read_ushortu_read_stringu	_HUGE_VALu_read_floatu_write_shortu
_write_ushortu_write_longu_write_ulongu
_write_stringu_write_floatuchunkuChunku	Aifc_readu
Aifc_writeuNoneuopenuopenfpu__name__usysuargvuappendufnufuprintugetnchannelsu
getnframesugetsampwidthugetframerateugetcomptypeugetcompnameugnugu	setparamsu	getparamsu
readframesudatauwriteframesuclose(((u)/opt/alt/python33/lib64/python3.3/aifc.pyu<module>�sj
!��s






?>