Krotos Modules 3
Loading...
Searching...
No Matches
krotos::SWIPE_PitchEstimation Class Reference

A Sawtooth waveform inspired pitch estimator for speech and music. Paper: https://www.researchgate.net/publication/23558616_A_sawtooth_waveform_inspired_pitch_estimator_for_speech_and_music. More...

#include <SWIPE_PitchEstimation.h>

Public Member Functions

 SWIPE_PitchEstimation (const float sampleRate, const float timeStep, const float log2PitchStep, const float ERBStep, const float normOverlap, const float strenThresh)
 
void initVectors ()
 
std::pair< Eigen::VectorXf, Eigen::VectorXf > calculatePitchStrengthPairs (std::vector< float > &signal)
 
Eigen::VectorXf getTimes ()
 

Private Member Functions

Eigen::VectorXf calculateLog2PitchCands (float log2PitchStep)
 
Eigen::VectorXf calculatePitchCands (const Eigen::VectorXf &log2PitchCands)
 
std::pair< Eigen::VectorXf, Eigen::VectorXf > selectCandidatesForWindowSize (size_t winSizeIDx)
 
Eigen::VectorXf getERBsSubset (const Eigen::VectorXf &pitchCandsSubset)
 
Eigen::MatrixXf pitchStrengthAllCandidates (const Eigen::VectorXf &ERBs, Eigen::MatrixXf &ERBsDistrValues, const Eigen::VectorXf &pitchCands)
 
Eigen::VectorXf pitchStrengthOneCandidate (const Eigen::VectorXf &ERBS, const Eigen::MatrixXf &normERBsDistrValues, float pitchCand)
 
std::pair< Eigen::VectorXf, Eigen::VectorXf > fineTunePitch (Eigen::MatrixXf globStrMatrix)
 
Eigen::VectorXi primes (int n)
 
Eigen::MatrixXf cumsum (const Eigen::MatrixXf &input)
 
Eigen::VectorXf polyfit (const Eigen::VectorXf &x, const Eigen::VectorXf &y, int n)
 
Eigen::MatrixXf computeN (const Eigen::MatrixXf &ERBsDistrValues)
 

Private Attributes

float m_sampleRate {-1.0f}
 
float m_timeStep {-1.0f}
 
float m_log2PitchStep {-1.0f}
 
float m_ERBStep {-1.0f}
 
float m_normOverlap {-1.0f}
 
float m_strenThresh {-1.0f}
 
Eigen::Vector2f m_pitchLims
 
Eigen::VectorXf m_times
 
Eigen::VectorXf m_pitchCands
 
Eigen::VectorXf m_winSizes
 
Eigen::VectorXf m_log2DistWin1OptPitchAndPitchCands
 
Eigen::VectorXf m_ERBs
 

Detailed Description

A Sawtooth waveform inspired pitch estimator for speech and music. Paper: https://www.researchgate.net/publication/23558616_A_sawtooth_waveform_inspired_pitch_estimator_for_speech_and_music.

Class representing the Harmonic Representation of an audio signal.

From the paper abstract:
Sawtooth Waveform Inspired Pitch Estimator (SWIPE) has been developed for
processing speech and music. SWIPE is shown to outperform existing algorithms on several
publicly available speech/musical-instruments databases and a disordered speech database.
SWIPE estimates the pitch as the fundamental frequency of the sawtooth waveform whose
spectrum best matches the spectrum of the input signal. A decaying cosine kernel provides an
extension to older frequency-based, sieve-type estimation algorithms by providing smooth peaks
with decaying amplitudes to correlate with the harmonics of the signal. An improvement on the
algorithm is achieved by using only the first and prime harmonics, which significantly reduces
subharmonic errors commonly found in other pitch estimation algorithms.

TODO: REPLACE ALL VECTORS AND MATRIX AS WELL AS LINEAR ALGEBRA OPERATIONS WITH EIGEN!!!.

This class evaluates a spectrogram of the audio signal, estimates the fundamental pitches for all hop times, and optimizes and corrects the fundamental frequencies while evaluating the inharmonicity coefficient. This process yields the frequencies of the rest of the harmonic partials and all their amplitudes using the spectrogram.

Constructor & Destructor Documentation

◆ SWIPE_PitchEstimation()

krotos::SWIPE_PitchEstimation::SWIPE_PitchEstimation ( const float sampleRate,
const float timeStep,
const float log2PitchStep,
const float ERBStep,
const float normOverlap,
const float strenThresh )

Member Function Documentation

◆ calculateLog2PitchCands()

Eigen::VectorXf krotos::SWIPE_PitchEstimation::calculateLog2PitchCands ( float log2PitchStep)
private

Defines pitch candidates.

◆ calculatePitchCands()

Eigen::VectorXf krotos::SWIPE_PitchEstimation::calculatePitchCands ( const Eigen::VectorXf & log2PitchCands)
private

