From ba7cc94d4ae55e171f0e08126abb0cb13d8f9f8f Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 31 Aug 2012 09:21:00 +0100 Subject: blocking loading playlists --- liveengine/src/layers.cpp | 34 ++++++++++-- liveengine/src/layers.h | 20 +++++-- liveengine/src/main.cpp | 2 +- liveengine/src/testApp.cpp | 130 +++++++++++++++++++++++++++++++++------------ liveengine/src/testApp.h | 32 +++++++++-- 5 files changed, 173 insertions(+), 45 deletions(-) (limited to 'liveengine/src') diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp index dbf6ccd..f140073 100644 --- a/liveengine/src/layers.cpp +++ b/liveengine/src/layers.cpp @@ -9,7 +9,7 @@ layer::layer(string _f) void layer::load(string _f){ } -void layer::draw() { +void layer::draw(float a) { } @@ -28,16 +28,42 @@ svglayer::svglayer(string _f) void svglayer::load(string _f){ svg.load(_f); printf("%i paths\n",svg.getNumPath()); - for (int i=0;i fills; + vector strokes; }; +class imglayer: public layer +{ + public: + imglayer(); + imglayer(string _f); + virtual ~imglayer(); + void load(string _f); + void draw(float a); + protected: + private: + ofImage img; +}; #endif // SVGLAYER_H diff --git a/liveengine/src/main.cpp b/liveengine/src/main.cpp index 41470a2..5c556af 100644 --- a/liveengine/src/main.cpp +++ b/liveengine/src/main.cpp @@ -6,7 +6,7 @@ int main( ){ ofAppGlutWindow window; - ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context + ofSetupOpenGL(&window, 800,600, OF_WINDOW); // <-------- setup the GL context //ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // this kicks off the running of my app diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp index 9a84eda..ee89f6a 100755 --- a/liveengine/src/testApp.cpp +++ b/liveengine/src/testApp.cpp @@ -1,11 +1,39 @@ #include "testApp.h" - +void testApp::loadplaylist(string _name){ + int numLayers=0; + layers.clear(); + if( !XML.loadFile(_name) ){ + printf("unable to load %s check data/ folder\n",_name.c_str()); + }else{ + if(XML.pushTag("playlist")) { + numLayers=XML.getNumTags("svglayer"); + if(numLayers) { + for (int i=0;i>7,(controller_colours[i].g*controllers[i])>>7,(controller_colours[i].b*controllers[i])>>7)); - ofRect(note*notewidth,i*noteheight,notewidth,noteheight); + float lamda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); + + if (note>0) { + switch(mode) { + case BLOCKS: + for (int i=0;i>7,(controller_colours[i].g*controllers[i])>>7,(controller_colours[i].b*controllers[i])>>7)); + ofRect((note-START_NOTE)*notewidth,i*noteheight,notewidth,noteheight); + } + break; + case LIST: + ofPushMatrix(); + //ofScale(sin(ofGetElapsedTimef())+1.1,sin(ofGetElapsedTimef())+1.1); + if (layers.find(note)!=layers.end()) layers[note]->draw(lamda); + ofPopMatrix(); + break; + } } - ofSetColor((sin(ofGetElapsedTimef())+1)*128,255,255); - ofPushMatrix(); - //ofScale(sin(ofGetElapsedTimef())+1.1,sin(ofGetElapsedTimef())+1.1); - if (layers.find(note)!=layers.end()) layers[note]->draw(); - ofPopMatrix(); //for (int i=0;idraw(); ofSetColor(255,255,255); @@ -92,13 +125,41 @@ void testApp::draw(){ //-------------------------------------------------------------- void testApp::keyPressed (int key){ + if(key == 'q'){ + loadplaylist("insects.xml"); + } + if(key == 'w'){ + loadplaylist("barcelona.xml"); + } + if(key == 'e'){ + loadplaylist("organs.xml"); + } + if(key == 'r'){ + loadplaylist("tai_chi.xml"); + } if(key == 's'){ XML.saveFile("settings.xml"); printf("settings saved!\n"); } if(key == 'f'){ toggleFPS(); - } + } + if(key >='0' && key <= '9'){ + mode=key-'0'; + } + if(key == OF_KEY_LEFT){ + xshift--; + } + if(key == OF_KEY_RIGHT){ + xshift++; + } + if(key == OF_KEY_DOWN){ + yshift--; + } + if(key == OF_KEY_UP){ + yshift++; + } + } //-------------------------------------------------------------- @@ -170,7 +231,8 @@ void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){ // if (layers[i]->note==eventArgs.byteOne) layers[i]->setActive(noteOn); //} printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo); - note=eventArgs.byteOne-START_NOTE; + note=eventArgs.byteOne; + lastnoteTime=ofGetElapsedTimef(); break; case 176: //control change channel 0 //for (int i=0;i layers; + }; -- cgit v1.2.3