@@ -93,7 +93,8 @@ class Error(Exception):
9393_array_fmts = None , 'b' , 'h' , None , 'i'
9494
9595_wave_params = namedtuple ('_wave_params' ,
96- 'nchannels sampwidth framerate nframes comptype compname' )
96+ 'nchannels sampwidth framerate nframes comptype compname format' ,
97+ defaults = (WAVE_FORMAT_PCM ,))
9798
9899
99100def _byteswap (data , width ):
@@ -349,7 +350,8 @@ def getcompname(self):
349350 def getparams (self ):
350351 return _wave_params (self .getnchannels (), self .getsampwidth (),
351352 self .getframerate (), self .getnframes (),
352- self .getcomptype (), self .getcompname ())
353+ self .getcomptype (), self .getcompname (),
354+ self .getformat ())
353355
354356 def setpos (self , pos ):
355357 if pos < 0 or pos > self ._nframes :
@@ -552,20 +554,25 @@ def getcompname(self):
552554 return self ._compname
553555
554556 def setparams (self , params ):
555- nchannels , sampwidth , framerate , nframes , comptype , compname = params
556557 if self ._datawritten :
557558 raise Error ('cannot change parameters after starting to write' )
559+ if len (params ) == 6 :
560+ nchannels , sampwidth , framerate , nframes , comptype , compname = params
561+ format = WAVE_FORMAT_PCM
562+ else :
563+ nchannels , sampwidth , framerate , nframes , comptype , compname , format = params
558564 self .setnchannels (nchannels )
559565 self .setsampwidth (sampwidth )
560566 self .setframerate (framerate )
561567 self .setnframes (nframes )
562568 self .setcomptype (comptype , compname )
569+ self .setformat (format )
563570
564571 def getparams (self ):
565572 if not self ._nchannels or not self ._sampwidth or not self ._framerate :
566573 raise Error ('not all parameters set' )
567574 return _wave_params (self ._nchannels , self ._sampwidth , self ._framerate ,
568- self ._nframes , self ._comptype , self ._compname )
575+ self ._nframes , self ._comptype , self ._compname , self . _format )
569576
570577 def tell (self ):
571578 return self ._nframeswritten
0 commit comments