GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-60729: Add IEEE format wave audio support by mbeijen · Pull Request #145384 · python/cpython

Conversation

@mbeijen

@mbeijen mbeijen commented Mar 1, 2026 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This is an updated version of #102574, the original PR where @lkoenig added support for IEEE Wave Audio.

As requested by @encukou

I've

  • Renamed the new 'getencoding/setencoding' to 'getformat/setformat' - format is the term used in the specifications
  • Added format to getparams
  • Added FACT chunk to written non-PCM wave files, which is required by the spec (and is what Audacity does)
  • Added documentation!

Closes: #102574

  • Issue: wave file module does not support 32bit float format #60729

📚 Documentation preview 📚: https://cpython-previews--145384.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lkoenig and others added 5 commits March 1, 2026 09:54
@lkoenig @mbeijen
Add support for floating point wave files.
9263225
This adds support for floating point wav files and fix python#60729.
@mbeijen
wave: rename encoding API to format
e025d53
'format' is the term used in the wave audio specification
@mbeijen
wave: write FACT chunk for IEEE float
1701bf5
Per the RIFF/WAVE Rev. 3 documentation, non-PCM formats require a fact chunk, while PCM does not.
This is also what libsdnfile/audacity do

Reference: https://mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html (see the 'fact Chunk' section and linked Rev. 3 RIFF docs).
@mbeijen
wave: add format to getparams
0ad941f
@mbeijen
wave: add documentation on IEEE support, format API
7a1fce1
@mbeijen
mbeijen requested a review from AA-Turner as a code owner March 1, 2026 08:57
@bedevere-app bedevere-app Bot added the awaiting review label Mar 1, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Mar 1, 2026
wave file module does not support 32bit float format #60729
Closed
@mbeijen mbeijen mentioned this pull request Mar 1, 2026
gh-60729: Add support for floating point wave files. #102574
Closed
@mbeijen
wave: add documentation for undocumented methods
9bae85b
These methods are public but were previously not documented. This caused
the unit tests to fail when I mentioned changes to getparams() in the
whats new ;-)
aisk
aisk reviewed Mar 1, 2026
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2023-03-10-13-10-06.gh-issue-60729.KCCHTe.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mbeijen @aisk
Update Misc/NEWS.d/next/Library/2023-03-10-13-10-06.gh-issue-60729.KC…
1db52c0
…CHTe.rst

Co-authored-by: AN Long <[email protected]>
@mbeijen
mbeijen requested a review from aisk March 1, 2026 15:49
lkoenig
lkoenig reviewed Mar 2, 2026
View reviewed changes

@lkoenig lkoenig left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pushing that forward.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mbeijen reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
encukou
encukou reviewed Mar 2, 2026
View reviewed changes

@encukou encukou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!
I didn't finish reviewing today; sending the comments I have.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/wave.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/wave.rst Outdated
Comment on lines +110 to +111
This is one of ``WAVE_FORMAT_PCM``, ``WAVE_FORMAT_IEEE_FLOAT``, or
``WAVE_FORMAT_EXTENSIBLE``.

@encukou encukou Mar 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document these using .. data::, and link to them using :data:?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbeijen mbeijen Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/wave.rst Outdated
Comment on lines +128 to +129
framerate, nframes, comptype, compname, format)``, equivalent to output
of the ``get*()`` methods.

@encukou encukou Mar 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a backwards-incompatible change: before someone could write:

    nc, sw, fr, nf, ct, cn = wav.getparams()

