Skip to content

Commit

Permalink
Release Mini song switcher v2.1 (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschnell1 committed Jul 2, 2024
1 parent c687b9d commit 312ae97
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 12 deletions.
52 changes: 40 additions & 12 deletions Various/mschnell_Mini song switcher.eel
Original file line number Diff line number Diff line change
@@ -1,34 +1,60 @@
// @description Mini song switcher
// @author mschnell
// @version 1.1
// @changelog Avoid starting play for other than the accessed project (tab)
// @version 2.1
// @changelog
// Allow for accessing multiple project tabs
// bug fixes
// @provides [main] mschnell_Mini song switcher/mschnell_Mini song switcher project.eel
// @about
// # Mini Song switcher
// ## Description
// The mschnell_Mini song switcher is inspired by the cfillion_Song switcher.
//
// It is a lot less versatile and only features a single script and no GUI
// It is a lot less versatile and only features two scripts and no GUI
//
// Other than the cfillion_Song switcher is does not work on the foreground Project (Tab) but on the first project (Tab) that holds a project with the string `_song_` in it's name.
// Other than the cfillion_Song switcher is does not work on the foreground Project (Tab) but by default on the first project (Tab) that holds a project with the string `_song_` in it's name.
//
// Optional the `Mini song switcher project` script can be used to select one of multiple Project Tabs. Now the first project with `_song_` in it's name is used afterwards when same had been called with value 0 and `_song_#_` in it's name is used appropriately otherwise (# = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ... 99).
//
// If such is not found, it works on the foreground project (Tab). Don't forget to enable "run background projects" on the project tab !
//
// It uses the same track structure as the cfillion_Song switcher (Description see there)
//
// When a CC action is received, it unmutes the track named according to the CC value (e.g. 1. XYZ or 23. Hello) and mutes all other appropriately named tracks
// When a CC action is received, it unmutes the track named according to the CC value (e.g. 1. XYZ or 23. Hello) and mutes all other appropriately named tracks (allowed numbers are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ... 99)
//
// It then start playback (from the location of the play cursor)
//
// When a value of 0 is given or no appropriately named track is found, the playback is stopped.

#tab_name = "*_song_*";
#tab_name = "_song_";

res = GetExtState(#tab_id, "Mini_Song_Switcher", "tab_id");
tab_no = 0;
res == 1 ? (
c0 = str_getchar(#tab_id, 0);
c1 = str_getchar(#tab_id, 1);
(c0 >= '0') && (c0 <= '9') && (c1 >= '0') && (c1 <= '9') ? (
tab_no = (c0 - '0') * 10 + (c1 -'0');
);
c0 == '0' ? (
strcpy_from(#tab_id, #tab_id, 1);
);
);
tab_no ? (
#tab_name += #tab_id;
#tab_name += "_";
);
#tab_name1 = "*";
#tab_name1 += #tab_name;
#tab_name1 += "*";


get_action_context(#filename, sectionID, cmdID, mode, resolution, val);
tab = 0;
while (
proj = EnumProjects(tab, #proj_name);
p = proj;
n = match("*_song_*", #proj_name);
n = match(#tab_name1, #proj_name);
n ? (
p = 0;
);
Expand All @@ -52,7 +78,7 @@
(c0 >= '0') && (c0 <= '9') ? song_no = c0 - '0';
);
c2 == '.' ? (
(c0 >= '0') && (c0 <= '9') || (c1 >= '0') && (c1 <= '9') ? (
(c0 >= '0') && (c0 <= '9') && (c1 >= '0') && (c1 <= '9') ? (
song_no = (c0 - '0') * 10 + (c1 -'0');
);
);
Expand All @@ -64,7 +90,7 @@
) : (
mute = 1;
);
SetMediaTrackInfo_Value(track, "B_MUTE", mute); // set unmute
SetMediaTrackInfo_Value(track, "B_MUTE", mute); // set mute / unmute
);
);
track_index += 1;
Expand All @@ -74,16 +100,18 @@
song_found != 0 ? (
play_cmd_id = 1007;
Main_OnCommandEx(play_cmd_id, 0, proj);
sprintf(#s, "Song Started: %s\r\n", #play_name);
sprintf(#s, "Song Started: %s in project %s\r\n", #play_name, #tab_name1);
ShowConsoleMsg(#s);
) : (
sprintf(#s, "Song does not exist: %d\r\n", val);
sprintf(#s, "Song does not exist: %d in project %s\r\n", val, #tab_name1);
ShowConsoleMsg(#s);
)
) : (
running ? (
stop_cmd_id = 1016;
Main_OnCommandEx(stop_cmd_id, 0, proj);
ShowConsoleMsg("Song Stopped\r\n");
sprintf(#s, "Song Stopped in project %s\r\n", #tab_name1);
ShowConsoleMsg(#s);
);
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- @noindex

#tab_id = " ";
get_action_context(#filename, sectionID, cmdID, mode, resolution, val) ? (
c0 = (val / 10) | 0;
c1 = (val % 10) | 0;
str_setchar(#tab_id, 0, c0+'0');
str_setchar(#tab_id, 1, c1+'0');
);
SetExtState("Mini_Song_Switcher", "tab_id", #tab_id, 0);

0 comments on commit 312ae97

Please sign in to comment.