diff options
Diffstat (limited to 'gui/src/ofApp.cpp')
| -rw-r--r-- | gui/src/ofApp.cpp | 93 |
1 files changed, 63 insertions, 30 deletions
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index 44939cc..367fdd2 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -65,6 +65,13 @@ void ofApp::setup(){ lasergui.add(laser_blank_num.set("blank points", 8, 0, 32)); lasergui.add(laser_max_angle.set("max angle", 15.0f, 1.0f, 90.0f)); + responsegui.setup("audio response","",230,970); + responsegui.add(onset_threshold.set("onset threshold", 0.05f, 0.0f, 1.0f )); + responsegui.add(use_onset.set("trigger onset",false)); + responsegui.add(onset_duration.set("duration", 10, 1, 100)); + + onset_frame=0; + chaosgui.setup("chaos","",460,820); chaosgui.add(plotter.usechaos.set("use",false)); chaosgui.add(plotter.chaosamount.set("amount", 0.0f, -0.1f, 0.1f)); @@ -76,7 +83,7 @@ void ofApp::setup(){ drawgui.setup("drawing","",10,0); drawgui.add(contour_threshold.setup("threshold", 140, 0, 255)); - drawgui.add(contour_simplify.setup("simplify", 0.8, 0.0, 1.0)); + drawgui.add(contour_simplify.setup("simplify", 0.8, 0.0, 10.0)); drawgui.add(contour_useColour.setup("use colour", true)); drawgui.add(laser_R.setup("red", 140, 0, 255)); drawgui.add(laser_G.setup("green", 140, 0, 255)); @@ -186,13 +193,16 @@ void ofApp::loadSong(string str){ } void ofApp::onNoteOn(GistEvent &e){ - + //ofLog() << "<<NOTE ON>>"; + onset_frame=0; + onset_number++; //noteOnRadius = 100; }; void ofApp::onNoteOff(GistEvent &e){ - + //ofLog() << "<<NOTE OFF>>"; + //turn off? //noteOnRadius = 0; }; @@ -352,7 +362,12 @@ void ofApp::updateOutput(ofEventArgs & args){ plotter.addpoints(fftSmoothed); } else { - plotter.addpoints(centre); + if (!use_onset||onset_frame<onset_duration){ + plotter.addpoints(centre); + } + else { + plotter.blankframe(); + } } } } @@ -456,6 +471,9 @@ void ofApp::update(){ movie.update(); } + gist.setThreshold(GIST_PEAK_ENERGY,onset_threshold); + + onset_frame++; } const ofPoint previewframesize=ofPoint(320,240); @@ -503,6 +521,7 @@ void ofApp::draw(){ drawgui.draw(); audiogui.draw(); chaosgui.draw(); + responsegui.draw(); //================================== NDI /* @@ -620,6 +639,10 @@ void ofApp::draw(){ } + ofSetColor(255); + + ofDrawBitmapString(ofToString(onset_number)+":"+(onset_frame==0?"BEAT":ofToString(onset_frame)),10,ofGetHeight()-15); + } void ofApp::drawOutput(ofEventArgs & args){ @@ -706,25 +729,27 @@ void ofApp::drawOutput(ofEventArgs & args){ } */ case Player:{ - if (movie.isLoaded()){ - ofPoint scale=ofPoint(outputWindowSize.x/movie.getWidth(),outputWindowSize.y/movie.getHeight()); - colorImg.setFromPixels(movie.getPixels()); - if (grayImage.getWidth()!=colorImg.getWidth()||grayImage.getHeight()!=colorImg.getHeight()){ - grayImage.clear(); - } - grayImage=colorImg; - grayImage.threshold(contour_threshold); - contourFinder.findContours(grayImage, 20, (340*240)/3, 10, true); - for (int i = 0; i < contourFinder.nBlobs; i++){ - colourPolyline shape; - for (auto& point:contourFinder.blobs[i].pts){ - ofVec3f p=point*scale; - ofColor c=colorImg.getPixels().getColor(point.x,point.y); - shape.addVertex(p,contour_useColour?c:ofColor(laser_R,laser_G,laser_B)); + if (!use_onset||onset_frame<onset_duration){ + if (movie.isLoaded()){ + ofPoint scale=ofPoint(outputWindowSize.x/movie.getWidth(),outputWindowSize.y/movie.getHeight()); + colorImg.setFromPixels(movie.getPixels()); + if (grayImage.getWidth()!=colorImg.getWidth()||grayImage.getHeight()!=colorImg.getHeight()){ + grayImage.clear(); } - shape.simplify(contour_simplify); - polyOutput.push_back(shape); - } + grayImage=colorImg; + grayImage.threshold(contour_threshold); + contourFinder.findContours(grayImage, 20, (340*240)/3, 10, true); + for (int i = 0; i < contourFinder.nBlobs; i++){ + colourPolyline shape; + for (auto& point:contourFinder.blobs[i].pts){ + ofVec3f p=point*scale; + ofColor c=colorImg.getPixels().getColor(point.x,point.y); + shape.addVertex(p,contour_useColour?c:ofColor(laser_R,laser_G,laser_B)); + } + shape.simplify(contour_simplify); + polyOutput.push_back(shape); + } + } } break; } @@ -853,15 +878,22 @@ void ofApp::drawOutput(ofEventArgs & args){ int num = 0; int pnum=0; - if (polyOutput.size()){ - if (laser_power) { - num=laser.draw(scaledWarpedOutput); - } - for (auto& shape:warpedOutput){ - shape.draw(); - pnum+=shape.size(); + + if (laser_power&&polyOutput.size()) { + num=laser.draw(scaledWarpedOutput); + } + else { + colourPolyline blank; + for (int i=0;i<100;i++){ + blank.addVertex(ofGetWidth()/2,ofGetHeight()/2,0,0,0); } + laser.draw(blank); } + for (auto& shape:warpedOutput){ + shape.draw(); + pnum+=shape.size(); + } + if (bDrawFrame){ lineTransformer::drawWarpFrame(warpframe); @@ -1058,7 +1090,8 @@ void ofApp::dragEvent(ofDragInfo dragInfo){ if (movie.load(filename)){ cout << "loaded "<< filename<<std::endl; movie.setLoopState(OF_LOOP_NORMAL); - movie.play(); + movie.setVolume(0.0f); + movie.play(); } else { cout << "failed to load"<<std::endl; |
