From 796d647fd38f7cf01cb70bbb0700b75427e42d55 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 28 Oct 2012 17:40:19 +0000 Subject: starting to build kinect addition --- liveengineUnmapped/src/layers.cpp | 115 +++++++ liveengineUnmapped/src/layers.h | 54 ++++ liveengineUnmapped/src/main.cpp | 20 ++ liveengineUnmapped/src/playlist.cpp | 91 ++++++ liveengineUnmapped/src/playlist.h | 30 ++ liveengineUnmapped/src/testApp.cpp | 577 ++++++++++++++++++++++++++++++++++++ liveengineUnmapped/src/testApp.h | 205 +++++++++++++ liveengineUnmapped/src/viewport.cpp | 110 +++++++ liveengineUnmapped/src/viewport.h | 34 +++ 9 files changed, 1236 insertions(+) create mode 100755 liveengineUnmapped/src/layers.cpp create mode 100755 liveengineUnmapped/src/layers.h create mode 100755 liveengineUnmapped/src/main.cpp create mode 100755 liveengineUnmapped/src/playlist.cpp create mode 100755 liveengineUnmapped/src/playlist.h create mode 100755 liveengineUnmapped/src/testApp.cpp create mode 100755 liveengineUnmapped/src/testApp.h create mode 100755 liveengineUnmapped/src/viewport.cpp create mode 100755 liveengineUnmapped/src/viewport.h (limited to 'liveengineUnmapped/src') diff --git a/liveengineUnmapped/src/layers.cpp b/liveengineUnmapped/src/layers.cpp new file mode 100755 index 0000000..4ac0c59 --- /dev/null +++ b/liveengineUnmapped/src/layers.cpp @@ -0,0 +1,115 @@ +#include "layers.h" + +svglayer::svglayer() { + xo=0;yo=0; +} +svglayer::svglayer(string _f) +{ + load(_f); +} + +void svglayer::load(string _f){ + //check if files exits + svg.load(_f); + printf("%s: %i paths\n",_f.c_str(),svg.getNumPath()); + for (int i=0;i0); +} +void svglayer::getCentre(int cx,int cy) { + if (svg.getNumPath()>0) { + xo=(cx-svg.getWidth())/2; + yo=(cy-svg.getHeight())/2; + } +} + +void svglayer::draw(float a,int cx,int cy,float colShift) { + getCentre(cx,cy); + for (int i=0;i0.0f) { + c.setHue(fmod(c.getHue()+colShift,255.0f)); + //printf ("shift from %f to %f\n",c.getHue(),c.getHue()+colShift); + } + svg.getPathAt(i).setFillColor(c); + svg.getPathAt(i).draw(xo,yo); + } +} +/* +void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift) { + getCentre(cx,cy); + //draw layers tinted by controllers + for (int i=0;i0.1) { + svg.getPathAt(i).draw(xo,yo); + } + } +} +*/ + +void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift) { + getCentre(cx,cy); + //draw layers grouped by controllers + float layerspercontroller=((float)svg.getNumPath())/6.0f; + + for (int i=0;i<6;i++) { + for (int j=(int)(i*layerspercontroller);j<(int)((i+1)*layerspercontroller);j++) { + svg.getPathAt(j).setFillColor(fills[i]*a*controllers[i]); + if (!transparentBlack||((a*controllers[i])/127.0)>0.1) { + svg.getPathAt(j).draw(xo,yo); + } + } + } +} + + +svglayer::~svglayer() +{ + //dtor +} + +imglayer::imglayer() { + //img.setUseTexture(false); +} +imglayer::imglayer(string _f) +{ + load(_f); +} + +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,int cx,int cy,float colShift) { + //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,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) { + imglayer::draw(a,cx,cy,colShift); +} + + +imglayer::~imglayer() +{ + //img.setUseTexture(false); //free texture +} diff --git a/liveengineUnmapped/src/layers.h b/liveengineUnmapped/src/layers.h new file mode 100755 index 0000000..c6f4171 --- /dev/null +++ b/liveengineUnmapped/src/layers.h @@ -0,0 +1,54 @@ +#ifndef SVGLAYER_H +#define SVGLAYER_H + +#include "ofxSVGTiny.h" +#include "ofMain.h" + +class layer +{ + public: + layer(){}; + layer(string _f) {load(_f);}; + virtual ~layer(){}; + virtual void load(string _f){}; + virtual void draw(float a,int cx,int cy,float colShift){}; + virtual void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f){ draw(a,cx,cy,colShift);}; + bool getLoaded() {return isLoaded;}; + protected: + bool isLoaded; + private: + +}; + +class svglayer: public layer +{ + public: + svglayer(); + svglayer(string _f); + virtual ~svglayer(); + void load(string _f); + void draw(float a,int cx,int cy,float colShift); + void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f); + void getCentre(int cx,int cy); + protected: + private: + ofxSVGTiny svg; + vector fills; + vector strokes; + float xo,yo; +}; + +class imglayer: public layer +{ + public: + imglayer(); + imglayer(string _f); + virtual ~imglayer(); + void load(string _f); + void draw(float a,int cx,int cy,float colShift); + void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift); + protected: + private: + ofImage img; +}; +#endif // SVGLAYER_H diff --git a/liveengineUnmapped/src/main.cpp b/liveengineUnmapped/src/main.cpp new file mode 100755 index 0000000..6f40023 --- /dev/null +++ b/liveengineUnmapped/src/main.cpp @@ -0,0 +1,20 @@ +#include "ofMain.h" +#include "testApp.h" +#include "ofxFensterManager.h" +#include "ofAppGlutWindow.h" + +//======================================================================== +int main( ){ + + ofAppGlutWindow window; + ofSetupOpenGL(ofxFensterManager::get(),2048,768, OF_WINDOW); //2048,768 + //ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context + //ofSetupOpenGL(&window, 1024,768, OF_WINDOW); + + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + //ofRunApp( new testApp()); + ofRunFensterApp( new testApp()); + +} diff --git a/liveengineUnmapped/src/playlist.cpp b/liveengineUnmapped/src/playlist.cpp new file mode 100755 index 0000000..51bd852 --- /dev/null +++ b/liveengineUnmapped/src/playlist.cpp @@ -0,0 +1,91 @@ +#include "playlist.h" + +playlist::playlist() +{ + name=""; + thumbnail.allocate(128,128,GL_RGB); + thumbnailed=false; +} + +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"); + loadimg(); //how to do this from the worker thread??? + startThread(false, false); //blocking, verbose + } + + + +} + +void playlist::threadedFunction(){ + if( lock() ){ + loadsvg(); + unlock(); + } +} + +void playlist::loadsvg(){ + int numLayers=0; + layers.clear(); + name=XML.getAttribute("playlist", "name", ""); + if(XML.pushTag("playlist")) { + numLayers=XML.getNumTags("svglayer"); + if(numLayers) { + for (int i=0;i::iterator i=layers.begin(); + i->second->draw(1.0,64,64,0.0); + ofPopMatrix(); + thumbnail.end(); + thumbnailed=true; + } +} + + +void playlist::loadimg(){ + int numLayers=0; + layers.clear(); + if(XML.pushTag("playlist")) { + numLayers=XML.getNumTags("imglayer"); + if(numLayers) { + for (int i=0;i layers; + string name; + protected: + private: +}; + +#endif // PLAYLIST_H diff --git a/liveengineUnmapped/src/testApp.cpp b/liveengineUnmapped/src/testApp.cpp new file mode 100755 index 0000000..cada0e7 --- /dev/null +++ b/liveengineUnmapped/src/testApp.cpp @@ -0,0 +1,577 @@ +#include "testApp.h" +previewWindow::~previewWindow(){ + cout << "preview window destroyed" << endl; +} +void previewWindow::setup(){} +void previewWindow::setBuffer(ofFbo *buffer){ + rb=buffer; +} +void previewWindow::draw(){ + + rb->draw(0,0,ofGetWidth(),ofGetHeight()); //why crash? + +} +//-------------------------------------------------------------- +guiWindow::~guiWindow(){ + cout << "gui window destroyed" << endl; +} +void guiWindow::setup(){} +void guiWindow::setParent(testApp *p){ + parent=p; +} +void guiWindow::draw(){ + + parent->gui.draw(); + if (parent->list.lock()) { //if loaded + if (!parent->list.thumbnailed) parent->list.makeThumbnail(); + if (parent->list.thumbnailed) parent->list.thumbnail.draw(20,ofGetHeight()-150); + parent->list.unlock(); + } + ofDrawBitmapString(parent->list.name,20,ofGetHeight()-10); + +} +void guiWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ + parent->dragEvent(dragInfo); +} +void guiWindow::windowMoved(int x,int y){ + //printf("window moved!\n"); +} + +//-------------------------------------------------------------- +void testApp::setup(){ + int midiPort=0; + midiChannel=0; + if( !XML.loadFile("settings.xml") ){ + printf("unable to load settings.xml check data/ folder\n"); + }else{ + printf("settings loaded!\n"); + midiPort=ofToInt(XML.getAttribute("liveEngine", "port", "0")); //default to 0/all + 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")) { + int numViews=XML.getNumTags("viewport"); + if(numViews) { + for (int i=0;icreateFenster(0, 0, 600, 800, OF_WINDOW); + ofAddListener(win->events.mouseDragged, this, &testApp::mousePressedEvent); + ofAddListener(win->events.mousePressed, this, &testApp::mousePressedEvent); + ofAddListener(win->events.keyPressed, this, &testApp::keyPressedEvent); + win->setWindowTitle("preview"); + win->addListener(prevWin); + prevWin->setup(); + prevWin->setBuffer(&viewports[0]->rb2); + + fullscreenoutput=false; + + guiWin=new guiWindow(); + gui.setup("","panel.xml",0,0); + gui.add(reversemain.setup("reverse main", false)); + gui.add(controlColours.setup("control colours", false)); + gui.add(noteRandomiseColours.setup("randomise note colours", false)); + gui.add(transparentBlack.setup("transparent black", false)); + gui.add(resetDrawscale.setup("reset draw scale")); + gui.add(resetFBscale.setup("reset FB scale")); + + resetDrawscale.addListener(this,&testApp::resetDrawscalePressed); + resetFBscale.addListener(this,&testApp::resetFBscalePressed); + + //gui window stuff + ofxFenster* win2=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW); + + ofAddListener(win2->events.windowResized, this, &testApp::windowEvent); + + win2->setWindowTitle("config"); + win2->addListener(guiWin); + guiWin->setup(); + guiWin->setParent(this); + + +} + +void testApp::resetDrawscalePressed(bool & pressed){ + scale=1.0f; +} +void testApp::resetFBscalePressed(bool & pressed){ + fscale=1.0f; +} + +void testApp::makeColours() { + controller_colours=new ofColor[NUM_CONTROLLERS]; + for (int i=0;iupdate(); +} + +//-------------------------------------------------------------- +void testApp::draw(){ + + float lambda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); + + ofSetColor(255-fadetime,255-fadetime,255-fadetime); //for feedback + + //vp1.draw(lambda,controllers,xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,scale,fscale,noteRandomiseColours?colShift:0.0f); + //vp2.draw(lambda,controllers,reversemain?-xshift:xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,reversemain?1.0f/scale:scale,reversemain?1.0f/fscale:fscale,noteRandomiseColours?colShift:0.0f); + for (int i=0;idraw(lambda,controllers,even&&reversemain?-xshift:xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,even&&reversemain?1.0f/scale:scale,even&&reversemain?1.0f/fscale:fscale,noteRandomiseColours?colShift:0.0f); + } + + ofSetColor(255,255,255); + if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); + + /* + rb1.begin(); + + + // can this work? + //grab.setAnchorPoint(xshift,yshift); + //grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER); + //grab.draw(0,0); // xshift,yshift); + + ofSetColor(255-fadetime,255-fadetime,255-fadetime); + for (int i=(xshift>0?xshift-rb1.getWidth():xshift);i0?yshift-rb1.getHeight():yshift);j0) { + 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: + if (list.lock()) { //if playlist is loaded + ofPushMatrix(); + ofTranslate(rb1.getWidth()/2,rb1.getHeight()/2); + ofScale(scale,scale,scale); + ofRotate(rotate); + ofTranslate(-rb1.getWidth()/2,-rb1.getHeight()/2); + if (list.layers.find(note)!=list.layers.end()) { + if (controlColours) list.layers[note]->draw(lamda,controllers,512,384,transparentBlack); + else list.layers[note]->draw(lamda,512,384); + } + ofPopMatrix(); + list.unlock(); + } + break; + } + } + + //for (int i=0;idraw(); + ofSetColor(255,255,255); + if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); + + rb1.end(); + + rb2.begin(); + ofSetColor(255,255,255); + rb1.draw(0,0); + rb2.end(); + + rb2.draw(1024,0); + + rb3.begin(); //landscape + + + + ofSetColor(255-fadetime,255-fadetime,255-fadetime); + for (int i=(xshift>0?xshift-rb3.getWidth():xshift);i0?yshift-rb3.getHeight():yshift);j0) { + 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: + if (list.lock()) { //if playlist is loaded + ofPushMatrix(); + ofTranslate(rb3.getWidth()/2,rb3.getHeight()/2); + ofScale(scale,scale,scale); + ofRotate(rotate); + ofTranslate(-rb3.getWidth()/2,-rb3.getHeight()/2); + if (list.layers.find(note)!=list.layers.end()) { + if (controlColours) list.layers[note]->draw(lamda,controllers,512,384,transparentBlack); + else list.layers[note]->draw(lamda,512,384); + } + ofPopMatrix(); + list.unlock(); + } + break; + } + } + + ofPopMatrix(); + + //for (int i=0;idraw(); + ofSetColor(255,255,255); + if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); + + rb3.end(); + + rb4.begin(); + ofSetColor(255,255,255); + rb3.draw(0,0); + rb4.end(); + + rb4.draw(0,0); + + */ + + /* test screen shape + ofSetColor(255,0,0); + ofRect(0,0,1024,768); + ofSetColor(0,255,0); + ofRect(1024,0,1024,768); + */ + +} + +//-------------------------------------------------------------- +void testApp::keyPressed(int key, ofxFenster* win){ + if(key == ' '){ + fullscreenoutput=!fullscreenoutput; + win->setFullscreen(fullscreenoutput); + printf("resolution: %ix%i %s\n",win->getWidth(),win->getHeight(),fullscreenoutput?"fullscreen":"windowed"); + } + else keyPressed(key); +} +void testApp::keyPressed(int key){ + if(key == 'q'){ + list.load("insects.xml"); + } + if(key == 'Q'){ + list.load("birds.xml"); + } + if(key == 'w'){ + list.load("teamsports.xml"); + } + if(key == 'W'){ + list.load("american_football.xml"); + } + if(key == 'e'){ + list.load("organs.xml"); + } + if(key == 'E'){ + list.load("crests.xml"); + } + if(key == 'r'){ + list.load("tai_chi.xml"); + } + if(key == 'R'){ + list.load("cricket.xml"); + } + if(key == 't'){ + list.load("reptiles.xml"); + } + if(key == 'T'){ + list.load("tools.xml"); + } + if(key == 'y'){ + list.load("miltary_ladies.xml"); + } + if(key == 'Y'){ + list.load("women_ethnic.xml"); + } + if(key == 'u'){ + list.load("knights.xml"); + } + if(key == 'U'){ + list.load("food.xml"); + } + if(key == 'i'){ + list.load("mil_historic.xml"); + } + if(key == 'I'){ + list.load("mil_ethnic.xml"); + } + if(key == 'o'){ + list.load("yoga.xml"); + } + if(key == 'O'){ + list.load("computers.xml"); + } + if(key == 'p'){ + list.load("dancing.xml"); + } + if(key == 'P'){ + list.load("trainers.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 == 267){ + xshift--; + } + if(key == 268){ + xshift++; + } + if(key == 269){ + yshift--; + } + if(key == 270){ + yshift++; + } + if(key == '='){ + makeColours(); + } + if(key == '+'){ + fadetime=min(128,fadetime+1); + } + if(key == '_'){ + fadetime=max(0,fadetime-1); + } + if(key == ']'){ + scale*=1.01; + } + if(key == '['){ + scale/=1.01; + } + if(key == '}'){ + rotate+=90; + } + if(key == '{'){ + rotate-=90; + } + + + if(key == 'd'){ + debug=!debug; + } + + if (key=='j') { + fscale=1.0f; + } + if (key=='h') { + scale=1.0f; + } + +} + +//-------------------------------------------------------------- +void testApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void testApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void testApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mouseReleased(int x, int y, int button){ + + +} +void testApp::mousePressed(int x, int y, int button) { +} + +//-------------------------------------------------------------- +void testApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void testApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- + +void testApp::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ + dragEvent(dragInfo); +} +void testApp::dragEvent(ofDragInfo dragInfo){ + printf("got draginfo: %s\n",dragInfo.files[0].c_str()); + int sta=dragInfo.files[0].find_last_of("\\/")+1; + int len=(dragInfo.files[0].find_last_of(".")+4)-sta; + string filename=dragInfo.files[0].substr(sta,len); + printf("loading %s\n",filename.c_str()); + + list.load(filename); +} +void testApp::windowEvent(ofResizeEventArgs &args){ + printf("window event\n"); +} + +void testApp::mousePressedEvent(ofMouseEventArgs &args) { + //printf("mouse: %i,%i %i of %ix%i\n",args.x,args.y,args.button,win->getWidth(),win->getHeight()); + //0-2 + switch (args.button) { + case 0: + xshift=args.x-(win->getWidth()/2); + yshift=args.y-(win->getHeight()/2); + break; + case 1: + scale=pow(pow(args.x-(win->getWidth()/2),2)+pow(args.y-(win->getHeight()/2),2),0.5)/(win->getWidth()*.1); + break; + case 2: + fscale=(pow(pow(args.x-(win->getWidth()/2),2)+pow(args.y-(win->getHeight()/2),2),0.5)/(win->getWidth()))+0.5; + break; + } +} + +void testApp::keyPressedEvent(ofKeyEventArgs &args) { + //printf("window key pressed: %i (%c)\n",args.key,args.key); + keyPressed(args.key); +} + +void testApp::toggleFPS(){ + showFPS=!showFPS; +} + +void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){ + + //newMessage(eventArgs.port, eventArgs.channel, eventArgs.byteTwo, eventArgs.timestamp); + +//byteOne : message type + + /* + int port; + int channel; + int status; + int byteOne; + int byteTwo; + double timestamp; + */ + + //printf("%d %d %d %d %d\n",eventArgs.port,eventArgs.channel,eventArgs.status,eventArgs.byteOne,eventArgs.byteTwo); + + bool noteOn; //this old thing! + + if ((midiChannel==0)||(eventArgs.channel==midiChannel)) { + switch(eventArgs.status) { + case 144: //noteon-off channel 0 + noteOn=(eventArgs.byteTwo==0?false:true); + //for (int i=0;inote==eventArgs.byteOne) layers[i]->setActive(noteOn); + //} + if (debug) printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo); + note=eventArgs.byteOne; + lastnoteTime=ofGetElapsedTimef(); + if (noteRandomiseColours) { + makeColours(); // + } + break; + case 176: //control change channel 0 + //for (int i=0;imix==eventArgs.byteOne) layers[i]->setMixAmt(((float)eventArgs.byteTwo)/127.0f); + //} + if (debug) printf("cc: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo); + controllers[eventArgs.byteOne-START_CONTROLLER]=eventArgs.byteTwo; + } + } +} + diff --git a/liveengineUnmapped/src/testApp.h b/liveengineUnmapped/src/testApp.h new file mode 100755 index 0000000..fe988f1 --- /dev/null +++ b/liveengineUnmapped/src/testApp.h @@ -0,0 +1,205 @@ +#pragma once + +//#include + +#include "ofMain.h" +#include "ofxXmlSettings.h" + +/* +modprobe snd-virmidi +have had problems with it not being recognised - rebuild seemed to fix it + + +6 controllers +each note switches in 6 new visuals which are at the same strengths +as the previous bunch + +is it necessary to represent them seperately? + +maybe take them all in, but initially modulate one picture on the strength of the strongest + +maybe each object is a plugin and the 6 controllers affect 6 parameters of it +ie speed, matting type, colour tweak + +object that plays when a note is received can be called a track, a sample, a bank, a layer? + +object remembers playback head/ heads + +initial footage set for each track: program change? +(does this leave any room for creative input) or set via gui? + +video playback object +still image object + +load files in gui - loadable area + +creative input - alter layers live via AVS compatible system which also allows local MIDI control, +scripting, manipulating layers etc + +probably pretty tricky to create a .ape loader - difficulty in recreating the windows GUI + +probably a lot easier to think about a way of making a modular editor that can be manipulated live +nice to think about making scripted layers - using nseel or other + +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 + + +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 + +option to randomise colours on each note + +--make transparent + +--interface for exploring and saving - swapping? + + +*/ + + + +#define OF_ADDON_USING_OFXMIDIIN + + +#include "ofxMidi.h" +#include "ofxFensterManager.h" + +#include "ofxGui.h" + + +#include "viewport.h" + +/* +enum PropertyAttribute { + None = 0, + ReadOnly = 1 << 0, + DontEnum = 1 << 1, + DontDelete = 1 << 2 +}; +*/ + +class previewWindow; +class guiWindow; + +//#define GRAB_TEXTURE + +class testApp : public ofxFensterListener, public ofxMidiListener{ + + public: + + void setup(); + void update(); + void draw(); + + void keyPressed(int key, ofxFenster* win); + void keyPressed(int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h); + void gotMessage(ofMessage msg); + void dragEvent(ofDragInfo dragInfo); + void dragEvent(ofDragInfo dragInfo,ofxFenster* win); + + void mousePressedEvent(ofMouseEventArgs &args); + void keyPressedEvent(ofKeyEventArgs &args); + void windowEvent(ofResizeEventArgs &args); + + void makeColours(); + + void toggleFPS(); + bool showFPS; + + ofxXmlSettings XML; + + unsigned char* controllers; + int note, mode; + + //to be moved into svg object gui + + bool debug; + + bool fullscreenoutput; + + float lastnoteTime; + float decayTime; + + int fadetime; + int rotate; + float scale,fscale; + + int xshift,yshift; + + ofColor* controller_colours; + + float colShift; + + viewport vp1,vp2; + vector viewports; + + previewWindow *prevWin; + guiWindow *guiWin; + + ofxFenster* win; + + int midiChannel; + + ofxMidiIn midiIn; + + void newMidiMessage(ofxMidiEventArgs& eventArgs); + + playlist list; + + + ofxPanel gui; + ofxToggle reversemain; + ofxToggle controlColours; + ofxToggle noteRandomiseColours; + ofxToggle transparentBlack; + ofxButton resetDrawscale; + ofxButton resetFBscale; + + void resetDrawscalePressed(bool & pressed); + void resetFBscalePressed(bool & pressed); + + +}; + + +class previewWindow: public ofxFensterListener{ +public: + ~previewWindow(); + ofFbo *rb; + void setup(); + void setBuffer(ofFbo *buffer); + void draw(); +}; + +class guiWindow: public ofxFensterListener{ +public: + ~guiWindow(); + testApp *parent; + void setup(); + void setParent(testApp *p); + void draw(); + void dragEvent(ofDragInfo dragInfo,ofxFenster* win); + void windowMoved(int x, int y); +}; + + diff --git a/liveengineUnmapped/src/viewport.cpp b/liveengineUnmapped/src/viewport.cpp new file mode 100755 index 0000000..a15d5ba --- /dev/null +++ b/liveengineUnmapped/src/viewport.cpp @@ -0,0 +1,110 @@ +#include "viewport.h" + + + +viewport::viewport() +{ + //ctor +} +viewport::viewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) { + setup(_w,_h,_x,_y,_r,_ox,_oy); +} + +void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) { + r=_r; + w=_w; + h=_h; + x=_x; + y=_y; + ox=_ox; + oy=_oy; + rb1.allocate(w,h,GL_RGB); + rb2.allocate(w,h,GL_RGB); + + printf("%ix%i, vp offset: %f,%f\n",w,h,-(sin(ofDegToRad(r))*h/2)-(cos(ofDegToRad(r))*w/2),-(sin(ofDegToRad(r))*w/2)-(cos(ofDegToRad(r))*h/2)); +} + +void viewport::draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale,float colShift){ + + + + // test screen shape + /* + ofSetColor(255,0,0); + ofRect(0,0,w/2,h/2); + ofRect(w/2,h/2,w/2,h/2); + ofSetColor(0,255,0); + ofRect(0,h/2,w/2,h/2); + ofRect(w/2,0,w/2,h/2); + */ + + rb1.begin(); + + //can be done with texture offset? + + int startx=((w-(w*fscale))/2)+xshift; + while (startx>0) startx-=(w*fscale); + int starty=((h-(h*fscale))/2)+yshift; + while (starty>0) starty-=(h*fscale); + + for (int i=startx;i0) { + 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: + if (list.lock()) { //if playlist is loaded + if (list.layers.find(note)!=list.layers.end()) { + ofPushMatrix(); + ofTranslate(w/2,h/2); + ofScale(scale,scale,scale); + ofTranslate(-w/2,-h/2); + if (controlColours) list.layers[note]->draw(a,controllers,w,h,transparentBlack,colShift); + else list.layers[note]->draw(a,w,h,colShift); + ofPopMatrix(); + } + list.unlock(); + } + break; + } + } + + rb1.end(); + + rb2.begin(); + ofSetColor(255,255,255); + rb1.draw(0,0); + rb2.end(); + + ofPushMatrix(); + ofTranslate(x+(w/2),y+(h/2)); + ofRotate(r); + //ofTranslate(-abs(sin(ofDegToRad(r))*h/2)-abs(cos(ofDegToRad(r))*w/2),-abs(sin(ofDegToRad(r))*w/2)-abs(cos(ofDegToRad(r))*h/2)); + ofTranslate(ox,oy); + + rb2.draw(0,0); + + ofPopStyle(); + + ofPopMatrix(); + +} + +viewport::~viewport() +{ + //dtor +} diff --git a/liveengineUnmapped/src/viewport.h b/liveengineUnmapped/src/viewport.h new file mode 100755 index 0000000..6d8f4bb --- /dev/null +++ b/liveengineUnmapped/src/viewport.h @@ -0,0 +1,34 @@ +#ifndef VIEWPORT_H +#define VIEWPORT_H + +#include "ofMain.h" +#include "playlist.h" + +#define NUM_NOTES 64 +#define START_NOTE 36 +#define NUM_CONTROLLERS 6 +#define START_CONTROLLER 102 + +#define NOTHING 0 +#define BLOCKS 1 +#define LIST 2 + + + +class viewport +{ + public: + viewport(); + viewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy); + void setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy); + void draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale,float colShift); + virtual ~viewport(); + ofFbo rb1,rb2; + float r; + protected: + private: + int x, y,w,h,ox,oy; + +}; + +#endif // VIEWPORT_H -- cgit v1.2.3