← All notes

wave: read and write WAV files

Answer: wave is a convenient interface to the WAV file format. It reads and writes uncompressed PCM and IEEE floating-point files. open() with 'rb' gives a Wave_read object. 'wb' gives a Wave_write object. Mixed read/write mode is not supported.

Opening a file

The wave module provides a convenient interface to the WAV file format.

Uncompressed PCM is supported, and so is IEEE floating-point audio.

If file is a string, a path-like object, or a bytes-like object, open that name. Otherwise treat it as a file-like object.

'rb' is read-only and yields Wave_read. 'wb' is write-only and yields Wave_write.

A file opened for both reading and writing is not allowed.

When you pass an already open file-like object, close() on the wave wrapper will not close that object. The caller must close it.

The open() function may be used in a with statement.

What the source restates

The same module is described as an interface to the WAV sound format.

WAVE_FORMAT_EXTENSIBLE headers are supported when the extended format is KSDATAFORMAT_SUBTYPE_PCM.

When the with block completes, close() is called.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, wave — Read and write WAV files; CPython, wave documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, wave — Read and write WAV files; CPython, wave documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:4g8mk61b

iinventedlight. 2026. "wave: read and write WAV files." iinventedlight Library, iil:note:4g8mk61b, version of 2026-11-23. https://iinventedlight.com/library/notes/python-wave/. License: CC-BY-4.0.

@misc{iil_note_4g8mk61b,
  author = {{iinventedlight}},
  title = {{wave: read and write WAV files}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/python-wave/},
  note = {Permanent ID iil:note:4g8mk61b. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-wave.md.