/snap/core22/2437/usr/lib/python3.10/__pycache__
NameSizeModeActions
abc.cpython-310.pyc67510644editdlrm
aifc.cpython-310.pyc246850644editdlrm
antigravity.cpython-310.pyc8220644editdlrm
argparse.cpython-310.pyc635390644editdlrm
ast.cpython-310.pyc557390644editdlrm
asynchat.cpython-310.pyc70250644editdlrm
asyncore.cpython-310.pyc160020644editdlrm
base64.cpython-310.pyc171620644editdlrm
bdb.cpython-310.pyc258320644editdlrm
binhex.cpython-310.pyc128700644editdlrm
bisect.cpython-310.pyc25880644editdlrm
bz2.cpython-310.pyc108700644editdlrm
calendar.cpython-310.pyc263030644editdlrm
cgi.cpython-310.pyc267230644editdlrm
cgitb.cpython-310.pyc99980644editdlrm
chunk.cpython-310.pyc48600644editdlrm
cmd.cpython-310.pyc127070644editdlrm
code.cpython-310.pyc99570644editdlrm
codecs.cpython-310.pyc332190644editdlrm
codeop.cpython-310.pyc55950644editdlrm
colorsys.cpython-310.pyc32650644editdlrm
compileall.cpython-310.pyc127330644editdlrm
configparser.cpython-310.pyc454580644editdlrm
contextlib.cpython-310.pyc208950644editdlrm
contextvars.cpython-310.pyc2460644editdlrm
copy.cpython-310.pyc69960644editdlrm
copyreg.cpython-310.pyc46830644editdlrm
cProfile.cpython-310.pyc51130644editdlrm
crypt.cpython-310.pyc35500644editdlrm
csv.cpython-310.pyc117980644editdlrm
dataclasses.cpython-310.pyc265780644editdlrm
datetime.cpython-310.pyc565330644editdlrm
decimal.cpython-310.pyc3620644editdlrm
difflib.cpython-310.pyc589050644editdlrm
dis.cpython-310.pyc156560644editdlrm
doctest.cpython-310.pyc761750644editdlrm
enum.cpython-310.pyc260630644editdlrm
filecmp.cpython-310.pyc87490644editdlrm
fileinput.cpython-310.pyc140720644editdlrm
fnmatch.cpython-310.pyc42440644editdlrm
fractions.cpython-310.pyc186000644editdlrm
ftplib.cpython-310.pyc289770644editdlrm
functools.cpython-310.pyc283350644editdlrm
genericpath.cpython-310.pyc39070644editdlrm
getopt.cpython-310.pyc63390644editdlrm
getpass.cpython-310.pyc42100644editdlrm
gettext.cpython-310.pyc182210644editdlrm
glob.cpython-310.pyc58520644editdlrm
graphlib.cpython-310.pyc76160644editdlrm
gzip.cpython-310.pyc185460644editdlrm
hashlib.cpython-310.pyc68450644editdlrm
heapq.cpython-310.pyc138650644editdlrm
hmac.cpython-310.pyc69730644editdlrm
imaplib.cpython-310.pyc423120644editdlrm
imghdr.cpython-310.pyc39050644editdlrm
imp.cpython-310.pyc97860644editdlrm
inspect.cpython-310.pyc851530644editdlrm
io.cpython-310.pyc36630644editdlrm
ipaddress.cpython-310.pyc626700644editdlrm
keyword.cpython-310.pyc9270644editdlrm
linecache.cpython-310.pyc41420644editdlrm
locale.cpython-310.pyc461540644editdlrm
lzma.cpython-310.pyc121000644editdlrm
mailbox.cpython-310.pyc600910644editdlrm
mailcap.cpython-310.pyc73200644editdlrm
mimetypes.cpython-310.pyc176190644editdlrm
modulefinder.cpython-310.pyc161660644editdlrm
netrc.cpython-310.pyc39330644editdlrm
nntplib.cpython-310.pyc316230644editdlrm
ntpath.cpython-310.pyc147040644editdlrm
nturl2path.cpython-310.pyc17470644editdlrm
numbers.cpython-310.pyc118660644editdlrm
opcode.cpython-310.pyc54470644editdlrm
operator.cpython-310.pyc135080644editdlrm
optparse.cpython-310.pyc477540644editdlrm
os.cpython-310.pyc315990644editdlrm
pathlib.cpython-310.pyc420520644editdlrm
pdb.cpython-310.pyc474400644editdlrm
pickle.cpython-310.pyc468820644editdlrm
pickletools.cpython-310.pyc677600644editdlrm
pipes.cpython-310.pyc77690644editdlrm
pkgutil.cpython-310.pyc183610644editdlrm
platform.cpython-310.pyc274290644editdlrm
plistlib.cpython-310.pyc237650644editdlrm
poplib.cpython-310.pyc135730644editdlrm
posixpath.cpython-310.pyc105600644editdlrm
pprint.cpython-310.pyc178750644editdlrm
profile.cpython-310.pyc143910644editdlrm
pstats.cpython-310.pyc236210644editdlrm
pty.cpython-310.pyc41430644editdlrm
pyclbr.cpython-310.pyc97750644editdlrm
pydoc.cpython-310.pyc856450644editdlrm
py_compile.cpython-310.pyc73390644editdlrm
queue.cpython-310.pyc107920644editdlrm
quopri.cpython-310.pyc57940644editdlrm
random.cpython-310.pyc227480644editdlrm
re.cpython-310.pyc142270644editdlrm
reprlib.cpython-310.pyc52500644editdlrm
rlcompleter.cpython-310.pyc59540644editdlrm
runpy.cpython-310.pyc94110644editdlrm
sched.cpython-310.pyc61150644editdlrm
secrets.cpython-310.pyc21750644editdlrm
selectors.cpython-310.pyc171050644editdlrm
shelve.cpython-310.pyc94920644editdlrm
shlex.cpython-310.pyc77820644editdlrm
shutil.cpython-310.pyc385360644editdlrm
signal.cpython-310.pyc29350644editdlrm
site.cpython-310.pyc179220644editdlrm
sitecustomize.cpython-310.pyc2250644editdlrm
smtpd.cpython-310.pyc261470644editdlrm
smtplib.cpython-310.pyc357660644editdlrm
sndhdr.cpython-310.pyc69620644editdlrm
socket.cpython-310.pyc289630644editdlrm
socketserver.cpython-310.pyc253470644editdlrm
sre_compile.cpython-310.pyc151940644editdlrm
sre_constants.cpython-310.pyc63570644editdlrm
sre_parse.cpython-310.pyc217550644editdlrm
ssl.cpython-310.pyc452710644editdlrm
stat.cpython-310.pyc42730644editdlrm
statistics.cpython-310.pyc370510644editdlrm
string.cpython-310.pyc71020644editdlrm
stringprep.cpython-310.pyc170750644editdlrm
struct.cpython-310.pyc3070644editdlrm
subprocess.cpython-310.pyc447410644editdlrm
sunau.cpython-310.pyc164820644editdlrm
symtable.cpython-310.pyc128350644editdlrm
sysconfig.cpython-310.pyc181510644editdlrm
tabnanny.cpython-310.pyc69500644editdlrm
tarfile.cpython-310.pyc706740644editdlrm
telnetlib.cpython-310.pyc185060644editdlrm
tempfile.cpython-310.pyc273390644editdlrm
textwrap.cpython-310.pyc138120644editdlrm
this.cpython-310.pyc12640644editdlrm
threading.cpython-310.pyc449690644editdlrm
timeit.cpython-310.pyc117690644editdlrm
token.cpython-310.pyc27380644editdlrm
tokenize.cpython-310.pyc171940644editdlrm
trace.cpython-310.pyc198700644editdlrm
traceback.cpython-310.pyc217120644editdlrm
tracemalloc.cpython-310.pyc175250644editdlrm
tty.cpython-310.pyc10790644editdlrm
turtle.cpython-310.pyc1288570644editdlrm
types.cpython-310.pyc95250644editdlrm
typing.cpython-310.pyc852770644editdlrm
uu.cpython-310.pyc38670644editdlrm
uuid.cpython-310.pyc224980644editdlrm
warnings.cpython-310.pyc136460644editdlrm
wave.cpython-310.pyc175940644editdlrm
weakref.cpython-310.pyc203430644editdlrm
webbrowser.cpython-310.pyc170000644editdlrm
xdrlib.cpython-310.pyc78800644editdlrm
zipapp.cpython-310.pyc60130644editdlrm
zipfile.cpython-310.pyc618450644editdlrm
zipimport.cpython-310.pyc170330644editdlrm
_aix_support.cpython-310.pyc28790644editdlrm
_bootsubprocess.cpython-310.pyc22940644editdlrm
_collections_abc.cpython-310.pyc329250644editdlrm
_compat_pickle.cpython-310.pyc58720644editdlrm
_compression.cpython-310.pyc45120644editdlrm
_distutils_system_mod.cpython-310.pyc54220644editdlrm
_markupbase.cpython-310.pyc75720644editdlrm
_osx_support.cpython-310.pyc115350644editdlrm
_pydecimal.cpython-310.pyc1577360644editdlrm
_pyio.cpython-310.pyc736540644editdlrm
_py_abc.cpython-310.pyc46830644editdlrm
_sitebuiltins.cpython-310.pyc35470644editdlrm
_strptime.cpython-310.pyc159450644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-310.pyc353850644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-310.pyc353790644editdlrm
_threading_local.cpython-310.pyc65390644editdlrm
_weakrefset.cpython-310.pyc76080644editdlrm
__future__.cpython-310.pyc41310644editdlrm
__phello__.foo.cpython-310.pyc1300644editdlrm
Edit: /snap/core22/2437/usr/lib/python3.10/__pycache__/aifc.cpython-310.pyc (24685B)
o p̦i] @stdZddlZddlZddlZddgZGdddeZdZddZd d Z d d Z d dZ ddZ dZ ddZddZddZddZddZddZddZdd lmZdd!lmZed"d#Zd$ej_d%ej_d&ej_d'ej_d(ej_d)ej_Gd*d+d+Z Gd,d-d-Z!d?d.dZ"e#d/kr8ddl$Z$e$j%d0dse$j%&d1e$j%d0Z'e"e'd2Z(e)d3e'e)d4e(*e)d5e(+e)d6e(,e)d7e(-e)d8e(.e)d9e(/e$j%d:dr%e$j%d:Z0e)d;e0e"e0d<Z1e12e(3 e(4d=Z5e5sne16e5qWdn 1swYe)d>WddSWddS1s1wYdSdS)@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 | +-----------------+ | | +----+------------+ | | AIFC | | +------------+ | | | | | . | | | . | | | . | +----+------------+ 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 (AIFF-C only). MARK <# of markers> (2 bytes) list of markers: (2 bytes, must be > 0) (4 bytes) ("pstring") COMM <# of channels> (2 bytes) <# of sound frames> (4 bytes) (2 bytes) (10 bytes, IEEE 80-bit extended floating point) in AIFF-C files only: (4 bytes) ("pstring") SSND (4 bytes, not used by this program) (4 bytes, not used by this program) 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. NErroropenc@s eZdZdS)rN)__name__ __module__ __qualname__rr/usr/lib/python3.10/aifc.pyrsl@QEcC0z td|ddWStjytdw)N>lrstructunpackreaderrorEOFErrorfilerrr _read_long rcCr )N>Lr rr rrrr _read_ulongrrcCr )N>hrr rrrr _read_shortrrcCr )N>Hrrr rrrr _read_ushortrrcCs@t|d}|dkrd}n||}|d@dkr|d}|S)Nr)ordr)rlengthdatadummyrrr _read_strings   r#gcCst|}d}|dkrd}|d}t|}t|}||kr'|kr'dkr/nnd}||S|dkr9t}||S|d}|d|td |d }||S) Nrrgi?lg@?)rr _HUGE_VALpow)fexponsignhimantlomantrrr _read_floats "r/cC|td|dS)Nrwriter packr*xrrr _write_shortr6cCr0)Nrr1r4rrr _write_ushortr7r8cCr0)Nr r1r4rrr _write_longr7r9cCr0)Nrr1r4rrr _write_ulongr7r:cCsVt|dkr td|tdt|||t|d@dkr)|ddSdS)Nz%string exceeds maximum pstring lengthBrr)len ValueErrorr2r r3)r*srrr _write_strings  rAc Csddl}|dkrd}|d}nd}|dkrd}d}d}nP||\}}|dks/|dks/||kr8|dB}d}d}n4|d}|dkrH|||}d}||B}||d}||}t|}|||d}||}t|}t||t||t||dS) Nrr%r$i@rr&i? )mathfrexpldexpfloorintr8r:) r*r5rCr,r+r-r.fmantfsmantrrr _write_floats8       rJ)Chunk) namedtuple _aifc_paramsz7nchannels sampwidth framerate nframes comptype compnamez3Number of audio channels (1 for mono, 2 for stereo)zSample width in byteszSampling frequencyzNumber of audio framesz(Compression type ("NONE" for AIFF files)zRA human-readable version of the compression type ('not compressed' for AIFF files)c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1ZdS)2 Aifc_readNcCs,d|_d|_g|_d|_||_t|}|dkrtd|d}|dkr*d|_ n |dkr2d|_ ntdd|_ d|_ d|_ zt|j}Wn t yPYn:w|}|d krb||d|_ n#|d krr||_ |d }d|_ n|d kr|t||_n |d kr|||q=|j r|j stddS)NrFORMz file does not start with FORM idr AIFFAIFCrznot an AIFF or AIFF-C fileCOMMSSNDFVERMARKz$COMM chunk and/or SSND chunk missing)_version_convert_markers _soundpos_filerKgetnamerr_aifc_comm_chunk_read _ssnd_chunk_ssnd_seek_neededr_read_comm_chunkr _readmarkskip)selfrchunkformdata chunknamer"rrrinitfp4sP        zAifc_read.initfpcCsFt|trt|d}z||WdS|||dS)Nrb) isinstancestrbuiltinsrrhcloserdr* file_objectrrr__init__\s  zAifc_read.__init__cC|SNrrdrrr __enter__hzAifc_read.__enter__cG |dSrrrmrdargsrrr__exit__k zAifc_read.__exit__cC|jSrr)r[rsrrrgetfpqzAifc_read.getfpcCsd|_d|_dS)Nrr)r`rZrsrrrrewindts zAifc_read.rewindcCs$|j}|durd|_|dSdSrr)r[rmrdrrrrrmxs  zAifc_read.closecCr|rr)rZrsrrrtell~r~zAifc_read.tellcCr|rr) _nchannelsrsrrr getnchannelsr~zAifc_read.getnchannelscCr|rr)_nframesrsrrr getnframesr~zAifc_read.getnframescCr|rr) _sampwidthrsrrr getsampwidthr~zAifc_read.getsampwidthcCr|rr) _frameratersrrr getframerater~zAifc_read.getframeratecCr|rr _comptypersrrr getcomptyper~zAifc_read.getcomptypecCr|rr _compnamersrrr getcompnamer~zAifc_read.getcompnamecCs*t||||||Srr)rMrrrrrrrsrrr getparamss  zAifc_read.getparamscCt|jdkr dS|jSNrr>rYrsrrr getmarkerszAifc_read.getmarkerscC.|jD] }||dkr|Sqtd|Nrzmarker {0!r} does not existrYrformatrdidmarkerrrrgetmark  zAifc_read.getmarkcCs*|dks ||jkr td||_d|_dS)Nrzposition not in ranger)rrrZr`)rdposrrrsetposs zAifc_read.setposcCs|jr"|jd|jd}|j|j}|r|j|dd|_|dkr(dS|j||j}|jr;|r;||}|jt||j|j |_|S)NrrTr) r`r_seekrrZ _framesizerXr>rr)rdnframesr"rr!rrr readframess       zAifc_read.readframescCddl}||dSNrr)audioopalaw2linrdr!rrrr _alaw2lin zAifc_read._alaw2lincCrr)rulaw2linrrrr _ulaw2linrzAifc_read._ulaw2lincC2ddl}t|ds d|_||d|j\}|_|SNr _adpcmstater)rhasattrr adpcm2linrrrr _adpcm2lins  zAifc_read._adpcm2lincCsRt||_t||_t|dd|_tt||_|jdkr#td|jdkr,td|j|j|_ |j rd}|j dkrGd}t dd |_ |d |_|rnt|jd}|d@dkra|d}|j ||_ |jd dt||_|jd kr|jd kr|j|_n|jdvr|j|_n|jdvr|j|_ntdd|_dSdSd |_d|_dS)NrTrbad sample widthbad # of channelsrzWarning: bad COMM chunk sizer r$NONEG722ulawULAWalawALAWunsupported compression typernot compressed)rrrrrrGr/rrrr] chunksizewarningswarnrrrrrr#rrrXrr)rdrekludger rrrrasF                   zAifc_read._read_comm_chunkcCst|}z#t|D]}t|}t|}t|}|s|r$|j|||fq WdStyIdt|jt|jdkrrr)rdrenmarkersirrnamewrrrrbs$  zAifc_read._readmark)rrrr[rhrprtrzr}rrmrrrrrrrrrrrrrrrrarbrrrrrNs4$(  *rNc@s0eZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dS)J Aifc_writeNcCs\t|tr't|d}z||Wn||dr%d|_dSdS||dS)Nwbz.aiffr)rjrkrlrrhrmendswithr]rnrrrrp/s    zAifc_write.__init__cCs^||_t|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ g|_ d|_d|_dS)Nrrrr)r[ _AIFC_versionrWrrrXrrrr_nframeswritten _datawritten _datalengthrY _marklengthr]rrrrrh?s zAifc_write.initfpcCrvrrrwrsrrr__del__Pr{zAifc_write.__del__cCrqrrrrsrrrrtSruzAifc_write.__enter__cGrvrrrwrxrrrrzVr{zAifc_write.__exit__cC|jrtdd|_dS)N0cannot change parameters after starting to writerrrr]rsrrraiff\ zAifc_write.aiffcCr)NrrrrsrrraifcarzAifc_write.aifccCs(|jrtd|dkrtd||_dS)Nrrr)rrr)rd nchannelsrrr setnchannelsf  zAifc_write.setnchannelscC|jstd|jS)Nznumber of channels not set)rrrsrrrrmzAifc_write.getnchannelscCs0|jrtd|dks|dkrtd||_dS)Nrrr r)rrr)rd sampwidthrrr setsampwidthrs  zAifc_write.setsampwidthcCr)Nzsample width not set)rrrsrrrryrzAifc_write.getsampwidthcCs(|jrtd|dkrtd||_dS)Nrrzbad frame rate)rrr)rd frameraterrr setframerate~rzAifc_write.setframeratecCr)Nzframe rate not set)rrrsrrrrrzAifc_write.getframeratecCs|jrtd||_dS)Nr)rrr)rdrrrr setnframesrzAifc_write.setnframescCr|rrrrsrrrrr~zAifc_write.getnframescCs.|jrtd|dvrtd||_||_dSNr)rrrrrrr)rrrr)rdcomptypecompnamerrr setcomptypes  zAifc_write.setcomptypecCr|rrrrsrrrrr~zAifc_write.getcomptypecCr|rrrrsrrrrr~zAifc_write.getcompnamecCsf|\}}}}}}|jrtd|dvrtd|||||||||||dSr)rrrrrrr)rdparamsrrrrrrrrr setparamss    zAifc_write.setparamscCs8|jr |jr |js tdt|j|j|j|j|j|jS)Nznot all parameters set)rrrrrMrrrrsrrrrs  zAifc_write.getparamscCs|dkrtd|dkrtdt|tstdtt|jD]}||j|dkr6|||f|j|<dSq |j|||fdS)Nrzmarker ID must be > 0zmarker position must be >= 0zmarker name must be bytes)rrjbytesrr>rYr)rdrrrrrrrsetmarks zAifc_write.setmarkcCrrrrrrrrrzAifc_write.getmarkcCrrrrsrrrrrzAifc_write.getmarkerscCr|rrrrsrrrrr~zAifc_write.tellcCszt|ttfst|d}|t|t||j|j}|j r'| |}|j ||j ||_ |j t||_ dS)Nr<)rjr bytearray memoryviewcast_ensure_header_writtenr>rrrXr[r2rr)rdr!rrrrwriteframesraws   zAifc_write.writeframesrawcCs2|||j|jks|j|jkr|dSdSrr)rrrrr _patchheader)rdr!rrr writeframess    zAifc_write.writeframescCs|jdurdSzM|d|jd@r|jd|jd|_||j|jks1|j|jks1|jrE| Wd|_ |j}d|_| dSWd|_ |j}d|_| dSd|_ |j}d|_| w)Nrrr=) r[rrr2 _writemarkersrrrrrrXrm)rdr*rrrrms4           zAifc_write.closecCrr)rlin2alawrrrr _lin2alawrzAifc_write._lin2alawcCrr)rlin2ulawrrrr _lin2ulawrzAifc_write._lin2ulawcCrr)rrr lin2adpcmrrrr _lin2adpcms  zAifc_write._lin2adpcmcCsj|js3|jdvr|jsd|_|jdkrtd|jstd|js%td|js,td||dSdS)NrrrrrrzRsample 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)rrrrrr _write_header)rddatasizerrrr s  z!Aifc_write._ensure_header_writtencCsF|jdkr |j|_dS|jdvr|j|_dS|jdvr!|j|_dSdS)Nrrr)rrrXrrrsrrr_init_compressions      zAifc_write._init_compressionc Cs@|jr |jdkr ||jd|js||j|j|_|j|j|j|_|jd@r3|jd|_|jre|jdvrM|jd|_|jd@rL|jd|_n|jdkre|jdd|_|jd@re|jd|_z|j |_ Wnt t fy{d|_ Ynw| |j}|jr|jd |jd t|jdt|j|jn|jd |jd t|j|t|j|j|j dur|j |_t|j|j|jd vrt|jdn t|j|jdt|j|j|jr|j|jt|j|j|jd|j dur |j |_t|j|jdt|jdt|jddS)NrrOr)rrrrrrr rQrUrPrRrrTrSr)r]rrr[r2rrrrr_form_length_posAttributeErrorOSError_write_form_lengthr:rWr6 _nframes_posrJrrAr_ssnd_length_pos)rd initlength commlengthrrrr%sb                         zAifc_write._write_headercCs\|jrdt|j}|d@r|d}d}nd}d}t|jd||jd|d||S) Nrr rrr rT)r]r>rr:r[r)rd datalengthr  verslengthrrrrXs"zAifc_write._write_form_lengthcCs|j}|jd@r|jd}|jdn|j}||jkr2|j|jkr2|jdkr2|j|ddS|j|j d| |}|j|j dt |j|j|j|j dt |j|d|j|d|j|_||_dS)Nrr=rrT)r[rrr2rrrrrrrrr:r)rdcurposr r"rrrres&        zAifc_write._patchheadercCst|jdkr dS|jdd}|jD]}|\}}}|t|dd}t|d@dkr1|d}qt|j||d|_t|jt|j|jD]}|\}}}t|j|t|j|t|j|qIdS)NrrVrrrT)r>rYr[r2r:rr6rA)rdr rrrrrrrr{s&         zAifc_write._writemarkers)(rrrr[rprhrrtrzrrrrrrrrrrrrrrrrrrrrrrmrrrrrrrrrrrrrrsL    3 rcCsF|durt|dr |j}nd}|dvrt|S|dvrt|Std)Nmoderi)rri)rrz$mode must be 'r', 'rb', 'w', or 'wb')rrrNrr)r*rrrrrs __main__rz/usr/demos/data/audio/bach.aiffrReadingz nchannels =z nframes =z sampwidth =z framerate =z comptype =z compname =rWritingrizDone.rr)7__doc__r rlr__all__ Exceptionrrrrrrr#r(r/r6r8r9r:rArJrerK collectionsrLrMrrrrrrrNrrrsysargvrfnr*printrrrrrrgngrrrr!rrrrrs   !             $