view Source/AubioOnsetDetector.h @ 2:b4c899822b4e

added in slope bang using median
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Wed, 19 Oct 2011 21:08:45 +0100
parents 8f67db3c0b01
children 979125db34ab
line wrap: on
line source

#ifndef AUBIOONSETDETECTOR_H
#define AUBIOONSETDETECTOR_H

#include "aubio.h"

class AubioOnsetDetector
{
public:		
	AubioOnsetDetector();
	~AubioOnsetDetector();
	void initialise();
	void resetValues();
	
	bool processframe(float frame[], int n);
	void onsetclass_energy();	
	void onsetclass_complex();
	void onsetclass_specdiff();
	void onsetclass_kl();
	void onsetclass_mkl();
	void onsetclass_hfc();
	void onsetclass_phase();
		
	bool checkForMedianOnset(float dfvalue);
	
	float getRawDetectionFrame();
	float getPeakPickedDetectionFrame();
	double framesToSeconds(float frames);
//	boolean getIsOnset();
	
	
	aubio_onsetdetection_t		*o;
	aubio_pvoc_t				*pv;
	aubio_pickpeak_t			*parms;
	
		
	fvec_t						*vec;
	fvec_t						*onset;
	cvec_t						*fftgrain;//complex vector of buffersize, 1
	
	bool aubioOnsetFound;//method used by Paul Brossier
	//see relevant papers - eg fast transients 2005
	int buffersize, hopsize, pos;
	float threshold,  threshold2;
	float rawDetectionValue, peakPickedDetectionValue;

	static const int numberOfDetectionValues = 16;
	float recentRawDetectionValues[numberOfDetectionValues];
	int recentValueIndex;
	
	float medianDetectionValue, aubioLongTermAverage ;
	bool anrMedianProcessedOnsetFound;//simple median method by Andrew Robertson
	//requires a fast rise, slower fall
	long lastMedianOnsetFrame, currentFrame;
	float thresholdRelativeToMedian;
	long cutoffForRepeatOnsetsMillis;
	float medianSpeed;
	float lastDfValue;
	float bestSlopeValue;
	double getBestSlopeValue(float dfvalue);
	double bestSlopeMedian;
	bool anrBestSlopeOnset;
	long lastSlopeOnsetFrame;
	bool slopeFallenBelowMedian;
	bool checkForSlopeOnset(float bestValue);
	
};

#endif