Skip to content

Commit

Permalink
Release Mini song switcher v1.1
Browse files Browse the repository at this point in the history
Avoid starting play for other than the accessed project (tab)
  • Loading branch information
mschnell1 committed Jun 23, 2024
1 parent f3e7d33 commit 36a6040
Showing 1 changed file with 68 additions and 70 deletions.
138 changes: 68 additions & 70 deletions Various/mschnell_Mini song switcher.eel
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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");
);
)

0 comments on commit 36a6040

Please sign in to comment.