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

#include <HarmonicRepresentation.h>

Classes

struct  ConfigParams
 Configuration parameters. More...
 
struct  HarmRepParams
 Parameters related to harmonic representation. More...
 
struct  SwipeParams
 Parameters related to pitch estimation. More...
 

Public Member Functions

 HarmonicRepresentation (float sampleRate)
 
Eigen::MatrixXf processSignal (std::vector< float > &inputSignal)
 Processes the input signal and returns the matrix of partial frequencies and partial amplitudes.
 

Private Member Functions

void replaceNanWithMedian (Eigen::VectorXf &inputVector)
 Replaces NaN values in the input vector with the median value.
 
Eigen::VectorXf fevalbp (const Eigen::MatrixXf &bp, const Eigen::VectorXf &x_v)
 Estimates pitches by linear interpolation.
 
Eigen::VectorXi findIndices (const Eigen::VectorXf &x_v, float threshMin=-std::numeric_limits< float >::infinity(), float threshMax=std::numeric_limits< float >::infinity())
 
std::vector< Eigen::MatrixXf > calculateReshaped2D (const Eigen::MatrixXf &multiplied, int tSize, int nFreqCorrs, int nInharmCoeffs)
 Reshapes a flat Eigen matrix into a vector of 2D matrices, intended for handling multidimensional matrices.
 
std::vector< Eigen::MatrixXi > applyTransformation (const std::vector< Eigen::MatrixXf > &reshapedMultiplied2_d, float binSize, int fSize)
 
std::vector< Eigen::MatrixXi > calculateDistrIdcs (int tSize, int nFreqCorrs, int nInharmCoeffs, int fSize, std::vector< Eigen::MatrixXi > &fSupIdcsTFHI2_d)
 
std::vector< Eigen::MatrixXf > extractSubmatrices (const Eigen::MatrixXf &distr, const std::vector< Eigen::MatrixXi > &distrIdcsTFHI2_d)
 
std::vector< Eigen::MatrixXf > computeTotalErgTFI (const std::vector< Eigen::MatrixXf > &submatrices_cell, int tSize, int nFreqCorrs, int nInharmCoeffs)
 
std::pair< Eigen::VectorXf, Eigen::VectorXi > maxRowValues (const Eigen::MatrixXf &matrix)
 

Private Attributes

struct krotos::HarmonicRepresentation::HarmRepParams harmRep
 
struct krotos::HarmonicRepresentation::ConfigParams config
 
struct krotos::HarmonicRepresentation::SwipeParams swipe
 
std::pair< Eigen::VectorXf, Eigen::VectorXf > m_pitchStrengthPair
 
Eigen::VectorXf m_times
 
const float m_sampleRate
 
float m_maxSwipepWinSize
 

Constructor & Destructor Documentation

◆ HarmonicRepresentation()

krotos::HarmonicRepresentation::HarmonicRepresentation ( float sampleRate)

Member Function Documentation

◆ applyTransformation()

std::vector< Eigen::MatrixXi > krotos::HarmonicRepresentation::applyTransformation ( const std::vector< Eigen::MatrixXf > & reshapedMultiplied2_d,
float binSize,
int fSize )
private

◆ calculateDistrIdcs()

std::vector< Eigen::MatrixXi > krotos::HarmonicRepresentation::calculateDistrIdcs ( int tSize,
int nFreqCorrs,
int nInharmCoeffs,
int fSize,
std::vector< Eigen::MatrixXi > & fSupIdcsTFHI2_d )
private

◆ calculateReshaped2D()

std::vector< Eigen::MatrixXf > krotos::HarmonicRepresentation::calculateReshaped2D ( const Eigen::MatrixXf & multiplied,
int tSize,
int nFreqCorrs,
int nInharmCoeffs )
private

Reshapes a flat Eigen matrix into a vector of 2D matrices, intended for handling multidimensional matrices.

4-D & 3-D Geometric Transformation Functions.

