Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.225.234.56
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : sunau.cpython-32.pyc
l
��bc@s�dZdZdZdZdZdZdZdZdZd	Z	d
Z
dZdZd
Z
dZeeeeee
gZGd�de�Zd�Zd�ZGd�d�ZGd�d�Zdd�ZeZdS(u�Stuff to parse Sun and NeXT audio files.

An audio file consists of a header followed by the data.  The structure
of the header is as follows.

        +---------------+
        | magic word    |
        +---------------+
        | header size   |
        +---------------+
        | data size     |
        +---------------+
        | encoding      |
        +---------------+
        | sample rate   |
        +---------------+
        | # of channels |
        +---------------+
        | info          |
        |               |
        +---------------+

The magic word consists of the 4 characters '.snd'.  Apart from the
info field, all header fields are 4 bytes in size.  They are all
32-bit unsigned integers encoded in big-endian byte order.

The header size really gives the start of the data.
The data size is the physical size of the data.  From the other
parameters the number of frames can be calculated.
The encoding gives the way in which audio samples are encoded.
Possible values are listed below.
The info field currently consists of an ASCII string giving a
human-readable description of the audio file.  The info field is
padded with NUL bytes to the header size.

Usage.

Reading audio files:
        f = sunau.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' or 'ULAW')
        getcompname()   -- returns human-readable version of
                           compression type ('not compressed' matches 'NONE')
        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 audio files:
        f = sunau.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.
idns.iiiiiiiiiiiiI����cBs|EeZdS(N(u__name__u
__module__(u
__locals__((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuError�s
uErrorcCsSd}xFtd�D]8}|jd�}|s7t�n|dt|�}qW|S(Niiii(urangeureaduEOFErroruord(ufileuxuiubyte((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu	_read_u32�s	cCseg}xEtd�D]7}t|d�\}}|jdt|��|}qW|jt|��dS(Niii(urangeudivmoduinsertuintuwriteubytes(ufileuxudatauiudum((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu
_write_u32�s
cBs�|EeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�ZdS(cCs\t|�td�krBddl}|j|d�}d|_n	d|_|j|�dS(NuiurbTF(utypeubuiltinsuopenuTrueu_openeduFalseuinitfp(uselfufubuiltins((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu__init__�s	cCs|jr|j�ndS(N(u_fileuclose(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu__del__�s	cCsv||_d|_tt|��}|tkr?td��ntt|��|_|jdkrrtd��n|jdkr�td��nt|�|_|jtkr�t|j�|_ntt|��|_	|j	t
kr�td��n|j	ttfkr d|_
d	|_n�|j	tkrBd	|_|_
nr|j	tkrdd|_|_
nP|j	tkr�d
|_|_
n.|j	tkr�d|_|_
ntd��tt|��|_tt|��|_|j|j|_|jdkri|j|jd�|_xVtt|j��D]3}|j|d
kr/|jd|�|_Pq/q/Wn	d|_dS(Niubad magic numberiuheader size too smalliduheader size ridiculously largeuencoding not (yet) supportediiiiuunknown encodingsu(u_fileu	_soundposuintu	_read_u32uAUDIO_FILE_MAGICuErroru	_hdr_sizeu
_data_sizeuAUDIO_UNKNOWN_SIZEu	_encodingu_simple_encodingsuAUDIO_FILE_ENCODING_MULAW_8uAUDIO_FILE_ENCODING_ALAW_8u
_sampwidthu
_framesizeuAUDIO_FILE_ENCODING_LINEAR_8uAUDIO_FILE_ENCODING_LINEAR_16uAUDIO_FILE_ENCODING_LINEAR_24uAUDIO_FILE_ENCODING_LINEAR_32u
_framerateu
_nchannelsureadu_infourangeulen(uselfufileumagicui((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuinitfp�sN				cCs|jS(N(u_file(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetfp�scCs|jS(N(u
_nchannels(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetnchannels�scCs|jS(N(u
_sampwidth(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetsampwidth�scCs|jS(N(u
_framerate(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetframerate�scCs4|jtkrtS|jtkr0|j|jSdS(Ni(u
_data_sizeuAUDIO_UNKNOWN_SIZEu	_encodingu_simple_encodingsu
_framesize(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu
getnframes�s
cCs.|jtkrdS|jtkr&dSdSdS(NuULAWuALAWuNONE(u	_encodinguAUDIO_FILE_ENCODING_MULAW_8uAUDIO_FILE_ENCODING_ALAW_8(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetcomptype�s
cCs.|jtkrdS|jtkr&dSdSdS(NuCCITT G.711 u-lawuCCITT G.711 A-lawunot compressed(u	_encodinguAUDIO_FILE_ENCODING_MULAW_8uAUDIO_FILE_ENCODING_ALAW_8(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetcompname�s
cCs:|j�|j�|j�|j�|j�|j�fS(N(ugetnchannelsugetsampwidthugetframerateu
getnframesugetcomptypeugetcompname(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu	getparams�scCsdS(N(uNone(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu
getmarkers�scCstd��dS(Nuno marks(uError(uselfuid((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetmark�scCs�|jtkr�|tkr-|jj�}n |jj||j|j�}|jtkr�ddl}|j	||j
�}n|SdS(Ni(u	_encodingu_simple_encodingsuAUDIO_UNKNOWN_SIZEu_fileureadu
_framesizeu
_nchannelsuAUDIO_FILE_ENCODING_MULAW_8uaudioopuulaw2linu
_sampwidthuNone(uselfunframesudatauaudioop((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu
readframes�s cCs d|_|jj|j�dS(Ni(u	_soundposu_fileuseeku	_hdr_size(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyurewinds	cCs|jS(N(u	_soundpos(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyutellscCsX|dks||j�kr-td��n|jj||j|j�||_dS(Niuposition not in range(u
getnframesuErroru_fileuseeku
_framesizeu	_hdr_sizeu	_soundpos(uselfupos((u,/usr/local/python-3.2/lib/python3.2/sunau.pyusetposscCs/|jr"|jr"|jj�nd|_dS(N(u_openedu_fileucloseuNone(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuclosesN(u__name__u
__module__u__init__u__del__uinitfpugetfpugetnchannelsugetsampwidthugetframerateu
getnframesugetcomptypeugetcompnameu	getparamsu
getmarkersugetmarku
readframesurewindutellusetposuclose(u
__locals__((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuAu_read�s$
				+														uAu_readcBs�|EeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS(cCs\t|�td�krBddl}|j|d�}d|_n	d|_|j|�dS(NuiuwbTF(utypeubuiltinsuopenuTrueu_openeduFalseuinitfp(uselfufubuiltins((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu__init__s	cCs#|jr|j�nd|_dS(N(u_fileucloseuNone(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu__del__(s	
cCsg||_d|_d|_d|_d|_t|_d|_d|_d|_	d|_
d|_dS(NisuULAW(u_fileu
_framerateu
_nchannelsu
_sampwidthu
_framesizeuAUDIO_UNKNOWN_SIZEu_nframesu_nframeswrittenu_datawrittenu_datalengthu_infou	_comptype(uselfufile((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuinitfp-s										cCs@|jrtd��n|dkr3td��n||_dS(Nu0cannot change parameters after starting to writeiiiu"only 1, 2, or 4 channels supported(iii(u_nframeswrittenuErroru
_nchannels(uselfu	nchannels((u,/usr/local/python-3.2/lib/python3.2/sunau.pyusetnchannels:s
	cCs|jstd��n|jS(Nunumber of channels not set(u
_nchannelsuError(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetnchannelsAs	cCs@|jrtd��n|dkr3td��n||_dS(Nu0cannot change parameters after starting to writeiiiubad sample width(iii(u_nframeswrittenuErroru
_sampwidth(uselfu	sampwidth((u,/usr/local/python-3.2/lib/python3.2/sunau.pyusetsampwidthFs
	cCs|jstd��n|jS(Nusample width not specified(u
_framerateuErroru
_sampwidth(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetsampwidthMs	cCs%|jrtd��n||_dS(Nu0cannot change parameters after starting to write(u_nframeswrittenuErroru
_framerate(uselfu	framerate((u,/usr/local/python-3.2/lib/python3.2/sunau.pyusetframerateRs	cCs|jstd��n|jS(Nuframe rate not set(u
_framerateuError(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetframerateWs	cCs@|jrtd��n|dkr3td��n||_dS(Nu0cannot change parameters after starting to writeiu# of frames cannot be negative(u_nframeswrittenuErroru_nframes(uselfunframes((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu
setnframes\s
	cCs|jS(N(u_nframeswritten(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu
getnframescscCs(|dkr||_ntd��dS(NuNONEuULAWuunknown compression type(uNONEuULAW(u	_comptypeuError(uselfutypeuname((u,/usr/local/python-3.2/lib/python3.2/sunau.pyusetcomptypefscCs|jS(N(u	_comptype(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetcomptypelscCs.|jdkrdS|jdkr&dSdSdS(NuULAWuCCITT G.711 u-lawuALAWuCCITT G.711 A-lawunot compressed(u	_comptype(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyugetcompnameos
cCs`|\}}}}}}|j|�|j|�|j|�|j|�|j||�dS(N(usetnchannelsusetsampwidthusetframerateu
setnframesusetcomptype(uselfuparamsu	nchannelsu	sampwidthu	framerateunframesucomptypeucompname((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu	setparamsws



cCs:|j�|j�|j�|j�|j�|j�fS(N(ugetnchannelsugetsampwidthugetframerateu
getnframesugetcomptypeugetcompname(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu	getparamsscCs|jS(N(u_nframeswritten(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyutell�scCs�|j�t|�|j}|jdkrPddl}|j||j�}n|jj|�|j	||_	|j
t|�|_
dS(NuULAWi(u_ensure_header_writtenulenu
_framesizeu	_comptypeuaudioopulin2ulawu
_sampwidthu_fileuwriteu_nframeswrittenu_datawritten(uselfudataunframesuaudioop((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuwriteframesraw�s
cCsB|j|�|j|jks1|j|jkr>|j�ndS(N(uwriteframesrawu_nframeswrittenu_nframesu_datalengthu_datawrittenu_patchheader(uselfudata((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuwriteframes�s
cCsw|j�|j|jks.|j|jkr;|j�n|jj�|jrj|jrj|jj	�nd|_dS(N(u_ensure_header_writtenu_nframeswrittenu_nframesu_datalengthu_datawrittenu_patchheaderu_fileuflushu_openeducloseuNone(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuclose�s


cCsb|js^|js!td��n|js9td��n|jsQtd��n|j�ndS(Nu# of channels not specifiedusample width not specifieduframe rate not specified(u_nframeswrittenu
_nchannelsuErroru
_sampwidthu
_framerateu
_write_header(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu_ensure_header_written�s				cCs�|jdkr�|jdkr0t}d|_q�|jdkrQt}d|_q�|jdkrrt}d|_q�td��n-|jdkr�t}d|_ntd��|j|j|_t	|j
t�dt|j
�}|dd@}t	|j
|�|jtkrt}n|j|j}t	|j
|�||_t	|j
|�t	|j
|j�t	|j
|j�|j
j|j
�|j
jd	|t|j
�d
�dS(NuNONEiiiuinternal erroruULAWiisii����(u	_comptypeu
_sampwidthuAUDIO_FILE_ENCODING_LINEAR_8u
_framesizeuAUDIO_FILE_ENCODING_LINEAR_16uAUDIO_FILE_ENCODING_LINEAR_32uErroruAUDIO_FILE_ENCODING_MULAW_8u
_nchannelsu
_write_u32u_fileuAUDIO_FILE_MAGICulenu_infou_nframesuAUDIO_UNKNOWN_SIZEu_datalengthu
_framerateuwrite(uselfuencodinguheader_sizeulength((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu
_write_header�s<		cCsF|jjd�t|j|j�|j|_|jjdd�dS(Niii(u_fileuseeku
_write_u32u_datawrittenu_datalength(uself((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu_patchheader�sN(u__name__u
__module__u__init__u__del__uinitfpusetnchannelsugetnchannelsusetsampwidthugetsampwidthusetframerateugetframerateu
setnframesu
getnframesusetcomptypeugetcomptypeugetcompnameu	setparamsu	getparamsutelluwriteframesrawuwriteframesucloseu_ensure_header_writtenu
_write_headeru_patchheader(u
__locals__((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuAu_writes.
				
															
			
	#uAu_writecCsl|dkr0t|d�r'|j}q0d}n|dkrFt|�S|dkr\t|�Std��dS(	Numodeurburuwuwbu$mode must be 'r', 'rb', 'w', or 'wb'(ururb(uwuwb(uNoneuhasattrumodeuAu_readuAu_writeuError(ufumode((u,/usr/local/python-3.2/lib/python3.2/sunau.pyuopen�s	

N(u__doc__uAUDIO_FILE_MAGICuAUDIO_FILE_ENCODING_MULAW_8uAUDIO_FILE_ENCODING_LINEAR_8uAUDIO_FILE_ENCODING_LINEAR_16uAUDIO_FILE_ENCODING_LINEAR_24uAUDIO_FILE_ENCODING_LINEAR_32uAUDIO_FILE_ENCODING_FLOATuAUDIO_FILE_ENCODING_DOUBLEuAUDIO_FILE_ENCODING_ADPCM_G721uAUDIO_FILE_ENCODING_ADPCM_G722u AUDIO_FILE_ENCODING_ADPCM_G723_3u AUDIO_FILE_ENCODING_ADPCM_G723_5uAUDIO_FILE_ENCODING_ALAW_8uAUDIO_UNKNOWN_SIZEu_simple_encodingsu	ExceptionuErroru	_read_u32u
_write_u32uAu_readuAu_writeuNoneuopenuopenfp(((u,/usr/local/python-3.2/lib/python3.2/sunau.pyu<module>hs6				��
© 2025 GrazzMean