Skip to content

Commit 56b0b29

Browse files
committed
Experimental support for fixed lanes
1 parent 6ccc1b7 commit 56b0b29

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

src/reaper_osara.cpp

+58-4
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,19 @@ bool isPosInItem(double pos, MediaItem* item) {
516516
return (start <= pos && pos <= end);
517517
}
518518

519-
bool isFreeItemPositioningEnabled(MediaTrack* track) {
520-
return *(bool*)GetSetMediaTrackInfo(track, "B_FREEMODE", nullptr);
519+
enum class FreeMode {
520+
none,
521+
free,
522+
fixed
523+
};
524+
525+
FreeMode getTrackFreeMode(MediaTrack* track) {
526+
int* freeMode = (int*)GetSetMediaTrackInfo(track, "I_FREEMODE", nullptr);
527+
if(freeMode) {
528+
return static_cast<FreeMode>(*freeMode);
529+
} else {// Reaper before version 7
530+
return *(bool*)GetSetMediaTrackInfo(track, "B_FREEMODE", nullptr) ? FreeMode::free : FreeMode::none;
531+
}
521532
}
522533

523534
const char* automationModeAsString(int mode) {
@@ -726,11 +737,13 @@ const char* (*NF_GetSWSTrackNotes)(MediaTrack* track) = nullptr;
726737
*/
727738

728739
bool shouldMoveToAutoItem = false;
740+
int trackFixedLane = -1;
729741

730742
void postGoToTrack(int command, MediaTrack* track) {
731743
fakeFocus = FOCUS_TRACK;
732744
selectedEnvelopeIsTake = false;
733745
shouldMoveToAutoItem = false;
746+
trackFixedLane = -1;
734747
SetCursorContext(0, NULL);
735748
if (!track)
736749
return;
@@ -830,8 +843,19 @@ void postGoToTrack(int command, MediaTrack* track) {
830843
s << " " << format(translate_plural("{} item", "{} items", itemCount),
831844
itemCount);
832845
}
833-
if (isFreeItemPositioningEnabled(track)) {
834-
s << " " << translate("free item positioning");
846+
switch (getTrackFreeMode(track)) {
847+
case FreeMode::free: {
848+
s << " " << translate("free item positioning");
849+
break;
850+
}
851+
case FreeMode::fixed: {
852+
int laneCount = *(int*)GetSetMediaTrackInfo(track, "I_NUMFIXEDLANES", nullptr);
853+
s << " " << format(
854+
translate_plural("{} Fixed item lane", "{} fixed item lanes", laneCount), laneCount);
855+
break;
856+
}
857+
case FreeMode::none:
858+
break;
835859
}
836860
}
837861
int count;
@@ -2868,6 +2892,9 @@ void moveToItem(int direction, bool clearSelection=true, bool select=true) {
28682892
pos = *(double*)GetSetMediaItemInfo(item, "D_POSITION", NULL);
28692893
if (direction == 1 ? pos < cursor : pos > cursor)
28702894
continue; // Not the right direction.
2895+
if (trackFixedLane >= 0 && (int)GetMediaItemInfo_Value(item, "I_FIXEDLANE") != trackFixedLane){
2896+
continue; // skip item not in focused lane
2897+
}
28712898
currentItem = item;
28722899
if ((clearSelection || select) && makeUndoPoint)
28732900
Undo_BeginBlock();
@@ -4202,6 +4229,31 @@ void cmdReportRegionMarkerItems(Command* command) {
42024229
}
42034230
}
42044231

4232+
void MoveToFixedLane (int direction) {
4233+
MediaTrack* track = GetLastTouchedTrack();
4234+
if (getTrackFreeMode(track) != FreeMode::fixed) {
4235+
outputMessage("Track not in fixed lane mode");
4236+
return;
4237+
}
4238+
int laneCount = (int)GetMediaTrackInfo_Value(track, "I_NUMFIXEDLANES");
4239+
trackFixedLane += direction;
4240+
if (trackFixedLane < 0) {
4241+
trackFixedLane = laneCount-1;
4242+
}
4243+
if (trackFixedLane >= laneCount) {
4244+
trackFixedLane = 0;
4245+
}
4246+
outputMessage(format(translate("Lane {}"), trackFixedLane + 1));
4247+
}
4248+
4249+
void cmdNextLane(Command* cmd) {
4250+
MoveToFixedLane(1);
4251+
}
4252+
4253+
void cmdPreviousLane(Command* cmd) {
4254+
MoveToFixedLane(-1);
4255+
}
4256+
42054257
#define DEFACCEL {0, 0, 0}
42064258

42074259
Command COMMANDS[] = {
@@ -4372,6 +4424,8 @@ Command COMMANDS[] = {
43724424
{ MAIN_SECTION, {DEFACCEL, _t("OSARA: Toggle track/take pan envelope visibility (depending on focus)")}, "OSARA_TOGGLEPANENVELOPE", cmdTogglePanEnvelope},
43734425
{ MAIN_SECTION, {DEFACCEL, _t("OSARA: Toggle track/take mute envelope visibility (depending on focus)")}, "OSARA_TOGGLEMUTEENVELOPE", cmdToggleMuteEnvelope},
43744426
{ MAIN_SECTION, {DEFACCEL, _t("OSARA: Toggle track pre-FX pan or take pitch envelope visibility (depending on focus)")}, "OSARA_TOGGLEPREFXPANTAKEPITCHENVELOPE", cmdTogglePreFXPanOrTakePitchEnvelope},
4427+
{ MAIN_SECTION, {DEFACCEL, _t("OSARA: Next fixed item lane")}, "OSARA_NEXTLANE", cmdNextLane},
4428+
{ MAIN_SECTION, {DEFACCEL, _t("OSARA: Previous fixed item lane")}, "OSARA_PREVIOUSLANE", cmdPreviousLane},
43754429
{MIDI_EDITOR_SECTION, {DEFACCEL, _t("OSARA: Enable noncontiguous selection/toggle selection of current chord/note")}, "OSARA_MIDITOGGLESEL", cmdMidiToggleSelection},
43764430
{MIDI_EDITOR_SECTION, {DEFACCEL, _t("OSARA: Move to next chord")}, "OSARA_NEXTCHORD", cmdMidiMoveToNextChord},
43774431
{MIDI_EDITOR_SECTION, {DEFACCEL, _t("OSARA: Move to previous chord")}, "OSARA_PREVCHORD", cmdMidiMoveToPreviousChord},

0 commit comments

Comments
 (0)