Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
 lŽŒYß|ã@sÈdZddlZddlZddlZdddgZGdd„deƒZdZdd „Zd d „Z d d „Z dd„Z dd„Z dZ dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zdd!lmZdd"lmZed#d$ƒZGd%d&„d&ƒZGd'd(„d(ƒZdd)d„ZeZed*krÄddlZej d+d… r‘ej 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 d5d…r½ej d5Z+e$d6e+ƒee+d7ƒ�EZ,e,j-e#j.ƒƒx(e#j/d8ƒZ0e0 r›Pe,j1e0ƒq„WWdQRXe$d9ƒWdQRXdS):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. éNÚErrorÚopenÚopenfpc@seZdZdS)rN)Ú__name__Ú __module__Ú __qualname__©rrú#/opt/python35/lib/python3.5/aifc.pyr�s l@QEc CsCy!tjd|jdƒƒdSWntjk r>t‚YnXdS)Nz>lér)ÚstructÚunpackÚreadÚerrorÚEOFError)Úfilerrr Ú _read_long”s!rc CsCy!tjd|jdƒƒdSWntjk r>t‚YnXdS)Nz>Lr r)r r r rr)rrrr Ú _read_ulongšs!rc CsCy!tjd|jdƒƒdSWntjk r>t‚YnXdS)Nz>hér)r r r rr)rrrr Ú _read_short s!rc CsCy!tjd|jdƒƒdSWntjk r>t‚YnXdS)Nz>Hrr)r r r rr)rrrr Ú _read_ushort¦s!rcCs\t|jdƒƒ}|dkr*d}n|j|ƒ}|d@dkrX|jdƒ}|S)Néró)Úordr )rÚlengthÚdataÚdummyrrr Ú _read_string¬s  rgâÿÿÿÿÿïcCs¼t|ƒ}d}|dkr.d }|d}t|ƒ}t|ƒ}||koh|kohdknrvd}n>|dkr‹t}n)|d}|d|td|d ƒ}||S) Nrri€giÿiÿ?lg@é?éÿÿÿÿ)rrÚ _HUGE_VALÚpow)ÚfÚexponÚsignÚhimantÚlomantrrr Ú _read_float¸s     '    r&cCs|jtjd|ƒƒdS)Nz>h)Úwriter Úpack)r!Úxrrr Ú _write_shortÉsr*cCs|jtjd|ƒƒdS)Nz>H)r'r r()r!r)rrr Ú _write_ushortÌsr+cCs|jtjd|ƒƒdS)Nz>l)r'r r()r!r)rrr Ú _write_longÏsr,cCs|jtjd|ƒƒdS)Nz>L)r'r r()r!r)rrr Ú _write_ulongÒsr-cCsqt|ƒdkrtdƒ‚|jtjdt|ƒƒƒ|j|ƒt|ƒd@dkrm|jdƒdS)Néÿz%string exceeds maximum pstring lengthÚBrrs)ÚlenÚ ValueErrorr'r r()r!Úsrrr Ú _write_stringÕs   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) Nri€ri@iÿiþ?é r)ÚmathÚfrexpÚldexpÚfloorÚintr+r-) r!r)r5r#r"r$r%ZfmantZfsmantrrr Ú _write_floatÝs8     $         r:)ÚChunk)Ú namedtupleÚ _aifc_paramsz7nchannels sampwidth framerate nframes comptype compnamec@s6eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„ZdS)2Ú Aifc_readNc Csªd|_d|_g|_d|_||_t|ƒ}|jƒdkrWtdƒ‚|jdƒ}|dkr~d|_ n$|dkr–d|_ n tdƒ‚d|_ xØd|_ yt|jƒ}Wnt k rßPYnX|jƒ}|d kr|j |ƒd|_ ng|d krA||_|jd ƒ}d|_ n7|d kr_t|ƒ|_n|d krx|j|ƒ|jƒq®W|j sš|j r¦tdƒ‚dS)NrsFORMz file does not start with FORM idr sAIFFsAIFCrznot an AIFF or AIFF-C filesCOMMsSSNDésFVERsMARKz$COMM chunk and/or SSND chunk missing)Ú_versionÚ_convertÚ_markersÚ _soundposÚ_filer;Zgetnamerr Ú_aifcZ_comm_chunk_readÚ_ssnd_seek_neededrÚ_read_comm_chunkÚ _ssnd_chunkrÚ _readmarkÚskip)ÚselfrÚchunkZformdataZ chunknamerrrr Úinitfp+sH                         zAifc_read.initfpc Cs^t|tƒrMtj|dƒ}y|j|ƒWqZ|jƒ‚YqZXn |j|ƒdS)NÚrb)Ú isinstanceÚstrÚbuiltinsrrMÚclose)rKr!Ú file_objectrrr Ú__init__Rs  zAifc_read.__init__cCs|S)Nr)rKrrr Ú __enter__^szAifc_read.__enter__cGs|jƒdS)N)rR)rKÚargsrrr Ú__exit__aszAifc_read.__exit__cCs|jS)N)rD)rKrrr ÚgetfpgszAifc_read.getfpcCsd|_d|_dS)Nrr)rFrC)rKrrr Úrewindjs zAifc_read.rewindcCs,|j}|dk r(d|_|jƒdS)N)rDrR)rKrrrr rRns   zAifc_read.closecCs|jS)N)rC)rKrrr ÚtelltszAifc_read.tellcCs|jS)N)Ú _nchannels)rKrrr Ú getnchannelswszAifc_read.getnchannelscCs|jS)N)Ú_nframes)rKrrr Ú getnframeszszAifc_read.getnframescCs|jS)N)Ú _sampwidth)rKrrr Ú getsampwidth}szAifc_read.getsampwidthcCs|jS)N)Ú _framerate)rKrrr Ú getframerate€szAifc_read.getframeratecCs|jS)N)Ú _comptype)rKrrr Ú getcomptypeƒszAifc_read.getcomptypecCs|jS)N)Ú _compname)rKrrr Ú getcompname†szAifc_read.getcompnamecCs=t|jƒ|jƒ|jƒ|jƒ|jƒ|jƒƒS)N)r=r\r`rbr^rdrf)rKrrr Ú getparamsŒszAifc_read.getparamscCs t|jƒdkrdS|jS)Nr)r0rB)rKrrr Ú getmarkers‘szAifc_read.getmarkerscCsAx%|jD]}||dkr |Sq Wtdj|ƒƒ‚dS)Nrzmarker {0!r} does not exist)rBrÚformat)rKÚidÚmarkerrrr Úgetmark–szAifc_read.getmarkcCs=|dks||jkr'tdƒ‚||_d|_dS)Nrzposition not in ranger)r]rrCrF)rKÚposrrr Úsetposœs  zAifc_read.setposcCsÍ|jr^|jjdƒ|jjdƒ}|j|j}|rU|jj|dƒd|_|dkrndS|jj||jƒ}|jr¥|r¥|j|ƒ}|jt|ƒ|j|j |_|S)Nrr?r) rFrHÚseekr rCÚ _framesizerAr0r[r_)rKÚnframesrrmrrrr Ú readframes¢s   zAifc_read.readframescCsddl}|j|dƒS)Nrr)ÚaudioopZalaw2lin)rKrrsrrr Ú _alaw2lin·s zAifc_read._alaw2lincCsddl}|j|dƒS)Nrr)rsZulaw2lin)rKrrsrrr Ú _ulaw2lin»s zAifc_read._ulaw2lincCsIddl}t|dƒs$d|_|j|d|jƒ\}|_|S)NrÚ _adpcmstater)rsÚhasattrrvZ adpcm2lin)rKrrsrrr Ú _adpcm2lin¿s   !zAifc_read._adpcm2lincCsªt|ƒ|_t|ƒ|_t|ƒdd|_tt|ƒƒ|_|j|j|_|j r”d}|j dkr—d}t j dƒd|_ |j dƒ|_|rt|jj dƒƒ}|d@dkrá|d}|j ||_ |jjddƒt|ƒ|_|jd kr¦|jd kr@|j|_nH|jdkr^|j|_n*|jdkr||j|_n tdƒ‚d|_nd |_d|_dS)Nér?rérzWarning: bad COMM chunk sizeér sNONEsG722óulawóULAWóalawóALAWzunsupported compression typersnot compressedr)r|r})r~r)rr[rr]r_r9r&rarprEÚ chunksizeÚwarningsÚwarnr rcrrrorrerxrArurtr)rKrLZkludgerrrr rGÇs<       zAifc_read._read_comm_chunkc CsÍt|ƒ}ydx]t|ƒD]O}t|ƒ}t|ƒ}t|ƒ}|sR|r|jj|||fƒqWWnVtk rÈdt|jƒt|jƒdkrªdnd|f}tj |ƒYnXdS)Nz;Warning: MARK chunk contains only %s marker%s instead of %srÚr2) rÚrangerrrBÚappendrr0r�r‚)rKrLZnmarkersÚirjrmÚnameÚwrrr rIís     ! * zAifc_read._readmark)rrrrDrMrTrUrWrXrYrRrZr\r^r`rbrdrfrgrhrlrnrrrtrurxrGrIrrrr r>s2 $ '                     &r>c@sÆeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zd4d5„Zd6d7„Zd8d9„Zd:d;„Z d<d=„Z!d>d?„Z"d@dA„Z#dBdC„Z$dDdE„Z%dFdG„Z&dHdI„Z'dS)JÚ Aifc_writeNc Csvt|tƒretj|dƒ}y|j|ƒWn|jƒ‚YnX|jdƒrrd|_n |j|ƒdS)NÚwbz.aiffr)rOrPrQrrMrRÚendswithrE)rKr!rSrrr rT!s  zAifc_write.__init__cCs‹||_t|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ g|_ d|_d|_dS)NsNONEsnot compressedrr)rDÚ _AIFC_versionr@rcrerAr[r_rar]Ú_nframeswrittenÚ _datawrittenÚ _datalengthrBÚ _marklengthrE)rKrrrr rM1s              zAifc_write.initfpcCs|jƒdS)N)rR)rKrrr Ú__del__BszAifc_write.__del__cCs|S)Nr)rKrrr rUEszAifc_write.__enter__cGs|jƒdS)N)rR)rKrVrrr rWHszAifc_write.__exit__cCs"|jrtdƒ‚d|_dS)Nz0cannot change parameters after starting to writer)r�rrE)rKrrr ÚaiffNs  zAifc_write.aiffcCs"|jrtdƒ‚d|_dS)Nz0cannot change parameters after starting to writer)r�rrE)rKrrr ÚaifcSs  zAifc_write.aifccCs:|jrtdƒ‚|dkr-tdƒ‚||_dS)Nz0cannot change parameters after starting to writerzbad # of channels)r�rr[)rKÚ nchannelsrrr Ú setnchannelsXs     zAifc_write.setnchannelscCs|jstdƒ‚|jS)Nznumber of channels not set)r[r)rKrrr r\_s  zAifc_write.getnchannelscCsF|jrtdƒ‚|dks-|dkr9tdƒ‚||_dS)Nz0cannot change parameters after starting to writerr zbad sample width)r�rr_)rKÚ sampwidthrrr Ú setsampwidthds    zAifc_write.setsampwidthcCs|jstdƒ‚|jS)Nzsample width not set)r_r)rKrrr r`ks  zAifc_write.getsampwidthcCs:|jrtdƒ‚|dkr-tdƒ‚||_dS)Nz0cannot change parameters after starting to writerzbad frame rate)r�rra)rKÚ frameraterrr Ú setframerateps     zAifc_write.setframeratecCs|jstdƒ‚|jS)Nzframe rate not set)rar)rKrrr rbws  zAifc_write.getframeratecCs"|jrtdƒ‚||_dS)Nz0cannot change parameters after starting to write)r�rr])rKrqrrr Ú setnframes|s  zAifc_write.setnframescCs|jS)N)r�)rKrrr r^�szAifc_write.getnframescCsC|jrtdƒ‚|d kr-tdƒ‚||_||_dS) Nz0cannot change parameters after starting to writeóNONEóulawóULAWóalawóALAWóG722zunsupported compression type)r›rœr�ržrŸr )r�rrcre)rKÚcomptypeÚcompnamerrr Ú setcomptype„s     zAifc_write.setcomptypecCs|jS)N)rc)rKrrr rd�szAifc_write.getcomptypecCs|jS)N)re)rKrrr rf�szAifc_write.getcompnamecCs�|\}}}}}}|jr-tdƒ‚|d krEtdƒ‚|j|ƒ|j|ƒ|j|ƒ|j|ƒ|j||ƒdS) Nz0cannot change parameters after starting to writeóNONEóulawóULAWóalawóALAWóG722zunsupported compression type)r¤r¥r¦r§r¨r©)r�rr•r—r™ršr£)rKÚparamsr”r–r˜rqr¡r¢rrr Ú setparams˜s        zAifc_write.setparamscCsU|j s|j s|j r*tdƒ‚t|j|j|j|j|j|jƒS)Nznot all parameters set)r[r_rarr=r]rcre)rKrrr rg¥s zAifc_write.getparamscCs¹|dkrtdƒ‚|dkr0tdƒ‚t|tƒsKtdƒ‚xNtt|jƒƒD]7}||j|dkra|||f|j| 0zmarker position must be >= 0zmarker name must be bytes)rrOÚbytesr„r0rBr…)rKrjrmr‡r†rrr Úsetmark«s     zAifc_write.setmarkcCsAx%|jD]}||dkr |Sq Wtdj|ƒƒ‚dS)Nrzmarker {0!r} does not exist)rBrri)rKrjrkrrr rl¸szAifc_write.getmarkcCs t|jƒdkrdS|jS)Nr)r0rB)rKrrr rh¾szAifc_write.getmarkerscCs|jS)N)r�)rKrrr rZÃszAifc_write.tellcCs©t|ttfƒs*t|ƒjdƒ}|jt|ƒƒt|ƒ|j|j}|j ro|j |ƒ}|j j |ƒ|j ||_ |j t|ƒ|_ dS)Nr/)rOr¬Ú bytearrayÚ memoryviewÚcastÚ_ensure_header_writtenr0r_r[rArDr'r�rŽ)rKrrqrrr ÚwriteframesrawÆs zAifc_write.writeframesrawcCs?|j|ƒ|j|jks1|j|jkr;|jƒdS)N)r²r�r]r�rŽÚ _patchheader)rKrrrr Ú writeframesÑs zAifc_write.writeframesc Cs¿|jdkrdSz|jdƒ|jd@rP|jjdƒ|jd|_|jƒ|j|jks‡|j|jks‡|jr‘|j ƒWdd|_ |j}d|_|j ƒXdS)Nrrs) rDr±rŽr'Ú _writemarkersr�r]r�r�r³rArR)rKr!rrr rR×s        zAifc_write.closecCsddl}|j|dƒS)Nrr)rsZlin2alaw)rKrrsrrr Ú _lin2alawðs zAifc_write._lin2alawcCsddl}|j|dƒS)Nrr)rsZlin2ulaw)rKrrsrrr Ú _lin2ulawôs zAifc_write._lin2ulawcCsIddl}t|dƒs$d|_|j|d|jƒ\}|_|S)Nrrvr)rsrwrvZ lin2adpcm)rKrrsrrr Ú _lin2adpcmøs   !zAifc_write._lin2adpcmcCs•|js‘|jd krE|js*d|_|jdkrEtdƒ‚|jsZtdƒ‚|jsotd ƒ‚|js„td ƒ‚|j|ƒdS) NóULAWóulawóALAWóalawóG722rzRsample 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)r¹rºr»r¼r½)r�rcr_rr[raÚ _write_header)rKZdatasizerrr r±ÿs          z!Aifc_write._ensure_header_writtencCs[|jdkr|j|_n9|jdkr<|j|_n|jdkrW|j|_dS)NsG722óulawóULAWóalawóALAW)r¿rÀ)rÁrÂ)rcr¸rAr·r¶)rKrrr Ú_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!t t fk rJd|_ YnX|j |jƒ}|jr¬|jjd ƒ|jjd ƒt|jd ƒt|j|jƒn|jjdƒ|jjdƒt|j|ƒt|j|jƒ|j dk r|jj ƒ|_t|j|jƒ|jdkrEt|jdƒnt|j|jdƒt|j|jƒ|jrž|jj|jƒt|j|jƒ|jjdƒ|j dk rÏ|jj ƒ|_t|j|jdƒt|jdƒt|jdƒdS)NsNONEsFORMróulawóULAWóalawóALAWróG722ér sAIFCsFVERsAIFFsCOMMr?sSSNDr)rÄrÅrÆrÇ)rÅrÄrÇrÆrÈ)rErcrÃrDr'r]r[r_r�rZÚ_form_length_posÚAttributeErrorÚOSErrorÚ_write_form_lengthr-r@r*Ú _nframes_posr:rar3reÚ_ssnd_length_pos)rKZ initlengthÚ commlengthrrr r¾s^        zAifc_write._write_headercCst|jr9d t|jƒ}|d@r0|d}d}n d}d}t|jd||jd|d|ƒ|S) Nrzéré rr r?ér{)rEr0rer-rDr�)rKÚ datalengthrÐZ verslengthrrr rÍJs     "zAifc_write._write_form_lengthcCs0|jjƒ}|jd@r<|jd}|jjdƒn |j}||jkrŒ|j|jkrŒ|jdkrŒ|jj|dƒdS|jj|j dƒ|j |ƒ}|jj|j dƒt |j|jƒ|jj|j dƒt |j|dƒ|jj|dƒ|j|_||_dS)Nrsrr?)rDrZrŽr'r�r]r�r�rorÊrÍrÎr-rÏ)rKZcurposrÔrrrr r³Ws&    zAifc_write._patchheadercCst|jƒdkrdS|jjdƒd}xX|jD]M}|\}}}|t|ƒdd}t|ƒd@dkr9|d}q9Wt|j|ƒ|d|_t|jt|jƒƒxP|jD]E}|\}}}t|j|ƒt|j|ƒt|j|ƒqÊWdS)NrsMARKrrér?)r0rBrDr'r-r�r*r3)rKrrkrjrmr‡rrr rµms" zAifc_write._writemarkers)(rrrrDrTrMr‘rUrWr’r“r•r\r—r`r™rbršr^r£rdrfr«rgr­rlrhrZr²r´rRr¶r·r¸r±rÃr¾rÍr³rµrrrr r‰sJ                              3 r‰cCsi|dkr-t|dƒr'|j}nd}|dkrCt|ƒS|dkrYt|ƒStdƒ‚dS) NÚmoderNÚrrˆrŠz$mode must be 'r', 'rb', 'w', or 'wb')r×rN)rˆrŠ)rwrÖr>r‰r)r!rÖrrr r€s      Ú__main__rz/usr/demos/data/audio/bach.aiffr×ZReadingz nchannels =z nframes =z sampwidth =z framerate =z comptype =z compname =rZWritingrˆizDone.)2Ú__doc__r rQr�Ú__all__Ú ExceptionrrŒrrrrrrr&r*r+r,r-r3r:rLr;Ú collectionsr<r=r>r‰rrrÚsysÚargvr…Úfnr!Úprintr\r^r`rbrdrfZgnÚgr«rgrrrr´rrrr Ú‡sh               ! üÿ€