summaryrefslogtreecommitdiff
path: root/liveengine/src/testApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-08-31 16:48:23 +0100
committerTim Redfern <tim@eclectronics.org>2012-08-31 16:48:23 +0100
commit34a459de430dd35034ec9404fe7ec54407641085 (patch)
treefcb318cebe27673ae63799f1b2bc33b328d98965 /liveengine/src/testApp.cpp
parentba7cc94d4ae55e171f0e08126abb0cb13d8f9f8f (diff)
threaded loader
Diffstat (limited to 'liveengine/src/testApp.cpp')
-rwxr-xr-xliveengine/src/testApp.cpp51
1 files changed, 12 insertions, 39 deletions
diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp
index ee89f6a..0d8ec28 100755
--- a/liveengine/src/testApp.cpp
+++ b/liveengine/src/testApp.cpp
@@ -1,35 +1,5 @@
#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<numLayers;i++) {
- string s=XML.getAttribute("svglayer", "file", "",i);
- printf("loading %s: ",s.c_str());
- layers[XML.getAttribute("svglayer", "note", 0,i)]=new svglayer(XML.getAttribute("svglayer", "file", "",i));
- }
- }
- else printf("no SVG layers loaded!\n");
- numLayers=XML.getNumTags("imglayer");
- if(numLayers) {
- for (int i=0;i<numLayers;i++) {
- string s=XML.getAttribute("imglayer", "file", "",i);
- printf("%s: ",s.c_str());
- //int i=XML.getAttribute("imglayer", "note", 0,i);
- //ofImage i =
- layers[XML.getAttribute("imglayer", "note", 0,i)]=new imglayer(XML.getAttribute("imglayer", "file", "",i));
- }
- }
- else printf("no IMG layers loaded!\n");
- }
- }
-}
//--------------------------------------------------------------
void testApp::setup(){
int midiPort=0;
@@ -108,11 +78,14 @@ void testApp::draw(){
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();
+ case LIST:
+ if (list.lock()) { //if playlist is loaded
+ ofPushMatrix();
+ //ofScale(sin(ofGetElapsedTimef())+1.1,sin(ofGetElapsedTimef())+1.1);
+ if (list.layers.find(note)!=list.layers.end()) list.layers[note]->draw(lamda);
+ ofPopMatrix();
+ list.unlock();
+ }
break;
}
}
@@ -126,16 +99,16 @@ void testApp::draw(){
//--------------------------------------------------------------
void testApp::keyPressed (int key){
if(key == 'q'){
- loadplaylist("insects.xml");
+ list.load("insects.xml");
}
if(key == 'w'){
- loadplaylist("barcelona.xml");
+ list.load("barcelona.xml");
}
if(key == 'e'){
- loadplaylist("organs.xml");
+ list.load("organs.xml");
}
if(key == 'r'){
- loadplaylist("tai_chi.xml");
+ list.load("tai_chi.xml");
}
if(key == 's'){
XML.saveFile("settings.xml");