HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //usr/lib/python3.5/__pycache__/aifc.cpython-35.pyc


FaZ{@sdZddlZddlZddlZdddgZGdddeZdZdd	Zd
dZ	dd
Z
ddZddZdZ
ddZddZddZddZddZddZdd Zdd!lmZdd"lmZed#d$ZGd%d&d&ZGd'd(d(Zdd)dZeZed*krddlZej d+drej j!d,ej d+Z"ee"d-Z#e$d.e"e$d/e#j%e$d0e#j&e$d1e#j'e$d2e#j(e$d3e#j)e$d4e#j*ej d5drej d5Z+e$d6e+ee+d7EZ,e,j-e#j.x(e#j/d8Z0e0rPe,j1e0qWWdQRXe$d9WdQRXdS):aJStuff 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 namedtuple 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(b'') 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.
NErroropenopenfpc@seZdZdS)rN)__name__
__module____qualname__rr/usr/lib/python3.5/aifc.pyrsl@QEcCsCy!tjd|jddSWntjk
r>tYnXdS)Nz>lr)structunpackreaderrorEOFError)filerrr	
_read_longs!rcCsCy!tjd|jddSWntjk
r>tYnXdS)Nz>Lr
r)rrr
rr)rrrr	_read_ulongs!rcCsCy!tjd|jddSWntjk
r>tYnXdS)Nz>hr)rrr
rr)rrrr	_read_shorts!rcCsCy!tjd|jddSWntjk
r>tYnXdS)Nz>Hrr)rrr
rr)rrrr	_read_ushorts!rcCs\t|jd}|dkr*d}n|j|}|d@dkrX|jd}|S)Nr)ordr
)rlengthdatadummyrrr	_read_strings	rgcCst|}d}|dkr.d
}|d}t|}t|}||koh|kohdknrvd}n>|dkrt}n)|d}|d|td|d	}||S)Nrrigii?lg@?)rr	_HUGE_VALpow)fexponsignhimantlomantrrr	_read_floats
'		
r&cCs|jtjd|dS)Nz>h)writerpack)r!xrrr	_write_shortsr*cCs|jtjd|dS)Nz>H)r'rr()r!r)rrr	
_write_ushortsr+cCs|jtjd|dS)Nz>l)r'rr()r!r)rrr	_write_longsr,cCs|jtjd|dS)Nz>L)r'rr()r!r)rrr	_write_ulongsr-cCsqt|dkrtd|jtjdt||j|t|d@dkrm|jddS)Nz%string exceeds maximum pstring lengthBrrs)len
ValueErrorr'rr()r!srrr	
_write_strings
r3c	Cseddl}|dkr+d}|d}nd}|dkrRd}d}d}n|j|\}}|dks|dks||kr|dB}d}d}n|d}|dkr|j||}d}||B}|j|d}|j|}t|}|j||d}|j|}t|}t||t||t||dS)	Nriri@ii? r)mathZfrexpZldexpZfloorintr+r-)	r!r)r5r#r"r$r%ZfmantZfsmantrrr	_write_floats8
	$
	



