diff options
| author | Tim Redfern <tim@getdrop.com> | 2018-05-22 22:21:52 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2018-05-22 22:21:52 +0100 |
| commit | cd298b5bf00661ce31ae1d4498de58d5291477f2 (patch) | |
| tree | f667bb56703380eec230fbf9acf0cd4988f90ffc /gistanalysis/src/ofApp.h | |
| parent | 583804a9b5c412849c9dc5e9947dd537aee3bb8b (diff) | |
&%0%& content?
Diffstat (limited to 'gistanalysis/src/ofApp.h')
| -rw-r--r-- | gistanalysis/src/ofApp.h | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/gistanalysis/src/ofApp.h b/gistanalysis/src/ofApp.h index e3ad339..44c4aa6 100644 --- a/gistanalysis/src/ofApp.h +++ b/gistanalysis/src/ofApp.h @@ -9,7 +9,8 @@ //This player includes a version of kissFFT. You can remove the one included in Gist. //https://github.com/borg/ofxOpenALSoundPlayer #include "ofxOpenALSoundPlayer.h" - +#include "ofxMidi.h" +#include "ofxGui.h" //Slightly modified to add a dynamic getVariable method to be able to plot based on //gist feature list @@ -26,6 +27,7 @@ public: Audioplotter(int _size=1,bool _joined=true){ set_size(_size); set_joined(_joined); + colour=ofColor(255,255,255); } void set_size(int _size){ history_size=_size; @@ -36,9 +38,11 @@ public: const vector <colourPolyline> &output(const ofMatrix4x4 xform=ofMatrix4x4(1.0f,0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f,0.0f, 0.0f,0.0f,1.0f,0.0f, - 0.0f,0.0f,0.0f,1.0f)){ + 0.0f,0.0f,0.0f,1.0f), + float scale=1.0f, + float decay=-1.0f){ //destructive or non? - float fadefactor=1.0f-(1.0f/history_size); + float fadefactor=decay<0.0f?1.0f-(1.0f/history_size):decay; for (int i=0;i<data.size();i++){ data[i]=lineTransformer::polyLineTransform(xform,data[i],fadefactor); @@ -49,10 +53,12 @@ public: void addpoints(vector <float> &audio,int number){ colourPolyline newdata; int num=min(number,(int)audio.size()); - int step=audio.size()/num; - int start=audio.size()/(num+1); + int step=audio.size()/(num+1); for (int i=0;i<num;i++){ - newdata.addVertex((start+(i*step)*ofGetWidth())/audio.size(),audio[start+(i*step)]*ofGetHeight()); + newdata.addVertex(((step*(i+1))*ofGetWidth())/audio.size(),audio[step*(i+1)]*ofGetHeight(),colour); + if (!joined){ + newdata.addVertex((((step*(i+1))*ofGetWidth())/audio.size())+1,(audio[step*(i+1)])*ofGetHeight(),0,0,0); + } } data.insert(data.begin(),newdata); while (data.size()>history_size) { @@ -60,19 +66,28 @@ public: } } + int numpoints(){ + int num=0; + for (auto d=data.begin();d!=data.end();d++){ + num+=d->size(); + } + return num; + } private: vector <colourPolyline> data; bool joined; int history_size; + ofColor colour; }; -class ofApp : public ofBaseApp{ +class ofApp : public ofBaseApp, public ofxMidiListener{ public: void setup(); void update(); void draw(); + void exit(); void keyPressed(int key); void keyReleased(int key); @@ -83,6 +98,17 @@ class ofApp : public ofBaseApp{ void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); + + void newMidiMessage(ofxMidiMessage& eventArgs); + + void updateOutput(ofEventArgs & args); + void drawOutput(ofEventArgs & args); + void outputKeyPressed(ofKeyEventArgs & args); + void outputKeyReleased(ofKeyEventArgs & args); + void outputMouseDragged(ofMouseEventArgs & args); + void outputMousePressed(ofMouseEventArgs & args); + void outputMouseReleased(ofMouseEventArgs & args); + void outputWindowResized(ofResizeEventArgs &resizeargs); ofSoundStream soundStream; ofxOpenALSoundPlayer player; @@ -128,5 +154,12 @@ class ofApp : public ofBaseApp{ ofxHelios laser; Audioplotter plotter; + + + ofxPanel gui; + ofParameter<int> numPlots; + ofParameter<float> scalePlot; + ofParameter<float> decayPlot; + ofParameter<ofVec2f> xform; }; |
