Metadata-Version: 2.4
Name: mp3peaks
Version: 0.1.1
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Rust
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
Classifier: Typing :: Typed
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Summary: audiowaveform-compatible peak waveforms for MP3s, decoded in memory-safe Rust (symphonia)
Keywords: audio,waveform,mp3,peaks,audiowaveform,peaks.js
License-Expression: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/monty5811/mp3peaks/blob/main/CHANGELOG.md
Project-URL: Homepage, https://github.com/monty5811/mp3peaks
Project-URL: Issues, https://github.com/monty5811/mp3peaks/issues
Project-URL: Source, https://github.com/monty5811/mp3peaks

# mp3peaks

Peak waveforms for MP3 files, in the JSON format
[`audiowaveform`](https://github.com/bbc/audiowaveform) writes, ready for
[peaks.js](https://github.com/bbc/peaks.js).

```
pip install mp3peaks
```

## Usage

```python
from mp3peaks import compute_waveform

with open("talk.mp3", "rb") as f:
    waveform = compute_waveform(f.read(), number_of_points=256, bits=8)

# {"version": 2, "channels": 1, "sample_rate": 44100, "samples_per_pixel": 31556,
#  "bits": 8, "length": 256, "data": [-3, 4, -41, 38, ...]}
```

- `number_of_points`: roughly how many min/max pairs you want back.
- `bits`: 8 or 16.
- `duration`: the length in seconds, if you know it. Otherwise it's read from
  the MP3.

Stereo is mixed down to one channel. It raises `mp3peaks.WaveformError` if the
bytes can't be decoded, and `ValueError` for bad arguments.

## Why

It was built for [Yet Another Sermon Host](https://yetanothersermon.host),
which draws a waveform for every uploaded sermon. It replaces calls to the
`audiowaveform` binary. That means no system package to install, and uploaded
files are decoded in memory-safe Rust rather than C. It's published in case
it's useful to anyone else. It's an independent project, not affiliated with
the BBC or the `audiowaveform` authors.

