| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,19 +9,14 @@ | |||
| 9 | 9 | -------------- | |
| 10 | 10 | ||
| 11 | 11 | 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. | ||
| 15 | 14 | ||
| 16 | 15 | .. versionchanged:: 3.12 | |
| 17 | 16 | ||
| 18 | 17 | Support for ``WAVE_FORMAT_EXTENSIBLE`` headers was added, provided that the | |
| 19 | 18 | extended format is ``KSDATAFORMAT_SUBTYPE_PCM``. | |
| 20 | 19 | ||
| 21 | - .. versionchanged:: next | ||
| 22 | - | ||
| 23 | - Support for reading and writing ``WAVE_FORMAT_IEEE_FLOAT`` files was added. | ||
| 24 | - | ||
| 25 | 20 | The :mod:`!wave` module defines the following function and exception: | |
| 26 | 21 | ||
| 27 | 22 | ||
@@ -65,21 +60,6 @@ The :mod:`!wave` module defines the following function and exception: | |||
| 65 | 60 | specification or hits an implementation deficiency. | |
| 66 | 61 | ||
| 67 | 62 | ||
| 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 | - | ||
| 83 | 63 | .. _wave-read-objects: | |
| 84 | 64 | ||
| 85 | 65 | Wave_read Objects | |
@@ -118,14 +98,6 @@ Wave_read Objects | |||
| 118 | 98 | Returns number of audio frames. | |
| 119 | 99 | ||
| 120 | 100 | ||
| 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 | - | ||
| 129 | 101 | .. method:: getcomptype() | |
| 130 | 102 | ||
| 131 | 103 | Returns compression type (``'NONE'`` is the only supported type). | |
@@ -140,8 +112,8 @@ Wave_read Objects | |||
| 140 | 112 | .. method:: getparams() | |
| 141 | 113 | ||
| 142 | 114 | 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. | ||
| 145 | 117 | ||
| 146 | 118 | ||
| 147 | 119 | .. method:: readframes(n) | |
@@ -218,9 +190,6 @@ Wave_write Objects | |||
| 218 | 190 | ||
| 219 | 191 | Set the sample width to *n* bytes. | |
| 220 | 192 | ||
| 221 | - For :data:`WAVE_FORMAT_IEEE_FLOAT`, only 4-byte (32-bit) and | ||
| 222 | - 8-byte (64-bit) sample widths are supported. | ||
| 223 | - | ||
| 224 | 193 | ||
| 225 | 194 | .. method:: getsampwidth() | |
| 226 | 195 | ||
@@ -269,32 +238,11 @@ Wave_write Objects | |||
| 269 | 238 | Return the human-readable compression type name. | |
| 270 | 239 | ||
| 271 | 240 | ||
| 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 | - | ||
| 288 | 241 | .. method:: setparams(tuple) | |
| 289 | 242 | ||
| 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. | ||
| 298 | 246 | ||
| 299 | 247 | ||
| 300 | 248 | .. method:: getparams() | |
@@ -331,6 +279,3 @@ Wave_write Objects | |||
| 331 | 279 | Note that it is invalid to set any parameters after calling :meth:`writeframes` | |
| 332 | 280 | or :meth:`writeframesraw`, and any attempt to do so will raise | |
| 333 | 281 | :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. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1518,21 +1518,6 @@ typing | |||
| 1518 | 1518 | wave | |
| 1519 | 1519 | ---- | |
| 1520 | 1520 | ||
| 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 | - | ||
| 1536 | 1521 | * Removed the ``getmark()``, ``setmark()`` and ``getmarkers()`` methods | |
| 1537 | 1522 | of the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes, | |
| 1538 | 1523 | which were deprecated since Python 3.13. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,18 +27,17 @@ def tearDown(self): | |||
| 27 | 27 | unlink(TESTFN) | |
| 28 | 28 | ||
| 29 | 29 | def check_params(self, f, nchannels, sampwidth, framerate, nframes, | |
| 30 | - comptype, compname, format): | ||
| 30 | + comptype, compname): | ||
| 31 | 31 | self.assertEqual(f.getnchannels(), nchannels) | |
| 32 | 32 | self.assertEqual(f.getsampwidth(), sampwidth) | |
| 33 | 33 | self.assertEqual(f.getframerate(), framerate) | |
| 34 | 34 | self.assertEqual(f.getnframes(), nframes) | |
| 35 | 35 | self.assertEqual(f.getcomptype(), comptype) | |
| 36 | 36 | self.assertEqual(f.getcompname(), compname) | |
| 37 | - self.assertEqual(f.getformat(), format) | ||
| 38 | 37 | ||
| 39 | 38 | params = f.getparams() | |
| 40 | 39 | self.assertEqual(params, | |
| 41 | - (nchannels, sampwidth, framerate, nframes, comptype, compname)) | ||
| 40 | + (nchannels, sampwidth, framerate, nframes, comptype, compname)) | ||
| 42 | 41 | self.assertEqual(params.nchannels, nchannels) | |
| 43 | 42 | self.assertEqual(params.sampwidth, sampwidth) | |
| 44 | 43 | self.assertEqual(params.framerate, framerate) | |
@@ -52,17 +51,13 @@ def check_params(self, f, nchannels, sampwidth, framerate, nframes, | |||
| 52 | 51 | ||
| 53 | 52 | ||
| 54 | 53 | class AudioWriteTests(AudioTests): | |
| 55 | - readonly = False | ||
| 56 | 54 | ||
| 57 | 55 | def create_file(self, testfile): | |
| 58 | - if self.readonly: | ||
| 59 | - self.skipTest('Read only file format') | ||
| 60 | 56 | f = self.fout = self.module.open(testfile, 'wb') | |
| 61 | 57 | f.setnchannels(self.nchannels) | |
| 62 | 58 | f.setsampwidth(self.sampwidth) | |
| 63 | 59 | f.setframerate(self.framerate) | |
| 64 | 60 | f.setcomptype(self.comptype, self.compname) | |
| 65 | - f.setformat(self.format) | ||
| 66 | 61 | return f | |
| 67 | 62 | ||
| 68 | 63 | def check_file(self, testfile, nframes, frames): | |
@@ -72,14 +67,13 @@ def check_file(self, testfile, nframes, frames): | |||
| 72 | 67 | self.assertEqual(f.getframerate(), self.framerate) | |
| 73 | 68 | self.assertEqual(f.getnframes(), nframes) | |
| 74 | 69 | self.assertEqual(f.readframes(nframes), frames) | |
| 75 | - self.assertEqual(f.getformat(), self.format) | ||
| 76 | 70 | ||
| 77 | 71 | def test_write_params(self): | |
| 78 | 72 | f = self.create_file(TESTFN) | |
| 79 | 73 | f.setnframes(self.nframes) | |
| 80 | 74 | f.writeframes(self.frames) | |
| 81 | 75 | 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) | ||
| 83 | 77 | f.close() | |
| 84 | 78 | ||
| 85 | 79 | def test_write_context_manager_calls_close(self): | |
@@ -263,7 +257,7 @@ def test_read_params(self): | |||
| 263 | 257 | f = self.f = self.module.open(self.sndfilepath) | |
| 264 | 258 | #self.assertEqual(f.getfp().name, self.sndfilepath) | |
| 265 | 259 | 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) | ||
| 267 | 261 | ||
| 268 | 262 | def test_close(self): | |
| 269 | 263 | with open(self.sndfilepath, 'rb') as testfile: | |
@@ -304,8 +298,6 @@ def test_read(self): | |||
| 304 | 298 | f.setpos(f.getnframes() + 1) | |
| 305 | 299 | ||
| 306 | 300 | def test_copy(self): | |
| 307 | - if self.readonly: | ||
| 308 | - self.skipTest('Read only file format') | ||
| 309 | 301 | f = self.f = self.module.open(self.sndfilepath) | |
| 310 | 302 | fout = self.fout = self.module.open(TESTFN, 'wb') | |
| 311 | 303 | fout.setparams(f.getparams()) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments