Skip to content

Commit

Permalink
Fixed some docs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-werner committed Oct 22, 2020
1 parent ed57add commit 3021301
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 24 deletions.
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
# rir_generator
# Room Impulse Response Generator

[![Documentation Status](https://readthedocs.org/projects/rir-generator/badge/?version=latest)](https://rir-generator.readthedocs.io/en/latest/?badge=latest)
[![Build Status](https://travis-ci.org/audiolabs/rir-generator.svg?branch=master)](https://travis-ci.org/audiolabs/rir-generator)

This is a python port of the RIR-Generator code from https://github.com/ehabets/RIR-Generator

This package contains:

- C implementation of the RIR code and the corresponding .h file
- A cffi wrapper

Python dependencies: cffi, numpy
This is a Python port of the RIR-Generator code from https://github.com/ehabets/RIR-Generator

## Installation

Expand All @@ -20,15 +13,19 @@ pip install rir-generator

## Usage

Example

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

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

h = rir.generate(
c=340, # Sound velocity (m/s)
fs=16000, # Sample frequency (samples/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]
],
Expand All @@ -37,4 +34,12 @@ h = rir_generator.generate(
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)
```
51 changes: 42 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,50 @@
rir_generator
=============

Contents:
Room Impulse Response Generator
===============================

.. toctree::
:maxdepth: 2
:maxdepth: 2
:hidden:

module
references

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

Example
-------

.. code-block:: 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)
module
references
# Convolve 2-channel signal with 3 impulse responses
signal = ss.convolve(h[:, None, :], signal[:, :, None])
Python- and C-based generator for `room impulse responses`_, for use in `convolutional reverb`_.
print(signal.shape) # (15557, 2, 3)
.. _room impulse responses: https://en.wikipedia.org/wiki/Impulse_response#Acoustic_and_audio_applications
.. _room impulse response: https://en.wikipedia.org/wiki/Impulse_response#Acoustic_and_audio_applications
.. _convolutional reverb: https://en.wikipedia.org/wiki/Convolution_reverb


Expand Down
2 changes: 1 addition & 1 deletion rir_generator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def generate(
.. code-block::
[beta_x1, beta_x2, beta_y1, beta_y2, beta_z1, beta_z2]`
[beta_x1, beta_x2, beta_y1, beta_y2, beta_z1, beta_z2]
or
Expand Down

0 comments on commit 3021301

Please sign in to comment.