diff options
| author | Comment <tim@gray.(none)> | 2013-05-29 20:16:58 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-05-29 20:16:58 +0100 |
| commit | 3919daab84baefb846c4efc27eff9b40b9cc03db (patch) | |
| tree | 95318aaa386903969dfb734058fc35d1f927cb8f | |
| parent | a720f370fdb8a79a70a218c1d7bcb9069f50ff9d (diff) | |
looking pretty sweet
| -rwxr-xr-x | src/testApp.cpp | 58 | ||||
| -rwxr-xr-x | src/testApp.h | 4 | ||||
| -rwxr-xr-x | src/viewport.cpp | 8 | ||||
| -rwxr-xr-x | src/viewport.h | 5 |
4 files changed, 72 insertions, 3 deletions
diff --git a/src/testApp.cpp b/src/testApp.cpp index e66f892..b58971d 100755 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -11,6 +11,34 @@ void previewWindow::draw(){ for (auto i:parent->viewports) i.draw(parent->brightSlider,previewscale); } +void previewWindow::mouseDragged(int x, int y, int button){ + //cerr<<"dragged "<<x<<","<<y<<endl; + if (button==0&&parent->viewports.size()) { + //get relative coords to window + + + parent->control.bx=((float)((x/previewscale)%parent->viewports[0].w))/parent->viewports[0].w; + parent->control.by=((float)((y/previewscale)%parent->viewports[0].h))/parent->viewports[0].h; + parent->control.drawseconds=ofGetElapsedTimef()-drawStartTime; + } +} +void previewWindow::mousePressed(int x, int y, int button){ + + if (button==0&&parent->viewports.size()) { + drawStartTime=ofGetElapsedTimef(); + //get relative coords to window + parent->control.bx=((float)((x/previewscale)%parent->viewports[0].w))/parent->viewports[0].w; + parent->control.by=((float)((y/previewscale)%parent->viewports[0].h))/parent->viewports[0].h; + parent->control.drawseconds=0.01f; + } + //cerr<<"pressed button "<<button<<" "<<bx<<","<<by<<endl; +} +void previewWindow::mouseReleased(int x, int y, int button){ + //cerr<<"released "<<x<<","<<y<<endl; + if (button==0) { + parent->control.drawseconds=-1.0f; + } +} void previewWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ if (parent->viewports.size()){ int sta=dragInfo.files[0].find_last_of("\\/")+1; @@ -294,17 +322,41 @@ void testApp::update(){ control.waveheight=slidWave; control.fade=(uint8_t)fadeSlider; - if (vamphost.feat.size()) cerr<<"found "<<vamphost.feat.size()<<" feature(s)\n"; + //if (vamphost.feat.size()) cerr<<"found "<<vamphost.feat.size()<<" feature(s)\n"; + + if (vamphost.feat.size()) { + control.feats.clear(); + for (int i=0;i<vamphost.feat.size();i++){ + if (vamphost.feat[i].size()){ + if (vamphost.feat[i][0].values.size()){ + control.feats.push_back((float)vamphost.feat[i][0].values[0]); + } + } + } + } } //-------------------------------------------------------------- void testApp::draw(){ - + /* +[F] [v2] Key Detector, "qm-keydetector" [Queen Mary, University of London] + > Key and Tonality + - Estimate the key of the music + (0) Tonic Pitch, "tonic" + - Tonic of the estimated key (from C = 1 to B = 12) + (1) Key Mode, "mode" + - Major or minor mode of the estimated key (major = 0, minor = 1) + (2) Key, "key" + - Estimated key (from C major = 1 to B major = 12 and C minor = 13 to B minor = 24) + (3) Key Strength Plot, "keystrength" + - Correlation of the chroma vector with stored key profile for each major and minor key +*/ for (auto i:viewports) i.drawport(control); ofPushMatrix(); - ofTranslate((ofGetWidth()/2)-(2*windowsize),(ofGetHeight()/2)-windowsize); + //ofTranslate((ofGetWidth()/2)-(2*windowsize),(ofGetHeight()/2)-windowsize); + ofTranslate(1,1); for (auto i:viewports) i.draw((uint8_t)brightSlider); ofPopMatrix(); diff --git a/src/testApp.h b/src/testApp.h index 90bc4fc..bd34832 100755 --- a/src/testApp.h +++ b/src/testApp.h @@ -114,6 +114,10 @@ public: void setParent(testApp *p); void draw(); void dragEvent(ofDragInfo dragInfo,ofxFenster* win); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + float drawStartTime; }; class guiWindow: public ofxFensterListener{ diff --git a/src/viewport.cpp b/src/viewport.cpp index 369d176..35f2641 100755 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -64,6 +64,10 @@ void viewport::drawport(vpcontrol &control){ ofRect(0,0,bw,bh);
}
+ //for (int i=0;i<control.feats.size();i++){
+ // ofCircle(bw*0.2*i,bh*0.5,control.feats[i]*w);
+ //}
+
ofSetLineWidth(control.thickness);
if (!control.fillwave) {
@@ -89,6 +93,10 @@ void viewport::drawport(vpcontrol &control){ ofFill();
+ if (control.drawseconds>-1){
+ ofCircle(control.bx*bw,control.by*bh,(control.drawseconds*bh*.02)+(bh*.01));
+ }
+
rb1.end();
rb2.begin();
diff --git a/src/viewport.h b/src/viewport.h index b7b8910..072ec7a 100755 --- a/src/viewport.h +++ b/src/viewport.h @@ -79,6 +79,7 @@ class vpcontrol { thickness=1.0f;
waveheight=1.0f;
fade=0;
+ drawseconds=-1.0f;
left.assign(bufferSize, 0.0);
right.assign(bufferSize, 0.0);
@@ -114,11 +115,15 @@ class vpcontrol { vector <float> right;
vector <float> volHistory;
+ vector <float> feats;
+
int bufferCounter;
int drawCounter;
float smoothedVol;
float scaledVol;
+
+ float bx,by,drawseconds;
};
class viewport
|
