135135
136136import struct
137137import __builtin__
138- try :
139- import CL
140- except ImportError :
141- pass
142138
143139Error = 'aifc.Error'
144140
@@ -378,13 +374,14 @@ def initfp(self, file):
378374 if not self ._comm_chunk_read or not self ._ssnd_chunk :
379375 raise Error , 'COMM chunk and/or SSND chunk missing'
380376 if self ._aifc and self ._decomp :
381- params = [CL .ORIGINAL_FORMAT , 0 ,
382- CL .BITS_PER_COMPONENT , self ._sampwidth * 8 ,
383- CL .FRAME_RATE , self ._framerate ]
377+ import cl
378+ params = [cl .ORIGINAL_FORMAT , 0 ,
379+ cl .BITS_PER_COMPONENT , self ._sampwidth * 8 ,
380+ cl .FRAME_RATE , self ._framerate ]
384381 if self ._nchannels == 1 :
385- params [1 ] = CL .MONO
382+ params [1 ] = cl .MONO
386383 elif self ._nchannels == 2 :
387- params [1 ] = CL .STEREO_INTERLEAVED
384+ params [1 ] = cl .STEREO_INTERLEAVED
388385 else :
389386 raise Error , 'cannot compress more than 2 channels'
390387 self ._decomp .SetParams (params )
@@ -483,7 +480,8 @@ def readframes(self, nframes):
483480## if 0: access *: private
484481
485482 def _decomp_data (self , data ):
486- dummy = self ._decomp .SetParam (CL .FRAME_BUFFER_SIZE ,
483+ import cl
484+ dummy = self ._decomp .SetParam (cl .FRAME_BUFFER_SIZE ,
487485 len (data ) * 2 )
488486 return self ._decomp .Decompress (len (data ) / self ._nchannels ,
489487 data )
@@ -537,7 +535,7 @@ def _read_comm_chunk(self, chunk):
537535 return
538536 # for ULAW and ALAW try Compression Library
539537 try :
540- import cl , CL
538+ import cl
541539 except ImportError :
542540 if self ._comptype == 'ULAW' :
543541 try :
@@ -549,10 +547,10 @@ def _read_comm_chunk(self, chunk):
549547 pass
550548 raise Error , 'cannot read compressed AIFF-C files'
551549 if self ._comptype == 'ULAW' :
552- scheme = CL .G711_ULAW
550+ scheme = cl .G711_ULAW
553551 self ._framesize = self ._framesize / 2
554552 elif self ._comptype == 'ALAW' :
555- scheme = CL .G711_ALAW
553+ scheme = cl .G711_ALAW
556554 self ._framesize = self ._framesize / 2
557555 else :
558556 raise Error , 'unsupported compression type'
@@ -810,8 +808,9 @@ def close(self):
810808## if 0: access *: private
811809
812810 def _comp_data (self , data ):
813- dum = self ._comp .SetParam (CL .FRAME_BUFFER_SIZE , len (data ))
814- dum = self ._comp .SetParam (CL .COMPRESSED_BUFFER_SIZE , len (data ))
811+ import cl
812+ dum = self ._comp .SetParam (cl .FRAME_BUFFER_SIZE , len (data ))
813+ dum = self ._comp .SetParam (cl .COMPRESSED_BUFFER_SIZE , len (data ))
815814 return self ._comp .Compress (nframes , data )
816815
817816 def _lin2ulaw (self , data ):
@@ -852,7 +851,7 @@ def _init_compression(self):
852851 self ._convert = self ._lin2adpcm
853852 return
854853 try :
855- import cl , CL
854+ import cl
856855 except ImportError :
857856 if self ._comptype == 'ULAW' :
858857 try :
@@ -863,21 +862,21 @@ def _init_compression(self):
863862 pass
864863 raise Error , 'cannot write compressed AIFF-C files'
865864 if self ._comptype == 'ULAW' :
866- scheme = CL .G711_ULAW
865+ scheme = cl .G711_ULAW
867866 elif self ._comptype == 'ALAW' :
868- scheme = CL .G711_ALAW
867+ scheme = cl .G711_ALAW
869868 else :
870869 raise Error , 'unsupported compression type'
871870 self ._comp = cl .OpenCompressor (scheme )
872- params = [CL .ORIGINAL_FORMAT , 0 ,
873- CL .BITS_PER_COMPONENT , self ._sampwidth * 8 ,
874- CL .FRAME_RATE , self ._framerate ,
875- CL .FRAME_BUFFER_SIZE , 100 ,
876- CL .COMPRESSED_BUFFER_SIZE , 100 ]
871+ params = [cl .ORIGINAL_FORMAT , 0 ,
872+ cl .BITS_PER_COMPONENT , self ._sampwidth * 8 ,
873+ cl .FRAME_RATE , self ._framerate ,
874+ cl .FRAME_BUFFER_SIZE , 100 ,
875+ cl .COMPRESSED_BUFFER_SIZE , 100 ]
877876 if self ._nchannels == 1 :
878- params [1 ] = CL .MONO
877+ params [1 ] = cl .MONO
879878 elif self ._nchannels == 2 :
880- params [1 ] = CL .STEREO_INTERLEAVED
879+ params [1 ] = cl .STEREO_INTERLEAVED
881880 else :
882881 raise Error , 'cannot compress more than 2 channels'
883882 self ._comp .SetParams (params )
0 commit comments