◆ calculatePitchStrengthPairs()

std::pair< Eigen::VectorXf, Eigen::VectorXf > krotos::SWIPE_PitchEstimation::calculatePitchStrengthPairs ( std::vector< float > & signal)

Estimates the pitch of the vector signal every timeStep seconds.

Parameters
signalsignal in time vector representation
Returns
first vector is the vector of pitch estimates
second vector is the strength of every pitch estimate TODO:: Rewrite after high level refactor to return Eigen pair

◆ computeN()

Eigen::MatrixXf krotos::SWIPE_PitchEstimation::computeN ( const Eigen::MatrixXf & ERBsDistrValues)
private

◆ cumsum()

Eigen::MatrixXf krotos::SWIPE_PitchEstimation::cumsum ( const Eigen::MatrixXf & input)
private

◆ fineTunePitch()

std::pair< Eigen::VectorXf, Eigen::VectorXf > krotos::SWIPE_PitchEstimation::fineTunePitch ( Eigen::MatrixXf globStrMatrix)
private

The pitch is fine-tuned using parabolic interpolation with a resolution of 1 cent

◆ getERBsSubset()

Eigen::VectorXf krotos::SWIPE_PitchEstimation::getERBsSubset ( const Eigen::VectorXf & pitchCandsSubset)
private

Used to compute loudness at ERBs uniformly-spaced frequencies.

◆ getTimes()

Eigen::VectorXf krotos::SWIPE_PitchEstimation::getTimes ( )
inline

Returns the vector of times at which the pitch was estimated.

Returns
vector of times

◆ initVectors()

void krotos::SWIPE_PitchEstimation::initVectors ( )

Initialize vectors for intermediate calculations. Called in the constructor after initial parameters have been setup.

◆ pitchStrengthAllCandidates()

Eigen::MatrixXf krotos::SWIPE_PitchEstimation::pitchStrengthAllCandidates ( const Eigen::VectorXf & ERBs,
Eigen::MatrixXf & ERBsDistrValues,
const Eigen::VectorXf & pitchCands )
private

◆ pitchStrengthOneCandidate()

Eigen::VectorXf krotos::SWIPE_PitchEstimation::pitchStrengthOneCandidate ( const Eigen::VectorXf & ERBS,
const Eigen::MatrixXf & normERBsDistrValues,
float pitchCand )
private

◆ polyfit()

Eigen::VectorXf krotos::SWIPE_PitchEstimation::polyfit ( const Eigen::VectorXf & x,
const Eigen::VectorXf & y,
int n )
private

Polynomial curve fitting.

Parameters
xQuery points.These correspond to the fitted function values contained in y
yFitted values at query points. The values in y correspond to the query points contained in x
nDegree of polynomial fit
Returns
Coefficients for a polynomial p(x) of degree n that is a best fit (in a least-squares sense) for the data in y The coefficients in p are in descending powers, and the length of p is n+1

◆ primes()

Eigen::VectorXi krotos::SWIPE_PitchEstimation::primes ( int n)
private

Vector/Linear algebra operations. TODO Move somewhere to be reused

◆ selectCandidatesForWindowSize()

std::pair< Eigen::VectorXf, Eigen::VectorXf > krotos::SWIPE_PitchEstimation::selectCandidatesForWindowSize ( size_t winSizeIDx)
private

Select candidates that use a specific window size.

Member Data Documentation

◆ m_ERBs

Eigen::VectorXf krotos::SWIPE_PitchEstimation::m_ERBs
private

◆ m_ERBStep

float krotos::SWIPE_PitchEstimation::m_ERBStep {-1.0f}
private

◆ m_log2DistWin1OptPitchAndPitchCands

Eigen::VectorXf krotos::SWIPE_PitchEstimation::m_log2DistWin1OptPitchAndPitchCands
private

◆ m_log2PitchStep

float krotos::SWIPE_PitchEstimation::m_log2PitchStep {-1.0f}
private

◆ m_normOverlap

float krotos::SWIPE_PitchEstimation::m_normOverlap {-1.0f}
private

◆ m_pitchCands

Eigen::VectorXf krotos::SWIPE_PitchEstimation::m_pitchCands
private

◆ m_pitchLims

Eigen::Vector2f krotos::SWIPE_PitchEstimation::m_pitchLims
private

The pitch is searched within the range m_pitchLims(in Hertz)

◆ m_sampleRate

float krotos::SWIPE_PitchEstimation::m_sampleRate {-1.0f}
private

◆ m_strenThresh

float krotos::SWIPE_PitchEstimation::m_strenThresh {-1.0f}
private

◆ m_times

Eigen::VectorXf krotos::SWIPE_PitchEstimation::m_times
private

◆ m_timeStep

float krotos::SWIPE_PitchEstimation::m_timeStep {-1.0f}
private

◆ m_winSizes

Eigen::VectorXf krotos::SWIPE_PitchEstimation::m_winSizes
private

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