diff options
Diffstat (limited to 'liveengineUnmapped/src')
| -rwxr-xr-x | liveengineUnmapped/src/layers.cpp | 152 | ||||
| -rwxr-xr-x | liveengineUnmapped/src/layers.h | 97 | ||||
| -rwxr-xr-x | liveengineUnmapped/src/playlist.cpp | 76 | ||||
| -rwxr-xr-x | liveengineUnmapped/src/testApp.cpp | 173 | ||||
| -rwxr-xr-x | liveengineUnmapped/src/testApp.h | 4 |
5 files changed, 187 insertions, 315 deletions
diff --git a/liveengineUnmapped/src/layers.cpp b/liveengineUnmapped/src/layers.cpp index a0fb213..36de3b1 100755 --- a/liveengineUnmapped/src/layers.cpp +++ b/liveengineUnmapped/src/layers.cpp @@ -1,60 +1,60 @@ #include "layers.h"
-svglayer::svglayer() { - xo=0;yo=0; +svglayer::svglayer() {
+ xo=0;yo=0;
}
svglayer::svglayer(string _f)
{
load(_f);
}
-void svglayer::load(string _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;i<svg.getNumPath();i++) { - fills.push_back(svg.getPathAt(i).getFillColor()); + 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());
- } + }
isLoaded= (svg.getNumPath()>0);
}
void svglayer::getCentre(int cx,int cy) {
if (svg.getNumPath()>0) {
- xo=(cx-svg.getWidth())/2;
- yo=(cy-svg.getHeight())/2;
+ xo=cx-256; //(cx-svg.getWidth())/2;
+ yo=cy-256; //(cy-svg.getHeight())/2;
}
}
void svglayer::draw(float a,int cx,int cy,float colShift) {
- getCentre(cx,cy); + getCentre(cx,cy);
for (int i=0;i<svg.getNumPath();i++) {
ofColor c=fills[i]*a;
if (colShift>0.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); + }
+ 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); + getCentre(cx,cy);
//draw layers tinted by controllers
- for (int i=0;i<svg.getNumPath();i++) { - float h=fmod(fills[i].getHue()+colShift,255.0f); - float ha=h/42.7; //0-5 - int h1=(((int)ha)+2)%6; - int h2=h1+1; - float f2=ha-h1; - float f1=1.0f-f2; - //if (transparentBlack) printf("transparent black draw %f\n",(a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0))); - - svg.getPathAt(i).setFillColor(fills[i]*a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0));; - if (!transparentBlack||(a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0))>0.1) { - svg.getPathAt(i).draw(xo,yo); - } + for (int i=0;i<svg.getNumPath();i++) {
+ float h=fmod(fills[i].getHue()+colShift,255.0f);
+ float ha=h/42.7; //0-5
+ int h1=(((int)ha)+2)%6;
+ int h2=h1+1;
+ float f2=ha-h1;
+ float f1=1.0f-f2;
+ //if (transparentBlack) printf("transparent black draw %f\n",(a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0)));
+
+ svg.getPathAt(i).setFillColor(fills[i]*a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0));;
+ if (!transparentBlack||(a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0))>0.1) {
+ svg.getPathAt(i).draw(xo,yo);
+ }
}
}
*/
@@ -65,42 +65,42 @@ void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transp float layerspercontroller=((float)svg.getNumPath())/6.0f;
for (int i=0;i<6;i++) {
- //for (int j=(int)((i+1)*layerspercontroller)-1;j>(int)(i*layerspercontroller);j--) { + //for (int j=(int)((i+1)*layerspercontroller)-1;j>(int)(i*layerspercontroller);j--) {
for (int j=(int)(i*layerspercontroller);j<(int)((i+1)*layerspercontroller);j++) {
svg.getPathAt(j).setFillColor(fills[j]*a*(((float)controllers[5-i])/127.0f)); //try to reverse order of these
if (!transparentBlack||((a*controllers[5-i])/127.0f)>0.1) {
svg.getPathAt(j).draw(xo,yo);
}
}
- } + }
//printf("counted %i layers of %i\n",(int)(6*layerspercontroller),svg.getNumPath());
-} +}
svglayer::~svglayer()
{
//dtor
-} - -//------------------------------------------------------------------------ -imglayer::imglayer() { - //sprite.setUseTexture(false); +}
+
+//------------------------------------------------------------------------
+imglayer::imglayer() {
+ //sprite.setUseTexture(false);
}
imglayer::imglayer(string _filename,int _frames,int _start,float _rate,int n, int e){
load(_filename,_frames,_start,_rate,n,e);
}
-void imglayer::load(string _filename,int _frames,int _start,float _rate,int n, int e){ - startNote=n; +void imglayer::load(string _filename,int _frames,int _start,float _rate,int n, int e){
+ startNote=n;
endNote=e;
sprite.load(_filename,_frames,_start);
sprite.setFrameRate(_rate);
}
- -void imglayer::draw(float a,int cx,int cy,float colShift) { +
+void imglayer::draw(float a,int cx,int cy,float colShift) {
//if (sprite.isAllocated()) if (!sprite.isUsingTexture()) sprite.setUseTexture(true); //has to be done from the main thread? still doesn't work
- +
sprite.update();
int x,y,w,h;
if ((((float)cx)/cy)<(((float)sprite.getWidth())/sprite.getHeight())){
@@ -115,25 +115,25 @@ void imglayer::draw(float a,int cx,int cy,float colShift) { w=((float)cy)*(((float)sprite.getWidth())/sprite.getHeight());
x=(cx-w)/2;
}
- ofEnableAlphaBlending(); + ofEnableAlphaBlending();
sprite.draw(x,y,w,h);
ofDisableAlphaBlending();
-} - -void imglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) { +}
+
+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);
}
void imglayer::setNote(int note)
-{ - //is called rerpeatedly no startNote,endNote +{
+ //is called rerpeatedly no startNote,endNote
//printf("note %i (%i - %i)\n",note,startNote,endNote);
if ((startNote<=note)&&(endNote>=note)) {
if (!sprite.getIsPlaying()) {
sprite.play();
- } + }
//printf("triggered frame %i of %i\n",(int)(((((float)note-startNote)/((float)endNote-startNote)))*sprite.getTotalFrames()),sprite.getTotalFrames());
sprite.setCurrentFrame((int)(((((float)note-startNote)/((float)endNote-startNote)))*sprite.getTotalFrames()));
//printf("movie %i (%i - %i) frame: %i\n",note,startNote,endNote,(int)(((((float)note-startNote)/((float)endNote-startNote)))*mov.getTotalNumFrames()));
@@ -144,20 +144,20 @@ void imglayer::setNote(int note) }
}
-}; +};
imglayer::~imglayer()
{
//sprite.setUseTexture(false); //free texture
-} -//------------------------------------------------------------------------ -videolayer::videolayer() { - //sprite.setUseTexture(false); +}
+//------------------------------------------------------------------------
+videolayer::videolayer() {
+ //sprite.setUseTexture(false);
}
videolayer::videolayer(string _f,int n,int e,float s)
-{ - startNote=n; +{
+ startNote=n;
endNote=e;
speed=s;
load(_f);
@@ -174,8 +174,8 @@ void videolayer::load(string _f){ printf("%s %s %i bpp\n",success?"loaded":"not loaded",_f.c_str(),success?mov.getPixelsRef().getBytesPerPixel():0);
}
-void videolayer::draw(float a,int cx,int cy,float colShift) { - if (mov.isPlaying()) { +void videolayer::draw(float a,int cx,int cy,float colShift) {
+ if (mov.isPlaying()) {
mov.update();
//unsigned char *pix=mov.getPixels();
//for (int i=0;i<mov.getWidth()*mov.getHeight()*4;i+=4) pix[i+3]=(pix[i]>>2)+(pix[i+1]>>1)+(pix[i+2]>>2);
@@ -194,34 +194,34 @@ void videolayer::draw(float a,int cx,int cy,float colShift) { }
ofEnableAlphaBlending();
mov.draw(x,y,w,h);
- ofDisableAlphaBlending(); + ofDisableAlphaBlending();
}
-} - -void videolayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) { +}
+
+void videolayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) {
draw(a,cx,cy,colShift);
-} - -void videolayer::setNote(int note) +}
+
+void videolayer::setNote(int note)
{
- - if ((startNote<=note)&&(endNote>=note)) { +
+ if ((startNote<=note)&&(endNote>=note)) {
if (!mov.isPlaying()) {
//printf("starting movie!\n");
mov.setUseTexture(true);
mov.play();
mov.setSpeed(speed);
- } + }
mov.setFrame((int)(((((float)note-startNote)/((float)endNote-startNote)))*mov.getTotalNumFrames()));
- //printf("movie %i (%i - %i) frame: %i\n",note,startNote,endNote,(int)(((((float)note-startNote)/((float)endNote-startNote)))*mov.getTotalNumFrames())); - } - else { - if (mov.isPlaying()) { - mov.stop(); - } - } - -}; + //printf("movie %i (%i - %i) frame: %i\n",note,startNote,endNote,(int)(((((float)note-startNote)/((float)endNote-startNote)))*mov.getTotalNumFrames()));
+ }
+ else {
+ if (mov.isPlaying()) {
+ mov.stop();
+ }
+ }
+
+};
videolayer::~videolayer()
diff --git a/liveengineUnmapped/src/layers.h b/liveengineUnmapped/src/layers.h index f8ed650..0ddca29 100755 --- a/liveengineUnmapped/src/layers.h +++ b/liveengineUnmapped/src/layers.h @@ -1,7 +1,7 @@ #ifndef SVGLAYER_H
#define SVGLAYER_H
-#include "ofxSVGTiny.h" +#include "ofxSVGTiny.h"
#include "ofMain.h"
#include "ofxSprite.h"
@@ -12,13 +12,13 @@ class 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;}; + 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;};
virtual void setNote(int note) {};
string name;
int startNote,endNote;
- protected: + protected:
bool isLoaded;
private:
@@ -31,31 +31,31 @@ class svglayer: public layer svglayer(string _f);
virtual ~svglayer();
void load(string _f);
- void draw(float a,int cx,int cy,float colShift); + 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 <ofColor> fills; - vector <ofColor> strokes; + ofxSVGTiny svg;
+ vector <ofColor> fills;
+ vector <ofColor> strokes;
float xo,yo;
};
- -class sunkenSprite: public ofxSprite { - public: +
+class sunkenSprite: public ofxSprite {
+ public:
float playhead,frameRate;
- void setFrameRate(float frameRate) { this->frameRate = frameRate;}; - void play() { - startTime=ofGetElapsedTimef(); - ofxSprite::play(); - } - void update() { + void setFrameRate(float frameRate) { this->frameRate = frameRate;};
+ void play() {
+ startTime=ofGetElapsedTimef();
+ ofxSprite::play();
+ }
+ void update() {
if (!getIsPlaying()) return;
- playhead=fmod(speed * frameRate * (ofGetElapsedTimef()-startTime),(float)getTotalFrames()); - ofxSprite::setCurrentFrame(playhead); - - } + playhead=fmod(speed * frameRate * (ofGetElapsedTimef()-startTime),(float)getTotalFrames());
+ ofxSprite::setCurrentFrame(playhead);
+
+ }
void setCurrentFrame(float frame) {
//this idea doesn't work - fucks up when frameRate is 0 -
//need to rethink
@@ -64,7 +64,7 @@ class sunkenSprite: public ofxSprite { //this still might not be not entirely correct
if (frameRate>0) startTime-=(frame-pos) / ((float)(frameRate * speed ));
//printf("sunkensprite setting frame %i of %i\n",(int)frame,getTotalFrames());
- //printf("1 checking frame %i of %i\n",(int)frame,getTotalFrames()); + //printf("1 checking frame %i of %i\n",(int)frame,getTotalFrames());
ofxSprite::setCurrentFrame(frame);
/*
pos = frame;
@@ -75,28 +75,29 @@ class sunkenSprite: public ofxSprite { while (pos>=totalFrames) pos -= totalFrames;
} else { pos = totalFrames-.00001f; isPlaying=false; }
printf("set movie frame %i of %i\n",(int)pos,totalFrames);
- */ - } - void draw(int x,int y,int w,int h) { - - int f=playhead; - float fr=fmod(playhead,1.0); - ofSetColor(255,255,255,(1.0-fr)*255); - //not always? - getImageAtFrame(f).setUseTexture(true); + */
+ }
+ void draw(int x,int y,int w,int h) {
+
+ int f=playhead;
+ float fr=fmod(playhead,1.0);
+ ofSetColor(255,255,255,(1.0-fr)*255);
+ //not always?
+ getImageAtFrame(f).setUseTexture(true);
getImageAtFrame(f).reloadTexture();
- getImageAtFrame(f).draw(x,y,w,h); + getImageAtFrame(f).draw(x,y,w,h);
ofSetColor(255,255,255,fr*255);
- f=(f+1)%getTotalFrames(); + f=(f+1)%getTotalFrames();
getImageAtFrame(f).setUseTexture(true);
getImageAtFrame(f).reloadTexture();
- getImageAtFrame(f).draw(x,y,w,h); - } - - private: - float startTime; - -}; + getImageAtFrame(f).draw(x,y,w,h);
+ }
+
+ private:
+ float startTime;
+ float speed,pos; //will this override the base class speed correctly?
+
+};
class imglayer: public layer
{
@@ -105,14 +106,14 @@ class imglayer: public layer imglayer(string _f,int _frames=1,int _start=1,float _rate=0,int note=0,int endnote=0);
virtual ~imglayer();
void load(string _filename,int _frames=1,int _start=1,float _rate=0.0,int note=0,int endnote=0);
- void draw(float a,int cx,int cy,float colShift); + 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);
void setNote(int n);
protected:
private:
sunkenSprite sprite;
-}; - +};
+
class videolayer: public layer
{
public:
@@ -120,11 +121,11 @@ class videolayer: public layer videolayer(string _f,int n,int e,float s);
virtual ~videolayer();
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); - void setNote(int n); + 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);
+ void setNote(int n);
protected:
- private: + private:
float speed;
ofVideoPlayer mov;
};
diff --git a/liveengineUnmapped/src/playlist.cpp b/liveengineUnmapped/src/playlist.cpp index 61987d1..ce3beba 100755 --- a/liveengineUnmapped/src/playlist.cpp +++ b/liveengineUnmapped/src/playlist.cpp @@ -1,18 +1,18 @@ -#include "playlist.h"
-
-playlist::playlist()
+#include "playlist.h" + +playlist::playlist() { name=""; thumbnail.allocate(128,128,GL_RGB); - thumbnailed=false;
+ 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());
+ 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??? @@ -29,38 +29,38 @@ void playlist::threadedFunction(){ unlock(); printf("unlocking thread\n"); } -}
+} void playlist::loadLayers(){ int numLayers=0; layers.clear(); name=XML.getAttribute("playlist", "name", ""); float speed=XML.getAttribute("playlist", "speed", 0); - 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: \n",s.c_str());
- layers[XML.getAttribute("svglayer", "note", 0,i)]=new svglayer(XML.getAttribute("svglayer", "file", "",i));
+ 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: \n",s.c_str()); + layers[XML.getAttribute("svglayer", "note", 0,i)]=new svglayer(XML.getAttribute("svglayer", "file", "",i)); } - thumbnailed=false;
+ thumbnailed=false; } - numLayers=XML.getNumTags("movlayer");
- if(numLayers) {
- for (int i=0;i<numLayers;i++) {
- string s=XML.getAttribute("movlayer", "file", "",i);
+ numLayers=XML.getNumTags("movlayer"); + if(numLayers) { + for (int i=0;i<numLayers;i++) { + string s=XML.getAttribute("movlayer", "file", "",i); printf("loading %s: \n",s.c_str()); int note=XML.getAttribute("movlayer", "note", 0,i); - int endnote=XML.getAttribute("movlayer", "endnote", 0,i);
+ int endnote=XML.getAttribute("movlayer", "endnote", 0,i); layers[note]=new videolayer(XML.getAttribute("movlayer", "file", "",i),note,endnote,speed); if (endnote>note) { for (int j=note+1;j<endnote;j++) { layers[j]=layers[note]; } - }
+ } } - thumbnailed=false;
+ thumbnailed=false; } numLayers=XML.getNumTags("imglayer"); if(numLayers) { @@ -81,7 +81,7 @@ void playlist::loadLayers(){ } thumbnailed=false; } - XML.popTag();
+ XML.popTag(); } } @@ -106,22 +106,22 @@ void playlist::makeThumbnail(){ 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));
- }
- }
+ 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();
+ XML.popTag(); } } -
-playlist::~playlist()
-{
- //dtor
-}
+ +playlist::~playlist() +{ + //dtor +} diff --git a/liveengineUnmapped/src/testApp.cpp b/liveengineUnmapped/src/testApp.cpp index 91359f8..260b242 100755 --- a/liveengineUnmapped/src/testApp.cpp +++ b/liveengineUnmapped/src/testApp.cpp @@ -45,6 +45,7 @@ void guiWindow::windowMoved(int x,int y){ //-------------------------------------------------------------- void testApp::setup(){ + int midiPort=0; midiChannel=0; if( !XML.loadFile("settings.xml") ){ @@ -119,12 +120,7 @@ void testApp::setup(){ //ofSetVerticalSync(true); deosn't seem effective //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 - */ + ofSetFrameRate(60); rotate=-90; scale=1.0f; @@ -181,7 +177,8 @@ void testApp::setup(){ guiWin->setup(); guiWin->setParent(this); - debug=false; + //debug=true; + } @@ -205,6 +202,8 @@ void testApp::update(){ //-------------------------------------------------------------- void testApp::draw(){ + + float lambda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); int ft=255-(fadetime*((float)fadeScale)*0.1f); @@ -223,135 +222,6 @@ void testApp::draw(){ 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);i<rb1.getWidth()*2;i+=ofGetWidth()) { - for (int j=(yshift>0?yshift-rb1.getHeight():yshift);j<rb1.getHeight()*2;j+=rb1.getHeight()) { - rb2.draw(i,j); - } - } - - float notewidth=rb1.getWidth()/NUM_NOTES; - float noteheight=rb1.getHeight()/NUM_CONTROLLERS; - - - - 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: - 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;i<numLayers;i++) layers[i]->draw(); - 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);i<rb3.getWidth()*2;i+=ofGetWidth()) { - for (int j=(yshift>0?yshift-rb3.getHeight():yshift);j<rb3.getHeight()*2;j+=rb3.getHeight()) { - rb4.draw(i,j); - } - } - - notewidth=rb3.getHeight()/NUM_NOTES; - noteheight=rb3.getWidth()/NUM_CONTROLLERS; - - ofPushMatrix(); - ofTranslate(rb3.getWidth(),rb3.getHeight()/2); - ofRotate(90); - ofTranslate(-rb3.getWidth()/2,-rb3.getHeight()/2); - - 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: - 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;i<numLayers;i++) layers[i]->draw(); - 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); - */ - } //-------------------------------------------------------------- @@ -467,7 +337,7 @@ 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); + string filename="images/"+dragInfo.files[0].substr(sta,len); printf("loading %s\n",filename.c_str()); list.load(filename); @@ -502,9 +372,9 @@ void testApp::toggleFPS(){ showFPS=!showFPS; } -void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){ +void testApp::newMidiMessage(ofxMidiMessage& eventArgs){ if ((midiChannel==0)||(eventArgs.channel==midiChannel)) { - nmidiMessage(eventArgs.status,eventArgs.byteOne,eventArgs.byteTwo); + nmidiMessage(eventArgs.status,eventArgs.bytes[0],eventArgs.bytes[1]); } } @@ -535,17 +405,17 @@ void testApp::nmidiMessage(int event,int data1, int data2) { note=data1; lastnoteTime=ofGetElapsedTimef(); - if (list.lock()&&list.layers.size()) { //if playlist is loaded - map<int, layer*>::iterator itr; - //for(itr = list.layers.begin(); itr != list.layers.end(); ++itr){ - // list.layers[itr->first]->setNote(note); - //} - if (list.layers.find(note)!=list.layers.end()) list.layers[note]->setNote(note); - list.unlock(); - } - if (noteRandomiseColours) { - makeColours(); // - } + if (list.layers.size()&&list.lock()) { //if playlist is loaded + map<int, layer*>::iterator itr; + //for(itr = list.layers.begin(); itr != list.layers.end(); ++itr){ + // list.layers[itr->first]->setNote(note); + //} + if (list.layers.find(note)!=list.layers.end()) list.layers[note]->setNote(note); + list.unlock(); + } + if (noteRandomiseColours) { + makeColours(); // + } randOffs=ofRandom(100.0f); break; case 176: //control change channel 0 @@ -555,5 +425,8 @@ void testApp::nmidiMessage(int event,int data1, int data2) { if (debug) printf("cc: %i %i\n",data1,data2); if (data1>=START_CONTROLLER) controllers[data1-START_CONTROLLER]=data2; } + } + + diff --git a/liveengineUnmapped/src/testApp.h b/liveengineUnmapped/src/testApp.h index 1e56c33..9dd9b62 100755 --- a/liveengineUnmapped/src/testApp.h +++ b/liveengineUnmapped/src/testApp.h @@ -71,7 +71,6 @@ option to randomise colours on each note */ - #define OF_ADDON_USING_OFXMIDIIN @@ -80,7 +79,6 @@ option to randomise colours on each note #include "ofxGui.h" - #include "viewport.h" /* @@ -163,7 +161,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ ofxMidiIn midiIn; - void newMidiMessage(ofxMidiEventArgs& eventArgs); + void newMidiMessage(ofxMidiMessage& eventArgs); playlist list; |
