andrew@0: andrew@0: #ifndef AUBIOONSETDETECTOR_H andrew@0: #define AUBIOONSETDETECTOR_H andrew@0: andrew@0: #include "aubio.h" andrew@0: andrew@0: class AubioOnsetDetector andrew@0: { andrew@0: public: andrew@0: AubioOnsetDetector(); andrew@0: ~AubioOnsetDetector(); andrew@0: void initialise(); andrew@0: void resetValues(); andrew@0: andrew@0: bool processframe(float frame[], int n); andrew@0: void onsetclass_energy(); andrew@0: void onsetclass_complex(); andrew@0: void onsetclass_specdiff(); andrew@0: void onsetclass_kl(); andrew@0: void onsetclass_mkl(); andrew@0: void onsetclass_hfc(); andrew@0: void onsetclass_phase(); andrew@0: andrew@0: bool checkForMedianOnset(float dfvalue); andrew@0: andrew@0: float getRawDetectionFrame(); andrew@0: float getPeakPickedDetectionFrame(); andrew@0: double framesToSeconds(float frames); andrew@0: // boolean getIsOnset(); andrew@0: andrew@0: andrew@0: aubio_onsetdetection_t *o; andrew@0: aubio_pvoc_t *pv; andrew@0: aubio_pickpeak_t *parms; andrew@0: andrew@0: andrew@0: fvec_t *vec; andrew@0: fvec_t *onset; andrew@0: cvec_t *fftgrain;//complex vector of buffersize, 1 andrew@0: andrew@0: bool aubioOnsetFound;//method used by Paul Brossier andrew@0: //see relevant papers - eg fast transients 2005 andrew@0: int buffersize, hopsize, pos; andrew@0: float threshold, threshold2; andrew@0: float rawDetectionValue, peakPickedDetectionValue; andrew@0: andrew@2: static const int numberOfDetectionValues = 16; andrew@2: float recentRawDetectionValues[numberOfDetectionValues]; andrew@2: int recentValueIndex; andrew@0: andrew@0: float medianDetectionValue, aubioLongTermAverage ; andrew@0: bool anrMedianProcessedOnsetFound;//simple median method by Andrew Robertson andrew@0: //requires a fast rise, slower fall andrew@0: long lastMedianOnsetFrame, currentFrame; andrew@0: float thresholdRelativeToMedian; andrew@0: long cutoffForRepeatOnsetsMillis; andrew@0: float medianSpeed; andrew@2: float lastDfValue; andrew@2: float bestSlopeValue; andrew@2: double getBestSlopeValue(float dfvalue); andrew@2: double bestSlopeMedian; andrew@2: bool anrBestSlopeOnset; andrew@2: long lastSlopeOnsetFrame; andrew@2: bool slopeFallenBelowMedian; andrew@2: bool checkForSlopeOnset(float bestValue); andrew@0: andrew@3: void updateDetectionTriggerThreshold(const float& val); andrew@3: andrew@3: float detectionTriggerThreshold, detectionTriggerRatio; andrew@3: andrew@0: }; andrew@0: andrew@0: #endif