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¯Fã@sþdZddlmZeddƒZdZdZdZdZd Zd Z d Z d Z d Z dZ dZdZdZdZeeeee egZGdd„deƒZdd„Zdd„ZGdd„dƒZGdd„dƒZddd„ZeZdS) aÚStuff to parse Sun and NeXT audio files. An audio file consists of a header followed by the data. The structure of the header is as follows. +---------------+ | magic word | +---------------+ | header size | +---------------+ | data size | +---------------+ | encoding | +---------------+ | sample rate | +---------------+ | # of channels | +---------------+ | info | | | +---------------+ The magic word consists of the 4 characters '.snd'. Apart from the info field, all header fields are 4 bytes in size. They are all 32-bit unsigned integers encoded in big-endian byte order. The header size really gives the start of the data. The data size is the physical size of the data. From the other parameters the number of frames can be calculated. The encoding gives the way in which audio samples are encoded. Possible values are listed below. The info field currently consists of an ASCII string giving a human-readable description of the audio file. The info field is padded with NUL bytes to the header size. Usage. Reading audio files: f = sunau.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' or 'ULAW') getcompname() -- returns human-readable version of compression type ('not compressed' matches 'NONE') getparams() -- returns a namedtuple consisting of all of the above in the above order getmarkers() -- returns None (for compatibility with the aifc module) getmark(id) -- raises an error since the mark does not exist (for compatibility with the 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 audio files: f = sunau.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 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. The close() method is called automatically when the class instance is destroyed. é)Ú namedtupleÚ _sunau_paramsz7nchannels sampwidth framerate nframes comptype compnameidns.éééééééééééélÿÿc@seZdZdS)ÚErrorN)Ú__name__Ú __module__Ú __qualname__©rrú$/opt/python35/lib/python3.5/sunau.pyrˆs rcCsPd}xCtdƒD]5}|jdƒ}|s4t‚|dt|ƒ}qW|S)Nrrré)ÚrangeÚreadÚEOFErrorÚord)ÚfileÚxÚiZbyterrrÚ _read_u32‹srcCseg}xEtdƒD]7}t|dƒ\}}|jdt|ƒƒ|}qW|jt|ƒƒdS)Nrrr)rÚdivmodÚinsertÚintÚwriteÚbytes)rrÚdatarÚdÚmrrrÚ _write_u32”s  r'c@seZdZdd„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)S)*ÚAu_readcCs\t|ƒtdƒkrBddl}|j|dƒ}d|_n d|_|j|ƒdS)NÚrÚrbTF)ÚtypeÚbuiltinsÚopenÚ_openedÚinitfp)ÚselfÚfr,rrrÚ__init__žs    zAu_read.__init__cCs|jr|jƒdS)N)Ú_fileÚclose)r0rrrÚ__del__§s zAu_read.__del__cCs|S)Nr)r0rrrÚ __enter__«szAu_read.__enter__cGs|jƒdS)N)r4)r0ÚargsrrrÚ__exit__®szAu_read.__exit__c Cso||_d|_tt|ƒƒ}|tkr<tdƒ‚tt|ƒƒ|_|jdkrltdƒ‚|jdkr‡tdƒ‚t|ƒ|_|jtkr·t|jƒ|_tt|ƒƒ|_ |j t krçtdƒ‚|j t t fkrd|_ d |_n”|j tkr3d |_|_ nr|j tkrUd|_|_ nP|j tkrwd |_|_ n.|j tkr™d |_|_ n td ƒ‚tt|ƒƒ|_tt|ƒƒ|_|j|j|_|jdkr+|j|jdƒ|_|jjd ƒ\|_}}n d|_y|jƒ|_Wn!ttfk rjd|_YnXdS)Nrzbad magic numberr zheader size too smallédzheader size ridiculously largezencoding not (yet) supportedrrrrzunknown encodingsó)r3Ú _soundposr!rÚAUDIO_FILE_MAGICrZ _hdr_sizeÚ _data_sizeÚAUDIO_UNKNOWN_SIZEÚ _encodingÚ_simple_encodingsÚAUDIO_FILE_ENCODING_MULAW_8ÚAUDIO_FILE_ENCODING_ALAW_8Ú _sampwidthÚ _framesizeÚAUDIO_FILE_ENCODING_LINEAR_8ÚAUDIO_FILE_ENCODING_LINEAR_16ÚAUDIO_FILE_ENCODING_LINEAR_24ÚAUDIO_FILE_ENCODING_LINEAR_32Ú _framerateÚ _nchannelsrÚ_infoÚ partitionÚtellÚ _data_posÚAttributeErrorÚOSError)r0rÚmagicÚ_rrrr/±sP            ! zAu_read.initfpcCs|jS)N)r3)r0rrrÚgetfpÝsz Au_read.getfpcCs|jS)N)rJ)r0rrrÚ getnchannelsàszAu_read.getnchannelscCs|jS)N)rC)r0rrrÚ getsampwidthãszAu_read.getsampwidthcCs|jS)N)rI)r0rrrÚ getframerateæszAu_read.getframeratecCs4|jtkrtS|jtkr0|j|jSdS)Nr)r=r>r?r@rD)r0rrrÚ getnframesés zAu_read.getnframescCs.|jtkrdS|jtkr&dSdSdS)NÚULAWÚALAWÚNONE)r?rArB)r0rrrÚ getcomptypeðs zAu_read.getcomptypecCs.|jtkrdS|jtkr&dSdSdS)NzCCITT G.711 u-lawzCCITT G.711 A-lawznot compressed)r?rArB)r0rrrÚ getcompnameøs zAu_read.getcompnamecCs=t|jƒ|jƒ|jƒ|jƒ|jƒ|jƒƒS)N)rrTrUrVrWr[r\)r0rrrÚ getparamsszAu_read.getparamscCsdS)Nr)r0rrrÚ getmarkersszAu_read.getmarkerscCstdƒ‚dS)Nzno marks)r)r0ÚidrrrÚgetmarkszAu_read.getmarkcCsš|jtkr–|tkr-|jjƒ}n|jj||jƒ}|jt|ƒ|j7_|jtkr’ddl }|j ||j ƒ}|SdS)Nr) r?r@r>r3rrDr;ÚlenrAÚaudioopZulaw2linrC)r0Únframesr$rbrrrÚ readframes s  zAu_read.readframescCs;|jdkrtdƒ‚|jj|jƒd|_dS)Nz cannot seekr)rNrPr3Úseekr;)r0rrrÚrewinds zAu_read.rewindcCs|jS)N)r;)r0rrrrMsz Au_read.tellcCsp|dks||jƒkr*tdƒ‚|jdkrEtdƒ‚|jj|j||jƒ||_dS)Nrzposition not in rangez cannot seek)rWrrNrPr3rerDr;)r0ÚposrrrÚsetpos!s   zAu_read.setposcCs/|j}|r+d|_|jr+|jƒdS)N)r3r.r4)r0rrrrr4)s    z Au_read.closeN)rrrr2r5r6r8r/rSrTrUrVrWr[r\r]r^r`rdrfrMrhr4rrrrr(œs(     ,             r(c@s<eZdZdd„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„Zd3S)4ÚAu_writecCs\t|ƒtdƒkrBddl}|j|dƒ}d|_n d|_|j|ƒdS)Nr)rÚwbTF)r+r,r-r.r/)r0r1r,rrrr22s    zAu_write.__init__cCs |jr|jƒd|_dS)N)r3r4)r0rrrr5;s  zAu_write.__del__cCs|S)Nr)r0rrrr6@szAu_write.__enter__cGs|jƒdS)N)r4)r0r7rrrr8CszAu_write.__exit__cCsg||_d|_d|_d|_d|_t|_d|_d|_d|_ d|_ d|_ dS)Nrr:rX) r3rIrJrCrDr>Ú_nframesÚ_nframeswrittenÚ _datawrittenÚ _datalengthrKÚ _comptype)r0rrrrr/Fs          zAu_write.initfpcCs:|jrtdƒ‚|dkr-tdƒ‚||_dS)Nz0cannot change parameters after starting to writerrrz"only 1, 2, or 4 channels supported)rrr)rlrrJ)r0Ú nchannelsrrrÚ setnchannelsSs     zAu_write.setnchannelscCs|jstdƒ‚|jS)Nznumber of channels not set)rJr)r0rrrrTZs  zAu_write.getnchannelscCs:|jrtdƒ‚|dkr-tdƒ‚||_dS)Nz0cannot change parameters after starting to writerrrrzbad sample width)rrrr)rlrrC)r0Ú sampwidthrrrÚ setsampwidth_s     zAu_write.setsampwidthcCs|jstdƒ‚|jS)Nzsample width not specified)rIrrC)r0rrrrUfs  zAu_write.getsampwidthcCs"|jrtdƒ‚||_dS)Nz0cannot change parameters after starting to write)rlrrI)r0Ú frameraterrrÚ setframerateks  zAu_write.setframeratecCs|jstdƒ‚|jS)Nzframe rate not set)rIr)r0rrrrVps  zAu_write.getframeratecCs:|jrtdƒ‚|dkr-tdƒ‚||_dS)Nz0cannot change parameters after starting to writerz# of frames cannot be negative)rlrrk)r0rcrrrÚ setnframesus     zAu_write.setnframescCs|jS)N)rl)r0rrrrW|szAu_write.getnframescCs(|dkr||_n tdƒ‚dS)NrZrXzunknown compression type)rZrX)ror)r0r+ÚnamerrrÚ setcomptypes  zAu_write.setcomptypecCs|jS)N)ro)r0rrrr[…szAu_write.getcomptypecCs.|jdkrdS|jdkr&dSdSdS)NrXzCCITT G.711 u-lawrYzCCITT G.711 A-lawznot compressed)ro)r0rrrr\ˆs zAu_write.getcompnamecCs`|\}}}}}}|j|ƒ|j|ƒ|j|ƒ|j|ƒ|j||ƒdS)N)rqrsrurvrx)r0ÚparamsrprrrtrcZcomptypeZcompnamerrrÚ setparams�s     zAu_write.setparamscCs=t|jƒ|jƒ|jƒ|jƒ|jƒ|jƒƒS)N)rrTrUrVrWr[r\)r0rrrr]˜szAu_write.getparamscCs|jS)N)rl)r0rrrrM�sz Au_write.tellcCs±t|ttfƒs*t|ƒjdƒ}|jƒ|jdkrdddl}|j||j ƒ}t |ƒ|j }|j j |ƒ|j||_|jt |ƒ|_dS)NÚBrXr)Ú isinstancer#Ú bytearrayÚ memoryviewÚcastÚ_ensure_header_writtenrorbZlin2ulawrCrarDr3r"rlrm)r0r$rbrcrrrÚwriteframesraw s  zAu_write.writeframesrawcCs?|j|ƒ|j|jks1|j|jkr;|jƒdS)N)r�rlrkrnrmÚ _patchheader)r0r$rrrÚ writeframes¬s zAu_write.writeframesc Cs|jr{zI|jƒ|j|jks:|j|jkrD|jƒ|jjƒWd|j}d|_|jrz|j ƒXdS)N) r3r€rlrkrnrmr‚Úflushr.r4)r0rrrrr4²s      zAu_write.closecCsV|jsR|jstdƒ‚|js3tdƒ‚|jsHtdƒ‚|jƒdS)Nz# of channels not specifiedzsample width not specifiedzframe rate not specified)rlrJrrCrIÚ _write_header)r0rrrr€Äs       zAu_write._ensure_header_writtenc Cs|jdkr¢|jdkr0t}d|_qÏ|jdkrQt}d|_qÏ|jdkrrt}d|_qÏ|jdkr“t}d|_qÏtdƒ‚n-|jdkrÃt}d|_n tdƒ‚|j|j |_t |j t ƒdt |jƒ}|d d @}t |j |ƒ|jtkr;t}n|j|j}y|j jƒ|_Wn!ttfk r„d|_YnXt |j |ƒ||_t |j |ƒt |j |jƒt |j |j ƒ|j j|jƒ|j jd |t |jƒd ƒdS) NrZrrrrzinternal errorrXr r sr iøÿÿÿ)rorCrErDrFrGrHrrArJr'r3r<rarKrkr>rMÚ_form_length_posrOrPrnrIr")r0ÚencodingZ header_sizeÚlengthrrrr…ÎsJ        zAu_write._write_headercCsd|jdkrtdƒ‚|jj|jƒt|j|jƒ|j|_|jjddƒdS)Nz cannot seekrr)r†rPr3rer'rmrn)r0rrrr‚øs   zAu_write._patchheaderN)rrrr2r5r6r8r/rqrTrsrUrurVrvrWrxr[r\rzr]rMr�rƒr4r€r…r‚rrrrri0s2                     *riNcCsi|dkr-t|dƒr'|j}nd}|dkrCt|ƒS|dkrYt|ƒStdƒ‚dS) NÚmoder*ÚrÚwrjz$mode must be 'r', 'rb', 'w', or 'wb')rŠr*)r‹rj)Úhasattrr‰r(rir)r1r‰rrrr-s      r-)Ú__doc__Ú collectionsrrr<rArErFrGrHZAUDIO_FILE_ENCODING_FLOATZAUDIO_FILE_ENCODING_DOUBLEZAUDIO_FILE_ENCODING_ADPCM_G721ZAUDIO_FILE_ENCODING_ADPCM_G722Z AUDIO_FILE_ENCODING_ADPCM_G723_3Z AUDIO_FILE_ENCODING_ADPCM_G723_5rBr>r@Ú Exceptionrrr'r(rir-ZopenfprrrrÚhs<   ”Ð