summaryrefslogtreecommitdiff
path: root/gui/src/ofApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2017-08-31 23:16:52 +0100
committerTim Redfern <tim@getdrop.com>2017-08-31 23:16:52 +0100
commit14da9cce8d665d2872b76909e8abc001a9921297 (patch)
tree872a61f062f3353e664c080c9f63c7ead3f53899 /gui/src/ofApp.cpp
parent4637492e2a31c78f9109941638171d05e4007c4c (diff)
additive no good
Diffstat (limited to 'gui/src/ofApp.cpp')
-rw-r--r--gui/src/ofApp.cpp101
1 files changed, 98 insertions, 3 deletions
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp
index 11ca50d..d99300c 100644
--- a/gui/src/ofApp.cpp
+++ b/gui/src/ofApp.cpp
@@ -4,13 +4,28 @@
//--------------------------------------------------------------
void ofApp::setup(){
- if (dmx.connect("tty.usbserial-EN143965")){
+ if (dmx.connect("tty.usbserial-ENP6ESY9")){
printf("DMX connected!\n");
- map.push_back(dmxMap(&dmx,1,2,3,100,100));
+ //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
+
+ map.push_back(dmxMap(&dmx,66,67,68,65,0.1,0.1));
+ map.push_back(dmxMap(&dmx,72,73,74,71,0.5,0.1));
+ map.push_back(dmxMap(&dmx,78,79,80,77,0.9,0.1));
}
else printf("DMX not connected.\n");
+ midiIn.listPorts();
+ midiIn.openPort(0);
+ midiIn.addListener(this);
+
+ dmxIntensity=0;
}
//--------------------------------------------------------------
@@ -29,7 +44,7 @@ void ofApp::updateOutput(ofEventArgs & args){
if (dmx.isConnected()){
for (auto m=map.begin();m!=map.end();m++){
- m->update();
+ m->update(dmxIntensity);
}
}
@@ -50,6 +65,86 @@ void ofApp::drawOutput(ofEventArgs & args){
}
//--------------------------------------------------------------
+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
+
+ if (msg.channel==1&&msg.control==1){
+ //pot 0
+ //from .9 to 1.1 but reaching numbers very near 1
+
+ images.decayFactor=1.0 - (pow(2.0f,((float)msg.value-64)/8)/pow(2,8));
+
+ //printf("Val %i, decay: %f \n",msg.value,sf);
+
+ }
+ if (msg.channel==1&&msg.control==65){
+ //top button 0
+ }
+ if (msg.channel==1&&msg.control==73){
+ //bottom button 0
+ }
+ if (msg.channel==1&&msg.control==81){
+ //fader 0
+ dmxIntensity=msg.value*2;
+ }
+
+//column 1 for image set 0
+
+ if (msg.channel==1&&msg.control==2){
+ //pot 1
+ }
+ if (msg.channel==1&&msg.control==66){
+ //top button 1
+ images.additive=(msg.value==127);
+ }
+ if (msg.channel==1&&msg.control==74){
+ //bottom button 1
+ }
+ if (msg.channel==1&&msg.control==82){
+ //fader 1
+ images.intensity=((float)msg.value)/127.0f;
+ }
+
+}
+
+//--------------------------------------------------------------
void ofApp::keyPressed(ofKeyEventArgs &keyargs){
images.keyPressed(keyargs);
}