Skip to content

[FIX] start an impulse response at sample 0 when nothing precedes its peak - #128

Open
aguirreSL wants to merge 2 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-fix_ir_start
Open

aguirreSL wants to merge 2 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-fix_ir_start

Conversation

@aguirreSL

@aguirreSL aguirreSL commented Nov 1, 2026 •

Copy link
Copy Markdown

_start_sample_ISO3382 finds where an impulse response starts, the last sample before the maximum that lies 20 dB below it (ISO 3382-1:2009, A.3.4), and crop_IR and RoomAnalysis cut the broadband response there. Two of its cases returned sample 1 where sample 0 is meant, a remnant of 1-based indexing:

  1. When the maximum is on the first sample, the function returned its default of 1, so the cropped response lost its peak.
  2. When the last sample 20 dB below the maximum is the first sample, it returned 1, so the start moved one sample late.

Both now return 0. The other cases keep the index of the last sample below the threshold, the same convention as ita_start_IR of the ITA-Toolbox.

A response with exact silence before its peak, as image sources give, also printed a RuntimeWarning for the logarithm of zero; that warning is silenced, since those samples are below any threshold anyway.

The tests in tests/test_ir_start.py check the three cases with synthetic responses: the peak on the first sample gives 0, a ramp to a peak at sample 100 gives the last sample of the ramp 20 dB below it, and a single sample below the threshold at the start gives 0. The first and the last fail without this change.

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

… peak

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