summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--liveengine/liveengine.cbp6
-rw-r--r--liveengine/src/layers.cpp10
-rw-r--r--liveengine/src/layers.h3
-rw-r--r--liveengine/src/playlist.cpp58
-rw-r--r--liveengine/src/playlist.h23
-rwxr-xr-xliveengine/src/testApp.cpp51
-rwxr-xr-xliveengine/src/testApp.h12
7 files changed, 111 insertions, 52 deletions
diff --git a/liveengine/liveengine.cbp b/liveengine/liveengine.cbp
index db4e112..ae2bc2e 100644
--- a/liveengine/liveengine.cbp
+++ b/liveengine/liveengine.cbp
@@ -34,7 +34,9 @@
<Unit filename="addons.make">
<Option virtualFolder="build config/" />
</Unit>
- <Unit filename="bin/data/insects.xml" />
+ <Unit filename="bin/data/insects.xml">
+ <Option virtualFolder="build config/" />
+ </Unit>
<Unit filename="bin/data/settings.xml">
<Option virtualFolder="build config/" />
</Unit>
@@ -50,6 +52,8 @@
<Unit filename="src/main.cpp">
<Option virtualFolder="src/" />
</Unit>
+ <Unit filename="src/playlist.cpp" />
+ <Unit filename="src/playlist.h" />
<Unit filename="src/testApp.cpp">
<Option virtualFolder="src/" />
</Unit>
diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp
index f140073..3ae7810 100644
--- a/liveengine/src/layers.cpp
+++ b/liveengine/src/layers.cpp
@@ -19,7 +19,9 @@ layer::~layer()
}
-svglayer::svglayer() {}
+svglayer::svglayer() {
+ xo=0;yo=0;
+}
svglayer::svglayer(string _f)
{
load(_f);
@@ -32,14 +34,16 @@ void svglayer::load(string _f){
fills.push_back(svg.getPathAt(i).getFillColor());
strokes.push_back(svg.getPathAt(i).getStrokeColor());
printf(" path %i: fill %08x stroke %08x\n",i,svg.getPathAt(i).getFillColor().getHex(),svg.getPathAt(i).getStrokeColor().getHex());
- }
+ }
+ xo=(ofGetWidth()-svg.getWidth())/2;
+ yo=(ofGetHeight()-svg.getHeight())/2;
}
void svglayer::draw(float a) {
//svg.draw();
for (int i=0;i<svg.getNumPath();i++) {
svg.getPathAt(i).setFillColor(fills[i]*a);
- svg.getPathAt(i).draw();
+ svg.getPathAt(i).draw(xo,yo);
}
}
diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h
index 55f9529..f7cbc85 100644
--- a/liveengine/src/layers.h
+++ b/liveengine/src/layers.h
@@ -27,7 +27,8 @@ class svglayer: public layer
private:
ofxSVGTiny svg;
vector <ofColor> fills;
- vector <ofColor> strokes;
+ vector <ofColor> strokes;
+ float xo,yo;
};
class imglayer: public layer
diff --git a/liveengine/src/playlist.cpp b/liveengine/src/playlist.cpp
new file mode 100644
index 0000000..896c788
--- /dev/null
+++ b/liveengine/src/playlist.cpp
@@ -0,0 +1,58 @@
+#include "playlist.h"
+
+playlist::playlist()
+{
+}
+
+void playlist::load(string _name){
+ printf("loading %s\n",_name.c_str());
+
+
+ if( !XML.loadFile(_name) ){
+ printf("unable to load %s check data/ folder\n",_name.c_str());
+ }else {
+ printf("starting loader thread\n");
+ startThread(false, false); //blocking, verbose
+ }
+
+
+
+}
+
+void playlist::threadedFunction(){
+
+ if( lock() ){
+
+ int numLayers=0;
+ layers.clear();
+ 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");
+ }
+ unlock();
+ }
+
+}
+
+playlist::~playlist()
+{
+ //dtor
+}
diff --git a/liveengine/src/playlist.h b/liveengine/src/playlist.h
new file mode 100644
index 0000000..afedec9
--- /dev/null
+++ b/liveengine/src/playlist.h
@@ -0,0 +1,23 @@
+#ifndef PLAYLIST_H
+#define PLAYLIST_H
+
+#include "ofThread.h"
+#include "ofxXmlSettings.h"
+
+#include "layers.h"
+
+
+class playlist : public ofThread {
+ public:
+ playlist();
+ virtual ~playlist();
+ void load(string _name);
+ void threadedFunction();
+
+ ofxXmlSettings XML;
+ map<int,layer*> layers;
+ protected:
+ private:
+};
+
+#endif // PLAYLIST_H
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");
diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h
index 7e0272f..0f97068 100755
--- a/liveengine/src/testApp.h
+++ b/liveengine/src/testApp.h
@@ -71,13 +71,10 @@ non random colours
#include "ofxMidi.h"
-
-#include "layers.h"
-
#define BLOCKS 0
#define LIST 1
-
+#include "playlist.h"
class testApp : public ofBaseApp, public ofxMidiListener{
@@ -101,12 +98,11 @@ class testApp : public ofBaseApp, public ofxMidiListener{
void toggleFPS();
bool showFPS;
- void loadplaylist(string _name);
-
ofxXmlSettings XML;
unsigned char* controllers;
- int note,mode;
+ int note,
+ mode;
float lastnoteTime;
float decayTime;
@@ -123,7 +119,7 @@ class testApp : public ofBaseApp, public ofxMidiListener{
void newMidiMessage(ofxMidiEventArgs& eventArgs);
- map<int,layer*> layers;
+ playlist list;
};