Skip to main content

PyTorch-based room impulse response (RIR) simulation toolkit for static and dynamic scenes.

Project description

TorchRIR

PyTorch-based room impulse response (RIR) simulation toolkit focused on a clean, modern API with GPU support. This project has been substantially assisted by AI using Codex.

[!WARNING] TorchRIR is under active development and may contain bugs or breaking changes. Please validate results for your use case. If you find bugs or have feature requests, please open an issue. Contributions are welcome.

Installation

pip install torchrir

Examples

  • examples/static.py: fixed sources/mics with binaural output.
    uv run python examples/static.py --plot
  • examples/dynamic_src.py: moving sources, fixed mics.
    uv run python examples/dynamic_src.py --plot
  • examples/dynamic_mic.py: fixed sources, moving mics.
    uv run python examples/dynamic_mic.py --plot
  • examples/cli.py: unified CLI for static/dynamic scenes, JSON/YAML configs.
    uv run python examples/cli.py --mode static --plot
  • examples/cmu_arctic_dynamic_dataset.py: small dynamic dataset generator (fixed room/mics, randomized source motion).
    uv run python examples/cmu_arctic_dynamic_dataset.py --num-scenes 4 --num-sources 2
  • examples/benchmark_device.py: CPU/GPU benchmark for RIR simulation.
    uv run python examples/benchmark_device.py --dynamic

Core API Overview

  • Geometry: Room, Source, MicrophoneArray
  • Static RIR: simulate_rir
  • Dynamic RIR: simulate_dynamic_rir
  • Dynamic convolution: DynamicConvolver
  • Metadata export: build_metadata, save_metadata_json

Module Layout (for contributors)

  • torchrir.sim: simulation backends (ISM implementation lives under torchrir.sim.ism)
  • torchrir.signal: convolution utilities and dynamic convolver
  • torchrir.geometry: array geometries, sampling, trajectories
  • torchrir.viz: plotting and animation helpers
  • torchrir.models: room/scene/result data models
  • torchrir.io: audio I/O and metadata serialization
  • torchrir.util: shared math/tensor/device helpers
  • torchrir.infra: logging utilities
from torchrir import DynamicConvolver, MicrophoneArray, Room, Source, simulate_rir

room = Room.shoebox(size=[6.0, 4.0, 3.0], fs=16000, beta=[0.9] * 6)
sources = Source.from_positions([[1.0, 2.0, 1.5]])
mics = MicrophoneArray.from_positions([[2.0, 2.0, 1.5]])

rir = simulate_rir(room=room, sources=sources, mics=mics, max_order=6, tmax=0.3)
# For dynamic scenes, compute rirs with simulate_dynamic_rir and convolve:
# y = DynamicConvolver(mode="trajectory").convolve(signal, rirs)

For detailed documentation, see the docs under docs/ and Read the Docs.

Future Work

  • Ray tracing backend: implement RayTracingSimulator with frequency-dependent absorption/scattering.
  • CUDA-native acceleration: introduce dedicated CUDA kernels for large-scale RIR generation.
  • Dataset expansion: add additional dataset integrations beyond CMU ARCTIC (see TemplateDataset), including torchaudio datasets (e.g., LibriSpeech, VCTK, LibriTTS, SpeechCommands, CommonVoice, GTZAN, MUSDB-HQ).
  • Add regression tests comparing generated RIRs against gpuRIR outputs.

Related Libraries

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchrir-0.3.0.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchrir-0.3.0-py3-none-any.whl (57.9 kB view details)

Uploaded Python 3

File details

Details for the file torchrir-0.3.0.tar.gz.

File metadata

  • Download URL: torchrir-0.3.0.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for torchrir-0.3.0.tar.gz
Algorithm Hash digest
SHA256 88014b48c8f7fbe728484e76d92f112cbe2d215c6e9a0cbd93807521526681d6
MD5 8b3612ef2d9899cf9a03f915fe037007
BLAKE2b-256 5b3fd3884ee68c666cdf2eb08da3ceb55e9dde15e50d64b01739f23d55044153

See more details on using hashes here.

File details

Details for the file torchrir-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: torchrir-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 57.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for torchrir-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b94a8a8aa651e4ea0f38994aa488d7e1ad50baf9aee718aaa960494ddf0cd0c
MD5 2974790fbf09d21c11e3be2a9193dc3f
BLAKE2b-256 825a778ecf975b1e5574c6b3e22bf182d037699e516997e7027a2e6a527d8ed0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page