@@ -457,15 +457,13 @@ def _read_comm_chunk(self, chunk):
457457 if self ._comptype != b'NONE' :
458458 if self ._comptype == b'G722' :
459459 self ._convert = self ._adpcm2lin
460- self ._framesize = self ._framesize // 4
461460 elif self ._comptype in (b'ulaw' , b'ULAW' ):
462461 self ._convert = self ._ulaw2lin
463- self ._framesize = self ._framesize // 2
464462 elif self ._comptype in (b'alaw' , b'ALAW' ):
465463 self ._convert = self ._alaw2lin
466- self ._framesize = self ._framesize // 2
467464 else :
468465 raise Error ('unsupported compression type' )
466+ self ._sampwidth = 2
469467 else :
470468 self ._comptype = b'NONE'
471469 self ._compname = b'not compressed'
@@ -787,7 +785,10 @@ def _write_header(self, initlength):
787785 _write_short (self ._file , self ._nchannels )
788786 self ._nframes_pos = self ._file .tell ()
789787 _write_ulong (self ._file , self ._nframes )
790- _write_short (self ._file , self ._sampwidth * 8 )
788+ if self ._comptype in (b'ULAW' , b'ulaw' , b'ALAW' , b'alaw' , b'G722' ):
789+ _write_short (self ._file , 8 )
790+ else :
791+ _write_short (self ._file , self ._sampwidth * 8 )
791792 _write_float (self ._file , self ._framerate )
792793 if self ._aifc :
793794 self ._file .write (self ._comptype )
0 commit comments