99--------------
1010
1111The :mod: `!wave ` module provides a convenient interface to the Waveform Audio
12- "WAVE" (or "WAV") file format. Only uncompressed PCM encoded wave files are
13- supported.
12+ "WAVE" (or "WAV") file format.
13+
14+ The module supports uncompressed PCM and IEEE floating-point WAV formats.
1415
1516.. versionchanged :: 3.12
1617
1718 Support for ``WAVE_FORMAT_EXTENSIBLE `` headers was added, provided that the
1819 extended format is ``KSDATAFORMAT_SUBTYPE_PCM ``.
1920
21+ .. versionchanged :: 3.15
22+
23+ Support for reading and writing ``WAVE_FORMAT_IEEE_FLOAT `` files was added.
24+
2025The :mod: `!wave ` module defines the following function and exception:
2126
2227
@@ -98,6 +103,14 @@ Wave_read Objects
98103 Returns number of audio frames.
99104
100105
106+ .. method :: getformat()
107+
108+ Returns the frame format code.
109+
110+ This is one of ``WAVE_FORMAT_PCM ``, ``WAVE_FORMAT_IEEE_FLOAT ``, or
111+ ``WAVE_FORMAT_EXTENSIBLE ``.
112+
113+
101114 .. method :: getcomptype()
102115
103116 Returns compression type (``'NONE' `` is the only supported type).
@@ -112,8 +125,8 @@ Wave_read Objects
112125 .. method :: getparams()
113126
114127 Returns a :func: `~collections.namedtuple ` ``(nchannels, sampwidth,
115- framerate, nframes, comptype, compname) ``, equivalent to output of the
116- ``get*() `` methods.
128+ framerate, nframes, comptype, compname, format ) ``, equivalent to output
129+ of the ``get*() `` methods.
117130
118131
119132 .. method :: readframes(n)
@@ -238,11 +251,27 @@ Wave_write Objects
238251 Return the human-readable compression type name.
239252
240253
254+ .. method :: setformat(format)
255+
256+ Set the frame format code.
257+
258+ Supported values are ``WAVE_FORMAT_PCM `` and
259+ ``WAVE_FORMAT_IEEE_FLOAT ``.
260+
261+
262+ .. method :: getformat()
263+
264+ Return the current frame format code.
265+
266+
241267 .. method :: setparams(tuple)
242268
243- The *tuple * should be ``(nchannels, sampwidth, framerate, nframes, comptype,
244- compname) ``, with values valid for the ``set*() `` methods. Sets all
245- parameters.
269+ The *tuple * should be
270+ ``(nchannels, sampwidth, framerate, nframes, comptype, compname, format) ``,
271+ with values valid for the ``set*() `` methods. Sets all parameters.
272+
273+ For backwards compatibility, a 6-item tuple without *format * is also
274+ accepted and defaults to ``WAVE_FORMAT_PCM ``.
246275
247276
248277 .. method :: getparams()
@@ -279,3 +308,6 @@ Wave_write Objects
279308 Note that it is invalid to set any parameters after calling :meth: `writeframes `
280309 or :meth: `writeframesraw `, and any attempt to do so will raise
281310 :exc: `wave.Error `.
311+
312+ For ``WAVE_FORMAT_IEEE_FLOAT `` output, a ``fact `` chunk is written as
313+ required by the WAVE specification for non-PCM formats.
0 commit comments