Skip to main content

PyLevelator

中文文档

A modern Python implementation of the Levelator audio leveling tool, with a command-line interface and Python API.

Features

  • Fast — ~40% faster than the original C++ Levelator (1.8s vs 3.0s for 30s audio)
  • Cross-platform — Windows, macOS, Linux; Python 3.8+
  • Easy to install — pip install pylevelator
  • Configurable — tune RMS target, gain limits, smoothing, lookahead
  • CLI + API — use from the command line or integrate as a library

Performance

Benchmarked on 30s audio (44.1 kHz, mono, Intel i7, 8 threads):

Implementation Time Relative
Original Levelator (C++, 2010) 3.0s 1.0×
PyLevelator 1.8s 1.7× faster

How It Works

PyLevelator processes audio through five stages to balance loudness:

  1. RMS Envelope Calculation — slides a window (default: 0.5s) over the audio and computes the root-mean-square energy at each position. This gives a smoothed representation of how loud the audio is at every moment.

  2. Gain Curve Calculation — at each sample, computes how much gain (in dB) is needed to bring the local RMS up to the target level. Gain is clamped to the [min_gain, max_gain] range (default: [-10 dB, +20 dB]).

  3. Gain Smoothing — applies a moving-average filter (default: 0.3s) to the gain curve so that adjacent samples don't jump abruptly. Without this, the output would sound "choppy" or "pumping".

  4. Lookahead Limiting — scans forward in time and pre-emptively reduces gain before any peak that would exceed the clipping threshold. The reduction is spread over the preceding lookahead window (default: 0.1s). This is the key step that makes Levelator sound natural — it reacts to peaks before they happen rather than after.

  5. Gain Application — multiplies each audio sample by its corresponding gain value and hard-limits the output to ±0.99 to prevent digital clipping.

The result: quiet passages are boosted, loud passages are gently tamed, and the overall recording feels consistently loud without the "pumping" artifacts of simple compressors.

Installation

pip install pylevelator

Pre-built wheels for Python 3.8–3.11 on Windows, macOS (arm64 + x86_64), and Linux.

From source

Requires a C compiler with OpenMP support:

  • Windows — MSVC (Visual Studio 2019+)
  • macOS — libomp (brew install libomp)
  • Linux — GCC with libgomp
git clone https://github.com/KakaruHayate/pylevelator.git
cd pylevelator
pip install .

Quick Start

Command line

pylvl -i input.wav -o output.wav
pylvl -i input.wav -o output.wav --target-rms 0.15
pylvl -i input_dir/ -o output_dir/
pylvl --help

Python API

from pylevelator import Levelator, process

# Basic usage
lv = Levelator()
lv.process("input.wav", "output.wav")

# Custom parameters
lv = Levelator(target_rms=0.15, max_gain=18.0, smoothing=0.4)
lv.process("input.wav", "output.wav")

# One-liner
process("input.wav", "output.wav", target_rms=0.15)

CLI Options

Flag Default Description
-i, --input required Input audio file or directory
-o, --output required Output audio file or directory
--target-rms 0.12 Target RMS level (0.0–1.0)
--window-size 0.5 Analysis window in seconds
--smoothing 0.3 Gain smoothing window in seconds
--max-gain 20.0 Maximum gain in dB
--min-gain −10.0 Minimum gain in dB
--lookahead 0.1 Lookahead time in seconds
--pattern *.wav File pattern for batch mode
-v, --verbose off Verbose output

Parameter Guide

  • target-rms — target loudness level. Higher = louder output.

    • Podcasts / voice: 0.15–0.20 (louder)
    • Music / dynamic content: 0.08–0.12 (preserve dynamics)
    • Default (0.12) is roughly −18 dBFS.
  • window-size — how quickly the algorithm reacts to volume changes.

    • Smaller (0.2–0.3s): faster, more aggressive
    • Larger (0.5–1.0s): slower, smoother, preserves dynamics
  • smoothing — how smooth the gain transitions are.

    • Larger (0.4–0.6s): fewer abrupt changes, may feel sluggish
    • Smaller (0.1–0.2s): quicker response, may sound less natural
  • max-gain / min-gain — safety rails.

    • Lower max-gain if you hear noise in boosted quiet sections.
    • Raise min-gain if you want to preserve the original dynamics more.
  • lookahead — time window for the peak limiter.

    • Larger (0.15–0.2s): more clipping protection, slightly slower response
    • Smaller (0.05–0.1s): snappier, less headroom

Supported Formats

PyLevelator uses soundfile for I/O, supporting: WAV, FLAC, OGG, AIFF, CAF, and more. The output format matches the input format automatically.

License

MIT — see LICENSE.

Metadata

Release files for pylevelator 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylevelator 1.2.1
File Size Uploaded Provenance Actions
pylevelator-1.2.1.tar.gz 178.3 kB With provenance Details for pylevelator-1.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pylevelator 1.2.1
File Actions
pylevelator-1.2.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for pylevelator-1.2.1-cp311-cp311-win_amd64.whl
pylevelator-1.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for pylevelator-1.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pylevelator-1.2.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for pylevelator-1.2.1-cp311-cp311-macosx_11_0_arm64.whl
pylevelator-1.2.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for pylevelator-1.2.1-cp310-cp310-win_amd64.whl
pylevelator-1.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for pylevelator-1.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pylevelator-1.2.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for pylevelator-1.2.1-cp310-cp310-macosx_11_0_arm64.whl
pylevelator-1.2.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for pylevelator-1.2.1-cp39-cp39-win_amd64.whl
pylevelator-1.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details for pylevelator-1.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pylevelator-1.2.1-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details for pylevelator-1.2.1-cp39-cp39-macosx_11_0_arm64.whl
pylevelator-1.2.1-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for pylevelator-1.2.1-cp38-cp38-win_amd64.whl
pylevelator-1.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details for pylevelator-1.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pylevelator-1.2.1-cp38-cp38-macosx_11_0_arm64.whl CPython 3.8 CPython 3.8 macOS 11.0+ ARM64 Details for pylevelator-1.2.1-cp38-cp38-macosx_11_0_arm64.whl

