1515 getsampwidth() -- returns sample width in bytes
1616 getframerate() -- returns sampling frequency
1717 getnframes() -- returns number of audio frames
18- getencoding() -- returns frame encoding (WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT
18+ getformat() -- returns frame encoding (WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT
1919 or WAVE_FORMAT_EXTENSIBLE)
2020 getcomptype() -- returns compression type ('NONE' for linear samples)
2121 getcompname() -- returns human-readable version of
4444 setsampwidth(n) -- set the sample width
4545 setframerate(n) -- set the frame rate
4646 setnframes(n) -- set the number of frames
47- setencoding(encoding )
48- -- set the frame encoding . Only WAVE_FORMAT_PCM,
47+ setformat(format )
48+ -- set the frame format . Only WAVE_FORMAT_PCM and
4949 WAVE_FORMAT_IEEE_FLOAT are supported.
5050 setcomptype(type, name)
5151 -- set the compression type and the
@@ -232,10 +232,10 @@ class Wave_read:
232232 available through the getsampwidth() method
233233 _framerate -- the sampling frequency
234234 available through the getframerate() method
235- _encoding -- frame encoding
235+ _format -- frame format
236236 One of WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT
237237 or WAVE_FORMAT_EXTENSIBLE available through
238- getencoding () method
238+ getformat () method
239239 _comptype -- the AIFF-C compression type ('NONE' if AIFF)
240240 available through the getcomptype() method
241241 _compname -- the human-readable AIFF-C compression type
@@ -337,6 +337,9 @@ def getsampwidth(self):
337337 def getframerate (self ):
338338 return self ._framerate
339339
340+ def getformat (self ):
341+ return self ._format
342+
340343 def getcomptype (self ):
341344 return self ._comptype
342345
@@ -348,9 +351,6 @@ def getparams(self):
348351 self .getframerate (), self .getnframes (),
349352 self .getcomptype (), self .getcompname ())
350353
351- def getencoding (self ):
352- return self ._encoding
353-
354354 def setpos (self , pos ):
355355 if pos < 0 or pos > self ._nframes :
356356 raise Error ('position not in range' )
@@ -380,16 +380,16 @@ def readframes(self, nframes):
380380
381381 def _read_fmt_chunk (self , chunk ):
382382 try :
383- self ._encoding , self ._nchannels , self ._framerate , dwAvgBytesPerSec , wBlockAlign = struct .unpack_from ('<HHLLH' , chunk .read (14 ))
383+ self ._format , self ._nchannels , self ._framerate , dwAvgBytesPerSec , wBlockAlign = struct .unpack_from ('<HHLLH' , chunk .read (14 ))
384384 except struct .error :
385385 raise EOFError from None
386- if self ._encoding not in (WAVE_FORMAT_PCM , WAVE_FORMAT_IEEE_FLOAT , WAVE_FORMAT_EXTENSIBLE ):
387- raise Error ('unknown format: %r' % (self ._encoding ,))
386+ if self ._format not in (WAVE_FORMAT_PCM , WAVE_FORMAT_IEEE_FLOAT , WAVE_FORMAT_EXTENSIBLE ):
387+ raise Error ('unknown format: %r' % (self ._format ,))
388388 try :
389389 sampwidth = struct .unpack_from ('<H' , chunk .read (2 ))[0 ]
390390 except struct .error :
391391 raise EOFError from None
392- if self ._encoding == WAVE_FORMAT_EXTENSIBLE :
392+ if self ._format == WAVE_FORMAT_EXTENSIBLE :
393393 try :
394394 cbSize , wValidBitsPerSample , dwChannelMask = struct .unpack_from ('<HHL' , chunk .read (8 ))
395395 # Read the entire UUID from the chunk
@@ -432,8 +432,8 @@ class Wave_write:
432432 set through the setsampwidth() or setparams() method
433433 _framerate -- the sampling frequency
434434 set through the setframerate() or setparams() method
435- _encoding -- frame encoding
436- set through setencoding () method
435+ _format -- frame format
436+ set through setformat () method
437437 _nframes -- the number of audio frames written to the header
438438 set through the setnframes() or setparams() method
439439
@@ -461,7 +461,7 @@ def initfp(self, file):
461461 self ._file = file
462462 self ._convert = None
463463 self ._nchannels = 0
464- self ._encoding = WAVE_FORMAT_PCM
464+ self ._format = WAVE_FORMAT_PCM
465465 self ._sampwidth = 0
466466 self ._framerate = 0
467467 self ._nframes = 0
@@ -534,15 +534,15 @@ def setcomptype(self, comptype, compname):
534534 self ._comptype = comptype
535535 self ._compname = compname
536536
537- def setencoding (self , encoding ):
537+ def setformat (self , format ):
538538 if self ._datawritten :
539539 raise Error ('cannot change parameters after starting to write' )
540- if encoding not in (WAVE_FORMAT_IEEE_FLOAT , WAVE_FORMAT_PCM ):
540+ if format not in (WAVE_FORMAT_IEEE_FLOAT , WAVE_FORMAT_PCM ):
541541 raise Error ('unsupported wave format' )
542- self ._encoding = encoding
542+ self ._format = format
543543
544- def getencoding (self ):
545- return self ._encoding
544+ def getformat (self ):
545+ return self ._format
546546
547547 def getcomptype (self ):
548548 return self ._comptype
@@ -627,7 +627,7 @@ def _write_header(self, initlength):
627627 self ._form_length_pos = None
628628 self ._file .write (struct .pack ('<L4s4sLHHLLHH4s' ,
629629 36 + self ._datalength , b'WAVE' , b'fmt ' , 16 ,
630- self ._encoding , self ._nchannels , self ._framerate ,
630+ self ._format , self ._nchannels , self ._framerate ,
631631 self ._nchannels * self ._framerate * self ._sampwidth ,
632632 self ._nchannels * self ._sampwidth ,
633633 self ._sampwidth * 8 , b'data' ))
0 commit comments