ISoundLocalizer<T>

Interfaces · AiDotNet.Interfaces

Interface for sound localization models that estimate the spatial position of sound sources.

For Beginners

Sound localization is like closing your eyes and pointing to where a sound is coming from.

How it works (like human hearing):

  1. Sound reaches one ear slightly before the other (ITD - Interaural Time Difference)
  2. Sound is slightly louder in the closer ear (ILD - Interaural Level Difference)
  3. Head shape affects high frequencies differently for each ear
  4. Brain combines all cues to determine direction

What’s measured:

  • Azimuth: Left-right angle (0° = front, 90° = right, -90° = left)
  • Elevation: Up-down angle (0° = level, 90° = above)
  • Distance: How far away (harder to estimate from audio alone)

Use cases:

  • Spatial audio for VR/AR (place sounds correctly in 3D)
  • Smart speakers (know which direction user is speaking from)
  • Security (detect where intruder sounds come from)
  • Robotics (navigate toward or away from sounds)
  • Audio surveillance (track moving sound sources)
  • Hearing aids (enhance sounds from specific directions)

How It Works

Sound localization estimates where sound is coming from in 3D space. This requires multi-channel audio (stereo or more) and uses differences in timing, loudness, and spectral content between channels to determine direction.

Properties

Property Summary
MicrophoneArrayConfig<T> ArrayConfig { get; } Gets the microphone array geometry if applicable.
bool SupportsDistanceEstimation { get; } Gets whether this model can estimate distance (not just direction).
bool SupportsMultipleSourceTracking { get; } Gets whether this model can track multiple simultaneous sources.
int RequiredChannels { get; } Gets the number of audio channels required.
int SampleRate { get; } Gets the expected sample rate for input audio.

Methods

Method Summary
IReadOnlyList<DirectionEstimate<T>> EstimateDirections(Tensor<T> audio, int maxSources) Estimates direction of arrival (DOA) for dominant sources.
LocalizationResult<T> Localize(Tensor<T> audio) Localizes sound sources in multi-channel audio.
SoundTrackingResult<T> TrackSources(Tensor<T> audio, double windowDuration) Tracks sound source positions over time.
Task<LocalizationResult<T>> LocalizeAsync(Tensor<T> audio, CancellationToken cancellationToken) Localizes sound sources asynchronously.
Tensor<T> Beamform(Tensor<T> audio, double targetAzimuth, double targetElevation) Beamforms audio to focus on a specific direction.
Tensor<T> ComputeSpatialSpectrum(Tensor<T> audio, double azimuthResolution) Computes spatial power spectrum for visualization.