Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Mini song switcher v1.1 #1409

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
);
)