diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-08-31 09:21:00 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-08-31 09:21:00 +0100 |
| commit | ba7cc94d4ae55e171f0e08126abb0cb13d8f9f8f (patch) | |
| tree | e015563027592464817796f3b9da72ba62ebcaff /liveengine/src | |
| parent | 766266368648487735894e6bf01c0330db6be2aa (diff) | |
blocking loading playlists
Diffstat (limited to 'liveengine/src')
| -rw-r--r-- | liveengine/src/layers.cpp | 34 | ||||
| -rw-r--r-- | liveengine/src/layers.h | 20 | ||||
| -rw-r--r-- | liveengine/src/main.cpp | 2 | ||||
| -rwxr-xr-x | liveengine/src/testApp.cpp | 130 | ||||
| -rwxr-xr-x | liveengine/src/testApp.h | 32 |
5 files changed, 173 insertions, 45 deletions
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<svg.getNumPath();i++) {
+ for (int i=0;i<svg.getNumPath();i++) { + 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());
}
}
-void svglayer::draw() {
- svg.draw();
+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(); + }
}
svglayer::~svglayer()
{
//dtor
}
+
+imglayer::imglayer() {}
+imglayer::imglayer(string _f)
+{
+ load(_f);
+}
+
+void imglayer::load(string _f){
+ bool success=img.loadImage(_f);
+ printf("%s\n",success?"loaded":"not loaded");
+}
+
+void imglayer::draw(float a) {
+ img.draw(0,0,ofGetWidth(),ofGetHeight());
+}
+
+imglayer::~imglayer()
+{
+ //dtor
+}
diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h index e3b0fd8..55f9529 100644 --- a/liveengine/src/layers.h +++ b/liveengine/src/layers.h @@ -10,7 +10,7 @@ class layer layer(string _f);
virtual ~layer();
virtual void load(string _f);
- virtual void draw();
+ virtual void draw(float a);
protected:
private:
};
@@ -22,10 +22,24 @@ class svglayer: public layer svglayer(string _f);
virtual ~svglayer();
void load(string _f);
- void draw();
+ void draw(float a);
protected:
private:
- ofxSVGTiny svg;
+ ofxSVGTiny svg; + vector <ofColor> fills; + vector <ofColor> 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<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;
midiChannel=0;
- int numLayers=0;
if( !XML.loadFile("settings.xml") ){
printf("unable to load settings.xml check data/ folder\n");
}else{
@@ -14,19 +42,7 @@ void testApp::setup(){ midiChannel=ofToInt(XML.getAttribute("liveEngine", "channel", "0"));
if (midiChannel) printf("listening on port %d, midi channel %d\n",midiPort,midiChannel);
else printf("listening on port %d, all midi channels\n",midiPort);
- if(XML.pushTag("liveEngine")) {
- 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 layers loaded!\n");
- }
-
- }
+ }
midiIn.listPorts();
midiIn.openPort(midiPort);
@@ -45,14 +61,22 @@ void testApp::setup(){ controller_colours=new ofColor[NUM_CONTROLLERS]; for (int i=0;i<NUM_CONTROLLERS;i++) controller_colours[i]=ofColor::fromHsb(ofRandom(255), 255, 255); - //grab.allocate(ofGetWidth(), ofGetHeight(),OF_IMAGE_COLOR_ALPHA); - grab.setUseTexture(true); + grab.allocate(ofGetWidth(), ofGetHeight(),GL_RGB); + //grab.setUseTexture(true); showFPS=false;
ofBackground(0,0,0); -
-
+ ofSetBackgroundAuto(false);
+
+ xshift=1;
+ yshift=1;
+
+ mode=BLOCKS; + + lastnoteTime=ofGetElapsedTimef(); + decayTime=2.0f;
+
//ofSetVerticalSync(true); deosn't seem effective
//glXSwapIntervalSGI(1);
} @@ -65,24 +89,33 @@ void testApp::update(){ //-------------------------------------------------------------- void testApp::draw(){
ofSetColor(255,255,255); - grab.grabScreen( 0, 0, ofGetWidth(), ofGetHeight() ); - grab.update();
- grab.reloadTexture(); - ofBackground(0,0,0); - //grab.draw( 1,1); + grab.loadScreenData( 0, 0, ofGetWidth(), ofGetHeight() ); + //grab.update();
+ //grab.reloadTexture(); + //ofBackground(0,0,0); + grab.draw( xshift,yshift); float notewidth=ofGetWidth()/NUM_NOTES; float noteheight=ofGetHeight()/NUM_CONTROLLERS; - for (int i=0;i<NUM_CONTROLLERS;i++){ - ofSetColor(ofColor((controller_colours[i].r*controllers[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<NUM_CONTROLLERS;i++){ + ofSetColor(ofColor((controller_colours[i].r*controllers[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;i<numLayers;i++) layers[i]->draw();
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<numLayers;i++){
diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h index 0ad4dc3..7e0272f 100755 --- a/liveengine/src/testApp.h +++ b/liveengine/src/testApp.h @@ -41,7 +41,21 @@ initially - divide screen into grid - play notes with fade class that loads an svg and maps controllers to layers layers are there but maybe its best to draw all of the colours mapped in some way rather than cutting out layers - colour transformation based on a hue angle -can draw + +fix feedback - direction etc +all drawn/ scaled from middle +colours for svgs +multi screen +loader/ programme changer - seperate xml for main programme and for each content section +script engine for scaling +more specific colour filtering for photos +auto masks based on colour + +wrap around/ scale textures + +3d blocks +non random colours + */ @@ -60,6 +74,9 @@ can draw #include "layers.h" +#define BLOCKS 0 +#define LIST 1 + @@ -84,13 +101,21 @@ class testApp : public ofBaseApp, public ofxMidiListener{ void toggleFPS(); bool showFPS; + void loadplaylist(string _name); + ofxXmlSettings XML; unsigned char* controllers; - unsigned char note; + int note,mode; + + float lastnoteTime; + float decayTime; + + int xshift,yshift; + ofColor* controller_colours; - ofImage grab; + ofTexture grab; int midiChannel; @@ -99,5 +124,6 @@ class testApp : public ofBaseApp, public ofxMidiListener{ void newMidiMessage(ofxMidiEventArgs& eventArgs); map<int,layer*> layers; + }; |
