9
9
*/
10
10
11
11
// #define CALLBACK_DIAGNOSTICS
12
- // #define DEBUG_DIAGNOSTICS
13
- // #define BASIC_DIAGNOSTICS
12
+ #define DEBUG_DIAGNOSTICS
13
+ #define BASIC_DIAGNOSTICS
14
14
15
15
#include < string>
16
16
#include < sstream>
@@ -229,9 +229,6 @@ class NiMidiSurface: public BaseSurface {
229
229
this ->_sendCc (CMD_LOOP, 0 );
230
230
}
231
231
}
232
-
233
- // ToDo: add button lights for 4D encoder navigation (blue LEDs)
234
-
235
232
236
233
virtual void SetTrackListChange () override {
237
234
#ifdef CALLBACK_DIAGNOSTICS
@@ -288,7 +285,19 @@ class NiMidiSurface: public BaseSurface {
288
285
this ->_bankStart = id - numInBank;
289
286
if (this ->_bankStart != oldBankStart) {
290
287
// Update everything
291
- this ->_allMixerUpdate (); // Note: this will also update the g_muteStateBank and g_soloStateBank caches
288
+ this ->_allMixerUpdate (); // Note: this will also update 4D track nav LEDs, g_muteStateBank and g_soloStateBank caches
289
+ }
290
+ else {
291
+ // Update 4D Encoder track navigation LEDs
292
+ int numTracks = CSurf_NumTracks (false );
293
+ int trackNavLights = 3 ; // left and right on
294
+ if (g_trackInFocus < 2 ) {
295
+ trackNavLights &= 2 ; // left off
296
+ }
297
+ if (g_trackInFocus >= numTracks) {
298
+ trackNavLights &= 1 ; // right off
299
+ }
300
+ this ->_sendCc (CMD_NAV_TRACKS, trackNavLights);
292
301
}
293
302
if (g_trackInFocus != 0 ) {
294
303
// Mark selected track as available and update Mute and Solo Button lights
@@ -556,6 +565,7 @@ class NiMidiSurface: public BaseSurface {
556
565
this ->_onBankSelect (convertSignedMidiValue (value));
557
566
break ;
558
567
case CMD_NAV_CLIPS:
568
+ // ToDo: Consider to also update the 4D encoder LEDs depending on marker presence and playhead position
559
569
// Value is -1 or 1.
560
570
Main_OnCommand (value == 1 ?
561
571
40173 : // Markers: Go to next marker/project end
@@ -715,7 +725,7 @@ class NiMidiSurface: public BaseSurface {
715
725
int numInBank = 0 ;
716
726
this ->_bankEnd = this ->_bankStart + BANK_NUM_TRACKS - 1 ; // avoid ambiguity: track counting always zero based
717
727
int numTracks = CSurf_NumTracks (false );
718
- // Set bank select button lights
728
+ // Update bank select button lights
719
729
// ToDo: Consider optimizing this piece of code
720
730
int bankLights = 3 ; // left and right on
721
731
if (numTracks < BANK_NUM_TRACKS) {
@@ -736,6 +746,16 @@ class NiMidiSurface: public BaseSurface {
736
746
this ->_sendSysex (CMD_TRACK_AVAIL, 0 , i);
737
747
}
738
748
}
749
+ // Update 4D Encoder track navigation LEDs
750
+ int trackNavLights = 3 ; // left and right on
751
+ if (g_trackInFocus < 2 ) {
752
+ trackNavLights &= 2 ; // left off
753
+ }
754
+ if (g_trackInFocus >= numTracks) {
755
+ trackNavLights &= 1 ; // right off
756
+ }
757
+ this ->_sendCc (CMD_NAV_TRACKS, trackNavLights);
758
+ // Update current bank
739
759
for (int id = this ->_bankStart ; id <= this ->_bankEnd ; ++id, ++numInBank) {
740
760
MediaTrack* track = CSurf_TrackFromID (id, false );
741
761
if (!track) {
0 commit comments