Skip to content

Add generate.stochastic_ir, a statistical room impulse response - #109

Open
aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-stochastic_ir
Open

aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-stochastic_ir

Conversation

@aguirreSL

@aguirreSL aguirreSL commented Nov 1, 2026 •

Copy link
Copy Markdown

Adds pytta.generate.stochastic_ir(reverbTime, volume, distance=1, c=343, samplingRate=None, timeLength=None, seed=None), a synthetic impulse response of a diffuse room after the statistical model of Kuttruff, Room Acoustics, 6th ed. (2016), sec. 4.2. It covers ita_stochastic_room_impulse_response of the ITA-Toolbox without an HRTF:

  1. The direct sound, 1 / distance, arrives at distance / c.
  2. The reflections arrive as a Poisson process of density 4πc³t² / V (eq. 4.6), drawn with the inverse of its integral.
  3. Each reflection has a random sign and the amplitude 10^(-3t / T) / (ct), so that the energy decays by 60 dB in the reverberation time T (eq. 4.7).

The ITA function belongs to an application of the ITA-Toolbox whose license is "all rights reserved", so nothing was taken from its code; this implementation is written from Kuttruff. One reverberation time applies to all frequencies, and a binaural response would need the HRTF convolution of each reflection, which is left out.

The tests in tests/test_stochastic_ir.py, for T = 0.8 s, V = 200 m³ and 3 m, print the measured values:

  1. Nothing arrives before the direct sound, which has the amplitude 1 / distance.
  2. Between 20 and 40 ms there are 49 reflections for 47 expected from eq. 4.6, within 4 standard deviations of the Poisson count.
  3. The backward integrated energy gives T30 = 0.806 s, within 2 % of T.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant