Commit Graph

5 Commits

Author SHA1 Message Date
Alex
8073e3eb02 Fix ITD angle wrapping past 360°
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 21:52:07 -05:00
Alex
cae14023b7 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>
2026-04-12 21:51:25 -05:00
Alex
2a25db8498 Add ILD-based distance estimation + proximity zones
Computes Interaural Level Difference (dB) from left/right ear energy.
Fuses with triangulated distance (70/30 weight) for more robust estimate.
Classifies into proximity zones: intimate (<0.5m), conversational (0.5-2m),
across_room (2-5m), far (>5m).

ILD→distance mapping is empirical and should be calibrated per install.
Gaze vertical component now responds to proximity (closer = eyes down).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 21:12:00 -05:00
Alex
36aeb19280 Add binaural recording + tune spatial tracking
binaural_recorder.py: Records left/right ear streams as stereo WAV
in rolling 5-minute segments. Training data for spatial audio models.
Enabled via BINAURAL_RECORD=1 env var.

spatial.py: Tune smoothing — alpha 0.3→0.4 (snappier response),
idle return speed 0.05→0.03 (gentler drift), timeout 2s→1.5s.

headmic.py: Wire binaural recorder into audio loop, add /recording
endpoint for stats, feed both ear streams (not just best beam).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 20:53:05 -05:00
Alex
e0a4af031f Add binaural triangulation + smooth gaze tracking
spatial.py: Triangulates sound source position from two DoA angles using
ray intersection. Exponential smoothing prevents jitter. Gaze drifts back
to center after 2s of silence. Converts position (mm) to gaze (0-255).

headmic.py: Replaces simple doa_poll_loop with doa_track_loop that runs
the spatial tracker and pushes gaze to the eye service when the position
changes. Rate-limited to 10 pushes/sec with minimum delta threshold.

/doa endpoint now returns triangulated position + gaze coordinates.
Array separation (175mm) stored in config, overridable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 15:12:28 -05:00