Table of Contents

Interface IChordRecognizer<T>

Namespace
AiDotNet.Interfaces
Assembly
AiDotNet.dll

Interface for chord recognition models that identify musical chords in audio.

public interface IChordRecognizer<T>

Type Parameters

T

The numeric type used for calculations.

Remarks

Chord recognition analyzes audio to identify the musical chords being played. This involves detecting the simultaneous notes and classifying them into standard chord types (major, minor, seventh, etc.).

For Beginners: Chord recognition is like having a musician listen to a song and tell you what chords are being played.

How it works:

  1. Audio is converted to a chromagram (12 pitch classes)
  2. The pitch content is compared to known chord templates
  3. The best-matching chord is selected for each time frame

What are chords?

  • A chord is multiple notes played together
  • "C major" = C + E + G notes together
  • "A minor" = A + C + E notes together
  • The chord creates the harmony of the music

Common use cases:

  • Learning songs (getting chord charts automatically)
  • Music production (analyzing harmony)
  • Music generation (understanding structure)
  • Cover song detection (comparing harmonic content)

Properties

SampleRate

Gets the expected sample rate for input audio.

int SampleRate { get; }

Property Value

int

SupportedChordTypes

Gets the list of chord types this model can recognize.

IReadOnlyList<string> SupportedChordTypes { get; }

Property Value

IReadOnlyList<string>

Remarks

Common chord types: Major, Minor, Diminished, Augmented, 7th, etc.

TimeResolution

Gets the time resolution for chord detection in seconds.

double TimeResolution { get; }

Property Value

double

Methods

ExtractChromagram(Tensor<T>)

Extracts chromagram features from audio.

Tensor<T> ExtractChromagram(Tensor<T> audio)

Parameters

audio Tensor<T>

Audio waveform tensor.

Returns

Tensor<T>

Chromagram tensor [12, time_frames] with energy per pitch class.

Remarks

For Beginners: A chromagram shows how much energy is in each of the 12 musical notes (C, C#, D, etc.) over time. It's the raw data used for chord recognition.

GetChordNotes(string)

Converts a chord symbol to its component notes.

IReadOnlyList<string> GetChordNotes(string chordSymbol)

Parameters

chordSymbol string

Chord symbol (e.g., "Cmaj", "Am7").

Returns

IReadOnlyList<string>

List of note names in the chord.

GetChordProbabilities(Tensor<T>)

Gets chord probabilities for each time frame.

Tensor<T> GetChordProbabilities(Tensor<T> audio)

Parameters

audio Tensor<T>

Audio waveform tensor.

Returns

Tensor<T>

Tensor of chord probabilities [time_frames, num_chords].

Remarks

Useful for visualizing chord likelihood over time or for custom post-processing of chord detection.

Recognize(Tensor<T>)

Recognizes chords in audio.

ChordRecognitionResult<T> Recognize(Tensor<T> audio)

Parameters

audio Tensor<T>

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

Returns

ChordRecognitionResult<T>

Chord recognition result with chord sequence.

Remarks

For Beginners: This is the main method for finding chords. - Pass in audio of music - Get back a list of chords and when they occur

RecognizeAsync(Tensor<T>, CancellationToken)

Recognizes chords asynchronously.

Task<ChordRecognitionResult<T>> RecognizeAsync(Tensor<T> audio, CancellationToken cancellationToken = default)

Parameters

audio Tensor<T>

Audio waveform tensor.

cancellationToken CancellationToken

Cancellation token for async operation.

Returns

Task<ChordRecognitionResult<T>>

Chord recognition result.