Total release size: 7.6 MB

Release files / pylevelator-1.2.1.tar.gz

Download URL pylevelator-1.2.1.tar.gz
Size 178.3 kB
Tags Source
SHA-256 checksum
How to use checksums
518ed780f54f74d306b3440e3e23f47c2f75647f7c8258278743059626a76f36
BLAKE2b-256 checksum
How to use checksums
1aa32fb1f42cfc5cf4a553d39017c1ee40fd78145e0cbb37470d409e46dfba75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp311-cp311-win_amd64.whl

Download URL pylevelator-1.2.1-cp311-cp311-win_amd64.whl
Size 256.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
7f7a4556e8c20a0aa2ac76f75db3beb76908c1707b147ec4ceb932caa56fcdbc
BLAKE2b-256 checksum
How to use checksums
4bccaf23a093a829bd987b54712878c28129b0c34adc7220d63a2c7e8bce4e25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pylevelator-1.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 757.0 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ff7c83c1b8a98adba16cfa66855acfacdceb3d612dac8ed0f73523edbb61a414
BLAKE2b-256 checksum
How to use checksums
fffa67ef5fa115b5238de99cfef4894bdef1db8d3e5e67f96beb54077d588073
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL pylevelator-1.2.1-cp311-cp311-macosx_11_0_arm64.whl
Size 860.2 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
77781acc1fd4107b57dabbb7b8aeb361bbbe6c5f2ad2cd7d4beeb6d52a1618ec
BLAKE2b-256 checksum
How to use checksums
6fc7267af17a20d4c88ecf4f3f467f07b7bc12abdc55c3e72b1d8bc04fb5fe1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp310-cp310-win_amd64.whl

Download URL pylevelator-1.2.1-cp310-cp310-win_amd64.whl
Size 256.8 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
67159739f708f31d1b064df9355780be4dfc51f9cf13bf8a665973c715e5be53
BLAKE2b-256 checksum
How to use checksums
ce4b3834acd3a42dc288ee07c97ff94a46a640a72c5785c737c9191242e4950c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pylevelator-1.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 727.9 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
989b3495ad7a1c2aaa2f2a5eeb304e9799596aee3707953d63d5a4ab9ffdd133
BLAKE2b-256 checksum
How to use checksums
a780c756e9db8ad0af1f81c7965e5c2aee803196df5b7a933792bd2b2b41ad1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL pylevelator-1.2.1-cp310-cp310-macosx_11_0_arm64.whl
Size 862.0 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5daec1485c097a22e62dd88721681588a6df679e07909802fa251bfbc62ea9a1
BLAKE2b-256 checksum
How to use checksums
d0ab1e1d6b7b00bca052edae8eb9dcdb089ee01c2b2874856bfd1d2beccb31ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp39-cp39-win_amd64.whl

Download URL pylevelator-1.2.1-cp39-cp39-win_amd64.whl
Size 257.2 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
fc6acf1f6fae1e50f9dff270c3514f758d65486f6a105825aa28ec5be4eb2302
BLAKE2b-256 checksum
How to use checksums
5017a2662e7e192e40f96761b2d807cc4a7146c46d34bd31cf4902d5c00fd3ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pylevelator-1.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 726.2 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bc084857597943ec5dca9cc4dc6c2292f31d46cc9380329f0a96e22051760e6c
BLAKE2b-256 checksum
How to use checksums
f84e1b6fad6e70b852ac8119350b20d02ee51c2785aac70fe87c02cdc104b75e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp39-cp39-macosx_11_0_arm64.whl

Download URL pylevelator-1.2.1-cp39-cp39-macosx_11_0_arm64.whl
Size 862.4 kB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fff38d9c3abbab0698e90035749b842cb0e730bef71991b9b36d30b03961fc92
BLAKE2b-256 checksum
How to use checksums
d48e06e275fbf28bd48c7a78c4e69d73f102e5b752a11eba76195c218d8e5e9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp38-cp38-win_amd64.whl

Download URL pylevelator-1.2.1-cp38-cp38-win_amd64.whl
Size 256.2 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
a4cebaa9923dcfbc92fd711c88053e2c60da54dced36118e86f434905d535566
BLAKE2b-256 checksum
How to use checksums
39e3b6d801578295a1cef36fc73c6d4de0c2f48fa6727125f4128e2d64702b63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pylevelator-1.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 745.7 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
46cbef5809f20b59cf00f63d3ad3a3f7aa8957cd313c8684ba8b8d2011e5aab0
BLAKE2b-256 checksum
How to use checksums
66dd872510aac80d8481e82be8b07135f932d81aaafcd42f8871096bb1d2ab92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / pylevelator-1.2.1-cp38-cp38-macosx_11_0_arm64.whl

Download URL pylevelator-1.2.1-cp38-cp38-macosx_11_0_arm64.whl
Size 863.1 kB
Tags CPython 3.8 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
483a4020133a8c18efdc3872ee22cb279b5146b2be85caa072673b7426582847
BLAKE2b-256 checksum
How to use checksums
4822027321e9dd2f4c757c1d861d1514bc06eca05623a3328e76b1e3f3a985ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Security for pylevelator 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 13 files in this release have been uploaded with provenance metadata.

Select from 13 files

Attestation for pylevelator-1.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page