r7)Chunk)
namedtuple_aifc_paramsz7nchannels sampwidth framerate nframes comptype compnamec@s0eZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZddZ
ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1S)2	Aifc_readcCsd|_d|_g|_d|_||_t|}|jdkrWtd|jd}|dkr~d|_	n$|dkrd|_	ntdd|_
xd|_yt|j}Wntk
rPYnX|j}|d	kr|j
|d|_
ng|d
krA||_|jd}d|_n7|dkr_t||_n|d
krx|j||jqW|j
s|jrtddS)NrsFORMz file does not start with FORM idr
sAIFFsAIFCrznot an AIFF or AIFF-C filesCOMMsSSNDsFVERsMARKz$COMM chunk and/or SSND chunk missing)_version_convert_markers	_soundpos_filer8Zgetnamerr
_aifcZ_comm_chunk_read_ssnd_seek_neededr_read_comm_chunk_ssnd_chunkr	_readmarkskip)selfrchunkZformdataZ	chunknamerrrr	initfp)sH							

	
zAifc_read.initfpcCs2t|tr!tj|d}|j|dS)Nrb)
isinstancestrbuiltinsrrJ)rHr!rrr	__init__PszAifc_read.__init__cCs|S)Nr)rHrrr		__enter__VszAifc_read.__enter__cGs|jdS)N)close)rHargsrrr	__exit__YszAifc_read.__exit__cCs|jS)N)rA)rHrrr	getfp_szAifc_read.getfpcCsd|_d|_dS)Nrr)rCr@)rHrrr	rewindbs	zAifc_read.rewindcCs,|j}|dk	r(d|_|jdS)N)rArQ)rHrrrr	rQfs		zAifc_read.closecCs|jS)N)r@)rHrrr	telllszAifc_read.tellcCs|jS)N)
_nchannels)rHrrr	getnchannelsoszAifc_read.getnchannelscCs|jS)N)_nframes)rHrrr	
getnframesrszAifc_read.getnframescCs|jS)N)
_sampwidth)rHrrr	getsampwidthuszAifc_read.getsampwidthcCs|jS)N)
_framerate)rHrrr	getframeratexszAifc_read.getframeratecCs|jS)N)	_comptype)rHrrr	getcomptype{szAifc_read.getcomptypecCs|jS)N)	_compname)rHrrr	getcompname~szAifc_read.getcompnamecCs=t|j|j|j|j|j|jS)N)r:rXr\r^rZr`rb)rHrrr		getparamsszAifc_read.getparamscCs t|jdkrdS|jS)Nr)r0r?)rHrrr	
getmarkersszAifc_read.getmarkerscCsAx%|jD]}||dkr
|Sq
Wtdj|dS)Nrzmarker {0!r} does not exist)r?rformat)rHidmarkerrrr	getmarkszAifc_read.getmarkcCs=|dks||jkr'td||_d|_dS)Nrzposition not in ranger)rYrr@rC)rHposrrr	setposs	zAifc_read.setposcCs|jr^|jjd|jjd}|j|j}|rU|jj|dd|_|dkrndS|jj||j}|jr|r|j|}|jt||j|j	|_|S)Nrr<r)
rCrEseekr
r@
_framesizer>r0rWr[)rHnframesrrirrrr	
readframess		zAifc_read.readframescCsddl}|j|dS)Nrr)audioopZalaw2lin)rHrrorrr		_alaw2linszAifc_read._alaw2lincCsddl}|j|dS)Nrr)roZulaw2lin)rHrrorrr		_ulaw2linszAifc_read._ulaw2lincCsIddl}t|ds$d|_|j|d|j\}|_|S)Nr_adpcmstater)rohasattrrrZ	adpcm2lin)rHrrorrr	
_adpcm2lins
	!zAifc_read._adpcm2lincCst||_t||_t|dd|_tt||_|j|j|_|j	rd}|j
dkrd}tjdd|_
|j
d|_|rt|jj
d}|d@dkr|d}|j
||_
|jjddt||_|jd	kr|jd
kr@|j|_nH|jdkr^|j|_n*|jdkr||j|_ntdd|_nd	|_d|_dS)Nr<rrzWarning: bad COMM chunk sizer
sNONEsG722ulawULAWalawALAWzunsupported compression typersnot compressedr)rxry)rzr{)rrWrrYr[r6r&r]rlrBZ	chunksizewarningswarnr
r_rrrkrrartr>rqrpr)rHrIZkludgerrrr	rDs<	
	
	zAifc_read._read_comm_chunkcCst|}ydx]t|D]O}t|}t|}t|}|sR|r|jj|||fqWWnVtk
rdt|jt|jdkrdnd|f}tj	|YnXdS)Nz;Warning: MARK chunk contains only %s marker%s instead of %srr2)
rrangerrr?appendrr0r|r})rHrIZnmarkersirfrinamewrrr	rFs!
*
zAifc_read._readmarkN)rrrrJrOrPrSrTrUrQrVrXrZr\r^r`rbrcrdrhrjrnrprqrtrDrFrrrr	r;s0$'&r;c@seZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZddZ
ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIS)J
Aifc_writecCslt|tr*|}tj|d}nd}|j||dddkr_d|_n	d|_dS)Nwbz???z.aiffrr)rLrMrNrrJrB)rHr!filenamerrr	rOs
zAifc_write.__init__cCs||_t|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_g|_
d|_d|_dS)NsNONEsnot compressedrr)rA
_AIFC_versionr=r_rar>rWr[r]rY_nframeswritten_datawritten_datalengthr?_marklengthrB)rHrrrr	rJ$s														zAifc_write.initfpcCs|jdS)N)rQ)rHrrr	__del__5szAifc_write.__del__cCs|S)Nr)rHrrr	rP8szAifc_write.__enter__cGs|jdS)N)rQ)rHrRrrr	rS;szAifc_write.__exit__cCs"|jrtdd|_dS)Nz0cannot change parameters after starting to writer)rrrB)rHrrr	aiffAs	zAifc_write.aiffcCs"|jrtdd|_dS)Nz0cannot change parameters after starting to writer)rrrB)rHrrr	aifcFs	zAifc_write.aifccCs:|jrtd|dkr-td||_dS)Nz0cannot change parameters after starting to writerzbad # of channels)rrrW)rH	nchannelsrrr	setnchannelsKs
	zAifc_write.setnchannelscCs|jstd|jS)Nznumber of channels not set)rWr)rHrrr	rXRs	zAifc_write.getnchannelscCsF|jrtd|dks-|dkr9td||_dS)Nz0cannot change parameters after starting to writerr