This could be solved by adding format as a named-only attribute (which, unfortunately, isn't easy with namedtuple), or maybe an argument to getparams.
You might want to leave getparams alone for now & tackle this in a focused follow-up PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbeijen mbeijen Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I reverted those changes now

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/wave.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_wave.py Outdated
class MiscTestCase(unittest.TestCase):
def test__all__(self):
not_exported = {'WAVE_FORMAT_PCM', 'WAVE_FORMAT_EXTENSIBLE', 'KSDATAFORMAT_SUBTYPE_PCM'}
not_exported = {'WAVE_FORMAT_PCM', 'WAVE_FORMAT_IEEE_FLOAT', 'WAVE_FORMAT_EXTENSIBLE', 'KSDATAFORMAT_SUBTYPE_PCM'}

@encukou encukou Mar 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please export the WAVE_FORMAT_ ones (add to __all__) instead, and remove them here.
No point in hiding them; they're needed for documented functionality.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@encukou encukou Mar 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'd keep KSDATAFORMAT_SUBTYPE_PCM hidden until it's documented; that seems out of scope for this PR.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbeijen mbeijen Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, they're exported now

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/wave.py
Comment on lines +650 to +653
try:
self._fact_sample_count_pos = self._file.tell()
except (AttributeError, OSError):
self._fact_sample_count_pos = None

@encukou encukou Mar 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what's the story about supporting files without tell?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbeijen mbeijen Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not trying to extend unseekable support in this PR. I’m keeping the existing behavior: if output is seekable, header fields (including fact) are patched as needed; for unseekable outputs, writing works when header values are already final, and mismatches can still fail as before.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@mbeijen @encukou
versionchanged
f87efee
Co-authored-by: Petr Viktorin <[email protected]>
@mbeijen mbeijen mentioned this pull request Mar 3, 2026
GH-145450: Document missing wave.Wave_write getter methods #145451
Merged
mbeijen added 4 commits March 3, 2026 20:38
@mbeijen
Merge remote-tracking branch 'upstream/main' into pythonGH-60729-add-…
cd49a3b
…ieee-wave-audio-support

# Conflicts:
#	Doc/library/wave.rst
@mbeijen
wave: restore getparams() backward compatibility
2cdf66d
@mbeijen
wave: export WAVE_FORMAT constants
de0c82e
@mbeijen
wave docs: add format constants as data
689ae2d
@mbeijen
mbeijen requested a review from encukou March 3, 2026 20:06
vstinner
vstinner reviewed Mar 4, 2026
View reviewed changes
Comment thread Doc/library/wave.rst

.. data:: WAVE_FORMAT_IEEE_FLOAT

Format code for IEEE floating-point audio.

@vstinner vstinner Mar 4, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the size of a sample? 32-bit? Or does it accept different sizes?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbeijen mbeijen Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for IEEE Float it can only be 32-bit or 64-bit. I've amended the documentation and added raising errors in case of setting sampwidth to different values for IEEE or setting format to IEEE if sampwidth is incorrect values

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mbeijen
wave: sampwidth for IEEE Float must be 4 or 8
6d62e66
This is also similar to what libsndfile does
@mbeijen
mbeijen force-pushed the GH-60729-add-ieee-wave-audio-support branch from eeee8cd to 6d62e66 Compare March 7, 2026 17:04
@mbeijen
mbeijen requested a review from vstinner March 7, 2026 19:00
encukou
encukou approved these changes Mar 12, 2026
View reviewed changes

@encukou encukou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you!
Will merge tomorrow if there are no objections.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mbeijen reacted with laugh emoji
All reactions
  • 😄 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Mar 12, 2026
@mbeijen

mbeijen commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

awesome and thanks in advance! While you're at it I'd like to ask you to also consider these (smaller) PRs I made for wave.py that did not get much attention yet:

  • gh-117716: Fix wave RIFF padding for data chunks #145237
  • gh-144975: Fix wave.Wave_write.setframerate() validation order #144976

There's also this but it might warrant some rework after this IEEE PR is merged, I might want to make a new one for that

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou
encukou merged commit 61f2a1a into python:main Mar 13, 2026
51 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 13, 2026
@encukou

encukou commented Mar 13, 2026

Copy link
Copy Markdown
Member

I put them on my list :)

mbeijen reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

encukou added a commit to encukou/cpython that referenced this pull request Mar 13, 2026
@encukou
Revert "pythonGH-60729: Add IEEE format wave audio support (pythonGH-…
fcb8c9d
…145384)"

This reverts commit 61f2a1a.
@encukou

encukou commented Mar 13, 2026

Copy link
Copy Markdown
Member

Unfortunately, the tests break on big-endian machines.
I'll not be available for the rest of the week, so I'll revert the commit for now and try looking into it next week.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mbeijen

mbeijen commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

That is a shame. So how should I proceed? Since this is merged already, new PR with this code plus fixes? Also why these did not fail before?

I will try to locate my sun 3/60 and run unit tests. Oh no I will get my amiga. Or maybe my Mac PPC? Oh I do not own any of these machines anymore. I will just set up QEMU then

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou

encukou commented Mar 13, 2026

Copy link
Copy Markdown
Member

Yeah, new PR with this plus fixes. It's all squashed anyway.

Also why these did not fail before?

They're not on GitHub Actions; they're slow so they don't run on every commit.

Here's the failure, for the record: https://buildbot.python.org/#/builders/1636/builds/2307/steps/6/logs/stdio

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

encukou added a commit that referenced this pull request Mar 13, 2026
@encukou
GH-60729: Revert "Add IEEE format wave audio support (GH-145384)" (GH…
747ef70
…-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.
@mbeijen mbeijen mentioned this pull request Mar 13, 2026
GH-60729: Add IEEE format wave audio support take two #145931
Merged
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@mbeijen @lkoenig @ljfp
pythonGH-60729: Add IEEE format wave audio support (pythonGH-145384)
038aa29
Co-authored-by: Lionel Koenig <[email protected]>
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@encukou @ljfp
pythonGH-60729: Revert "Add IEEE format wave audio support (pythonGH-…
0528f01
…145384)" (pythonGH-145928)

Revert "pythonGH-60729: Add IEEE format wave audio support (pythonGH-145384)"

This reverts commit 61f2a1a for now;
as tests fail on big-endian machines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@aisk aisk Awaiting requested review from aisk
@vstinner vstinner Awaiting requested review from vstinner
+1 more reviewer
@lkoenig lkoenig lkoenig left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mbeijen @encukou @vstinner @lkoenig @aisk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.