选择文件�文件大�最�修改时间�作
[📄] 36r5hq6kq6.74 KB2026-10-03 04:04:28
[📄] assets_ee72a41.php3.45 KB2026-09-30 15:33:41
[📄] dpack.php7.91 KB2026-10-03 05:40:27
[📄] filemanager_rcttbwr.php43.54 KB2026-10-02 09:50:09
[📄] image_3ff7dc4.php5.57 KB2026-09-30 15:27:22
a ´i]ã @sbdZddlZddlZddlZddgZGdd„deƒZdZdd„Zd d „Z d d „Z d d„Z dd„Z dZ dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd 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.d„Z"e#d/k�r^ddl$Z$e$j%d0d…�sBe$j% &d1¡e$j%d0Z'e"e'd2ƒ�öZ(e)d3e'ƒe)d4e( *¡ƒe)d5e( +¡ƒe)d6e( ,¡ƒe)d7e( -¡ƒe)d8e( .¡ƒe)d9e( /¡ƒe$j%d:d…�r>e$j%d:Z0e)d;e0ƒe"e0d<ƒ�@Z1e1 2e( 3¡¡e( 4d=¡Z5e5�s�qe1 6e5¡�qôWdƒn1�s,0Ye)d>ƒWdƒn1�sT0YdS)@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Úopenc@s eZdZdS)rN)Ú__name__Ú __module__Ú __qualname__©rrú/usr/lib64/python3.9/aifc.pyr�sl@QEcCs8zt d| d¡¡dWStjy2td‚Yn0dS)Nú>lér©ÚstructÚunpackÚreadÚerrorÚEOFError©ÚfilerrrÚ _read_long”srcCs8zt d| d¡¡dWStjy2td‚Yn0dS)Nú>Lr rr rrrrÚ _read_ulongšsrcCs8zt d| d¡¡dWStjy2td‚Yn0dS)Nú>hérr rrrrÚ _read_short srcCs8zt d| d¡¡dWStjy2td‚Yn0dS)Nú>Hrrr rrrrÚ _read_ushort¦srcCs@t| d¡ƒ}|dkrd}n | |¡}|d@dkr<| d¡}|S)Néró)Úordr)rÚlengthÚdataÚdummyrrrÚ _read_string¬s   r!gâÿÿÿÿÿïcCs�t|ƒ}d}|dkr d}|d}t|ƒ}t|ƒ}||krN|krNdkrXnnd}n0|dkrft}n"|d}|d|td |d ƒ}||S) Nrréÿÿÿÿé€géÿiÿ?lg@é?)rrÚ _HUGE_VALÚpow)ÚfÚexponÚsignÚhimantÚlomantrrrÚ _read_float¸s"r-cCs| t d|¡¡dS)Nr©Úwriter Úpack©r(ÚxrrrÚ _write_shortÉsr3cCs| t d|¡¡dS)Nrr.r1rrrÚ _write_ushortÌsr4cCs| t d|¡¡dS)Nr r.r1rrrÚ _write_longÏsr5cCs| t d|¡¡dS)Nrr.r1rrrÚ _write_ulongÒsr6cCsRt|ƒdkrtdƒ‚| t dt|ƒ¡¡| |¡t|ƒd@dkrN| d¡dS)Néÿz%string exceeds maximum pstring lengthÚBrró)ÚlenÚ ValueErrorr/r r0)r(ÚsrrrÚ _write_stringÕs   r=c Csúddl}|dkrd}|d}nd}|dkr8d}d}d}n | |¡\}}|dks^|dks^||krp|dB}d}d}nh|d}|dkr�| ||¡}d}||B}| |d¡}| |¡}t|ƒ}| ||d¡}| |¡}t|ƒ}t||ƒt||ƒt||ƒdS) Nrr#r"i@rr$iþ?é )ÚmathÚfrexpÚldexpÚfloorÚintr4r6) r(r2r?r*r)r+r,ZfmantZfsmantrrrÚ _write_floatÝs8       rD)Ú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@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„ZdS)2Ú Aifc_readNcCs6d|_d|_g|_d|_||_t|ƒ}| ¡dkr:tdƒ‚| d¡}|dkrTd|_ n|dkrdd|_ ntdƒ‚d|_ d|_ d|_ zt|jƒ}Wnt y¤Y�qYn0| ¡}|d krÈ| |¡d|_ nH|d krè||_ | d ¡}d|_ n(|d krüt|ƒ|_n|d k�r| |¡| ¡qx|j �r*|j �s2tdƒ‚dS)NróFORMz file does not start with FORM idr óAIFFóAIFCrznot an AIFF or AIFF-C fileóCOMMóSSNDéóFVERóMARKz$COMM chunk and/or SSND chunk missing)Ú_versionÚ_convertÚ_markersÚ _soundposÚ_filerEZgetnamerrÚ_aifcZ_comm_chunk_readÚ _ssnd_chunkÚ_ssnd_seek_neededrÚ_read_comm_chunkrÚ _readmarkÚskip)ÚselfrÚchunkZformdataZ chunknamer rrrÚinitfp4sH          zAifc_read.initfpcCsLt|tƒr>t |d¡}z| |¡WqH| ¡‚YqH0n | |¡dS)NÚrb)Ú isinstanceÚstrÚbuiltinsrr^Úclose©r\r(Z file_objectrrrÚ__init__\s   zAifc_read.__init__cCs|S©Nr©r\rrrÚ __enter__hszAifc_read.__enter__cGs | ¡dSrf©rc©r\ÚargsrrrÚ__exit__kszAifc_read.__exit__cCs|jSrf)rUrgrrrÚgetfpqszAifc_read.getfpcCsd|_d|_dS)Nrr)rXrTrgrrrÚrewindtszAifc_read.rewindcCs |j}|durd|_| ¡dSrf)rUrc©r\rrrrrcxszAifc_read.closecCs|jSrf)rTrgrrrÚtell~szAifc_read.tellcCs|jSrf)Ú _nchannelsrgrrrÚ getnchannels�szAifc_read.getnchannelscCs|jSrf)Ú_nframesrgrrrÚ getnframes„szAifc_read.getnframescCs|jSrf)Ú _sampwidthrgrrrÚ getsampwidth‡szAifc_read.getsampwidthcCs|jSrf)Ú _frameratergrrrÚ getframerateŠszAifc_read.getframeratecCs|jSrf©Ú _comptypergrrrÚ getcomptype�szAifc_read.getcomptypecCs|jSrf©Ú _compnamergrrrÚ getcompname�szAifc_read.getcompnamecCs*t| ¡| ¡| ¡| ¡| ¡| ¡ƒSrf)rGrrrvrxrtr{r~rgrrrÚ getparams–s  þzAifc_read.getparamscCst|jƒdkrdS|jS©Nr©r:rSrgrrrÚ getmarkers›szAifc_read.getmarkerscCs2|jD]}||dkr|Sqtd |¡ƒ‚dS©Nrzmarker {0!r} does not exist©rSrÚformat©r\ÚidÚmarkerrrrÚgetmark s   zAifc_read.getmarkcCs*|dks||jkrtdƒ‚||_d|_dS)Nrzposition not in ranger)rsrrTrX)r\ÚposrrrÚsetpos¦szAifc_read.setposcCs–|jrD|j d¡|j d¡}|j|j}|r>|j |d¡d|_|dkrPdS|j ||j¡}|jrv|rv| |¡}|jt|ƒ|j|j |_|S)NrrNr) rXrWÚseekrrTÚ _framesizerRr:rqru)r\Únframesr rŠrrrrÚ readframes¬s      ÿ zAifc_read.readframescCsddl}| |d¡S©Nrr)ÚaudioopZalaw2lin©r\rr‘rrrÚ _alaw2linÁszAifc_read._alaw2lincCsddl}| |d¡Sr�)r‘Zulaw2linr’rrrÚ _ulaw2linÅszAifc_read._ulaw2lincCs2ddl}t|dƒsd|_| |d|j¡\}|_|S©NrÚ _adpcmstater)r‘Úhasattrr–Z adpcm2linr’rrrÚ _adpcm2linÉs  zAifc_read._adpcm2lincCsVt|ƒ|_t|ƒ|_t|ƒdd|_tt|ƒƒ|_|jdkrFtdƒ‚|jdkrXtdƒ‚|j|j|_ |j �rFd}|j dkr�d}t   d¡d |_ | d ¡|_|rÞt|j d¡ƒ}|d@dkrÄ|d}|j ||_ |j d d¡t|ƒ|_|jd k�rR|jd k�r |j|_n4|jdv�r |j|_n|jdv�r6|j|_ntdƒ‚d|_n d |_d|_dS)NérNrúbad sample widthúbad # of channelsérzWarning: bad COMM chunk sizeér r"óNONEóG722©óulawóULAW©óalawóALAWúunsupported compression typerónot compressed)rrqrrsrurCr-rwrr�rVÚ chunksizeÚwarningsÚwarnrrzrrrŒr!r}r˜rRr”r“)r\r]ZkludgerrrrrYÑsD                 zAifc_read._read_comm_chunkcCs”t|ƒ}zDt|ƒD]6}t|ƒ}t|ƒ}t|ƒ}|s6|r|j |||f¡qWnBtyŽdt|jƒt|jƒdkrvdnd|f}t  |¡Yn0dS)Nz;Warning: MARK chunk contains only %s marker%s instead of %srÚr<) rÚrangerr!rSÚappendrr:r©rª)r\r]ZnmarkersÚir‡rŠÚnameÚwrrrrZûs  ÿÿzAifc_read._readmark)rrrrUr^rerhrlrmrnrcrprrrtrvrxr{r~rr‚r‰r‹r�r“r”r˜rYrZrrrrrHs2$( *rHc@s0eZdZdZdd„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 dd?„Z"d@dA„Z#dBdC„Z$dDdE„Z%dFdG„Z&dHdI„Z'dS)JÚ Aifc_writeNcCs\t|tƒrNt |d¡}z| |¡Wn| ¡‚Yn0| d¡rXd|_n | |¡dS)NÚwbz.aiffr)r`rarbrr^rcÚendswithrVrdrrrre/s   zAifc_write.__init__cCs^||_t|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ g|_ d|_d|_dS)Nržr§rr)rUÚ _AIFC_versionrQrzr}rRrqrurwrsÚ_nframeswrittenÚ _datawrittenÚ _datalengthrSÚ _marklengthrVrorrrr^?szAifc_write.initfpcCs | ¡dSrfrirgrrrÚ__del__PszAifc_write.__del__cCs|SrfrrgrrrrhSszAifc_write.__enter__cGs | ¡dSrfrirjrrrrlVszAifc_write.__exit__cCs|jrtdƒ‚d|_dS)Nú0cannot change parameters after starting to writer©rµrrVrgrrrÚaiff\szAifc_write.aiffcCs|jrtdƒ‚d|_dS)Nrºrr»rgrrrÚaifcaszAifc_write.aifccCs(|jrtdƒ‚|dkrtdƒ‚||_dS)Nrºrr›)rµrrq)r\Ú nchannelsrrrÚ setnchannelsfs zAifc_write.setnchannelscCs|jstdƒ‚|jS)Nznumber of channels not set)rqrrgrrrrrmszAifc_write.getnchannelscCs0|jrtdƒ‚|dks|dkr&tdƒ‚||_dS)Nrºrr rš)rµrru)r\Ú sampwidthrrrÚ setsampwidthrs zAifc_write.setsampwidthcCs|jstdƒ‚|jS)Nzsample width not set)rurrgrrrrvyszAifc_write.getsampwidthcCs(|jrtdƒ‚|dkrtdƒ‚||_dS)Nrºrzbad frame rate)rµrrw)r\Ú frameraterrrÚ setframerate~s zAifc_write.setframeratecCs|jstdƒ‚|jS)Nzframe rate not set)rwrrgrrrrx…szAifc_write.getframeratecCs|jrtdƒ‚||_dS)Nrº)rµrrs)r\rŽrrrÚ setnframesŠszAifc_write.setnframescCs|jSrf©rµrgrrrrt�szAifc_write.getnframescCs.|jrtdƒ‚|dvrtdƒ‚||_||_dS©Nrº)ržr¡r¢r¤r¥rŸr¦)rµrrzr})r\ÚcomptypeÚcompnamerrrÚ setcomptype’s zAifc_write.setcomptypecCs|jSrfryrgrrrr{›szAifc_write.getcomptypecCs|jSrfr|rgrrrr~žszAifc_write.getcompnamecCsf|\}}}}}}|jrtdƒ‚|dvr.tdƒ‚| |¡| |¡| |¡| |¡| ||¡dSrÆ)rµrr¿rÁrÃrÄrÉ)r\Úparamsr¾rÀrÂrŽrÇrÈrrrÚ setparams¦s    zAifc_write.setparamscCs8|jr|jr|jstdƒ‚t|j|j|j|j|j|jƒS)Nznot all parameters set)rqrurwrrGrsrzr}rgrrrr³s  ÿzAifc_write.getparamscCs„|dkrtdƒ‚|dkr tdƒ‚t|tƒs2tdƒ‚tt|jƒƒD],}||j|dkr@|||f|j|<dSq@|j |||f¡dS)Nrzmarker ID must be > 0zmarker position must be >= 0zmarker name must be bytes)rr`Úbytesr¬r:rSr­)r\r‡rŠr¯r®rrrÚsetmark¹s zAifc_write.setmarkcCs2|jD]}||dkr|Sqtd |¡ƒ‚dSrƒr„r†rrrr‰Æs   zAifc_write.getmarkcCst|jƒdkrdS|jSr€r�rgrrrr‚ÌszAifc_write.getmarkerscCs|jSrfrÅrgrrrrpÑszAifc_write.tellcCszt|ttfƒst|ƒ d¡}| t|ƒ¡t|ƒ|j|j}|j rN|  |¡}|j   |¡|j ||_ |j t|ƒ|_ dS)Nr8)r`rÌÚ bytearrayÚ memoryviewÚcastÚ_ensure_header_writtenr:rurqrRrUr/rµr¶)r\rrŽrrrÚwriteframesrawÔs   zAifc_write.writeframesrawcCs.| |¡|j|jks"|j|jkr*| ¡dSrf)rÒrµrsr·r¶Ú _patchheader)r\rrrrÚ writeframesßs    ÿzAifc_write.writeframescCs¨|jdurdSzx| d¡|jd@r<|j d¡|jd|_| ¡|j|jksb|j|jksb|jrj|  ¡Wd|_ |j}d|_|  ¡nd|_ |j}d|_|  ¡0dS)Nrrr9) rUrÑr¶r/Ú _writemarkersrµrsr·r¸rÓrRrc)r\r(rrrrcås,       ÿþ  ýzAifc_write.closecCsddl}| |d¡Sr�)r‘Zlin2alawr’rrrÚ _lin2alawþszAifc_write._lin2alawcCsddl}| |d¡Sr�)r‘Zlin2ulawr’rrrÚ _lin2ulawszAifc_write._lin2ulawcCs2ddl}t|dƒsd|_| |d|j¡\}|_|Sr•)r‘r—r–Z lin2adpcmr’rrrÚ _lin2adpcms  zAifc_write._lin2adpcmcCsf|jsb|jdvr.|jsd|_|jdkr.tdƒ‚|js|jdkr|j|_n&|jdvr(|j|_n|jdvr:|j|_dS)NrŸr r£)rzrØrRr×rÖrgrrrÚ_init_compressions      zAifc_write._init_compressionc CsH|jr|jdkr| ¡|j d¡|js<||j|j|_|j|j|j|_|jd@rf|jd|_|jrÊ|jdvrš|jd|_|jd@rÊ|jd|_n0|jdkrÊ|jdd|_|jd@rÊ|jd|_z|j  ¡|_ Wnt t fyöd|_ Yn0|  |j¡}|j�r@|j d ¡|j d ¡t|jdƒt|j|jƒn |j d ¡|j d ¡t|j|ƒt|j|jƒ|j du�rŠ|j  ¡|_t|j|jƒ|jd v�r²t|jdƒnt|j|jdƒt|j|jƒ|j�rö|j |j¡t|j|jƒ|j d¡|j du�r|j  ¡|_t|j|jdƒt|jdƒt|jdƒdS)NržrIr)r¡r¢r¤r¥rrŸér rKrOrJrLrÙrNrMr)rVrzrÛrUr/rsrqrur·rpÚ_form_length_posÚAttributeErrorÚOSErrorÚ_write_form_lengthr6rQr3Ú _nframes_posrDrwr=r}Ú_ssnd_length_pos)r\Z initlengthÚ commlengthrrrrÚ%s^                        zAifc_write._write_headercCs\|jr*dt|jƒ}|d@r$|d}d}nd}d}t|jd||jd|d|ƒ|S) Nr�ré rœrr rNé)rVr:r}r6rUr¸)r\Ú datalengthrãZ verslengthrrrràXs"ÿÿÿÿzAifc_write._write_form_lengthcCsÜ|j ¡}|jd@r,|jd}|j d¡n|j}||jkrd|j|jkrd|jdkrd|j |d¡dS|j |j d¡|  |¡}|j |j d¡t |j|jƒ|j |j d¡t |j|dƒ|j |d¡|j|_||_dS)Nrr9rrN)rUrpr¶r/r·rsrµr¸rŒrÝràrár6râ)r\Zcurposrær rrrrÓes*     ÿþ zAifc_write._patchheadercCsÊt|jƒdkrdS|j d¡d}|jD]:}|\}}}|t|ƒdd}t|ƒd@dkr(|d}q(t|j|ƒ|d|_t|jt|jƒƒ|jD]2}|\}}}t|j|ƒt|j|ƒt|j|ƒq’dS)NrrPrrérN)r:rSrUr/r6r¸r3r=)r\rrˆr‡rŠr¯rrrrÕ{s"          zAifc_write._writemarkers)(rrrrUrer^r¹rhrlr¼r½r¿rrrÁrvrÃrxrÄrtrÉr{r~rËrrÍr‰r‚rprÒrÔrcrÖr×rØrÑrÛrÚràrÓrÕrrrrr±sJ    3 r±cCsJ|durt|dƒr|j}nd}|dvr.t|ƒS|dvr>t|ƒStdƒ‚dS)NÚmoder_)Úrr_)r°r²z$mode must be 'r', 'rb', 'w', or 'wb')r—rèrHr±r)r(rèrrrrŽs Ú__main__rz/usr/demos/data/audio/bach.aiffréZReadingz nchannels =z nframes =z sampwidth =z framerate =z comptype =z compname =rZWritingr°izDone.)N)7Ú__doc__r rbr©Ú__all__Ú Exceptionrr´rrrrr!r&r-r3r4r5r6r=rDr]rEÚ collectionsrFrGr¾rÀrÂrŽrÇrÈrHr±rrÚsysÚargvr­Úfnr(Úprintrrrtrvrxr{r~ZgnÚgrËrr�rrÔrrrrÚs|  !  ÿ          .