Backbone - Singer Tone
 
Loading...
Searching...
No Matches
Backbone::SingerToneDetector Class Reference

High-level wrapper over SingerToneTracker to detect pitch from mono audio frames. Exposes last detection via read-only properties and provides a simple mode (most frequent note) helper. More...

Public Member Functions

 if (value==_sampleRate) return
 
 SingerToneDetector ()
 Creates a new SingerToneDetector with a default history size and recording enabled.
 
void setSampleRate (int samplerate)
 Legacy API. Use SampleRate instead.
 
bool DetectPitch (float[] inBuffer)
 Processes an audio frame and updates last detection properties.
 
int FindMode (int count)
 Finds the mode (most frequent MIDI note) within the most recent count records.
 
string GetLastNoteName (bool sharps=true, bool showOctave=true)
 Returns the formatted note name of the last detected MIDI note.
 
string MidiNoteToString (int note)
 Formats an arbitrary MIDI note number to a note name.
 

Public Attributes

float LastFrequencyHz { get
 Last detected frequency in Hz. Zero means no valid pitch.
 
int LastMidiNote { get
 Last detected MIDI note as integer (A4 = 69). Zero means no valid pitch.
 
float LastMidiNotePrecise { get
 Last detected MIDI note as float (note + cents/100).
 
string LastNoteName { get
 Last detected note name, e.g., "A# 4". Null or empty if no valid pitch.
 
int LastCents { get
 Last detected cents deviation from the integer MIDI note in [-50, 50].
 
int SampleRate
 Audio sample rate in Hz used by the underlying tracker. Setting a new value reconfigures internal filters.
 
 _sampleRate = value
 
tracker SampleRate = value
 
ReadOnlyCollection< SingerToneTracker.PitchRecordPitchHistory
 Read-only view of recent pitch records produced by the tracker. The collection can be empty if no detections were recorded yet.
 

Private Member Functions

void ResetLast ()
 Resets last detection properties to "no pitch" defaults.
 
int Repetitions (int element, int count, int startIndex)
 Counts how many times the MIDI note at element appears within the window [startIndex , startIndex + count ) in the history.
 

Private Attributes

SingerToneTracker tracker
 
int _sampleRate
 
 set
 

Detailed Description

High-level wrapper over SingerToneTracker to detect pitch from mono audio frames. Exposes last detection via read-only properties and provides a simple mode (most frequent note) helper.

Constructor & Destructor Documentation

◆ SingerToneDetector()

Backbone::SingerToneDetector::SingerToneDetector ( )

Creates a new SingerToneDetector with a default history size and recording enabled.

Member Function Documentation

◆ DetectPitch()

bool Backbone::SingerToneDetector::DetectPitch ( float[] inBuffer)

Processes an audio frame and updates last detection properties.

Parameters
inBufferMono PCM frame (float samples in [-1,1]). Must not be null or empty.
Returns
True if a valid pitch was detected; otherwise false.

◆ FindMode()

int Backbone::SingerToneDetector::FindMode ( int count)

Finds the mode (most frequent MIDI note) within the most recent count records.

Parameters
countNumber of recent records to consider. Clamped to available history.
Returns
The modal MIDI note, or 0 if not enough data.

◆ GetLastNoteName()

string Backbone::SingerToneDetector::GetLastNoteName ( bool sharps = true,
bool showOctave = true )

Returns the formatted note name of the last detected MIDI note.

Parameters
sharpsIf true, uses sharps (e.g., A#); otherwise flats (e.g., Bb).
showOctaveIf true, appends the octave number.
Returns
Note name or null if no valid pitch.

◆ if()

Backbone::SingerToneDetector::if ( value = =_sampleRate)

◆ MidiNoteToString()

string Backbone::SingerToneDetector::MidiNoteToString ( int note)

Formats an arbitrary MIDI note number to a note name.

Parameters
noteMIDI note number.
Returns
Formatted note name, or null if out of supported range.

◆ Repetitions()

int Backbone::SingerToneDetector::Repetitions ( int element,
int count,
int startIndex )
private

Counts how many times the MIDI note at element appears within the window [startIndex , startIndex + count ) in the history.

Parameters
elementIndex in the history whose note is used as the target.
countWindow length to scan.
startIndexStart index of the window in the history list.
Returns
Repetition count within the window.

◆ ResetLast()

void Backbone::SingerToneDetector::ResetLast ( )
private

Resets last detection properties to "no pitch" defaults.

◆ setSampleRate()

void Backbone::SingerToneDetector::setSampleRate ( int samplerate)
property

Legacy API. Use SampleRate instead.

Parameters
samplerateSample rate in Hz.

Member Data Documentation

◆ _sampleRate [1/2]

int Backbone::SingerToneDetector::_sampleRate
private

◆ _sampleRate [2/2]

Backbone::SingerToneDetector::_sampleRate = value

◆ LastCents

int Backbone::SingerToneDetector::LastCents { get

Last detected cents deviation from the integer MIDI note in [-50, 50].

◆ LastFrequencyHz

float Backbone::SingerToneDetector::LastFrequencyHz { get

Last detected frequency in Hz. Zero means no valid pitch.

◆ LastMidiNote

int Backbone::SingerToneDetector::LastMidiNote { get

Last detected MIDI note as integer (A4 = 69). Zero means no valid pitch.

◆ LastMidiNotePrecise

float Backbone::SingerToneDetector::LastMidiNotePrecise { get

Last detected MIDI note as float (note + cents/100).

◆ LastNoteName

string Backbone::SingerToneDetector::LastNoteName { get

Last detected note name, e.g., "A# 4". Null or empty if no valid pitch.

◆ PitchHistory

ReadOnlyCollection<SingerToneTracker.PitchRecord> Backbone::SingerToneDetector::PitchHistory
Initial value:
=> new ReadOnlyCollection<SingerToneTracker.PitchRecord>(
(IList<SingerToneTracker.PitchRecord>)tracker.PitchRecords)
SingerToneTracker tracker
Definition SingerToneDetector.cs:13
Real-time pitch tracker. Splits input into low/high bands, performs coarse-to-fine pitch detection,...
Definition SingerToneTracker.cs:12
Immutable pitch record.
Definition SingerToneTracker.cs:338

Read-only view of recent pitch records produced by the tracker. The collection can be empty if no detections were recorded yet.

◆ SampleRate [1/2]

int Backbone::SingerToneDetector::SampleRate
Initial value:
{
get => _sampleRate
int _sampleRate
Definition SingerToneDetector.cs:14

Audio sample rate in Hz used by the underlying tracker. Setting a new value reconfigures internal filters.

◆ SampleRate [2/2]

tracker Backbone::SingerToneDetector::SampleRate = value

◆ set

Backbone::SingerToneDetector::set
private
Initial value:
{
if (value <= 0) throw new ArgumentOutOfRangeException(nameof(value))

◆ tracker

SingerToneTracker Backbone::SingerToneDetector::tracker
private

The documentation for this class was generated from the following file: