Mercurial > hg > precise-onset-detection
diff ofxPreciseOnsetDetectorOffline/testApp.cpp @ 7:b1c13e8bec26
adding new files
author | Venetian |
---|---|
date | Thu, 14 Aug 2014 16:27:52 +0100 |
parents | eb29c6b6dff8 |
children |
line wrap: on
line diff
--- a/ofxPreciseOnsetDetectorOffline/testApp.cpp Sun Jan 19 23:07:13 2014 +0000 +++ b/ofxPreciseOnsetDetectorOffline/testApp.cpp Thu Aug 14 16:27:52 2014 +0100 @@ -2,95 +2,34 @@ //possible to just omit the drawing (uses ofxWindowRegion for the screen and ofxPlotFunction to plot beat times) +//w: export window +//x:export whole file +//o: open file + //-------------------------------------------------------------- void testApp::setup(){ - pov.window.setToRelativeSize(0.1, 0.1, 0.8, 0.3); - pov.pod = &preciseOnsetDetect;//set up pointer if we want to visualise the onsets in a window - -// preciseOnsetDetect.load("/Users/andrew/Documents/work/programming/MadMax/AudioFiles/AdamBetts/AdamBetss_1_Swing_Kick.wav"); -// preciseOnsetDetect.load("/Users/andrew/Music/Logic/GreenOnionsChichester/GreenOnionsChichester/Bouncing/Snare_Sontronics#08edit.aif"); - - std::string fileName = "/Users/andrew/Music/Logic/GreenOnionsEvaluation/GreenOnionsEvaluationPlain/Audio Files/SongClickTrack#09.aif"; -// fileName = "/Users/andrew/Music/Logic/GreenOnionsChichester/GreenOnionsChichester/Audio Files/Ride_SM58#08.aif"; - loadNewFile(fileName); + } -void testApp::loadNewFile(std::string filename){ - preciseOnsetDetect.load(filename); - preciseOnsetDetect.printOnsetLocations(); - - pov.newFile(); -} - //-------------------------------------------------------------- void testApp::update(){ - preciseOnsetDetect.update(); - pov.update(); + + onsetDetector.update(); } //-------------------------------------------------------------- void testApp::draw(){ - pov.draw(); + onsetDetector.draw(); } //-------------------------------------------------------------- void testApp::keyPressed(int key){ - std::string loadName; - switch (key) { - case 'r': - pov.resetWindow(); - break; - case 's': - pov.cropStart(); - break; - case 'e': - pov.cropEnd(); - break; - case 'w': - printf("Exporting between %f and %f\n", pov.windowStart, pov.windowEnd); - preciseOnsetDetect.exportOnsetTimes(pov.windowStart, pov.windowEnd); - break; - case 'x': - printf("Exporting between %f and %f\n", 0., pov.lengthSeconds()); - preciseOnsetDetect.exportOnsetTimes(0, pov.lengthSeconds()); - break; - - case 'o': - if (getFilenameFromDialogBox(&loadName)){ - printf("loading %s\n", (loadName).c_str()); - loadNewFile(loadName); - }; - - //delete testName; - break; - case ' ': - pov.togglePlay(); - break; - case OF_KEY_RETURN: - pov.soundPlay.stop(); - break; - - case OF_KEY_UP: - pov.zoomIn(); - break; - case OF_KEY_DOWN: - pov.zoomOut(); - break; - case OF_KEY_RIGHT: - pov.scrollRight(); - break; - case OF_KEY_LEFT: - pov.scrollLeft(); - break; - - default: - break; - } + onsetDetector.keyPressed(key); } //-------------------------------------------------------------- @@ -110,13 +49,8 @@ //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ -// if (window.tapped(x, y)){ -// windowPress = windowStart + (windowEnd-windowStart)*(x - window.x)/window.width; -// -// printf("window position is %f\n", windowPress); -// } - pov.mousePressed(x, y); + onsetDetector.mousePressed(x,y,button); } //-------------------------------------------------------------- @@ -141,40 +75,4 @@ -bool testApp::getFilenameFromDialogBox(std::string* fileNameToSave){ - //this uses a pointer structure within the loader and returns true if the dialogue box was used successfully - // first, create a string that will hold the URL - string URL; - - // // openFile(string& URL) returns 1 if a file was picked - // // returns 0 when something went wrong or the user pressed 'cancel' - // int response = ofxFileDialogOSX::openFile(URL); - // if(response){ - // // now you can use the URL - // *fileNameToSave = URL; - // //printf("\n filename is %s \n", soundFileName.c_str()); - // return true; - // } - // else { - // // soundFileName = "OPEN canceled. "; - // printf("\n open file cancelled \n"); - // return false; - // } - - // openFile(string& URL) returns 1 if a file was picked - // returns 0 when something went wrong or the user pressed 'cancel' - ofFileDialogResult fileResult = ofSystemLoadDialog("Choose audio file to load"); - - if(fileResult.bSuccess){ - // now you can use the URL - *fileNameToSave = fileResult.filePath; - //printf("\n filename is %s \n", soundFileName.c_str()); - return true; - } - else { - // soundFileName = "OPEN canceled. "; - printf("\n open file cancelled \n"); - return false; - } -}