@@ -468,15 +468,13 @@ def _read_comm_chunk(self, chunk):
468468 if self ._comptype != b'NONE' :
469469 if self ._comptype == b'G722' :
470470 self ._convert = self ._adpcm2lin
471- self ._framesize = self ._framesize // 4
472471 elif self ._comptype in (b'ulaw' , b'ULAW' ):
473472 self ._convert = self ._ulaw2lin
474- self ._framesize = self ._framesize // 2
475473 elif self ._comptype in (b'alaw' , b'ALAW' ):
476474 self ._convert = self ._alaw2lin
477- self ._framesize = self ._framesize // 2
478475 else :
479476 raise Error ('unsupported compression type' )
477+ self ._sampwidth = 2
480478 else :
481479 self ._comptype = b'NONE'
482480 self ._compname = b'not compressed'
@@ -804,7 +802,10 @@ def _write_header(self, initlength):
804802 _write_short (self ._file , self ._nchannels )
805803 self ._nframes_pos = self ._file .tell ()
806804 _write_ulong (self ._file , self ._nframes )
807- _write_short (self ._file , self ._sampwidth * 8 )
805+ if self ._comptype in (b'ULAW' , b'ulaw' , b'ALAW' , b'alaw' , b'G722' ):
806+ _write_short (self ._file , 8 )
807+ else :
808+ _write_short (self ._file , self ._sampwidth * 8 )
808809 _write_float (self ._file , self ._framerate )
809810 if self ._aifc :
810811 self ._file .write (self ._comptype )
0 commit comments