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

Performs Onset Detection with vibrato suppresion. More...

#include <SuperFluxOnsetDetection.h>

Public Member Functions

 SuperFluxOnsetDetection (std::vector< std::vector< float > > &logSpectrum, float sampleRate, int hopSize)
 
void setParametersMS (float preMax, float postMax, float preAvg, float postAvg, float combWidth)
 
void setDeltaPercentage (float deltaPrcnt)
 
std::vector< float > trajectoryTracking (std::vector< std::vector< float > > logSpectrum)
 
std::vector< float > calculateDetectionFunction (const std::vector< std::vector< float > > &logSpectrum, const std::vector< float > &maxLogSpectum)
 
std::vector< int > peakPicking (std::vector< float > detectionFunction)
 
std::vector< int > findOnsetsInSamples ()
 

Private Member Functions

float halfWaveRect (float x)
 
std::vector< float > movingMax (std::vector< float > detectionFunction)
 
std::vector< float > movingMean (std::vector< float > detectionFunction)
 

Private Attributes

std::vector< std::vector< float > > m_inputLogSpectrum
 
float m_deltaPrcnt {0.0f}
 
int m_preMaxFrames {0}
 
int m_postMaxFrames {0}
 
int m_preAvgFrames {0}
 
int m_postAvgFrames {0}
 
int m_combWidthFrames {0}
 
const int mi = 2
 
int m_numBands {0}
 
int m_numFrames {0}
 
float m_sampleRate {0.0f}
 
int m_hopSize {0}
 

Detailed Description

Performs Onset Detection with vibrato suppresion.

This class implements the SuperFlux onset detection algorithm, which is an enhanced version of the universal spectral flux onset detection. It only considers the magnitude spectrogram, relying on detection of positive changes in the energy over time, but instead of calculating the difference between adjacent frames, it uses a trajectory tracking phase, incorporating a maximum filter for tracking. To facilitate trajectory tracking, the linear magnitude spectrogram has to be filtered with a filterBank with M=138 triangular filters with center frequencies alligned on the western music scale(Call MusicScaleFilterBak.h before). TODO: Online version (super simple), ComplexFlux (incorporates phase info as well.)

Constructor & Destructor Documentation

◆ SuperFluxOnsetDetection()

krotos::SuperFluxOnsetDetection::SuperFluxOnsetDetection ( std::vector< std::vector< float > > & logSpectrum,
float sampleRate,
int hopSize )

Constructor

Parameters
logSpectrumthe filtered Spectrogram of the audiosignal in the form of [frames, bands]
sampleRatethe sampleRate of the audio signal ih Hz
hopSizethe hopSize of the STFT that initially was used on the signal to produce the spectrogram

Member Function Documentation

◆ calculateDetectionFunction()

std::vector< float > krotos::SuperFluxOnsetDetection::calculateDetectionFunction ( const std::vector< std::vector< float > > & logSpectrum,
const std::vector< float > & maxLogSpectum )

Caclulates the Detection function vector using the trajectory tracking parameter mi.

Parameters
logSpectrumthe filtered Spectrogram of the audiosignal in the form of [frames, bands]
maxLogSpectrumthe maximum filtered Spectrogram
Returns
the Detection function vector

◆ findOnsetsInSamples()

std::vector< int > krotos::SuperFluxOnsetDetection::findOnsetsInSamples ( )

◆ halfWaveRect()

float krotos::SuperFluxOnsetDetection::halfWaveRect ( float x)
inlineprivate

HalfWave Rectifier function.

◆ movingMax()

std::vector< float > krotos::SuperFluxOnsetDetection::movingMax ( std::vector< float > detectionFunction)
private

Moving maximum.

◆ movingMean()

std::vector< float > krotos::SuperFluxOnsetDetection::movingMean ( std::vector< float > detectionFunction)
private

Moving average.

◆ peakPicking()

std::vector< int > krotos::SuperFluxOnsetDetection::peakPicking ( std::vector< float > detectionFunction)

Peak picking stage.

Parameters
detectionFunctionthe Detection function vector
Returns
onsetPositions in samples

◆ setDeltaPercentage()

void krotos::SuperFluxOnsetDetection::setDeltaPercentage ( float deltaPrcnt)

Set delta threshold parameter percentage.

◆ setParametersMS()

void krotos::SuperFluxOnsetDetection::setParametersMS ( float preMax,
float postMax,
float preAvg,
float postAvg,
float combWidth )

Sets the peak picking parameters

Parameters
preMaxnumber of frames the moving max filter looks back in time
postMaxnumber of frames the moving max filter looks forward in time [set to 0 for online version]
preAvgnumber of frames the moving avg filter looks forward in time
postAvgnumber of frames the moving avg filter looks forward in time [set to 0 for online version]
combWidthnumber of frames between two valid onsets

◆ trajectoryTracking()

std::vector< float > krotos::SuperFluxOnsetDetection::trajectoryTracking ( std::vector< std::vector< float > > logSpectrum)

Applies maximum filter on each frequency bin of the filtered spectrogram and its near neighbors, limited to each frame.

Parameters
logSpectrumthe filtered Spectrogram of the audiosignal in the form of [frames, bands] returns the maximum filtered Spectrogram

Member Data Documentation

◆ m_combWidthFrames

int krotos::SuperFluxOnsetDetection::m_combWidthFrames {0}
private

◆ m_deltaPrcnt

float krotos::SuperFluxOnsetDetection::m_deltaPrcnt {0.0f}
private

Peak picking parameters

◆ m_hopSize

int krotos::SuperFluxOnsetDetection::m_hopSize {0}
private

◆ m_inputLogSpectrum

std::vector<std::vector<float> > krotos::SuperFluxOnsetDetection::m_inputLogSpectrum
private

◆ m_numBands

int krotos::SuperFluxOnsetDetection::m_numBands {0}
private

◆ m_numFrames

int krotos::SuperFluxOnsetDetection::m_numFrames {0}
private

◆ m_postAvgFrames

int krotos::SuperFluxOnsetDetection::m_postAvgFrames {0}
private

◆ m_postMaxFrames

int krotos::SuperFluxOnsetDetection::m_postMaxFrames {0}
private

◆ m_preAvgFrames

int krotos::SuperFluxOnsetDetection::m_preAvgFrames {0}
private

◆ m_preMaxFrames

int krotos::SuperFluxOnsetDetection::m_preMaxFrames {0}
private

◆ m_sampleRate

float krotos::SuperFluxOnsetDetection::m_sampleRate {0.0f}
private

◆ mi

const int krotos::SuperFluxOnsetDetection::mi = 2
private

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