From eb3cb30425bb7bf8411a1a2ca5e1d3ccda826a5e Mon Sep 17 00:00:00 2001 From: CoryBoris <129540279+CoryWBoris@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:10:10 -0400 Subject: [PATCH] Update song.py I registered a handler function to return a tuple with the file path, project name, and set name for any set that is currently open. I thought this would be helpful as I have wanted this feature in the past. I really love AbletonOSC by the way, thanks so much for maintaining it the way you all do! --- abletonosc/song.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/abletonosc/song.py b/abletonosc/song.py index 58d5f72..f0e2acd 100644 --- a/abletonosc/song.py +++ b/abletonosc/song.py @@ -245,6 +245,26 @@ def song_jump_to_cue_point(song, params: Tuple[Any] = ()): cue_point = song.cue_points[cue_point_index] cue_point.jump() self.osc_server.add_handler("/live/song/cue_point/jump", partial(song_jump_to_cue_point, self.song)) + + #-------------------------------------------------------------------------------- + # Callbacks for Song: File, Project, and Set Name + #-------------------------------------------------------------------------------- + def get_live_set_details(song, _): + """ + Handler function to return File, Project, and Set names as a tuple of length 3 when requested via OSC. + + Returns: + tuple: A tuple containing the full file path, parent folder name and + song file name of the current Live Set. + """ + song_file_path = song.file_path + folder_name = os.path.basename(os.path.dirname(song_file_path)) + song_file_name = os.path.basename(song_file_path) + + return (song_file_path, folder_name, song_file_name) + + # Register the handler function to be triggered when "/live/song/get/live_set" is received via OSC + self.osc_server.add_handler("/live/song/get/live_set", partial(get_live_set_details, self.song)) #-------------------------------------------------------------------------------- # Listener for /live/song/get/beat