Skip to content

[FEATURE] add image_source_ir to pytta.rooms - #101

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

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

Conversation

@aguirreSL

Copy link
Copy Markdown

Adds image_source_ir(dimensions, source, receiver, samplingRate, duration, reflection=1, half_width=8) to pytta.rooms: the impulse response of a rectangular room by the image source method of Allen and Berkley (1979), as ita_roomacoustics_imagesources of the ITA-Toolbox.

The images x = 2 l Lx + (1 - 2u) x0 (u = 0, 1, and the same in y and z) within c times the duration contribute the free-field Green's function δ(t - d/c) / (4π d). Each carries the reflection factor of the wall x = 0 to the power |l - u| and that of x = Lx to the power |l|, and likewise for y and z. The six factors are real and constant. ita_roomacoustics_imagesources derives them from a wall impedance Z as (Z - ρc) / (Z + ρc). Each arrival is placed between samples by a Hann-windowed sinc. Convolved with ρ dQ/dt of the source, the response gives the pressure.

The tests in tests/test_image_sources.py compare the spectrum of the response, below a quarter of the sampling rate where the windowed sinc is flat, with sums of spherical waves:

  1. With no reflection it is exp(-jωd/c) / (4πd) within 1.0e-4, and with only the wall x = 0 reflecting it adds the mirror image at (-x0, y0, z0) (7.3e-4).
  2. With the walls x = 0 and y = 0 reflecting with factors 0.5 and 0.8, it is the direct sound, the two first-order images and the corner image weighted by 0.4 (5.1e-4). With the wall x = Lx alone, the image lies at 2 Lx - x0 (5.8e-4).
  3. Positions outside the room are rejected.

A comparison of the decay with the reverberation time of Eyring was tried and left out. In a rectangular room with the same factor on every wall, the specular decay is not exponential. The paths close to the axes meet fewer walls and dominate the late part, so the decay came out 48 % longer than Eyring in a nearly cubic room.

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

image_source_ir gives the impulse response of a rectangular room by the
image source method of Allen and Berkley (1979), as
ita_roomacoustics_imagesources of the ITA-Toolbox: the free-field
Green's function of every image source within the duration, weighted by
the reflection factors of the six walls it goes through, each arrival
placed between samples by a Hann-windowed sinc.

Tests check against sums of spherical waves: the anechoic case, one
reflecting wall, two walls with different factors and their corner
image, and the opposite wall.

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