Skip to main content

cylimiter

A small package with stateful audio limiter implementation in Cython. Since the limiter is stateful it is suitable for streaming audio processing.

We're slowly growing into other effects beyond limiter, starting with streaming reverb in v0.4.

What's new?

v0.4: Added reverb with RIR

from cylimiter import ReverbRIR

reverb = ReverbRIR()  # default RIR
# or user-provided RIR:
#  reverb = ReverbRIR([0.001, 0.021, 0.007, ...])

reverb.apply(audio)          # makes a copy
reverb.apply_inplace(audio)  # no copies with np.array input

# preserves context between calls for streaming applications
for chunk in audio_source:
    reverb.apply_inplace(chunk)

Examples

import numpy as np
from cylimiter import Limiter

limiter = Limiter(attack=0.5, release=0.9, delay=100, threshold=0.9)
chunk_size = 1200  # for streaming processing

# Example of applying limiter in-place (more efficient)
audio = np.random.randn(44100) * 10
for i in range(0, 44100, chunk_size):
    chunk = audio[i * chunk_size: (i + 1) * chunk_size]
    limiter.limit_inplace(chunk)
    # ... do sth with chunk

# Example of applying limiter that copies the signal
audio = np.random.randn(1, 44100) * 10
audio_lim = limiter.limit(audio)

# Reset the limiter to re-use it on other signals
limiter.reset()

Installation

From PyPI via pip:

pip install cylimiter

From source:

git clone https://github.com/pzelasko/cylimiter
cd cylimiter
pip install .

Re-generate C++ sources from Cython:

cd extensions
cython -3 --cplus *.pyx

Motivation

I couldn't easily find a package that implements audio limiter in Python in a suitable way for streaming audio. The closest (and the main inspiration) is this gist by @bastibe. Since the algorithm is auto-regressive, I figured C++ will be much more efficient than Python.

Metadata

Release files for cylimiter 0.4.2

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

Source distribution (sdist)

Source distribution for cylimiter 0.4.2
File Size Uploaded
cylimiter-0.4.2.tar.gz 127.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cylimiter 0.4.2
File Interpreter ABI Platform
cylimiter-0.4.2-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 218.6 kB

Release files / cylimiter-0.4.2.tar.gz

Download URL cylimiter-0.4.2.tar.gz
Size 127.5 kB
Tags Source
SHA-256 checksum
How to use checksums
53afcc3a8143f3a0cfd782b3d61cf4388e6ed6ae575557e4c20ce040bf596db7
BLAKE2b-256 checksum
How to use checksums
7bee1327b48d7ca3fbfddec176337a0495da2d6c5bc2f5ca798bd5c6dd6fa7e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / cylimiter-0.4.2-cp310-cp310-macosx_11_0_arm64.whl

Download URL cylimiter-0.4.2-cp310-cp310-macosx_11_0_arm64.whl
Size 91.2 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ccb11f836f5a8d0deb707b7d15ab58e814892f745eb3a732738602d49cf4c55b
BLAKE2b-256 checksum
How to use checksums
8ad3682ae1bcd3665c45dc16b0bbf33a3447dc8e1f2217a0cc05b029c91fa2b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1

2 release files

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