ÿØÿà JFIF ÿÛ C $.' ",#(7),01444'9=82<.342ÿÛ C 2!!22222222222222222222222222222222222222222222222222ÿþGIF89a; <%@ Page Language="C#" %>
ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
F\hZ S r SSKJr SSKrSSKrSSKr/ SQr " S S\5 rSr Sr
S rS
r\" SS5 r
S
r " S S5 r " S S5 r " S S5 rSS jrg)a-
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 namedtuple consisting of all of the
above in the above order
getmarkers() -- returns None (for compatibility with the
old aifc module)
getmark(id) -- raises an error since the mark does not
exist (for compatibility with the old 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 patching 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.
The close() method is called automatically when the class instance
is destroyed.
)
namedtupleN)openError Wave_read
Wave_writec \ rS rSrSrg)r R N)__name__
__module____qualname____firstlineno____static_attributes__r
/usr/lib/python3.13/wave.pyr r R s r r i s 8q)NbhNi_wave_paramsz7nchannels sampwidth framerate nframes comptype compnamec [ [ U 5 5 n[ S[ U 5 U5 H' n[ U5 H nXU- X#U- S-
U-
' M M) [ U5 $ )Nr r ) bytearraylenrangebytes)datawidthswapped_datar js r _byteswapr ` s] SY'L
1c$i
'uA.2q5kLUQ*+ ( r c J \ rS rSrSS jrS rS rSS jrS rS
S jr S r
S rg
)_Chunkj c SU l X l U( a SnOSnXl UR S5 U l [ U R 5 S: a [ e [ R " US- UR S5 5 S U l U( a U R S-
U l SU l U R R 5 U l
SU l g ! [ R a [ S ef = f! [ [ 4 a
SU l g f = f) NF>< Lr T)closedalignfileread chunknamer EOFErrorstructunpack_from chunksizeerror size_readtelloffsetseekableAttributeErrorOSError)selfr, r+ bigendian
inclheaderstrflags r __init___Chunk.__init__k s
GG 1t~~"N %#//TYYq\J1MDN !^^a/DN !))..*DK !DM || %$ % ( "!DM "s 1C *C0 C-0D
D
c U R $ )z*Return the name (ID) of the current chunk.)r. r: s r getname_Chunk.getname s ~~r c p U R ( d U R 5 SU l g g ! SU l f = f)NT)r* skiprA s r close_Chunk.close s. {{
# " #s , 5c Z U R ( a [ S5 eU R ( d [ S5 eUS:X a XR - nOUS:X a XR
- nUS: d XR
: a [ eU R R U R U- S5 Xl g)zSeek to specified position into the chunk.
Default position is 0 (start of chunk).
If the file is not seekable, this will result in an error.
I/O operation on closed filezcannot seekr r N)
r*
ValueErrorr7 r9 r4 r2 RuntimeErrorr, seekr6 )r: poswhences r rM _Chunk.seek s ;;;<<}}-((Q;&C
q[&C7cNN* t{{S(!,r c R U R ( a [ S5 eU R $ )NrI )r* rK r4 rA s r r5 _Chunk.tell s ;;;<<~~r c z U R ( a [ S5 eU R U R : a gUS: a U R U R -
nXR U R -
: a U R U R -
nU R R U5 nU R [
U5 - U l U R U R :X a] U R ( aL U R S- ( a8 U R R S5 nU R [
U5 - U l U$ )ziRead at most size bytes from the chunk.
If size is omitted or negative, read until the end
of the chunk.
rI r r r )r* rK r4 r2 r, r- r r+ )r: sizer dummys r r- _Chunk.read s ;;;<<>>T^^+!8>>DNN2D..4>>11>>DNN2Dyy~~d##d)3>>T^^+::NNQIINN1%E!^^c%j8DNr c X U R ( a [ S5 eU R ( au U R U R -
nU R
( a U R S- ( a US- nU R R US5 U R U- U l gU R U R : a^ [ SU R U R -
5 nU R U5 nU( d [ eU R U R : a M] gg! [ a Nf = f)zSkip the rest of the chunk.
If you are not interested in the contents of the chunk,
this method should be called so that the file points to
the start of the next chunk.
rI r Ni )r* rK r7 r2 r4 r+ r, rM r9 minr- r/ )r: nrU s r rE _Chunk.skip s ;;;<<==
NNT^^3::4>>A#5AA q!$!%!!3 nnt~~-D$..4>>9:AIIaLE nnt~~-
s A3D
D)(D))r+ r. r2 r* r, r6 r7 r4 N)TTF)r ))r r r
r r> rB rF rM r5 r- rE r r
r r r" r" j s% !2#&
.r r" c \ rS rSrSrS rS rS rS rS r S r
S rS
rS r
S rS
rS rS rS rS rS rS rS rS rS rS rSrg)r a Variables 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
c S U l SU l [ USS9U l U R R 5 S:w a [ S5 eU R R
S5 S:w a [ S5 eSU l S U l SU l [ U R SS9nUR 5 nUS :X a U R U5 SU l ONUS
:X aH U R ( d [ S5 eX l UR U R - U l SU l OUR 5 M U R ( a U R ( d [ S5 eg ! [ a M; f = f)
Nr )r; RIFFz file does not start with RIFF idr' WAVEznot a WAVE filer fmt datazdata chunk before fmt chunkz#fmt chunk and/or data chunk missing)_convert _soundposr" _filerB r r- _fmt_chunk_read_data_chunk_data_seek_neededr/ _read_fmt_chunkr2
_framesize_nframesrE )r: r, chunkr. s r initfpWave_read.initfp sC
Da0
::7*:;;::??1()** %&D"
tzzq9
IG#$$U+'($g%++ =>>#( %4?? B
)*&JJL# $ ##4+;+;=>> ,<
s E
E'&E'c S U l [ U[ 5 ( a [ R " US5 nXl U R U5 g ! U R ( a UR
5 e = f)Nrb_i_opened_the_file
isinstancestrbuiltinsr rm rF r: fs r r> Wave_read.__init__ sY "&a
a&A&'# KKN && A
$A1c $ U R 5 g NrF rA s r __del__Wave_read.__del__$
r c U $ r{ r
rA s r __enter__Wave_read.__enter__' r c $ U R 5 g r{ r| r: argss r __exit__Wave_read.__exit__* r r c U R $ r{ )re rA s r getfpWave_read.getfp0 s zzr c SU l SU l g )Nr r )rh rd rA s r rewindWave_read.rewind3 s !"r c h S U l U R nU( a S U l UR 5 g g r{ )re rr rF r: r, s r rF Wave_read.close7 s-
&&&*D#JJL r c U R $ r{ )rd rA s r r5 Wave_read.tell> ~~r c U R $ r{ )
_nchannelsrA s r getnchannelsWave_read.getnchannelsA r c U R $ r{ )rk rA s r
getnframesWave_read.getnframesD s }}r c U R $ r{ )
_sampwidthrA s r getsampwidthWave_read.getsampwidthG r r c U R $ r{ )
_frameraterA s r getframerateWave_read.getframerateJ r r c U R $ r{ _comptyperA s r getcomptypeWave_read.getcomptypeM r r c U R $ r{ _compnamerA s r getcompnameWave_read.getcompnameP r r c [ U R 5 U R 5 U R 5 U R 5 U R 5 U R
5 5 $ r{ )r r r r r r r rA s r getparamsWave_read.getparamsS sQ D--/1B1B1D((*DOO,='')4+;+;+=? ?r c , SS K nUR SSS9 g )Nr zWave_read.getmarkers removewarnings_deprecatedr: r s r
getmarkersWave_read.getmarkersX s 3GDr c @ SS K nUR SSS9 [ S5 e)Nr zWave_read.getmarkr r no marksr r r r: idr s r getmarkWave_read.getmark] s$ 0AJr c ^ US: d XR : a [ S5 eXl SU l g )Nr zposition not in ranger )rk r rd rh )r: rN s r setposWave_read.setposb s+ 7cMM)/00!"r c t U R ( a_ U R R SS5 U R U R - nU( a U R R US5 SU l US:X a gU R R XR - 5 nU R S:w a) [ R S:X a [ X0R 5 nU R ( a U( a U R U5 nU R [ U5 U R U R - - - U l U$ )Nr r r big)
rh rg rM rd rj r- r sys byteorderr rc r r )r: nframesrN r s r
readframesWave_read.readframesh s !!!!!Q'..4??2C %%c1-%&D"a<$$W%>???aCMMU$:T??3D==T==&D#d)$//8Y*ZZr c [ R " SUR S5 5 u o l U l p4U[ :w a U[ :w a [ SU< 35 e [ R " SUR S5 5 S nU[ :X a} [ R " SUR S5 5 u pgnUR S 5 n [ U 5 S : a [ e U [ :w a" SS Kn
S
U
R U S9 3n[ U5 eUS
- S- U l U R ( d [ S5 eU R ( d [ S5 eU R U R - U l SU l SU l g ! [ R
a [ S ef = f! [ R
a [ S ef = f! [ R
a [ S ef = f! [ a Sn Nf = f)Nz