@maruaudio/dsp/acoustics/physics gives the room-acoustics DSP nodes their physical constants: the speed of sound from temperature and humidity, the temperature that gives a speed, and Vorländer's octave-band air absorption table, ported from pyroomacoustics' parameters.py. It also exports the shared simulation defaults (DEFAULT_*, ACOUSTICS_EPS = 1e-10) that upstream keeps in a mutable global store.
const air = initPhysics(20, 50) // 20 °C, 50 % relative humidity
const c = physicsSpeedOfSound(air) // 331.4 + 0.6 T + 0.0124 H m/s
writeAirAbsorption(air, coefficients) // seven bands, 125 Hz to 8 kHzParameters
| Call | Accepts | Default |
|---|---|---|
initPhysics(temperature, humidity, speed) | Humidity 0 to 100 %, else RangeError; an undefined temperature is derived from speed | humidity 0, speed 343 m/s |
initPhysicsFromSpeed(speed) | Any speed; humidity fixed at 0.3 % | none |
physicsAirAbsorption(state, band) | Band an integer 0 to 6; any other value returns 0 | none |
Lifecycle
initPhysics or initPhysicsFromSpeed allocate a small state record at init time; every other function is pure. writeAirAbsorption writes min(7, out.length) coefficients into a caller-owned array and allocates nothing.
When to use it
Setting up a simulated room: the speed of sound fixes delays and image distances, and the air-absorption row attenuates each octave band with distance.
Limits
- The speed formula is upstream's linear approximation; pressure is stored as 100 kPa and read by no formula.
- Air absorption has six rows: 10 °C or 20 °C (below 15 °C picks 10 °C) by humidity below 50 %, 50 to 70 % or above. NaN inputs fall through to the rows upstream's comparisons reach.
- Python-only settings (thread count, resample backend) are not ported.