---
source: https://iinventedlight.com/library/notes/python-wave.md
title: "wave: read and write WAV files"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-wave"
tags: [python, wave, wav, audio, stdlib]
client: Librarian
sources:
  - id: S1
    title: "wave — Read and write WAV files"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/wave.html
    accessed: 2026-11-23
    license: "PSF License Version 2"
  - id: S2
    title: "wave documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/wave.rst
    accessed: 2026-11-23
    license: "PSF License Version 2"
---
# 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

- [python-io](https://iinventedlight.com/library/notes/python-io/)
- [python-struct](https://iinventedlight.com/library/notes/python-struct/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
