summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-09-02 12:18:44 +0100
committerTim Redfern <tim@eclectronics.org>2012-09-02 12:18:44 +0100
commit65cf7b27e9d2f9e59da322b4fbad1ed1df27eb8d (patch)
tree3b2bfbca45418bfdeeb1f07553cef88c01e165e4
parent34a459de430dd35034ec9404fe7ec54407641085 (diff)
v 0.1
-rw-r--r--liveengine/liveengine.cbp8
-rw-r--r--liveengine/liveengine.layout16
-rw-r--r--liveengine/src/layers.cpp56
-rw-r--r--liveengine/src/layers.h17
-rw-r--r--liveengine/src/playlist.cpp63
-rw-r--r--liveengine/src/playlist.h2
-rwxr-xr-xliveengine/src/testApp.cpp54
-rwxr-xr-xliveengine/src/testApp.h7
8 files changed, 139 insertions, 84 deletions
diff --git a/liveengine/liveengine.cbp b/liveengine/liveengine.cbp
index ae2bc2e..d657653 100644
--- a/liveengine/liveengine.cbp
+++ b/liveengine/liveengine.cbp
@@ -52,8 +52,12 @@
<Unit filename="src/main.cpp">
<Option virtualFolder="src/" />
</Unit>
- <Unit filename="src/playlist.cpp" />
- <Unit filename="src/playlist.h" />
+ <Unit filename="src/playlist.cpp">
+ <Option virtualFolder="src/" />
+ </Unit>
+ <Unit filename="src/playlist.h">
+ <Option virtualFolder="src/" />
+ </Unit>
<Unit filename="src/testApp.cpp">
<Option virtualFolder="src/" />
</Unit>
diff --git a/liveengine/liveengine.layout b/liveengine/liveengine.layout
index bad1fb4..1691854 100644
--- a/liveengine/liveengine.layout
+++ b/liveengine/liveengine.layout
@@ -16,19 +16,19 @@
<File name="config.make" open="0" top="0" tabpos="3">
<Cursor position="477" topLine="0" />
</File>
- <File name="src/layers.cpp" open="0" top="0" tabpos="7">
- <Cursor position="801" topLine="16" />
+ <File name="src/layers.cpp" open="1" top="0" tabpos="3">
+ <Cursor position="1853" topLine="23" />
</File>
- <File name="src/layers.h" open="0" top="0" tabpos="6">
- <Cursor position="650" topLine="3" />
+ <File name="src/layers.h" open="1" top="0" tabpos="2">
+ <Cursor position="613" topLine="3" />
</File>
<File name="src/main.cpp" open="0" top="0" tabpos="7">
<Cursor position="220" topLine="0" />
</File>
- <File name="src/testApp.cpp" open="0" top="0" tabpos="8">
- <Cursor position="3081" topLine="0" />
+ <File name="src/testApp.cpp" open="1" top="1" tabpos="4">
+ <Cursor position="2295" topLine="66" />
</File>
- <File name="src/testApp.h" open="0" top="0" tabpos="4">
- <Cursor position="2615" topLine="82" />
+ <File name="src/testApp.h" open="1" top="0" tabpos="1">
+ <Cursor position="2630" topLine="82" />
</File>
</CodeBlocks_layout_file>
diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp
index 3ae7810..d2698ef 100644
--- a/liveengine/src/layers.cpp
+++ b/liveengine/src/layers.cpp
@@ -1,24 +1,5 @@
#include "layers.h"
-layer::layer() {}
-layer::layer(string _f)
-{
- load(_f);
-}
-
-void layer::load(string _f){
-}
-
-void layer::draw(float a) {
-
-}
-
-layer::~layer()
-{
- //dtor
-}
-
-
svglayer::svglayer() {
xo=0;yo=0;
}
@@ -45,6 +26,19 @@ void svglayer::draw(float a) {
svg.getPathAt(i).setFillColor(fills[i]*a);
svg.getPathAt(i).draw(xo,yo);
}
+}
+void svglayer::draw(float a,unsigned char* controllers) {
+ //draw layers tinted by controllers
+ for (int i=0;i<svg.getNumPath();i++) {
+ float h=fills[i].getHue();
+ float ha=h/42.7; //0-5
+ int h1=(int)ha;
+ int h2=h1+1;
+ float f2=ha-h1;
+ float f1=1.0f-f2;
+ svg.getPathAt(i).setFillColor(fills[i]*a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0));;
+ svg.getPathAt(i).draw(xo,yo);
+ }
}
svglayer::~svglayer()
@@ -52,7 +46,9 @@ svglayer::~svglayer()
//dtor
}
-imglayer::imglayer() {}
+imglayer::imglayer() {
+ //img.setUseTexture(false);
+}
imglayer::imglayer(string _f)
{
load(_f);
@@ -62,12 +58,24 @@ void imglayer::load(string _f){
bool success=img.loadImage(_f);
printf("%s\n",success?"loaded":"not loaded");
}
+
+/*
+WTF is going on with the image drawing
+
+
+*/
+void imglayer::draw(float a) {
+ //if (img.isAllocated()) if (!img.isUsingTexture()) img.setUseTexture(true); //has to be done from the main thread? still doesn't work
+ img.draw(0,0,ofGetWidth(),ofGetHeight());
+ printf("drawing %f\n",ofGetElapsedTimef());
+}
+
+void imglayer::draw(float a,unsigned char* controllers) {
+ imglayer::draw(a);
+}
-void imglayer::draw(float a) {
- img.draw(0,0,ofGetWidth(),ofGetHeight());
-}
imglayer::~imglayer()
{
- //dtor
+ //img.setUseTexture(false); //free texture
}
diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h
index f7cbc85..11e50ab 100644
--- a/liveengine/src/layers.h
+++ b/liveengine/src/layers.h
@@ -6,11 +6,12 @@
class layer
{
public:
- layer();
- layer(string _f);
- virtual ~layer();
- virtual void load(string _f);
- virtual void draw(float a);
+ layer(){};
+ layer(string _f) {load(_f);};
+ virtual ~layer(){};
+ virtual void load(string _f){};
+ virtual void draw(float a){};
+ virtual void draw(float a,unsigned char* controllers){ draw(a);};
protected:
private:
};
@@ -22,7 +23,8 @@ class svglayer: public layer
svglayer(string _f);
virtual ~svglayer();
void load(string _f);
- void draw(float a);
+ void draw(float a);
+ void draw(float a,unsigned char* controllers);
protected:
private:
ofxSVGTiny svg;
@@ -38,7 +40,8 @@ class imglayer: public layer
imglayer(string _f);
virtual ~imglayer();
void load(string _f);
- void draw(float a);
+ void draw(float a);
+ void draw(float a,unsigned char* controllers);
protected:
private:
ofImage img;
diff --git a/liveengine/src/playlist.cpp b/liveengine/src/playlist.cpp
index 896c788..3063595 100644
--- a/liveengine/src/playlist.cpp
+++ b/liveengine/src/playlist.cpp
@@ -12,6 +12,7 @@ void playlist::load(string _name){
printf("unable to load %s check data/ folder\n",_name.c_str());
}else {
printf("starting loader thread\n");
+ loadimg(); //how to do this from the worker thread???
startThread(false, false); //blocking, verbose
}
@@ -20,37 +21,45 @@ void playlist::load(string _name){
}
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");
- }
+ loadsvg();
unlock();
}
-
}
+
+void playlist::loadsvg(){
+ 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");
+ }
+ XML.popTag();
+}
+
+void playlist::loadimg(){
+ int numLayers=0;
+ layers.clear();
+ if(XML.pushTag("playlist")) {
+ 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());
+ layers[XML.getAttribute("imglayer", "note", 0,i)]=new imglayer(XML.getAttribute("imglayer", "file", "",i));
+ }
+ }
+ else printf("no IMG layers loaded!\n");
+ }
+ XML.popTag();
+}
playlist::~playlist()
{
diff --git a/liveengine/src/playlist.h b/liveengine/src/playlist.h
index afedec9..43982f9 100644
--- a/liveengine/src/playlist.h
+++ b/liveengine/src/playlist.h
@@ -11,6 +11,8 @@ class playlist : public ofThread {
public:
playlist();
virtual ~playlist();
+ void loadimg();
+ void loadsvg();
void load(string _name);
void threadedFunction();
diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp
index 0d8ec28..c23ec86 100755
--- a/liveengine/src/testApp.cpp
+++ b/liveengine/src/testApp.cpp
@@ -28,8 +28,9 @@ void testApp::setup(){
memset(controllers,NUM_CONTROLLERS,0);
note=0;
- controller_colours=new ofColor[NUM_CONTROLLERS];
- for (int i=0;i<NUM_CONTROLLERS;i++) controller_colours[i]=ofColor::fromHsb(ofRandom(255), 255, 255);
+ makeColours();
+
+ controlColours=false;
grab.allocate(ofGetWidth(), ofGetHeight(),GL_RGB);
//grab.setUseTexture(true);
@@ -39,8 +40,10 @@ void testApp::setup(){
ofSetBackgroundAuto(false);
- xshift=1;
- yshift=1;
+ xshift=-1;
+ yshift=-1;
+
+
mode=BLOCKS;
@@ -48,9 +51,19 @@ void testApp::setup(){
decayTime=2.0f;
//ofSetVerticalSync(true); deosn't seem effective
- //glXSwapIntervalSGI(1);
+ //glXSwapIntervalSGI(1);
+ /*
+ printf("hue of red is %f\n",ofColor(255,0,0).getHue());
+ printf("hue of green is %f\n",ofColor(0,255,0).getHue());
+ printf("hue of blue is %f\n",ofColor(0,0,255).getHue());
+ hue is float from 0.0-255.0
+ */
}
+void testApp::makeColours() {
+ controller_colours=new ofColor[NUM_CONTROLLERS];
+ for (int i=0;i<NUM_CONTROLLERS;i++) controller_colours[i]=ofColor::fromHsb(ofRandom(255), 255, 255);
+}
//--------------------------------------------------------------
void testApp::update(){
//for (int i=0;i<numLayers;i++) layers[i]->update();
@@ -60,10 +73,14 @@ void testApp::update(){
void testApp::draw(){
ofSetColor(255,255,255);
grab.loadScreenData( 0, 0, ofGetWidth(), ofGetHeight() );
- //grab.update();
- //grab.reloadTexture();
- //ofBackground(0,0,0);
- grab.draw( xshift,yshift);
+
+ /* can this work?
+ grab.setAnchorPoint(xshift,yshift);
+ grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER);
+ grab.draw(0,0); // xshift,yshift);
+ */
+ int startx=(xshift>0?xshift-ofGetWidth():xshift);
+ int starty=(yshift>0?yshift-ofGetHeight():yshift);
float notewidth=ofGetWidth()/NUM_NOTES;
float noteheight=ofGetHeight()/NUM_CONTROLLERS;
@@ -82,7 +99,10 @@ void testApp::draw(){
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);
+ if (list.layers.find(note)!=list.layers.end()) {
+ if (controlColours) list.layers[note]->draw(lamda,controllers);
+ else list.layers[note]->draw(lamda);
+ }
ofPopMatrix();
list.unlock();
}
@@ -121,18 +141,24 @@ void testApp::keyPressed (int key){
mode=key-'0';
}
if(key == OF_KEY_LEFT){
- xshift--;
+ xshift++;
+
}
if(key == OF_KEY_RIGHT){
- xshift++;
+ xshift--;
}
if(key == OF_KEY_DOWN){
yshift--;
}
if(key == OF_KEY_UP){
- yshift++;
+ yshift++;
}
-
+ if(key == '='){
+ makeColours();
+ }
+ if(key == '-'){
+ controlColours=!controlColours;
+ }
}
//--------------------------------------------------------------
diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h
index 0f97068..af99c6a 100755
--- a/liveengine/src/testApp.h
+++ b/liveengine/src/testApp.h
@@ -95,14 +95,17 @@ class testApp : public ofBaseApp, public ofxMidiListener{
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
+ void makeColours();
+
void toggleFPS();
bool showFPS;
ofxXmlSettings XML;
unsigned char* controllers;
- int note,
- mode;
+ int note, mode;
+
+ bool controlColours;
float lastnoteTime;
float decayTime;