Metadata-Version: 2.4
Name: rir-generator
Version: 0.3.0
Summary: Room Impulse Response Generator for Python
Author-email: Emanuël Habets <emanuel.habets@audiolabs-erlangen.de>, Nils Werner <nils.werner@fau.de>
License: MIT
Project-URL: Homepage, https://github.com/audiolabs/rir-generator
Project-URL: Documentation, https://rir-generator.readthedocs.io
Project-URL: Repository, https://github.com/audiolabs/rir-generator
Project-URL: Issues, https://github.com/audiolabs/rir-generator/issues
Project-URL: DOI, https://doi.org/10.5281/zenodo.4133077
Keywords: audio,acoustics,room impulse response,reverb,convolution
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: C++
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.17.0
Requires-Dist: scipy>=1.0.0
Requires-Dist: cffi>=1.1.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov>=2.0; extra == "dev"
Requires-Dist: pytest-black; extra == "dev"
Requires-Dist: build>=0.7.0; extra == "dev"
Requires-Dist: twine>=3.0.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=4.0.0; extra == "docs"
Requires-Dist: sphinxcontrib-napoleon; extra == "docs"
Requires-Dist: sphinxcontrib-bibtex; extra == "docs"
Requires-Dist: sphinx_rtd_theme; extra == "docs"
Requires-Dist: numpydoc>=1.0.0; extra == "docs"
Provides-Extra: tests
Requires-Dist: pytest>=6.0; extra == "tests"
Requires-Dist: pytest-cov>=2.0; extra == "tests"
Requires-Dist: pytest-black; extra == "tests"
Dynamic: license-file

# Room Impulse Response Generator

[![Documentation Status](https://readthedocs.org/projects/rir-generator/badge/?version=latest)](https://rir-generator.readthedocs.io/en/latest/?badge=latest)
[![CI Tests](https://github.com/audiolabs/rir-generator/actions/workflows/python-package.yml/badge.svg)](https://github.com/audiolabs/rir-generator/actions/workflows/python-package.yml)
[![PyPI version](https://badge.fury.io/py/rir-generator.svg)](https://badge.fury.io/py/rir-generator)
[![Python versions](https://img.shields.io/pypi/pyversions/rir-generator.svg)](https://pypi.org/project/rir-generator/)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4133077.svg)](https://doi.org/10.5281/zenodo.4133077)

Python- and C-based [room impulse response](https://en.wikipedia.org/wiki/Impulse_response#Acoustic_and_audio_applications) generator, for use in [convolutional reverb](https://en.wikipedia.org/wiki/Convolution_reverb).

Official Python port of https://github.com/ehabets/RIR-Generator.

## Installation

```sh
pip install rir-generator
```

## Usage

```python
import numpy as np
import scipy.signal as ss
import soundfile as sf
import rir_generator as rir

signal, fs = sf.read("bark.wav", always_2d=True)

h = rir.generate(
    c=340,                  # Sound velocity (m/s)
    fs=fs,                  # Sample frequency (samples/s)
    r=[                     # Receiver position(s) [x y z] (m)
        [2, 1.5, 1],
        [2, 1.5, 2],
        [2, 1.5, 3]
    ],
    s=[2, 3.5, 2],          # Source position [x y z] (m)
    L=[5, 4, 6],            # Room dimensions [x y z] (m)
    reverberation_time=0.4, # Reverberation time (s)
    nsample=4096,           # Number of output samples
)

print(h.shape)              # (4096, 3)
print(signal.shape)         # (11462, 2)

# Convolve 2-channel signal with 3 impulse responses
signal = ss.convolve(h[:, None, :], signal[:, :, None])

print(signal.shape)         # (15557, 2, 3)
```

## Development

### Installation for Development

```sh
git clone https://github.com/audiolabs/rir-generator.git
cd rir-generator
pip install -e .[dev]
```

### Running Tests

```sh
pytest
```

### Building from Source

```sh
python -m build
```

### Project Structure

The project follows the `src/` layout with **automatic versioning from git tags**:

```
src/
  rir_generator/
    __init__.py           # Main Python module
    _cffi/                # CFFI C++ extension bindings
      build.py            # CFFI build configuration
      rir_generator_core.cpp  # C++ implementation
      rir_generator_core.h    # C++ header
```
