From c37376ce7631fa94eb5dd58b9d806eeb1f2f6b5a Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Mon, 28 Apr 2014 18:34:30 +0100 Subject: [PATCH] -Hacked APC footswitch scene++ functionality into GenericMIDI --- src/controller/genericmidi.cxx | 56 +++++++++++++++++++++++++++++++++- src/controller/genericmidi.hxx | 5 +++ src/gridlogic.hxx | 3 +- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/controller/genericmidi.cxx b/src/controller/genericmidi.cxx index 2da3e8d..4177aa1 100644 --- a/src/controller/genericmidi.cxx +++ b/src/controller/genericmidi.cxx @@ -42,6 +42,29 @@ GenericMIDI::GenericMIDI(int waste, std::string n) : name = n; registerMidiPorts( name ); stat = CONTROLLER_OK; + + setFootswitchToNextScene( 0 ); +} + + +void GenericMIDI::setFootswitchToNextScene(int v) +{ + LUPPP_NOTE("Set Footswitch to %i", v ); + if ( v == 0 ) + { + footswitchNextScene = false; + footswitchPrevScene = false; + } + else if ( v > 0 ) + { + footswitchNextScene = true; + footswitchPrevScene = false; + } + else + { + footswitchNextScene = false; + footswitchPrevScene = true; + } } void GenericMIDI::setName(std::string n) @@ -441,6 +464,22 @@ void GenericMIDI::midi(unsigned char* midi) writeToGuiRingbuffer( &e2 ); } + if ( status == 0x90 && data == 0x64 ) // nudge + + { + // footpedal to scene++ + setFootswitchToNextScene( 1 ); + } + else if ( status == 0x90 && data == 0x65 ) // nudge + { + // footpedal to scene-- + setFootswitchToNextScene( -1 ); + } + else if ( status == 0x90 && data == 0x60 ) // > on bank select: clear scene + { + // footpedal to special clip + setFootswitchToNextScene( 0 ); + } + // iterate over bindings, execute binding action if matches for(unsigned int i = 0; i < midiToAction.size(); i++) { @@ -465,7 +504,22 @@ void GenericMIDI::midi(unsigned char* midi) break; case Event::GRID_SELECT_CLIP_EVENT: - jack->getGridLogic()->selectedTrackSceneEvent( value ); + // hack to do scene ++ / -- with footswitch + if ( footswitchNextScene && value > 0.5 ) // avoid note offs + { + cout << "footswitch next scene *now*" << endl; + jack->getGridLogic()->launchScene( jack->getGridLogic()->getCurrentScene() + 1 ); + } + else if ( footswitchPrevScene && value > 0.5 ) + { + cout << "footswitch prev scene *now*" << endl; + jack->getGridLogic()->launchScene( jack->getGridLogic()->getCurrentScene() - 1 ); + } + else + { + cout << "footswitch special clip action now" << endl; + jack->getGridLogic()->selectedTrackSceneEvent( value ); + } break; case Event::GRID_SELECT_CLIP_ENABLE: jack->getGridLogic()->setSelectTrackScene( b->active ); diff --git a/src/controller/genericmidi.hxx b/src/controller/genericmidi.hxx index 8c339d1..11482bd 100644 --- a/src/controller/genericmidi.hxx +++ b/src/controller/genericmidi.hxx @@ -76,6 +76,11 @@ class GenericMIDI : public Controller, public MidiIO void trackSend(int t, int send, float v); void trackSendActive(int t, int send, bool a); + /// footswitch -> scene launch controls + void setFootswitchToNextScene(int v); + bool footswitchNextScene; + bool footswitchPrevScene; + void reset(); diff --git a/src/gridlogic.hxx b/src/gridlogic.hxx index e6b7869..bbf9dfe 100644 --- a/src/gridlogic.hxx +++ b/src/gridlogic.hxx @@ -66,6 +66,7 @@ class GridLogic : public TimeObserver /// master controls, launches a horizontal scene with one event void launchScene( int scene ); + int getCurrentScene(){return sceneLaunch;} int getLaunchedScene(); /// selected track functions @@ -100,7 +101,7 @@ class GridLogic : public TimeObserver /// holds last scene launch int sceneLaunch; - /// holds selected track / scene + /// holds selected track / scene for special clip bool sampleTrackScene; // turn on to have selected clip, press event acted on int selectedTrack; int selectedScene;