Pitch-related DSP utilities and coarse-to-fine pitch detection.
More...
|
| | SingerToneDSP (double sampleRate, float minPitch, float maxPitch, float detectLevelThreshold) |
| | Initializes the DSP with sampling parameters and detection limits.
|
| |
| float | DetectPitch (float[] samplesLo, float[] samplesHi, int numSamples) |
| | Detects pitch on a frame using low/high prefiltered signals and a level gate.
|
| |
| bool | LevelIsAbove (float[] buffer, int len, float level) |
| | Returns true if any sample within the first len entries has absolute value at least level .
|
| |
| float | MidiNoteToPitch (float note) |
| | Converts a floating MIDI note to pitch in Hz (limited by m_maxPitch).
|
| |
|
| static double | CreateSineWave (float[] buffer, int numSamples, float sampleRate, float freq, float amplitude, double startAngle) |
| | Fills buffer with a sine wave. Returns the updated phase.
|
| |
| static void | CopyBuffer (T[] source, int srcStart, T[] destination, int dstStart, int length) |
| | Copies a block of elements from source to destination .
|
| |
| static bool | PitchToMidiNote (float pitch, out int note, out int cents) |
| | Converts a pitch in Hz to integer MIDI note and cents.
|
| |
| static float | PitchToMidiNote (float pitch) |
| | Converts a pitch in Hz to floating MIDI note (note + cents/100).
|
| |
| static string | GetNoteName (int note, bool sharps, bool showOctave) |
| | Formats a MIDI note to its musical note name.
|
| |
|
| static readonly double | InvLn2 = 1.0 / Math.Log(2.0) |
| | 1 / ln(2). Used to convert natural logarithms to log2.
|
| |
|
| int | CourseIndexForFreq (float hz) |
| | Returns coarse index for a given frequency in Hz.
|
| |
| float | DetectPitchLo (float[] samplesLo, float[] samplesHi) |
| | Coarse pass: scans candidate periods and refines around peaks.
|
| |
| float | DetectPitchHi (float[] samples, int lowFreqIdx) |
| | High-resolution refinement around the best coarse candidate.
|
| |
| float | InterpolateHermite (float fY0, float fY1, float fY2, float fY3, float frac) |
| | 4-point, 3rd-order Hermite interpolation.
|
| |
| float | InterpolateLinear (float y0, float y1, float frac) |
| | Linear interpolation.
|
| |
| float | RatioAbsDiffLinear (float[] samples, int freqIdx, int blockLen, int stepSize, bool hiRes) |
| | Medium/low resolution ratio of absolute differences using linear interpolation.
|
| |
| float | SumAbsDiffHermite (float[] samples, float fOffset, int blockLen, int stepSize) |
| | Medium/high resolution sum of absolute differences using Hermite interpolation.
|
| |
Pitch-related DSP utilities and coarse-to-fine pitch detection.
◆ SingerToneDSP()
| Backbone::SingerToneDSP::SingerToneDSP |
( |
double | sampleRate, |
|
|
float | minPitch, |
|
|
float | maxPitch, |
|
|
float | detectLevelThreshold ) |
Initializes the DSP with sampling parameters and detection limits.
- Parameters
-
| sampleRate | Sampling rate in Hz. |
| minPitch | Minimum detectable pitch in Hz. |
| maxPitch | Maximum detectable pitch in Hz. |
| detectLevelThreshold | Absolute signal threshold to attempt detection. |
◆ CopyBuffer()
| static void Backbone::SingerToneDSP::CopyBuffer |
( |
T[] | source, |
|
|
int | srcStart, |
|
|
T[] | destination, |
|
|
int | dstStart, |
|
|
int | length ) |
|
static |
Copies a block of elements from source to destination .
- Exceptions
-
| ArgumentOutOfRangeException | If length is negative. |
| Exception | If source or destination buffers are too small. |
◆ CourseIndexForFreq()
| int Backbone::SingerToneDSP::CourseIndexForFreq |
( |
float | hz | ) |
|
|
private |
Returns coarse index for a given frequency in Hz.
◆ CreateSineWave()
| static double Backbone::SingerToneDSP::CreateSineWave |
( |
float[] | buffer, |
|
|
int | numSamples, |
|
|
float | sampleRate, |
|
|
float | freq, |
|
|
float | amplitude, |
|
|
double | startAngle ) |
|
static |
Fills buffer with a sine wave. Returns the updated phase.
◆ DetectPitch()
| float Backbone::SingerToneDSP::DetectPitch |
( |
float[] | samplesLo, |
|
|
float[] | samplesHi, |
|
|
int | numSamples ) |
Detects pitch on a frame using low/high prefiltered signals and a level gate.
- Parameters
-
| samplesLo | Low-band samples. |
| samplesHi | High-band samples. |
| numSamples | Number of valid samples in the arrays. |
- Returns
- Detected pitch in Hz, or 0 if not found.
◆ DetectPitchHi()
| float Backbone::SingerToneDSP::DetectPitchHi |
( |
float[] | samples, |
|
|
int | lowFreqIdx ) |
|
private |
High-resolution refinement around the best coarse candidate.
◆ DetectPitchLo()
| float Backbone::SingerToneDSP::DetectPitchLo |
( |
float[] | samplesLo, |
|
|
float[] | samplesHi ) |
|
private |
Coarse pass: scans candidate periods and refines around peaks.
◆ GetNoteName()
| static string Backbone::SingerToneDSP::GetNoteName |
( |
int | note, |
|
|
bool | sharps, |
|
|
bool | showOctave ) |
|
static |
Formats a MIDI note to its musical note name.
- Parameters
-
| note | MIDI note number. |
| sharps | If true uses sharps, otherwise flats. |
| showOctave | If true appends the octave number. |
- Returns
- Formatted name or null if out of supported range.
◆ InterpolateHermite()
| float Backbone::SingerToneDSP::InterpolateHermite |
( |
float | fY0, |
|
|
float | fY1, |
|
|
float | fY2, |
|
|
float | fY3, |
|
|
float | frac ) |
|
private |
4-point, 3rd-order Hermite interpolation.
◆ InterpolateLinear()
| float Backbone::SingerToneDSP::InterpolateLinear |
( |
float | y0, |
|
|
float | y1, |
|
|
float | frac ) |
|
private |
◆ LevelIsAbove()
| bool Backbone::SingerToneDSP::LevelIsAbove |
( |
float[] | buffer, |
|
|
int | len, |
|
|
float | level ) |
Returns true if any sample within the first len entries has absolute value at least level .
◆ MidiNoteToPitch()
| float Backbone::SingerToneDSP::MidiNoteToPitch |
( |
float | note | ) |
|
Converts a floating MIDI note to pitch in Hz (limited by m_maxPitch).
◆ PitchToMidiNote() [1/2]
| static float Backbone::SingerToneDSP::PitchToMidiNote |
( |
float | pitch | ) |
|
|
static |
Converts a pitch in Hz to floating MIDI note (note + cents/100).
◆ PitchToMidiNote() [2/2]
| static bool Backbone::SingerToneDSP::PitchToMidiNote |
( |
float | pitch, |
|
|
out int | note, |
|
|
out int | cents ) |
|
static |
Converts a pitch in Hz to integer MIDI note and cents.
◆ RatioAbsDiffLinear()
| float Backbone::SingerToneDSP::RatioAbsDiffLinear |
( |
float[] | samples, |
|
|
int | freqIdx, |
|
|
int | blockLen, |
|
|
int | stepSize, |
|
|
bool | hiRes ) |
|
private |
Medium/low resolution ratio of absolute differences using linear interpolation.
◆ SumAbsDiffHermite()
| float Backbone::SingerToneDSP::SumAbsDiffHermite |
( |
float[] | samples, |
|
|
float | fOffset, |
|
|
int | blockLen, |
|
|
int | stepSize ) |
|
private |
Medium/high resolution sum of absolute differences using Hermite interpolation.
◆ InvLn2
| readonly double Backbone::SingerToneDSP::InvLn2 = 1.0 / Math.Log(2.0) |
|
static |
1 / ln(2). Used to convert natural logarithms to log2.
◆ kCourseOctaveSteps
| const int Backbone::SingerToneDSP::kCourseOctaveSteps = 96 |
|
private |
◆ kHiResDeltaIdx
| const int Backbone::SingerToneDSP::kHiResDeltaIdx = 5 |
|
private |
◆ kHiResStepMax
| const int Backbone::SingerToneDSP::kHiResStepMax = 5 |
|
private |
◆ kHiResStepMin
| const int Backbone::SingerToneDSP::kHiResStepMin = 1 |
|
private |
◆ kLoHiSwitchFreqHz
| const float Backbone::SingerToneDSP::kLoHiSwitchFreqHz = 250f |
|
private |
◆ kLoResDivisor
| const int Backbone::SingerToneDSP::kLoResDivisor = 10 |
|
private |
◆ kMaxMidiNote
| const int Backbone::SingerToneDSP::kMaxMidiNote = 108 |
|
private |
◆ kMinMidiNote
| const int Backbone::SingerToneDSP::kMinMidiNote = 21 |
|
private |
◆ kPeakScanSize
| const int Backbone::SingerToneDSP::kPeakScanSize = 23 |
|
private |
◆ kPeakThresh1
| const float Backbone::SingerToneDSP::kPeakThresh1 = 200f |
|
private |
◆ kPeakThresh2
| const float Backbone::SingerToneDSP::kPeakThresh2 = 600f |
|
private |
◆ kPointyFar
| const float Backbone::SingerToneDSP::kPointyFar = 1.5f |
|
private |
◆ kPointyNear
| const float Backbone::SingerToneDSP::kPointyNear = 1.2f |
|
private |
◆ kScanHiFreqStep
| const float Backbone::SingerToneDSP::kScanHiFreqStep = 1.005f |
|
private |
◆ kScanHiSize
| const int Backbone::SingerToneDSP::kScanHiSize = 31 |
|
private |
◆ kSkipSize
| const int Backbone::SingerToneDSP::kSkipSize = 8 |
|
private |
◆ m_blockLen14
| int Backbone::SingerToneDSP::m_blockLen14 |
|
private |
◆ m_blockLen24
| int Backbone::SingerToneDSP::m_blockLen24 |
|
private |
◆ m_blockLen34
| int Backbone::SingerToneDSP::m_blockLen34 |
|
private |
◆ m_blockLen44
| int Backbone::SingerToneDSP::m_blockLen44 |
|
private |
◆ m_detectCurve
| float [] Backbone::SingerToneDSP::m_detectCurve |
|
private |
◆ m_detectLevelThreshold
| float Backbone::SingerToneDSP::m_detectLevelThreshold |
|
private |
◆ m_maxNote
| int Backbone::SingerToneDSP::m_maxNote |
|
private |
◆ m_maxPitch
| float Backbone::SingerToneDSP::m_maxPitch |
|
private |
◆ m_minNote
| int Backbone::SingerToneDSP::m_minNote |
|
private |
◆ m_minPitch
| float Backbone::SingerToneDSP::m_minPitch |
|
private |
◆ m_numCourseSteps
| int Backbone::SingerToneDSP::m_numCourseSteps |
|
private |
◆ m_pCourseFreq
| float [] Backbone::SingerToneDSP::m_pCourseFreq |
|
private |
◆ m_pCourseFreqOffset
| float [] Backbone::SingerToneDSP::m_pCourseFreqOffset |
|
private |
◆ m_peakBuf
| readonly float [] Backbone::SingerToneDSP::m_peakBuf = new float[kScanHiSize] |
|
private |
◆ m_prevPitchIdx
| int Backbone::SingerToneDSP::m_prevPitchIdx |
|
private |
◆ m_sampleRate
| double Backbone::SingerToneDSP::m_sampleRate |
|
private |
◆ m_scanHiOffset
| readonly float [] Backbone::SingerToneDSP::m_scanHiOffset = new float[kScanHiSize] |
|
private |
◆ MaxNote
| int Backbone::SingerToneDSP::MaxNote => m_maxNote |
Maximum MIDI note supported.
◆ MaxPitch
| float Backbone::SingerToneDSP::MaxPitch => m_maxPitch |
Maximum detectable pitch (Hz).
◆ MinNote
| int Backbone::SingerToneDSP::MinNote => m_minNote |
Minimum MIDI note supported.
◆ MinPitch
| float Backbone::SingerToneDSP::MinPitch => m_minPitch |
Minimum detectable pitch (Hz).
The documentation for this class was generated from the following file: