#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;iupdate(); } //-------------------------------------------------------------- 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); float notewidth=ofGetWidth()/NUM_NOTES; float noteheight=ofGetHeight()/NUM_CONTROLLERS; float lamda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); if (note>0) { 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: ofPushMatrix(); //ofScale(sin(ofGetElapsedTimef())+1.1,sin(ofGetElapsedTimef())+1.1); if (layers.find(note)!=layers.end()) layers[note]->draw(lamda); ofPopMatrix(); break; } } //for (int i=0;idraw(); ofSetColor(255,255,255); if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); } //-------------------------------------------------------------- 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++; } } //-------------------------------------------------------------- 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){ } 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); //} printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo); note=eventArgs.byteOne; lastnoteTime=ofGetElapsedTimef(); break; case 176: //control change channel 0 //for (int i=0;imix==eventArgs.byteOne) layers[i]->setMixAmt(((float)eventArgs.byteTwo)/127.0f); //} printf("cc: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo); controllers[eventArgs.byteOne-START_CONTROLLER]=eventArgs.byteTwo; } } }