Skip to content

Commit 747ef70

Browse files
authored
GH-60729: Revert "Add IEEE format wave audio support (GH-145384)" (GH-145928)
Revert "GH-60729: Add IEEE format wave audio support (GH-145384)" This reverts commit 61f2a1a for now; as tests fail on big-endian machines.
1 parent 00a2585 commit 747ef70

File tree

7 files changed

+25
-352
lines changed

7 files changed

+25
-352
lines changed

Doc/library/wave.rst

Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@
99
--------------
1010

1111
The :mod:`!wave` module provides a convenient interface to the Waveform Audio
12-
"WAVE" (or "WAV") file format.
13-
14-
The module supports uncompressed PCM and IEEE floating-point WAV formats.
12+
"WAVE" (or "WAV") file format. Only uncompressed PCM encoded wave files are
13+
supported.
1514

1615
.. versionchanged:: 3.12
1716

1817
Support for ``WAVE_FORMAT_EXTENSIBLE`` headers was added, provided that the
1918
extended format is ``KSDATAFORMAT_SUBTYPE_PCM``.
2019

21-
.. versionchanged:: next
22-
23-
Support for reading and writing ``WAVE_FORMAT_IEEE_FLOAT`` files was added.
24-
2520
The :mod:`!wave` module defines the following function and exception:
2621

2722

@@ -65,21 +60,6 @@ The :mod:`!wave` module defines the following function and exception:
6560
specification or hits an implementation deficiency.
6661

6762

68-
.. data:: WAVE_FORMAT_PCM
69-
70-
Format code for uncompressed PCM audio.
71-
72-
73-
.. data:: WAVE_FORMAT_IEEE_FLOAT
74-
75-
Format code for IEEE floating-point audio.
76-
77-
78-
.. data:: WAVE_FORMAT_EXTENSIBLE
79-
80-
Format code for WAVE extensible headers.
81-
82-
8363
.. _wave-read-objects:
8464

8565
Wave_read Objects
@@ -118,14 +98,6 @@ Wave_read Objects
11898
Returns number of audio frames.
11999

120100

121-
.. method:: getformat()
122-
123-
Returns the frame format code.
124-
125-
This is one of :data:`WAVE_FORMAT_PCM`,
126-
:data:`WAVE_FORMAT_IEEE_FLOAT`, or :data:`WAVE_FORMAT_EXTENSIBLE`.
127-
128-
129101
.. method:: getcomptype()
130102

131103
Returns compression type (``'NONE'`` is the only supported type).
@@ -140,8 +112,8 @@ Wave_read Objects
140112
.. method:: getparams()
141113

142114
Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,
143-
framerate, nframes, comptype, compname)``, equivalent to output
144-
of the ``get*()`` methods.
115+
framerate, nframes, comptype, compname)``, equivalent to output of the
116+
``get*()`` methods.
145117

146118

147119
.. method:: readframes(n)
@@ -218,9 +190,6 @@ Wave_write Objects
218190

219191
Set the sample width to *n* bytes.
220192

221-
For :data:`WAVE_FORMAT_IEEE_FLOAT`, only 4-byte (32-bit) and
222-
8-byte (64-bit) sample widths are supported.
223-
224193

225194
.. method:: getsampwidth()
226195

@@ -269,32 +238,11 @@ Wave_write Objects
269238
Return the human-readable compression type name.
270239

271240

272-
.. method:: setformat(format)
273-
274-
Set the frame format code.
275-
276-
Supported values are :data:`WAVE_FORMAT_PCM` and
277-
:data:`WAVE_FORMAT_IEEE_FLOAT`.
278-
279-
When setting :data:`WAVE_FORMAT_IEEE_FLOAT`, the sample width must be
280-
4 or 8 bytes.
281-
282-
283-
.. method:: getformat()
284-
285-
Return the current frame format code.
286-
287-
288241
.. method:: setparams(tuple)
289242

290-
The *tuple* should be
291-
``(nchannels, sampwidth, framerate, nframes, comptype, compname, format)``,
292-
with values valid for the ``set*()`` methods. Sets all parameters.
293-
294-
For backwards compatibility, a 6-item tuple without *format* is also
295-
accepted and defaults to :data:`WAVE_FORMAT_PCM`.
296-
297-
For ``format=WAVE_FORMAT_IEEE_FLOAT``, *sampwidth* must be 4 or 8.
243+
The *tuple* should be ``(nchannels, sampwidth, framerate, nframes, comptype,
244+
compname)``, with values valid for the ``set*()`` methods. Sets all
245+
parameters.
298246

299247

300248
.. method:: getparams()
@@ -331,6 +279,3 @@ Wave_write Objects
331279
Note that it is invalid to set any parameters after calling :meth:`writeframes`
332280
or :meth:`writeframesraw`, and any attempt to do so will raise
333281
:exc:`wave.Error`.
334-
335-
For :data:`WAVE_FORMAT_IEEE_FLOAT` output, a ``fact`` chunk is written as
336-
required by the WAVE specification for non-PCM formats.

