perf: reuse GCC-PHAT TDOA; skip 16 kHz AudioNormalizer

Delay-and-Sum still uses the tutorial STFT/cov/GCC-PHAT/DelaySum/ISTFT
path. TDOA is refreshed every BEAMFORM_TDOA_EVERY hops (default 5).
This commit is contained in:
root
2026-08-28 06:19:02 +00:00
parent 23c2e9c4c0
commit b02138669a
6 changed files with 70 additions and 6 deletions
+26
View File
@@ -57,6 +57,32 @@ def test_beamform_loads_delaysum_module():
assert "beamform" in c.backend
def test_beamform_skips_normalizer_at_native_rate():
c = AudioCleaner(mode="off", beamform="force", sample_rate=16000)
assert c._normalizer is None
def test_tdoa_reused_across_hops():
c = AudioCleaner(mode="off", beamform="force", tdoa_every=5)
assert c._gccphat is not None
calls = {"n": 0}
orig = c._gccphat
def wrapped(*a, **k):
calls["n"] += 1
return orig(*a, **k)
c._gccphat = wrapped
hop = 3200
t = np.arange(hop)
ch0 = (np.sin(2 * np.pi * 440 * t / 16000) * 8000).astype(np.int16)
stereo = np.stack([ch0, np.roll(ch0, 2)], axis=1)
for _ in range(3):
out = c.process(stereo)
assert out.shape == (hop,)
assert calls["n"] == 1
def test_process_records_last_dt_ms():
c = AudioCleaner(mode="off", beamform="off")
hop = 3200