From 36a6040ff44b7c34a3e4051931a9a7a382ce3d24 Mon Sep 17 00:00:00 2001 From: Michael Schnell Date: Sun, 23 Jun 2024 14:28:41 +0200 Subject: [PATCH] Release Mini song switcher v1.1 Avoid starting play for other than the accessed project (tab) --- Various/mschnell_Mini song switcher.eel | 138 ++++++++++++------------ 1 file changed, 68 insertions(+), 70 deletions(-) diff --git a/Various/mschnell_Mini song switcher.eel b/Various/mschnell_Mini song switcher.eel index 83d855bdd..1c2cbc758 100644 --- a/Various/mschnell_Mini song switcher.eel +++ b/Various/mschnell_Mini song switcher.eel @@ -1,7 +1,7 @@ // @description Mini song switcher // @author mschnell -// @version 1.0 -// @changelog Initial Release +// @version 1.1 +// @changelog Avoid starting play for other than the accessed project (tab) // @about // # Mini Song switcher // ## Description @@ -11,81 +11,79 @@ // // 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. // -// If such is not found, it works on the foreground poject (Tab). Don't forget to enable all three background project playing options ! +// 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) +// 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 // // 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_*"; - get_action_context(#filename, sectionID, cmdID, mode, resolution, val); + #tab_name = "*_song_*"; - tab = 0; - while ( - proj = EnumProjects(tab, #proj_name); - p = proj; - n = match("*_song_*", #proj_name); - n ? ( - p = 0; - ); - tab += 1; - p; - ); + 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 ? ( + p = 0; + ); + tab += 1; + p; + ); + running = GetPlayStateEx(proj); + val != 0 ? ( + track_count = CountTracks(proj); + song_found = 0; + track_index = 0; + loop (track_count, + track = GetTrack(proj, track_index); + has_name = GetTrackName(track, #track_name); + has_name ? ( + c0 = str_getchar(#track_name, 0); + c1 = str_getchar(#track_name, 1); + c2 = str_getchar(#track_name, 2); + song_no = -1; + c1 == '.' ? ( + (c0 >= '0') && (c0 <= '9') ? song_no = c0 - '0'; + ); + c2 == '.' ? ( + (c0 >= '0') && (c0 <= '9') || (c1 >= '0') && (c1 <= '9') ? ( + song_no = (c0 - '0') * 10 + (c1 -'0'); + ); + ); + song_no != -1 ? ( + song_no == val ? ( + mute = 0; + song_found = 1; + #play_name = #track_name; + ) : ( + mute = 1; + ); + SetMediaTrackInfo_Value(track, "B_MUTE", mute); // set unmute + ); + ); + track_index += 1; + ); + stop_cmd_id = 1016; + Main_OnCommandEx(stop_cmd_id, 0, proj); + song_found != 0 ? ( + play_cmd_id = 1007; + Main_OnCommandEx(play_cmd_id, 0, proj); + sprintf(#s, "Song Started: %s\r\n", #play_name); + ShowConsoleMsg(#s); + ) : ( + sprintf(#s, "Song does not exist: %d\r\n", val); + ShowConsoleMsg(#s); + ) + ) : ( + running ? ( + Main_OnCommandEx(stop_cmd_id, 0, proj); + ShowConsoleMsg("Song Stopped\r\n"); + ); + ) - running = GetPlayState(); - val != 0 ? ( - - track_count = CountTracks(proj); - - song_found = 0; - track_index = 0; - loop (track_count, - track = GetTrack(proj, track_index); - has_name = GetTrackName(track, #track_name); - has_name ? ( - - c0 = str_getchar(#track_name, 0); - c1 = str_getchar(#track_name, 1); - c2 = str_getchar(#track_name, 2); - song_no = -1; - c1 == '.' ? ( - (c0 >= '0') && (c0 <= '9') ? song_no = c0 - '0'; - ); - c2 == '.' ? ( - (c0 >= '0') && (c0 <= '9') || (c1 >= '0') && (c1 <= '9') ? ( - song_no = (c0 - '0') * 10 + (c1 -'0'); - ); - ); - - song_no != -1 ? ( - song_no == val ? ( - mute = 0; - song_found = 1; - #play_name = #track_name; - ) : ( - mute = 1; - ); - SetMediaTrackInfo_Value(track, "B_MUTE", mute); // set unmute - ); - ); - track_index += 1; - ); - CSurf_OnStop(); - song_found != 0 ? ( - CSurf_OnPlay(); - sprintf(#s, "Song Started: %s\r\n", #play_name); - ShowConsoleMsg(#s); - ) : ( - sprintf(#s, "Song does not exist: %d\r\n", val); - ShowConsoleMsg(#s); - ) - ) : ( - running ? ( - CSurf_OnStop(); - ShowConsoleMsg("Song Stopped\r\n"); - ); - )