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
- id: C1 claim: wave is a convenient interface to the WAV file format. source: S1 evidence: "convenient interface to the Waveform Audio"
- id: C2 claim: It supports uncompressed PCM and IEEE floating-point WAV formats. source: S1 evidence: "uncompressed PCM and IEEE floating-point WAV formats"
- id: C3 claim: 'rb' returns Wave_read; 'wb' returns Wave_write. source: S1 evidence: "returns a Wave_read object"
- id: C4 claim: Read/write WAV files are not allowed. source: S1 evidence: "does not allow read/write WAV files"
- id: C5 claim: WAVE_FORMAT_EXTENSIBLE support requires KSDATAFORMAT_SUBTYPE_PCM. source: S2 evidence: "KSDATAFORMAT_SUBTYPE_PCM"
- id: C6 claim: A with block calls close() when it completes. source: S2 evidence: "block completes"
Sources
- [S1] wave — Read and write WAV files. Python Software Foundation. https://docs.python.org/3/library/wave.html . License: PSF License Version 2. Accessed 2026-11-23.
- [S2] wave documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/wave.rst . License: PSF License Version 2. Accessed 2026-11-23.
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
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.},
}
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.
- python-wave.schema.json (schema; CC-BY-4.0)
- python-wave.table.json (table; CC-BY-4.0)
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.