Real-time pitch tracker. Splits input into low/high bands, performs coarse-to-fine pitch detection, and emits records at a target rate. More...
Classes | |
| struct | PitchRecord |
| Immutable pitch record. More... | |
Public Member Functions | |
| delegate void | PitchDetectedHandler (SingerToneTracker sender, PitchRecord pitchRecord) |
| Raised when a pitch record is produced. | |
| SingerToneTracker () | |
| Initializes a new tracker. Call SampleRate setter to configure. | |
| Setup () | |
| if (!m_recordPitchRecords) m_pitchRecords.Clear() | |
| if (value > 0 &&m_pitchRecords.Capacity !=value) m_pitchRecords.Capacity | |
| void | Reset () |
| Resets internal state and clears filters, buffers, and history. Call this when sample positions are non-consecutive. | |
| void | ProcessBuffer (float[] inBuffer, int sampleCount=0) |
| Processes an input buffer. Emits zero or more PitchDetected events depending on how many detection windows fit between cached and new samples. | |
Public Attributes | |
| event PitchDetectedHandler | PitchDetected |
| double | SampleRate |
| Sample rate in Hz. Reconfigures internal filters and buffers when set. | |
| int | PitchRecordsPerSecond |
| Target number of pitch records per second. Clamped to [1, 100]. | |
| set { m_pitchRecordsPerSecond = Math.Max(1, Math.Min(100, value)) | |
| bool | RecordPitchRecords |
| Enables or disables history recording. Disabling clears previous records. | |
| m_recordPitchRecords = value | |
| int | PitchRecordHistorySize |
| Maximum number of records to keep in history. 0 means unbounded (not recommended in realtime). | |
| IList | PitchRecords => m_pitchRecords.AsReadOnly() |
| Read-only view of recorded pitch records. | |
| PitchRecord | CurrentPitchRecord => m_curPitchRecord |
| Latest pitch record produced by the tracker. | |
| long | CurrentPitchSamplePosition => m_curPitchSamplePos |
| Absolute sample position of the current detection window start. | |
| int | DetectSampleOffset => (m_pitchBufSize + m_detectOverlapSamples) / 2 |
| Estimated latency in samples between input and reported pitch. | |
Static Public Attributes | |
| static float | MinDetectFrequency => kMinFreq |
| Minimum detectable frequency in Hz. | |
| static float | MaxDetectFrequency => kMaxFreq |
| Maximum detectable frequency in Hz. | |
| static double | FrequencyStep => Math.Pow(2.0, 1.0 / kOctaveSteps) |
| Frequency ratio between adjacent coarse steps (2^(1/96)). | |
Private Member Functions | |
| void | Setup () |
| Configures filters, buffers, and timing based on current parameters. | |
| void | AddPitchRecord (float pitch) |
| Adds one pitch record to history and fires the event. | |
Private Attributes | |
| const int | kOctaveSteps = 96 |
| const int | kStepOverlap = 4 |
| const float | kMinFreq = 50.0f |
| const float | kMaxFreq = 1600.0f |
| const int | kStartCircular = 40 |
| const float | kDetectOverlapSec = 0.005f |
| const float | kMaxOctaveSecRate = 10.0f |
| const float | kAvgOffset = 0.005f |
| const int | kAvgCount = 1 |
| const float | kCircularBufSaveTime = 1.0f |
| SingerToneDSP | m_dsp |
| CircularBuffer< float > | m_circularBufferLo |
| CircularBuffer< float > | m_circularBufferHi |
| double | m_sampleRate |
| float | m_detectLevelThreshold = 0.01f |
| int | m_pitchRecordsPerSecond = 50 |
| float[] | m_pitchBufLo |
| float[] | m_pitchBufHi |
| int | m_pitchBufSize |
| int | m_samplesPerPitchBlock |
| int | m_curPitchIndex |
| long | m_curPitchSamplePos |
| int | m_detectOverlapSamples |
| float | m_maxOverlapDiff |
| bool | m_recordPitchRecords |
| int | m_pitchRecordHistorySize |
| readonly List< PitchRecord > | m_pitchRecords = new List<PitchRecord>() |
| PitchRecord | m_curPitchRecord = new PitchRecord() |
| IIRFilter | m_iirFilterLoLo |
| IIRFilter | m_iirFilterLoHi |
| IIRFilter | m_iirFilterHiLo |
| IIRFilter | m_iirFilterHiHi |
Real-time pitch tracker. Splits input into low/high bands, performs coarse-to-fine pitch detection, and emits records at a target rate.
| Backbone::SingerToneTracker::SingerToneTracker | ( | ) |
Initializes a new tracker. Call SampleRate setter to configure.
|
private |
Adds one pitch record to history and fires the event.
| Backbone::SingerToneTracker::if | ( | ! | m_recordPitchRecords | ) |
| Backbone::SingerToneTracker::if | ( | value | , |
| 0 &&m_pitchRecords.Capacity ! | = value ) |
| delegate void Backbone::SingerToneTracker::PitchDetectedHandler | ( | SingerToneTracker | sender, |
| PitchRecord | pitchRecord ) |
Raised when a pitch record is produced.
| void Backbone::SingerToneTracker::ProcessBuffer | ( | float[] | inBuffer, |
| int | sampleCount = 0 ) |
Processes an input buffer. Emits zero or more PitchDetected events depending on how many detection windows fit between cached and new samples.
| inBuffer | Mono float PCM samples in [-1, 1]. |
| sampleCount | Number of samples to process. 0 uses the full buffer length. |
| void Backbone::SingerToneTracker::Reset | ( | ) |
Resets internal state and clears filters, buffers, and history. Call this when sample positions are non-consecutive.
| Backbone::SingerToneTracker::Setup | ( | ) |
|
private |
Configures filters, buffers, and timing based on current parameters.
| PitchRecord Backbone::SingerToneTracker::CurrentPitchRecord => m_curPitchRecord |
Latest pitch record produced by the tracker.
| long Backbone::SingerToneTracker::CurrentPitchSamplePosition => m_curPitchSamplePos |
Absolute sample position of the current detection window start.
| int Backbone::SingerToneTracker::DetectSampleOffset => (m_pitchBufSize + m_detectOverlapSamples) / 2 |
Estimated latency in samples between input and reported pitch.
|
static |
Frequency ratio between adjacent coarse steps (2^(1/96)).
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
| Backbone::SingerToneTracker::m_recordPitchRecords = value |
|
private |
|
private |
|
static |
Maximum detectable frequency in Hz.
|
static |
Minimum detectable frequency in Hz.
| event PitchDetectedHandler Backbone::SingerToneTracker::PitchDetected |
| int Backbone::SingerToneTracker::PitchRecordHistorySize |
Maximum number of records to keep in history. 0 means unbounded (not recommended in realtime).
| IList Backbone::SingerToneTracker::PitchRecords => m_pitchRecords.AsReadOnly() |
Read-only view of recorded pitch records.
| int Backbone::SingerToneTracker::PitchRecordsPerSecond |
Target number of pitch records per second. Clamped to [1, 100].
| bool Backbone::SingerToneTracker::RecordPitchRecords |
Enables or disables history recording. Disabling clears previous records.
| double Backbone::SingerToneTracker::SampleRate |
Sample rate in Hz. Reconfigures internal filters and buffers when set.
| Backbone::SingerToneTracker::set { m_pitchRecordsPerSecond = Math.Max(1, Math.Min(100, value)) |