diff options
Diffstat (limited to 'liveengineUnmapped/src/testApp.cpp')
| -rwxr-xr-x | liveengineUnmapped/src/testApp.cpp | 173 |
1 files changed, 23 insertions, 150 deletions
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; } + } + + |
