MelodyExtractor<T>

Models & Types · AiDotNet.Audio.MusicAnalysis

Neural Melody Extractor that identifies the primary melodic line from polyphonic audio.

Inheritance: NeuralNetworkBase<T> → AudioNeuralNetworkBase<T> → MelodyExtractor<T>

Implements: IPitchDetector<T>

For Beginners

When you listen to a song, you can usually hum along to the main melody even though many instruments are playing. This model does the same thing - it finds and extracts just the main tune from a full song, ignoring background harmonies and rhythms.

Usage:

How It Works

The Melody Extractor identifies the primary melodic line from a polyphonic audio recording using a neural network. Unlike pitch detection (which finds any pitch), melody extraction specifically tracks the dominant melody even when other instruments are playing simultaneously.

Constructors

Constructor Summary
MelodyExtractor(NeuralNetworkArchitecture<T> architecture, MelodyExtractorOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) Creates a Melody Extractor in native training mode.
MelodyExtractor(NeuralNetworkArchitecture<T> architecture, string modelPath, MelodyExtractorOptions options) Creates a Melody Extractor in native training mode.

Properties

Property Summary
double MaxPitch { get; set; }
double MinPitch { get; set; }

Methods

Method Summary
IReadOnlyList<PitchFrame<T>> ExtractDetailedPitchContour(Tensor<T> audio, int hopSizeMs)
ModelMetadata<T> GetModelMetadata()
T MidiToPitch(double midiNote)
T[] ExtractPitchContour(Tensor<T> audio, int hopSizeMs)
ValueTuple<T, T>? DetectPitchWithConfidence(Tensor<T> audioFrame)
ValueTuple<bool, T> DetectPitch(Tensor<T> audioFrame)
double GetCentsDeviation(T pitchHz)
double PitchToMidi(T pitchHz)
string PitchToNoteName(T pitchHz)