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)
@@ -208,11 +221,27 @@ Wave_write Objects
208221 ``NONE `` is supported, meaning no compression.
209222
210223
224+ .. method :: setformat(format)
225+
226+ Set the frame format code.
227+
228+ Supported values are ``WAVE_FORMAT_PCM `` and
229+ ``WAVE_FORMAT_IEEE_FLOAT ``.
230+
231+
232+ .. method :: getformat()
233+
234+ Return the current frame format code.
235+
236+
211237 .. method :: setparams(tuple)
212238
213- The *tuple * should be ``(nchannels, sampwidth, framerate, nframes, comptype,
214- compname) ``, with values valid for the ``set*() `` methods. Sets all
215- parameters.
239+ The *tuple * should be
240+ ``(nchannels, sampwidth, framerate, nframes, comptype, compname, format) ``,
241+ with values valid for the ``set*() `` methods. Sets all parameters.
242+
243+ For backwards compatibility, a 6-item tuple without *format * is also
244+ accepted and defaults to ``WAVE_FORMAT_PCM ``.
216245
217246
218247 .. method :: tell()
@@ -242,3 +271,6 @@ Wave_write Objects
242271 Note that it is invalid to set any parameters after calling :meth: `writeframes `
243272 or :meth: `writeframesraw `, and any attempt to do so will raise
244273 :exc: `wave.Error `.
274+
275+ For ``WAVE_FORMAT_IEEE_FLOAT `` output, a ``fact `` chunk is written as
276+ required by the WAVE specification for non-PCM formats.
0 commit comments