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

A class calculating onset positions of signal based on a slope vector describing it's envelope. More...

#include <SlopEnvelopeOnsetdetection.h>

Public Member Functions

 OnsetDetector (float sampleRate)
 
std::vector< int > calculateOnsetsGlobal (std::vector< float > slopeVector, std::vector< float > normalisedEnvelopeVector)
 
void setThresholdPercentage (float thresholdPercentage)
 
void setOnsetMiliSeconds (float onsetMiliSeconds)
 
void setDecayLengthMiliSeconds (float decayLengthMiliSeconds)
 

Private Member Functions

std::pair< int, int > detectAttackSegment (const std::vector< float > &slopeFrame, const std::vector< float > &normalisedEnvelopeFrame, float thresholdValue)
 

Private Attributes

float m_threshold {0.0f}
 
int m_onset {}
 
int m_decayLength {}
 
float m_epsilon = 1e-6f
 
float m_sampleRate
 
bool m_finishFlag {false}
 

Detailed Description

A class calculating onset positions of signal based on a slope vector describing it's envelope.

This class handles the segmentation process using an iterative scheme. Each time a new onset-attackPosition is found the segment is extracted and the detection process is repeated until the next is found. Segmentation results are heavily influenced by the values of the segmentation parameters. Play around to fine tune to your signal.

Constructor & Destructor Documentation

◆ OnsetDetector()

krotos::OnsetDetector::OnsetDetector ( float sampleRate)

Member Function Documentation

◆ calculateOnsetsGlobal()

std::vector< int > krotos::OnsetDetector::calculateOnsetsGlobal ( std::vector< float > slopeVector,
std::vector< float > normalisedEnvelopeVector )

Contains the overall structure of the iterative routine. Terminates either if no more attacks-onsets are present in the signal or the whole signal has been consumed. Performs a search based on the slope Vector and assigns the normalised Envelope Vector to detectAttackSegment which is called iteratively.

Parameters
slopeVectorthe slope of the envelope Vector
normalisedEnvelopeVectorthe normalised envelope follower Vector

◆ detectAttackSegment()

std::pair< int, int > krotos::OnsetDetector::detectAttackSegment ( const std::vector< float > & slopeFrame,
const std::vector< float > & normalisedEnvelopeFrame,
float thresholdValue )
private

Detects the first attack segment in a region of the signal and returns a pair of attackPosition and finishPositions to move the iteration forward.

◆ setDecayLengthMiliSeconds()

void krotos::OnsetDetector::setDecayLengthMiliSeconds ( float decayLengthMiliSeconds)

◆ setOnsetMiliSeconds()

void krotos::OnsetDetector::setOnsetMiliSeconds ( float onsetMiliSeconds)

◆ setThresholdPercentage()

void krotos::OnsetDetector::setThresholdPercentage ( float thresholdPercentage)

Setters for the 3 main segmentation Parameters.

Member Data Documentation

◆ m_decayLength

int krotos::OnsetDetector::m_decayLength {}
private

◆ m_epsilon

float krotos::OnsetDetector::m_epsilon = 1e-6f
private

◆ m_finishFlag

bool krotos::OnsetDetector::m_finishFlag {false}
private

◆ m_onset

int krotos::OnsetDetector::m_onset {}
private

◆ m_sampleRate

float krotos::OnsetDetector::m_sampleRate
private

◆ m_threshold

float krotos::OnsetDetector::m_threshold {0.0f}
private

Segmentation Parameters.


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