This function takes a flat Eigen::MatrixXf and reshapes it based on specified dimensions (tSize, nFreqCorrs) and counters (nInharmCoeffs). It is particularly useful for processing multidimensional matrix data that has been flattened into a single dimension for storage or transmission. The reshaped matrices are stored in a std::vector, allowing for easy access and manipulation of individual 2D slices of the original multidimensional matrix.

Parameters
multipliedThe flat Eigen::MatrixXf to be reshaped into multiple 2D matrices.
tSizeThe number of rows for each reshaped 2D matrix.
nFreqCorrsThe number of columns for each reshaped 2D matrix.
nInharmCoeffsThe number of 2D matrices to extract from the flat matrix.
Returns
std::vector<Eigen::MatrixXf> A vector containing the reshaped 2D matrices.
Note
The function assumes that the size of 'multiplied' is exactly equal to tSize * nFreqCorrs * nInharmCoeffs. If this is not the case, the behavior is undefined. For safety, consider adding a validity check to ensure that 'multiplied' contains enough elements.

◆ computeTotalErgTFI()

std::vector< Eigen::MatrixXf > krotos::HarmonicRepresentation::computeTotalErgTFI ( const std::vector< Eigen::MatrixXf > & submatrices_cell,
int tSize,
int nFreqCorrs,
int nInharmCoeffs )
private

◆ extractSubmatrices()

std::vector< Eigen::MatrixXf > krotos::HarmonicRepresentation::extractSubmatrices ( const Eigen::MatrixXf & distr,
const std::vector< Eigen::MatrixXi > & distrIdcsTFHI2_d )
private

◆ fevalbp()

Eigen::VectorXf krotos::HarmonicRepresentation::fevalbp ( const Eigen::MatrixXf & bp,
const Eigen::VectorXf & x_v )
private

Estimates pitches by linear interpolation.

Given a set of time-pitch pairs, this function estimates pitches at specified times by linearly interpolating between the nearest pitch-time pairs.

Parameters
bpMatrix of time-pitch pairs.
x_vVector containing times at which pitches are to be estimated.
Returns
Vector containing estimated pitches.

◆ findIndices()

Eigen::VectorXi krotos::HarmonicRepresentation::findIndices ( const Eigen::VectorXf & x_v,
float threshMin = -std::numeric_limits<float>::infinity(),
float threshMax = std::numeric_limits<float>::infinity() )
private

◆ maxRowValues()

std::pair< Eigen::VectorXf, Eigen::VectorXi > krotos::HarmonicRepresentation::maxRowValues ( const Eigen::MatrixXf & matrix)
private

◆ processSignal()

Eigen::MatrixXf krotos::HarmonicRepresentation::processSignal ( std::vector< float > & inputSignal)

Processes the input signal and returns the matrix of partial frequencies and partial amplitudes.

Parameters
inputSignalA vector containing the input audio signal. TODO:: Rewrite as Eigen::VectorXf https://krotosltd.atlassian.net/jira/software/c/projects/RD/boards/43?selectedIssue=RD-272
Returns
A matrix representing the partial frequencies and partial amplitudes.

◆ replaceNanWithMedian()

void krotos::HarmonicRepresentation::replaceNanWithMedian ( Eigen::VectorXf & inputVector)
private

Replaces NaN values in the input vector with the median value.

Parameters
inputVectorThe input vector

Member Data Documentation

◆ config

struct krotos::HarmonicRepresentation::ConfigParams krotos::HarmonicRepresentation::config
private

◆ harmRep

struct krotos::HarmonicRepresentation::HarmRepParams krotos::HarmonicRepresentation::harmRep
private

◆ m_maxSwipepWinSize

float krotos::HarmonicRepresentation::m_maxSwipepWinSize
private

◆ m_pitchStrengthPair

std::pair<Eigen::VectorXf, Eigen::VectorXf> krotos::HarmonicRepresentation::m_pitchStrengthPair
private

◆ m_sampleRate

const float krotos::HarmonicRepresentation::m_sampleRate
private

◆ m_times

Eigen::VectorXf krotos::HarmonicRepresentation::m_times
private

◆ swipe

struct krotos::HarmonicRepresentation::SwipeParams krotos::HarmonicRepresentation::swipe
private

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