From ad9971b28599f97c5e657138034f40b57a6d59e9 Mon Sep 17 00:00:00 2001 From: Michael Schnell Date: Tue, 25 Jun 2024 20:37:28 +0200 Subject: [PATCH] Release Mini song switcher v2.1 Allow for accessing multiple project tabs bug fixes --- Various/mschnell_Mini song switcher.eel | 65 +++++++++++++++++-- .../New file 1.lua | 10 +++ 2 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 Various/mschnell_Mini song switcher/New file 1.lua diff --git a/Various/mschnell_Mini song switcher.eel b/Various/mschnell_Mini song switcher.eel index 1c2cbc758..b4795dac0 100644 --- a/Various/mschnell_Mini song switcher.eel +++ b/Various/mschnell_Mini song switcher.eel @@ -1,3 +1,31 @@ +// @description Mini song switcher +// @author mschnell +// @version 2.1 +// @changelog +// Allow for accessing multiple project tabs +// bug fixes +// @provides [main] mschnell_Mini song switcher/New file 1.lua > 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 two scripts and no GUI +// +// 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 (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. + // @description Mini song switcher // @author mschnell // @version 1.1 @@ -21,14 +49,35 @@ // // 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; ); @@ -52,7 +101,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'); ); ); @@ -64,7 +113,7 @@ ) : ( mute = 1; ); - SetMediaTrackInfo_Value(track, "B_MUTE", mute); // set unmute + SetMediaTrackInfo_Value(track, "B_MUTE", mute); // set mute / unmute ); ); track_index += 1; @@ -74,16 +123,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); ); ) diff --git a/Various/mschnell_Mini song switcher/New file 1.lua b/Various/mschnell_Mini song switcher/New file 1.lua new file mode 100644 index 000000000..350082b3c --- /dev/null +++ b/Various/mschnell_Mini song switcher/New file 1.lua @@ -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);