Doc/whatsnew/3.15.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,21 +1518,6 @@ typing
15181518
wave
15191519
----
15201520

1521-
* Added support for IEEE floating-point WAVE audio
1522-
(``WAVE_FORMAT_IEEE_FLOAT``) in :mod:`wave`.
1523-
1524-
* Added :meth:`wave.Wave_read.getformat`, :meth:`wave.Wave_write.getformat`,
1525-
and :meth:`wave.Wave_write.setformat` for explicit frame format handling.
1526-
1527-
* :meth:`wave.Wave_write.setparams` accepts both 7-item tuples including
1528-
``format`` and 6-item tuples for backwards compatibility (defaulting to
1529-
``WAVE_FORMAT_PCM``).
1530-
1531-
* ``WAVE_FORMAT_IEEE_FLOAT`` output now includes a ``fact`` chunk,
1532-
as required for non-PCM WAVE formats.
1533-
1534-
(Contributed by Lionel Koenig and Michiel W. Beijen in :gh:`60729`.)
1535-
15361521
* Removed the ``getmark()``, ``setmark()`` and ``getmarkers()`` methods
15371522
of the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes,
15381523
which were deprecated since Python 3.13.
-25.9 KB
Binary file not shown.

Lib/test/audiotests.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@ def tearDown(self):
2727
unlink(TESTFN)
2828

2929
def check_params(self, f, nchannels, sampwidth, framerate, nframes,
30-
comptype, compname, format):
30+
comptype, compname):
3131
self.assertEqual(f.getnchannels(), nchannels)
3232
self.assertEqual(f.getsampwidth(), sampwidth)
3333
self.assertEqual(f.getframerate(), framerate)
3434
self.assertEqual(f.getnframes(), nframes)
3535
self.assertEqual(f.getcomptype(), comptype)
3636
self.assertEqual(f.getcompname(), compname)
37-
self.assertEqual(f.getformat(), format)
3837

3938
params = f.getparams()
4039
self.assertEqual(params,
41-
(nchannels, sampwidth, framerate, nframes, comptype, compname))
40+
(nchannels, sampwidth, framerate, nframes, comptype, compname))
4241
self.assertEqual(params.nchannels, nchannels)
4342
self.assertEqual(params.sampwidth, sampwidth)
4443
self.assertEqual(params.framerate, framerate)
@@ -52,17 +51,13 @@ def check_params(self, f, nchannels, sampwidth, framerate, nframes,
5251

5352

5453
class AudioWriteTests(AudioTests):
55-
readonly = False
5654

5755
def create_file(self, testfile):
58-
if self.readonly:
59-
self.skipTest('Read only file format')
6056
f = self.fout = self.module.open(testfile, 'wb')
6157
f.setnchannels(self.nchannels)
6258
f.setsampwidth(self.sampwidth)
6359
f.setframerate(self.framerate)
6460
f.setcomptype(self.comptype, self.compname)
65-
f.setformat(self.format)
6661
return f
6762

6863
def check_file(self, testfile, nframes, frames):
@@ -72,14 +67,13 @@ def check_file(self, testfile, nframes, frames):
7267
self.assertEqual(f.getframerate(), self.framerate)
7368
self.assertEqual(f.getnframes(), nframes)
7469
self.assertEqual(f.readframes(nframes), frames)
75-
self.assertEqual(f.getformat(), self.format)
7670

7771
def test_write_params(self):
7872
f = self.create_file(TESTFN)
7973
f.setnframes(self.nframes)
8074
f.writeframes(self.frames)
8175
self.check_params(f, self.nchannels, self.sampwidth, self.framerate,
82-
self.nframes, self.comptype, self.compname, self.format)
76+
self.nframes, self.comptype, self.compname)
8377
f.close()
8478

8579
def test_write_context_manager_calls_close(self):
@@ -263,7 +257,7 @@ def test_read_params(self):
263257
f = self.f = self.module.open(self.sndfilepath)
264258
#self.assertEqual(f.getfp().name, self.sndfilepath)
265259
self.check_params(f, self.nchannels, self.sampwidth, self.framerate,
266-
self.sndfilenframes, self.comptype, self.compname, self.format)
260+
self.sndfilenframes, self.comptype, self.compname)
267261

268262
def test_close(self):
269263
with open(self.sndfilepath, 'rb') as testfile:
@@ -304,8 +298,6 @@ def test_read(self):
304298
f.setpos(f.getnframes() + 1)
305299

306300
def test_copy(self):
307-
if self.readonly:
308-
self.skipTest('Read only file format')
309301
f = self.f = self.module.open(self.sndfilepath)
310302
fout = self.fout = self.module.open(TESTFN, 'wb')
311303
fout.setparams(f.getparams())

0 commit comments

Comments
 (0)