cylimiter


Namecylimiter JSON
Version 0.4.2 PyPI version JSON
download
home_page
SummaryAudio limiter in Cython.
upload_time2023-01-30 16:40:22
maintainer
docs_urlNone
authorPiotr Żelasko
requires_python
licenseApache 2.0
keywords signal processing audio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```python
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

```python
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:
```bash
pip install cylimiter
```

From source:
```bash
git clone https://github.com/pzelasko/cylimiter
cd cylimiter
pip install .
```

Re-generate C++ sources from Cython:
```bash
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](https://gist.github.com/bastibe/747283c55aad66404046). Since the algorithm is auto-regressive, I figured C++ will be much more efficient than Python.



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cylimiter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "signal processing,audio",
    "author": "Piotr \u017belasko",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/7b/ee/1327b48d7ca3fbfddec176337a0495da2d6c5bc2f5ca798bd5c6dd6fa7e4/cylimiter-0.4.2.tar.gz",
    "platform": null,
    "description": "# cylimiter\n\nA small package with stateful audio limiter implementation in Cython. Since the limiter is stateful it is suitable for streaming audio processing.\n\nWe're slowly growing into other effects beyond limiter, starting with streaming reverb in v0.4.\n\n## What's new?\n\n### v0.4: Added reverb with RIR\n\n```python\nfrom cylimiter import ReverbRIR\n\nreverb = ReverbRIR()  # default RIR\n# or user-provided RIR:\n#  reverb = ReverbRIR([0.001, 0.021, 0.007, ...])\n\nreverb.apply(audio)          # makes a copy\nreverb.apply_inplace(audio)  # no copies with np.array input\n\n# preserves context between calls for streaming applications\nfor chunk in audio_source:\n    reverb.apply_inplace(chunk)\n```\n\n\n\n### Examples\n\n```python\nimport numpy as np\nfrom cylimiter import Limiter\n\nlimiter = Limiter(attack=0.5, release=0.9, delay=100, threshold=0.9)\nchunk_size = 1200  # for streaming processing\n\n# Example of applying limiter in-place (more efficient)\naudio = np.random.randn(44100) * 10\nfor i in range(0, 44100, chunk_size):\n    chunk = audio[i * chunk_size: (i + 1) * chunk_size]\n    limiter.limit_inplace(chunk)\n    # ... do sth with chunk\n\n# Example of applying limiter that copies the signal\naudio = np.random.randn(1, 44100) * 10\naudio_lim = limiter.limit(audio)\n\n# Reset the limiter to re-use it on other signals\nlimiter.reset()\n```\n\n## Installation\n\nFrom PyPI via pip:\n```bash\npip install cylimiter\n```\n\nFrom source:\n```bash\ngit clone https://github.com/pzelasko/cylimiter\ncd cylimiter\npip install .\n```\n\nRe-generate C++ sources from Cython:\n```bash\ncd extensions\ncython -3 --cplus *.pyx\n```\n\n## Motivation\n\nI 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](https://gist.github.com/bastibe/747283c55aad66404046). Since the algorithm is auto-regressive, I figured C++ will be much more efficient than Python.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Audio limiter in Cython.",
    "version": "0.4.2",
    "split_keywords": [
        "signal processing",
        "audio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ad3682ae1bcd3665c45dc16b0bbf33a3447dc8e1f2217a0cc05b029c91fa2b7",
                "md5": "539e8258290e98a921deec0e622a1a77",
                "sha256": "ccb11f836f5a8d0deb707b7d15ab58e814892f745eb3a732738602d49cf4c55b"
            },
            "downloads": -1,
            "filename": "cylimiter-0.4.2-cp310-cp310-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "539e8258290e98a921deec0e622a1a77",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": null,
            "size": 91158,
            "upload_time": "2023-01-30T16:40:20",
            "upload_time_iso_8601": "2023-01-30T16:40:20.682606Z",
            "url": "https://files.pythonhosted.org/packages/8a/d3/682ae1bcd3665c45dc16b0bbf33a3447dc8e1f2217a0cc05b029c91fa2b7/cylimiter-0.4.2-cp310-cp310-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7bee1327b48d7ca3fbfddec176337a0495da2d6c5bc2f5ca798bd5c6dd6fa7e4",
                "md5": "0e3d929eaed21641f9d967c791af1b52",
                "sha256": "53afcc3a8143f3a0cfd782b3d61cf4388e6ed6ae575557e4c20ce040bf596db7"
            },
            "downloads": -1,
            "filename": "cylimiter-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0e3d929eaed21641f9d967c791af1b52",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 127453,
            "upload_time": "2023-01-30T16:40:22",
            "upload_time_iso_8601": "2023-01-30T16:40:22.968332Z",
            "url": "https://files.pythonhosted.org/packages/7b/ee/1327b48d7ca3fbfddec176337a0495da2d6c5bc2f5ca798bd5c6dd6fa7e4/cylimiter-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-30 16:40:22",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "cylimiter"
}
        
Elapsed time: 0.03238s