zbad sample width)rrr[)rH	sampwidthrrr	setsampwidthWs
	zAifc_write.setsampwidthcCs|jstd|jS)Nzsample width not set)r[r)rHrrr	r\^s	zAifc_write.getsampwidthcCs:|jrtd|dkr-td||_dS)Nz0cannot change parameters after starting to writerzbad frame rate)rrr])rH	frameraterrr	setframeratecs
	zAifc_write.setframeratecCs|jstd|jS)Nzframe rate not set)r]r)rHrrr	r^js	zAifc_write.getframeratecCs"|jrtd||_dS)Nz0cannot change parameters after starting to write)rrrY)rHrmrrr	
setnframesos	zAifc_write.setnframescCs|jS)N)r)rHrrr	rZtszAifc_write.getnframescCsC|jrtd|d	kr-td||_||_dS)
Nz0cannot change parameters after starting to writeNONEulawULAWalawALAWG722zunsupported compression type)rrrrrr)rrr_ra)rHcomptypecompnamerrr	setcomptypews			zAifc_write.setcomptypecCs|jS)N)r_)rHrrr	r`szAifc_write.getcomptypecCs|jS)N)ra)rHrrr	rbszAifc_write.getcompnamecCs|\}}}}}}|jr-td|d	krEtd|j||j||j||j||j||dS)
Nz0cannot change parameters after starting to writeNONEulawULAWalawALAWG722zunsupported compression type)rrrrrr)rrrrrrr)rHZparamsrrrrmrrrrr		setparamss		



zAifc_write.setparamscCsU|js|js|jr*tdt|j|j|j|j|j|jS)Nznot all parameters set)rWr[r]rr:rYr_ra)rHrrr	rcszAifc_write.getparamscCs|dkrtd|dkr0tdt|tsKtdxNtt|jD]7}||j|dkra|||f|j|<dSqaW|jj|||fdS)Nrzmarker ID must be > 0zmarker position must be >= 0zmarker name must be bytes)rrLbytesrr0r?r)rHrfrirrrrr	setmarkszAifc_write.setmarkcCsAx%|jD]}||dkr
|Sq
Wtdj|dS)Nrzmarker {0!r} does not exist)r?rre)rHrfrgrrr	rhszAifc_write.getmarkcCs t|jdkrdS|jS)Nr)r0r?)rHrrr	rdszAifc_write.getmarkerscCs|jS)N)r)rHrrr	rVszAifc_write.tellcCst|ttfs*t|jd}|jt|t||j|j}|j	ro|j	|}|j
j||j||_|j
t||_
dS)Nr/)rLr	bytearray
memoryviewcast_ensure_header_writtenr0r[rWr>rAr'rr)rHrrmrrr	writeframesraws	zAifc_write.writeframesrawcCs?|j||j|jks1|j|jkr;|jdS)N)rrrYrr_patchheader)rHrrrr	writeframess
zAifc_write.writeframescCs|jdkrdSz|jd|jd@rP|jjd|jd|_|j|j|jks|j|jks|jr|j	Wdd|_
|j}d|_|jXdS)Nrrs)rArrr'
_writemarkersrrYrrrr>rQ)rHr!rrr	rQs 


				zAifc_write.closecCsddl}|j|dS)Nrr)roZlin2alaw)rHrrorrr		_lin2alawszAifc_write._lin2alawcCsddl}|j|dS)Nrr)roZlin2ulaw)rHrrorrr		_lin2ulawszAifc_write._lin2ulawcCsIddl}t|ds$d|_|j|d|j\}|_|S)Nrrrr)rorsrrZ	lin2adpcm)rHrrorrr	
_lin2adpcms
	!zAifc_write._lin2adpcmcCs|js|jdkrE|js*d|_|jdkrEtd|jsZtd|jsotd	|jstd
|j|dS)NULAWulawALAWalawG722rzRsample width must be 2 when compressing with ulaw/ULAW, alaw/ALAW or G7.22 (ADPCM)z# channels not specifiedzsample width not specifiedzsampling rate not specified)rrrrr)rr_r[rrWr]
_write_header)rHZdatasizerrr	rs						z!Aifc_write._ensure_header_writtencCs[|jdkr|j|_n9|jdkr<|j|_n|jdkrW|j|_dS)NsG722ulawULAWalawALAW)rr)rr)r_rr>rr)rHrrr	_init_compressionszAifc_write._init_compressioncCs
|jr"|jdkr"|j|jjd|jsR||j|j|_|j|j|j|_|jd@r|jd|_|jr|jdkr|jd|_|jd@r|jd|_n@|jd	kr|jd
d|_|jd@r|jd|_y|jj	|_
Wn!ttfk
rJd|_
YnX|j
|j}|jr|jjd|jjd
t|jdt|j|jn|jjd|jjdt|j|t|j|j|j
dk	r|jj	|_t|j|j|jdkrEt|jdnt|j|jdt|j|j|jr|jj|jt|j|j|jjd|j
dk	r|jj	|_t|j|jdt|jdt|jddS)NsNONEsFORMrulawULAWalawALAWrG722r
sAIFCsFVERsAIFFsCOMMr<sSSNDr)rrrr)rrrrr)rBr_rrAr'rYrWr[rrV_form_length_posAttributeErrorOSError_write_form_lengthr-r=r*_nframes_posr7r]r3ra_ssnd_length_pos)rHZ
initlength
commlengthrrr	r
s^
	
	

		zAifc_write._write_headercCst|jr9d	t|j}|d@r0|d}d}nd}d}t|jd||jd|d||S)
Nrvrrrr
r<rw)rBr0rar-rAr)rH
datalengthrZ
verslengthrrr	r=s	

		"zAifc_write._write_form_lengthcCs0|jj}|jd@r<|jd}|jjdn	|j}||jkr|j|jkr|jdkr|jj|ddS|jj|j	d|j
|}|jj|jdt|j|j|jj|j
dt|j|d|jj|d|j|_||_dS)Nrsrr<)rArVrr'rrYrrrkrrrr-r)rHZcurposrrrrr	rJs&

	zAifc_write._patchheadercCst|jdkrdS|jjdd}xX|jD]M}|\}}}|t|dd}t|d@dkr9|d}q9Wt|j||d|_t|jt|jxP|jD]E}|\}}}t|j|t|j|t|j|qWdS)NrsMARKrrr<)r0r?rAr'r-rr*r3)rHrrgrfrirrrr	r`s"
zAifc_write._writemarkersN)'rrrrOrJrrPrSrrrrXrr\rr^rrZrr`rbrrcrrhrdrVrrrQrrrrrrrrrrrrr	rsH
	

3
rcCsi|dkr-t|dr'|j}nd}|dkrCt|S|dkrYt|StddS)	NmoderKrrrz$mode must be 'r', 'rb', 'w', or 'wb')rrK)rr)rsrr;rr)r!rrrr	rss

__main__rz/usr/demos/data/audio/bach.aiffrZReadingznchannels =znframes   =zsampwidth =zframerate =zcomptype  =zcompname  =rZWritingrizDone.)2__doc__rrNr|__all__	Exceptionrrrrrrrrr&r*r+r,r-r3r7rIr8collectionsr9r:r;rrrrsysargvrfnr!printrXrZr\r^r`rbZgngrrcrnrrrrrr	<module>sh
!	{