#include "ofApp.h" #include "glew.h" //-------------------------------------------------------------- void ofApp::setup(){ if (dmx.connect("tty.usbserial-ENP6ESY9",120)){ printf("DMX connected!\n"); //sbx1 - 16chan at 1 //sbx2 - 16chan at 16 //sbx3 - 16chan at 32 //sbx4 - 16chan at 48 //par1 - shutter, intensirty, R, G, B, white at 64 //par2 - shutter, intensirty, R, G, B, white at 70 //par3 - shutter, intensirty, R, G, B, white at 76 // R, G, B, white, dimmer, shutter map.push_back(USBdmxMap(&dmx,80,0.1,0.1)); map.push_back(USBdmxMap(&dmx,90,0.5,0.1)); map.push_back(USBdmxMap(&dmx,100,0.9,0.1)); map.push_back(USBdmxMap(&dmx,110,0.5,0.5)); } else printf("USB DMX not connected.\n"); //artnet.setup("10.7.186.17"); //memset(dmx_data,0,512); midiIn.listPorts(); midiIn.openPort(0); midiIn.addListener(this); dmxIntensity=255; next_update=ofGetElapsedTimef()+0.1f; sets.push_back(chainImageSet()); sets.push_back(chainImageSet()); selected_set=0; sets[0].init(); sets[1].init(); } //-------------------------------------------------------------- void ofApp::update(){ std::stringstream strm; strm << "fps: " << ofGetFrameRate(); ofSetWindowTitle(strm.str()); } void ofApp::updateOutput(ofEventArgs & args){ for (int i=0;inext_update){ //if (dmx.isConnected()&&()){ for (auto m=map.begin();m!=map.end();m++){ m->update(dmxIntensity); } //artnet.sendDmx("10.7.175.170", dmx_data, 512); next_update=ofGetElapsedTimef()+0.1f; } } //-------------------------------------------------------------- void ofApp::exit() { // clean up midiIn.closePort(); midiIn.removeListener(this); } //-------------------------------------------------------------- /* midi - chan 1 bank 1 - program controls faders: cc 81 - 88 pots: cc 1 - 8 top buttons: cc 65 - 72 (0/127) next buttons: cc 73 - 80 (0/127) bank 2 - channel controls fader cc 7 / pot cc 10 channels 1-8 bank1 fader1 - light intensity pot 1 - zoom decay */ void ofApp::newMidiMessage(ofxMidiMessage& msg) { //printf("Midi: %i %i %i\n",msg.channel,msg.control,msg.value); //column 0 for general controls int offet=0; if (msg.channel==1&&msg.control==1+offet){ //pot 0 //from .9 to 1.1 but reaching numbers very near 1 float signed_value=(float)msg.value-64; if (signed_value<0){ sets[0].decayFactor=1.0 + (pow(4.0f,abs(signed_value)/8)/pow(4,8)); } else { sets[0].decayFactor=1.0 - (pow(4.0f,(signed_value)/8)/pow(4,8)); } sets[1].decayFactor=sets[0].decayFactor; printf("Val %i, decay: %f \n",msg.value,sets[0].decayFactor); } if (msg.channel==1&&msg.control==65+offet){ //top button 0 } if (msg.channel==1&&msg.control==73+offet){ //bottom button 0 } if (msg.channel==1&&msg.control==81+offet){ //fader 0 dmxIntensity=msg.value*2; printf("Val %i, dmx intensity: %i \n",msg.value,dmxIntensity); } //column 5 for image set 0 offet=4; if (msg.channel==1&&msg.control==1+offet){ //pot 1 } if (msg.channel==1&&msg.control==65+offet){ //top button 1 sets[0].additive=(msg.value==127); } if (msg.channel==1&&msg.control==73+offet){ //bottom button 1 } if (msg.channel==1&&msg.control==81+offet){ //fader 1 sets[0].intensity=((float)msg.value)/127.0f; } //column 6 for image set 1 offet=5; if (msg.channel==1&&msg.control==1+offet){ //pot 1 } if (msg.channel==1&&msg.control==65+offet){ //top button 1 sets[0].additive=(msg.value==127); } if (msg.channel==1&&msg.control==73+offet){ //bottom button 1 } if (msg.channel==1&&msg.control==81+offet){ //fader 1 sets[1].intensity=((float)msg.value)/127.0f; } //column 1 for more controls offet=1; if (msg.channel==1&&msg.control==1+offet){ //pot 1 for (int i=0;i