@maruaudio/dsp/acoustics/ray-tracer traces rays from a source around a rectangular room and records the energy that reaches each microphone, ported from pyroomacoustics' libroom ray tracer. Each ray loses energy to per-band wall absorption, may scatter towards the receivers, and deposits energy into histograms of 4 ms distance bins, by receiver and band, and, for directional receivers, by arrival direction over 720 directions. These histograms shape the diffuse tail that @maru/acoustics-rt-tail synthesises.
Parameters
createRayTracerParams returns the record beginRayTracer latches.
| Field | Accepts | Default |
|---|---|---|
room, source, mics | Positive room sides below 1e6 m; source and mics inside | 1 mic |
nMics, nBands, nRays | Floored and clamped: 1 to 2, 1 to 9, 1 to 262,144 | 1, 1, 1,024 |
absorption, scattering | 0 to 1 per wall and band | 0 |
pattern, orientation | Receiver cardioid-family p 0 to 1 and orientation | omni, +x |
order, hybrid | In hybrid mode receiver hits count only from bounce order on | 3, on |
speed, seconds, radius, binSeconds, threshold, seed | Positive below 1e6; threshold in (0, 1] | 343 m/s, 3 s, 0.5 m, 4 ms, 1e-7, 258 |
Invalid geometry or coefficients leave a silent, finished result.
Lifecycle
createRayTracer(maxBins) allocates fixed histograms (1 to 2,500 bins) → beginRayTracer(params) latches and clears → stepRayTracer(budget) until ready. A work unit is one ray segment with its scattering connections, or a 1,024-entry clear of the direction histogram.
When to use it
The diffuse part of a hybrid room simulation, after its image sources.
Limits
- Shoebox rooms only. A seeded xorshift32 replaces upstream's mt19937, so results are deterministic and budget-invariant but not bit-identical to upstream's; storage is bounded where upstream grows.