andrew@0: #ifndef _TEST_APP andrew@0: #define _TEST_APP andrew@0: andrew@0: andrew@0: #include "ofMain.h" andrew@0: andrew@0: #include "OnsetDetectionFunction.h" andrew@0: #include "PeakProcessor.h" andrew@0: #include "PreciseOnsetLocator.h" andrew@0: andrew@0: class testApp : public ofBaseApp{ andrew@0: andrew@0: public: andrew@0: andrew@0: void setup(); andrew@0: void update(); andrew@0: void draw(); andrew@0: andrew@0: void keyPressed(int key); andrew@0: void keyReleased(int key); andrew@0: void mouseMoved(int x, int y ); andrew@0: void mouseDragged(int x, int y, int button); andrew@0: void mousePressed(int x, int y, int button); andrew@0: void mouseReleased(int x, int y, int button); andrew@0: void windowResized(int w, int h); andrew@0: void dragEvent(ofDragInfo dragInfo); andrew@0: void gotMessage(ofMessage msg); andrew@0: andrew@0: void audioIn(float * input, int bufferSize, int nChannels); andrew@0: andrew@0: vector left; andrew@0: vector right; andrew@0: vector volHistory; andrew@0: andrew@0: int bufferCounter; andrew@0: int drawCounter; andrew@0: andrew@0: float smoothedVol; andrew@0: float scaledVol; andrew@0: andrew@0: ofSoundStream soundStream; andrew@0: andrew@0: OnsetDetectionFunction odf; andrew@0: andrew@0: PeakProcessor peakProcess; andrew@0: andrew@0: PreciseOnsetLocator precisionLocator; andrew@0: andrew@0: bool holdOn; andrew@0: int bufferSize; andrew@0: int exactOnsetIndex; andrew@0: vector onsetSamples;//holds the audio samples when onset is found andrew@0: // vector recentBufferSamples; andrew@0: andrew@0: /* andrew@0: //peak processing requires andrew@0: static const int vectorSize = 512/6; andrew@0: vector recentDFsamples; andrew@0: vector recentDFonsetFound; andrew@0: vector recentDFslopeValues; andrew@0: andrew@0: int numberOfDetectionValuesToTest; andrew@0: bool peakProcessing(const double& newDFval); andrew@0: double getBestSlopeValue(const float& dfvalue); andrew@0: bool checkForSlopeOnset(const float& bestValue); andrew@0: int currentFrame, lastSlopeOnsetFrame, cutoffForRepeatOnsetsFrames; andrew@0: void updateDetectionTriggerThreshold(const float& val); andrew@0: float detectionTriggerThreshold, detectionTriggerRatio; andrew@0: float bestSlopeMedian, thresholdRelativeToMedian; andrew@0: bool newOnsetFound, slopeFallenBelowMedian; andrew@0: */ andrew@0: /* andrew@0: andrew@0: andrew@0: andrew@0: double getLastEnergySum(const int& startIndex, const int& vectorSize); andrew@0: int findExactOnset(); andrew@0: andrew@0: */ andrew@0: }; andrew@0: andrew@0: andrew@0: #endif andrew@0: