Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

audiolabs/rir-generator

Open more actions menu

Repository files navigation

Room Impulse Response Generator

Documentation Status CI Tests PyPI version Python versions DOI

Python- and C-based room impulse response generator, for use in convolutional reverb.

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

Installation

pip install rir-generator

Usage

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

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

Running Tests

pytest

Building from Source

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.