Add ITD (Interaural Time Difference) via cross-correlation (#12)

Cross-correlates left/right ear audio frames (512 samples, ~32ms window)
to find the sub-millisecond delay between arrays. Converts delay to
bearing angle using speed of sound and array separation.

At 16kHz with 175mm separation, resolution is ~1 sample = 62.5μs = ~7°.
Not lab-grade, but adds a third independent angle estimate alongside
DoA and ILD. Works with current 2-channel firmware — no raw mics needed.

New fields in /doa spatial response:
  itd_angle: bearing from cross-correlation (degrees)
  itd_delay_us: raw time delay (microseconds, positive = source on right)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex
2026-04-12 21:51:25 -05:00
parent 0705b3818b
commit cae14023b7
2 changed files with 110 additions and 7 deletions

View File

@@ -450,7 +450,10 @@ def doa_track_loop():
if spatial_tracker and dual_stream:
left_energy = dual_stream.left.get_energy() if dual_stream.left else 0.0
right_energy = dual_stream.right.get_energy() if dual_stream.right else 0.0
result = spatial_tracker.update(state.doa, left_energy, right_energy)
left_audio = dual_stream.left.get_frame() if dual_stream.left else None
right_audio = dual_stream.right.get_frame() if dual_stream.right else None
result = spatial_tracker.update(
state.doa, left_energy, right_energy, left_audio, right_audio)
if result:
state.spatial = result
gx, gy = result["gaze_x"], result["gaze_y"]