Table of Contents

Interface IBeatTracker<T>

Namespace
AiDotNet.Interfaces
Assembly
AiDotNet.dll

Interface for beat tracking models that detect tempo and beat positions in audio.

public interface IBeatTracker<T>

Type Parameters

T

The numeric type used for calculations.

Remarks

Beat tracking analyzes audio to find the rhythmic pulse (beats) and estimate the tempo (beats per minute). This is fundamental to music information retrieval and enables beat-synchronized processing like auto-DJ mixing and rhythmic visualization.

For Beginners: Beat tracking is like tapping your foot to music - finding the pulse.

How it works:

  1. Audio is analyzed for rhythmic events (drum hits, bass notes, etc.)
  2. Periodicity detection finds the most likely beat period
  3. Beat positions are refined to align with actual events

Common use cases:

  • Music tempo detection ("this song is 120 BPM")
  • DJ software (beat matching between songs)
  • Music games (rhythm games like Guitar Hero)
  • Audio visualization (beat-synced lights)
  • Music production (quantizing to the beat)

Key concepts:

  • BPM (Beats Per Minute): The tempo or speed of the music
  • Downbeat: The first beat of a measure (often emphasized)
  • Beat phase: Where in the beat cycle we are

Properties

MaxBPM

Gets the maximum detectable BPM.

double MaxBPM { get; }

Property Value

double

MinBPM

Gets the minimum detectable BPM.

double MinBPM { get; }

Property Value

double

SampleRate

Gets the expected sample rate for input audio.

int SampleRate { get; }

Property Value

int

Methods

ComputeOnsetStrength(Tensor<T>)

Computes onset strength envelope for visualization or custom processing.

Tensor<T> ComputeOnsetStrength(Tensor<T> audio)

Parameters

audio Tensor<T>

Audio waveform tensor.

Returns

Tensor<T>

Onset strength values over time.

DetectDownbeats(Tensor<T>, BeatTrackingResult<T>?)

Detects downbeat positions (first beat of each measure).

DownbeatResult<T> DetectDownbeats(Tensor<T> audio, BeatTrackingResult<T>? beatTrackingResult = null)

Parameters

audio Tensor<T>

Audio waveform tensor.

beatTrackingResult BeatTrackingResult<T>

Optional pre-computed beat tracking result.

Returns

DownbeatResult<T>

Downbeat detection result.

Remarks

For Beginners: Downbeats are the "strong" beats (the "1" in counting "1-2-3-4"). Finding downbeats helps identify the musical structure.

EstimateTempo(Tensor<T>)

Estimates tempo without detecting individual beat positions.

T EstimateTempo(Tensor<T> audio)

Parameters

audio Tensor<T>

Audio waveform tensor.

Returns

T

Estimated tempo in BPM.

Remarks

Faster than full beat tracking when you only need the tempo.

GetTempoHypotheses(Tensor<T>, int)

Gets multiple tempo hypotheses with confidence scores.

IReadOnlyList<TempoHypothesis<T>> GetTempoHypotheses(Tensor<T> audio, int numHypotheses = 5)

Parameters

audio Tensor<T>

Audio waveform tensor.

numHypotheses int

Number of hypotheses to return.

Returns

IReadOnlyList<TempoHypothesis<T>>

List of tempo hypotheses with confidence scores.

Remarks

For Beginners: Sometimes tempo is ambiguous (could be 60 or 120 BPM). This returns multiple possibilities with confidence scores.

Track(Tensor<T>)

Detects tempo and beat positions in audio.

BeatTrackingResult<T> Track(Tensor<T> audio)

Parameters

audio Tensor<T>

Audio waveform tensor [samples] or [channels, samples].

Returns

BeatTrackingResult<T>

Beat tracking result with tempo and beat positions.

Remarks

For Beginners: This is the main method for finding beats. - Pass in audio of a song - Get back the tempo (BPM) and when each beat occurs

TrackAsync(Tensor<T>, CancellationToken)

Detects tempo and beat positions asynchronously.

Task<BeatTrackingResult<T>> TrackAsync(Tensor<T> audio, CancellationToken cancellationToken = default)

Parameters

audio Tensor<T>

Audio waveform tensor.

cancellationToken CancellationToken

Cancellation token for async operation.

Returns

Task<BeatTrackingResult<T>>

Beat tracking result.