ž ­ÿfNyc@sÄdZddlZddlZddlZdddgZGdd„deƒZdZdd „Zd d „Z d d „Z dd„Z dd„Z dZ dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zdd!lmZGd"d#„d#ƒZGd$d%„d%ƒZed&d„ZeZed'krÀddlZejd(d… ruejjd)ƒnejd(Z ee d*ƒZ!ze"d+e ƒe"d,e!j#ƒƒe"d-e!j$ƒƒe"d.e!j%ƒƒe"d/e!j&ƒƒe"d0e!j'ƒƒe"d1e!j(ƒƒejd2d…r®ejd2Z)e"d3e)ƒee)d4ƒZ*zDe*j+e!j,ƒƒx*e!j-d5ƒZ.e. r‚Pne*j/e.ƒqhWde*j0ƒXe"d6ƒnWde!j0ƒXndS(7uDStuff 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 tuple 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('') 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. iNuErroruopenuopenfpcBs|EeZdZdS(uErrorN(u__name__u __module__u __qualname__(u __locals__((u)/opt/alt/python33/lib64/python3.3/aifc.pyuErrorsl@QEc CsCy!tjd|jdƒƒdSWntjk r>t‚YnXdS(Nu>lii(ustructuunpackureaduerroruEOFError(ufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _read_long”s!u _read_longc CsCy!tjd|jdƒƒdSWntjk r>t‚YnXdS(Nu>Lii(ustructuunpackureaduerroruEOFError(ufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _read_ulongšs!u _read_ulongc CsCy!tjd|jdƒƒdSWntjk r>t‚YnXdS(Nu>hii(ustructuunpackureaduerroruEOFError(ufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _read_short s!u _read_shortc CsCy!tjd|jdƒƒdSWntjk r>t‚YnXdS(Nu>Hii(ustructuunpackureaduerroruEOFError(ufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _read_ushort¦s!u _read_ushortcCs_t|jdƒƒ}|dkr*d}n|j|ƒ}|d@dkr[|jdƒ}n|S(Niis(uorduread(ufileulengthudataudummy((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _read_string¬s  u _read_stringgâÿÿÿÿÿïcCs¿t|ƒ}d}|dkr1d }|d}nt|ƒ}t|ƒ}||kok|kokdknryd}n>|dkrŽt}n)|d}|d|td|d ƒ}||S( Niii€giÿiÿ?lg@i?iÿÿÿÿ(u _read_shortu _read_ulongu _HUGE_VALupow(ufuexponusignuhimantulomant((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _read_float¸s     '    u _read_floatcCs|jtjd|ƒƒdS(Nu>h(uwriteustructupack(ufux((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _write_shortÉsu _write_shortcCs|jtjd|ƒƒdS(Nu>H(uwriteustructupack(ufux((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _write_ushortÌsu _write_ushortcCs|jtjd|ƒƒdS(Nu>l(uwriteustructupack(ufux((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _write_longÏsu _write_longcCs|jtjd|ƒƒdS(Nu>L(uwriteustructupack(ufux((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _write_ulongÒsu _write_ulongcCswt|ƒdkr!tdƒ‚n|jtjdt|ƒƒƒ|j|ƒt|ƒd@dkrs|jdƒndS(Niÿu%string exceeds maximum pstring lengthuBiis(ulenu ValueErroruwriteustructupack(ufus((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _write_stringÕs  u _write_stringc Cshddl}|dkr+d}|d}nd}|dkrRd}d}d}në|j|ƒ\}}|dks‹|dks‹||kr¤|dB}d}d}n™|d}|dkrÕ|j||ƒ}d}n||B}|j|dƒ}|j|ƒ}t|ƒ}|j||dƒ}|j|ƒ}t|ƒ}t||ƒt||ƒt||ƒdS( Nii€ii@iÿiþ?i iÿÿÿÿ(umathufrexpuldexpuflooruintu _write_ushortu _write_ulong( ufuxumathusignuexponuhimantulomantufmantufsmant((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _write_floatÝs8     $          u _write_float(uChunkcBs|EeZdZdd„Zdd„Zdd„Zdd„Zd d „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-S(.u Aifc_readc Cs²d|_d|_g|_d|_||_t|ƒ}|jƒdkrZtdƒ‚n|j dƒ}|dkrd|_ n$|dkr™d|_ n tdƒ‚d|_ xÚd|_ yt|jƒ}Wnt k râPYnX|jƒ}|d kr|j|ƒd|_ nj|d krD||_|j d ƒ}d|_ n:|d krbt|ƒ|_n|d kr~|j|ƒn|jƒq±|j sŸ|j r®tdƒ‚ndS(NisFORMu file does not start with FORM idisAIFFsAIFCiunot an AIFF or AIFF-C filesCOMMsSSNDisFVERsMARKu$COMM chunk and/or SSND chunk missing(u_versionuNoneu_convertu_markersu _soundposu_fileuChunkugetnameuErrorureadu_aifcu_comm_chunk_readu_ssnd_seek_neededuEOFErroru_read_comm_chunku _ssnd_chunku _read_ulongu _readmarkuskip(uselfufileuchunkuformdatau chunknameudummy((u)/opt/alt/python33/lib64/python3.3/aifc.pyuinitfp$sH                        uAifc_read.initfpcCs5t|tƒr$tj|dƒ}n|j|ƒdS(Nurb(u isinstanceustrubuiltinsuopenuinitfp(uselfuf((u)/opt/alt/python33/lib64/python3.3/aifc.pyu__init__KsuAifc_read.__init__cCs|jS(N(u_file(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetfpTsuAifc_read.getfpcCsd|_d|_dS(Nii(u_ssnd_seek_neededu _soundpos(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyurewindWs uAifc_read.rewindcCs|jjƒdS(N(u_fileuclose(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyuclose[suAifc_read.closecCs|jS(N(u _soundpos(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyutell^suAifc_read.tellcCs|jS(N(u _nchannels(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getnchannelsasuAifc_read.getnchannelscCs|jS(N(u_nframes(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getnframesdsuAifc_read.getnframescCs|jS(N(u _sampwidth(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getsampwidthgsuAifc_read.getsampwidthcCs|jS(N(u _framerate(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getframeratejsuAifc_read.getframeratecCs|jS(N(u _comptype(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getcomptypemsuAifc_read.getcomptypecCs|jS(N(u _compname(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getcompnamepsuAifc_read.getcompnamecCs:|jƒ|jƒ|jƒ|jƒ|jƒ|jƒfS(N(u getnchannelsu getsampwidthu getframerateu getnframesu getcomptypeu getcompname(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getparamsvsuAifc_read.getparamscCs t|jƒdkrdS|jS(Ni(ulenu_markersuNone(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getmarkers{suAifc_read.getmarkerscCsAx%|jD]}||dkr |Sq Wtdj|ƒƒ‚dS(Niumarker {0!r} does not exist(u_markersuErroruformat(uselfuidumarker((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetmark€suAifc_read.getmarkcCs@|dks||jkr*tdƒ‚n||_d|_dS(Niuposition not in rangei(u_nframesuErroru _soundposu_ssnd_seek_needed(uselfupos((u)/opt/alt/python33/lib64/python3.3/aifc.pyusetpos†s uAifc_read.setposcCsÖ|jrd|jjdƒ|jjdƒ}|j|j}|rX|jj|dƒnd|_n|dkrtdS|jj||jƒ}|jr®|r®|j|ƒ}n|jt|ƒ|j|j |_|S(Niis( u_ssnd_seek_neededu _ssnd_chunkuseekureadu _soundposu _framesizeu_convertulenu _nchannelsu _sampwidth(uselfunframesudummyuposudata((u)/opt/alt/python33/lib64/python3.3/aifc.pyu readframesŒs   uAifc_read.readframescCsddl}|j|dƒS(Nii(uaudioopualaw2lin(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _alaw2lin¡s uAifc_read._alaw2lincCsddl}|j|dƒS(Nii(uaudioopuulaw2lin(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _ulaw2lin¥s uAifc_read._ulaw2lincCsLddl}t|dƒs'd|_n|j|d|jƒ\}|_|S(Niu _adpcmstatei(uaudioopuhasattruNoneu _adpcmstateu adpcm2lin(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _adpcm2lin©s   !uAifc_read._adpcm2lincCs¶t|ƒ|_t|ƒ|_t|ƒdd|_tt|ƒƒ|_|j|j|_|j r d}|j dkršd}t j dƒd|_ n|j dƒ|_|r t|jj dƒƒ}|d@dkrç|d}n|j ||_ |jjddƒnt|ƒ|_|jd kr²|jd krI|j|_nH|jdkrg|j|_n*|jdkr…|j|_n tdƒ‚d|_q²nd |_d|_dS(NiiiiiuWarning: bad COMM chunk sizeiisNONEsG722sulawsULAWsalawsALAWuunsupported compression typeisnot compressediÿÿÿÿ(sulawsULAW(salawsALAW(u _read_shortu _nchannelsu _read_longu_nframesu _sampwidthuintu _read_floatu _framerateu _framesizeu_aifcu chunksizeuwarningsuwarnureadu _comptypeuordufileuseeku _read_stringu _compnameu _adpcm2linu_convertu _ulaw2linu _alaw2linuError(uselfuchunkukludgeulength((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_read_comm_chunk±s<      uAifc_read._read_comm_chunkc CsÐt|ƒ}ygx`t|ƒD]R}t|ƒ}t|ƒ}t|ƒ}|sR|r|jj|||fƒqqWWnVtk rËdt|jƒt|jƒdkr­dnd|f}tj |ƒYnXdS(Nu;Warning: MARK chunk contains only %s marker%s instead of %siuus( u _read_shorturangeu _read_longu _read_stringu_markersuappenduEOFErrorulenuwarningsuwarn(uselfuchunkunmarkersuiuiduposunameuw((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _readmark×s     $ * uAifc_read._readmarkN(u__name__u __module__u __qualname__uinitfpu__init__ugetfpurewinducloseutellu getnchannelsu getnframesu getsampwidthu getframerateu getcomptypeu getcompnameu getparamsu getmarkersugetmarkusetposu readframesu _alaw2linu _ulaw2linu _adpcm2linu_read_comm_chunku _readmark(u __locals__((u)/opt/alt/python33/lib64/python3.3/aifc.pyu Aifc_reads,$ '                   &u Aifc_readcBs¬|EeZdZdd„Zdd„Zdd„Zdd„Zd d „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/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Zd;d<„Z d=d>„Z!d?d@„Z"dAdB„Z#dCdD„Z$dES(Fu Aifc_writecCslt|tƒr*|}tj|dƒ}nd}|j|ƒ|dd…dkr_d|_n d|_dS(Nuwbu???iu.aiffiiiûÿÿÿ(u isinstanceustrubuiltinsuopenuinitfpu_aifc(uselfufufilename((u)/opt/alt/python33/lib64/python3.3/aifc.pyu__init__ s  uAifc_write.__init__cCs‹||_t|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ g|_d|_d|_dS(NsNONEsnot compressedii(u_fileu _AIFC_versionu_versionu _comptypeu _compnameuNoneu_convertu _nchannelsu _sampwidthu _framerateu_nframesu_nframeswrittenu _datawrittenu _datalengthu_markersu _marklengthu_aifc(uselfufile((u)/opt/alt/python33/lib64/python3.3/aifc.pyuinitfps              uAifc_write.initfpcCs|jƒdS(N(uclose(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu__del__'suAifc_write.__del__cCs%|jrtdƒ‚nd|_dS(Nu0cannot change parameters after starting to writei(u_nframeswrittenuErroru_aifc(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyuaiff-s uAifc_write.aiffcCs%|jrtdƒ‚nd|_dS(Nu0cannot change parameters after starting to writei(u_nframeswrittenuErroru_aifc(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyuaifc2s uAifc_write.aifccCs@|jrtdƒ‚n|dkr3tdƒ‚n||_dS(Nu0cannot change parameters after starting to writeiubad # of channels(u_nframeswrittenuErroru _nchannels(uselfu nchannels((u)/opt/alt/python33/lib64/python3.3/aifc.pyu setnchannels7s   uAifc_write.setnchannelscCs|jstdƒ‚n|jS(Nunumber of channels not set(u _nchannelsuError(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getnchannels>s uAifc_write.getnchannelscCsL|jrtdƒ‚n|dks0|dkr?tdƒ‚n||_dS(Nu0cannot change parameters after starting to writeiiubad sample width(u_nframeswrittenuErroru _sampwidth(uselfu sampwidth((u)/opt/alt/python33/lib64/python3.3/aifc.pyu setsampwidthCs  uAifc_write.setsampwidthcCs|jstdƒ‚n|jS(Nusample width not set(u _sampwidthuError(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getsampwidthJs uAifc_write.getsampwidthcCs@|jrtdƒ‚n|dkr3tdƒ‚n||_dS(Nu0cannot change parameters after starting to writeiubad frame rate(u_nframeswrittenuErroru _framerate(uselfu framerate((u)/opt/alt/python33/lib64/python3.3/aifc.pyu setframerateOs   uAifc_write.setframeratecCs|jstdƒ‚n|jS(Nuframe rate not set(u _framerateuError(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getframerateVs uAifc_write.getframeratecCs%|jrtdƒ‚n||_dS(Nu0cannot change parameters after starting to write(u_nframeswrittenuErroru_nframes(uselfunframes((u)/opt/alt/python33/lib64/python3.3/aifc.pyu setnframes[s uAifc_write.setnframescCs|jS(N(u_nframeswritten(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getnframes`suAifc_write.getnframescCsI|jrtdƒ‚n|d kr3tdƒ‚n||_||_dS( Nu0cannot change parameters after starting to writesNONEsulawsULAWsalawsALAWsG722uunsupported compression type(sNONEsulawsULAWsalawsALAWsG722(u_nframeswrittenuErroru _comptypeu _compname(uselfucomptypeucompname((u)/opt/alt/python33/lib64/python3.3/aifc.pyu setcomptypecs   uAifc_write.setcomptypecCs|jS(N(u _comptype(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getcomptypelsuAifc_write.getcomptypecCs|jS(N(u _compname(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getcompnameosuAifc_write.getcompnamecCs“|\}}}}}}|jr0tdƒ‚n|d krKtdƒ‚n|j|ƒ|j|ƒ|j|ƒ|j|ƒ|j||ƒdS( Nu0cannot change parameters after starting to writesNONEsulawsULAWsalawsALAWsG722uunsupported compression type(sNONEsulawsULAWsalawsALAWsG722(u_nframeswrittenuErroru setnchannelsu setsampwidthu setframerateu setnframesu setcomptype(uselfuparamsu nchannelsu sampwidthu framerateunframesucomptypeucompname((u)/opt/alt/python33/lib64/python3.3/aifc.pyu setparamsws      uAifc_write.setparamscCsU|j s|j s|j r-tdƒ‚n|j|j|j|j|j|jfS(Nunot all parameters set(u _nchannelsu _sampwidthu _framerateuErroru_nframesu _comptypeu _compname(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getparams„suAifc_write.getparamscCsÂ|dkrtdƒ‚n|dkr6tdƒ‚nt|tƒsTtdƒ‚nxNtt|jƒƒD]7}||j|dkrj|||f|j| 0umarker position must be >= 0umarker name must be bytes(uErroru isinstanceubytesurangeulenu_markersuappend(uselfuiduposunameui((u)/opt/alt/python33/lib64/python3.3/aifc.pyusetmarkŠs  uAifc_write.setmarkcCsAx%|jD]}||dkr |Sq Wtdj|ƒƒ‚dS(Niumarker {0!r} does not exist(u_markersuErroruformat(uselfuidumarker((u)/opt/alt/python33/lib64/python3.3/aifc.pyugetmark—suAifc_write.getmarkcCs t|jƒdkrdS|jS(Ni(ulenu_markersuNone(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu getmarkerssuAifc_write.getmarkerscCs|jS(N(u_nframeswritten(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyutell¢suAifc_write.tellcCs‚|jt|ƒƒt|ƒ|j|j}|jrH|j|ƒ}n|jj|ƒ|j||_|jt|ƒ|_dS(N( u_ensure_header_writtenulenu _sampwidthu _nchannelsu_convertu_fileuwriteu_nframeswrittenu _datawritten(uselfudataunframes((u)/opt/alt/python33/lib64/python3.3/aifc.pyuwriteframesraw¥s uAifc_write.writeframesrawcCsB|j|ƒ|j|jks1|j|jkr>|jƒndS(N(uwriteframesrawu_nframeswrittenu_nframesu _datalengthu _datawrittenu _patchheader(uselfudata((u)/opt/alt/python33/lib64/python3.3/aifc.pyu writeframes®s uAifc_write.writeframesc CsÅ|jdkrdSz…|jdƒ|jd@rS|jjdƒ|jd|_n|jƒ|j|jksŠ|j|jksŠ|j r—|j ƒnWdd|_ |j}d|_|j ƒXdS(Niis( u_fileuNoneu_ensure_header_writtenu _datawrittenuwriteu _writemarkersu_nframeswrittenu_nframesu _datalengthu _marklengthu _patchheaderu_convertuclose(uselfuf((u)/opt/alt/python33/lib64/python3.3/aifc.pyuclose´s        uAifc_write.closecCsddl}|j|dƒS(Nii(uaudioopulin2alaw(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _lin2alawÍs uAifc_write._lin2alawcCsddl}|j|dƒS(Nii(uaudioopulin2ulaw(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _lin2ulawÑs uAifc_write._lin2ulawcCsLddl}t|dƒs'd|_n|j|d|jƒ\}|_|S(Niu _adpcmstatei(uaudioopuhasattruNoneu _adpcmstateu lin2adpcm(uselfudatauaudioop((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _lin2adpcmÕs   !uAifc_write._lin2adpcmcCsª|js¦|jd krN|js-d|_n|jdkrNtdƒ‚qNn|jsftdƒ‚n|js~td ƒ‚n|js–td ƒ‚n|j|ƒndS( NsULAWsulawsALAWsalawsG722iuRsample width must be 2 when compressing with ulaw/ULAW, alaw/ALAW or G7.22 (ADPCM)u# channels not specifiedusample width not specifiedusampling rate not specified(sULAWsulawsALAWsalawsG722(u_nframeswrittenu _comptypeu _sampwidthuErroru _nchannelsu _framerateu _write_header(uselfudatasize((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_ensure_header_writtenÜs      u!Aifc_write._ensure_header_writtencCs^|jdkr|j|_n<|jdkr<|j|_n|jdkrZ|j|_ndS(NsG722sulawsULAWsalawsALAW(sulawsULAW(salawsALAW(u _comptypeu _lin2adpcmu_convertu _lin2ulawu _lin2alaw(uself((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_init_compressionìs uAifc_write._init_compressioncCs(|jr%|jdkr%|jƒn|jjdƒ|jsX||j|j|_n|j|j|j|_|jd@r’|jd|_n|jr&|jdkrÝ|jd|_|jd@r#|jd|_q#q&|jd kr&|jd d |_|jd@r#|jd|_q#q&ny|jj ƒ|_ Wn!t t fk r_d|_ YnX|j|jƒ}|jrÁ|jjd ƒ|jjd ƒt|jd ƒt|j|jƒn|jjdƒ|jjdƒt|j|ƒt|j|jƒ|j dk r(|jj ƒ|_nt|j|jƒ|jdkr]t|jdƒnt|j|jdƒt|j|jƒ|jr¹|jj|jƒt|j|jƒn|jjdƒ|j dk rí|jj ƒ|_nt|j|jdƒt|jdƒt|jdƒdS(NsNONEsFORMisulawsULAWsalawsALAWisG722iisAIFCsFVERsAIFFsCOMMisSSNDi(sulawsULAWsalawsALAW(sULAWsulawsALAWsalawsG722(u_aifcu _comptypeu_init_compressionu_fileuwriteu_nframesu _nchannelsu _sampwidthu _datalengthutellu_form_length_posuAttributeErroruOSErroruNoneu_write_form_lengthu _write_ulongu_versionu _write_shortu _nframes_posu _write_floatu _framerateu _write_stringu _compnameu_ssnd_length_pos(uselfu initlengthu commlength((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _write_headerôs^        uAifc_write._write_headercCsw|jr<d t|jƒ}|d@r3|d}nd}n d}d}t|jd||jd|d|ƒ|S( Niiii iiiii(u_aifculenu _compnameu _write_ulongu_fileu _marklength(uselfu datalengthu commlengthu verslength((u)/opt/alt/python33/lib64/python3.3/aifc.pyu_write_form_length's     "uAifc_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(Nisii(u_fileutellu _datawrittenuwriteu _datalengthu_nframesu_nframeswrittenu _marklengthuseeku_form_length_posu_write_form_lengthu _nframes_posu _write_ulongu_ssnd_length_pos(uselfucurposu datalengthudummy((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _patchheader4s&    uAifc_write._patchheadercCst|jƒdkrdS|jjdƒd}x[|jD]P}|\}}}|t|ƒdd}t|ƒd@dkr9|d}q9q9Wt|j|ƒ|d|_t|jt|jƒƒxP|jD]E}|\}}}t|j|ƒt|j|ƒt|j|ƒqÍWdS(NisMARKiiii(ulenu_markersu_fileuwriteu _write_ulongu _marklengthu _write_shortu _write_string(uselfulengthumarkeruiduposuname((u)/opt/alt/python33/lib64/python3.3/aifc.pyu _writemarkersJs" uAifc_write._writemarkersN(%u__name__u __module__u __qualname__u__init__uinitfpu__del__uaiffuaifcu setnchannelsu getnchannelsu setsampwidthu getsampwidthu setframerateu getframerateu setnframesu getnframesu setcomptypeu getcomptypeu getcompnameu setparamsu getparamsusetmarkugetmarku getmarkersutelluwriteframesrawu writeframesucloseu _lin2alawu _lin2ulawu _lin2adpcmu_ensure_header_writtenu_init_compressionu _write_headeru_write_form_lengthu _patchheaderu _writemarkers(u __locals__((u)/opt/alt/python33/lib64/python3.3/aifc.pyu Aifc_writeësD                          3 u Aifc_writecCsl|dkr0t|dƒr'|j}q0d}n|dkrFt|ƒS|dkr\t|ƒStdƒ‚dS( Numodeurburuwuwbu$mode must be 'r', 'rb', 'w', or 'wb'(ururb(uwuwb(uNoneuhasattrumodeu Aifc_readu Aifc_writeuError(ufumode((u)/opt/alt/python33/lib64/python3.3/aifc.pyuopen]s       u__main__iu/usr/demos/data/audio/bach.aiffuruReadingu nchannels =u nframes =u sampwidth =u framerate =u comptype =u compname =iuWritinguwiuDone.(1u__doc__ustructubuiltinsuwarningsu__all__u ExceptionuErroru _AIFC_versionu _read_longu _read_ulongu _read_shortu _read_ushortu _read_stringu _HUGE_VALu _read_floatu _write_shortu _write_ushortu _write_longu _write_ulongu _write_stringu _write_floatuchunkuChunku Aifc_readu Aifc_writeuNoneuopenuopenfpu__name__usysuargvuappendufnufuprintu getnchannelsu getnframesu getsampwidthu getframerateu getcomptypeu getcompnameugnugu setparamsu getparamsu readframesudatau writeframesuclose(((u)/opt/alt/python33/lib64/python3.3/aifc.pyu‡sj               !ëÿs