-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
GH-60729: Add IEEE format wave audio support #145384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
9263225
e025d53
1701bf5
0ad941f
7a1fce1
9bae85b
1db52c0
f87efee
cd49a3b
2cdf66d
de0c82e
689ae2d
6d62e66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,14 +9,19 @@ | |
| -------------- | ||
|
|
||
| The :mod:`!wave` module provides a convenient interface to the Waveform Audio | ||
| "WAVE" (or "WAV") file format. Only uncompressed PCM encoded wave files are | ||
| supported. | ||
| "WAVE" (or "WAV") file format. | ||
|
|
||
| The module supports uncompressed PCM and IEEE floating-point WAV formats. | ||
|
|
||
| .. versionchanged:: 3.12 | ||
|
|
||
| Support for ``WAVE_FORMAT_EXTENSIBLE`` headers was added, provided that the | ||
| extended format is ``KSDATAFORMAT_SUBTYPE_PCM``. | ||
|
|
||
| .. versionchanged:: 3.15 | ||
|
|
||
| Support for reading and writing ``WAVE_FORMAT_IEEE_FLOAT`` files was added. | ||
|
|
||
| The :mod:`!wave` module defines the following function and exception: | ||
|
|
||
|
|
||
|
|
@@ -98,6 +103,14 @@ Wave_read Objects | |
| Returns number of audio frames. | ||
|
|
||
|
|
||
| .. method:: getformat() | ||
|
|
||
| Returns the frame format code. | ||
|
|
||
| This is one of ``WAVE_FORMAT_PCM``, ``WAVE_FORMAT_IEEE_FLOAT``, or | ||
| ``WAVE_FORMAT_EXTENSIBLE``. | ||
|
||
|
|
||
|
|
||
| .. method:: getcomptype() | ||
|
|
||
| Returns compression type (``'NONE'`` is the only supported type). | ||
|
|
@@ -112,8 +125,8 @@ Wave_read Objects | |
| .. method:: getparams() | ||
|
|
||
| Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth, | ||
| framerate, nframes, comptype, compname)``, equivalent to output of the | ||
| ``get*()`` methods. | ||
| framerate, nframes, comptype, compname, format)``, equivalent to output | ||
| of the ``get*()`` methods. | ||
|
||
|
|
||
|
|
||
| .. method:: readframes(n) | ||
|
|
@@ -181,11 +194,21 @@ Wave_write Objects | |
| Set the number of channels. | ||
|
|
||
|
|
||
| .. method:: getnchannels() | ||
|
|
||
| Return the number of channels. | ||
mbeijen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| .. method:: setsampwidth(n) | ||
|
|
||
| Set the sample width to *n* bytes. | ||
|
|
||
|
|
||
| .. method:: getsampwidth() | ||
|
|
||
| Return the sample width in bytes. | ||
|
|
||
|
|
||
| .. method:: setframerate(n) | ||
|
|
||
| Set the frame rate to *n*. | ||
|
|
@@ -195,24 +218,67 @@ Wave_write Objects | |
| integer. | ||
|
|
||
|
|
||
| .. method:: getframerate() | ||
|
|
||
| Return the frame rate. | ||
|
|
||
|
|
||
| .. method:: setnframes(n) | ||
|
|
||
| Set the number of frames to *n*. This will be changed later if the number | ||
| of frames actually written is different (this update attempt will | ||
| raise an error if the output stream is not seekable). | ||
|
|
||
|
|
||
| .. method:: getnframes() | ||
|
|
||
| Return the number of audio frames written so far. | ||
|
|
||
|
|
||
| .. method:: setcomptype(type, name) | ||
|
|
||
| Set the compression type and description. At the moment, only compression type | ||
| ``NONE`` is supported, meaning no compression. | ||
|
|
||
|
|
||
| .. method:: getcomptype() | ||
|
|
||
| Return the compression type (``'NONE'``). | ||
|
|
||
|
|
||
| .. method:: getcompname() | ||
|
|
||
| Return the human-readable compression type name. | ||
|
|
||
|
|
||
| .. method:: setformat(format) | ||
|
|
||
| Set the frame format code. | ||
|
|
||
| Supported values are ``WAVE_FORMAT_PCM`` and | ||
| ``WAVE_FORMAT_IEEE_FLOAT``. | ||
|
|
||
|
|
||
| .. method:: getformat() | ||
|
|
||
| Return the current frame format code. | ||
|
|
||
|
|
||
| .. method:: setparams(tuple) | ||
|
|
||
| The *tuple* should be ``(nchannels, sampwidth, framerate, nframes, comptype, | ||
| compname)``, with values valid for the ``set*()`` methods. Sets all | ||
| parameters. | ||
| The *tuple* should be | ||
| ``(nchannels, sampwidth, framerate, nframes, comptype, compname, format)``, | ||
| with values valid for the ``set*()`` methods. Sets all parameters. | ||
|
|
||
| For backwards compatibility, a 6-item tuple without *format* is also | ||
| accepted and defaults to ``WAVE_FORMAT_PCM``. | ||
|
|
||
|
|
||
| .. method:: getparams() | ||
|
|
||
| Return a :func:`~collections.namedtuple` | ||
| ``(nchannels, sampwidth, framerate, nframes, comptype, compname, format)`` | ||
| containing the current output parameters. | ||
|
|
||
|
|
||
| .. method:: tell() | ||
|
|
@@ -242,3 +308,6 @@ Wave_write Objects | |
| Note that it is invalid to set any parameters after calling :meth:`writeframes` | ||
| or :meth:`writeframesraw`, and any attempt to do so will raise | ||
| :exc:`wave.Error`. | ||
|
|
||
| For ``WAVE_FORMAT_IEEE_FLOAT`` output, a ``fact`` chunk is written as | ||
| required by the WAVE specification for non-PCM formats. | ||
Uh oh!
There was an error while loading. Please reload this page.