Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions abletonosc/osc_server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Tuple, Any, Callable
from .constants import OSC_LISTEN_PORT, OSC_RESPONSE_PORT
from ..pythonosc.osc_message import OscMessage, ParseError
from ..pythonosc.osc_bundle import OscBundle
from ..pythonosc.osc_message_builder import OscMessageBuilder, BuildError
# Live 12 fix: use full package path (relative imports fail, bare module name not found)
from AbletonOSC.pythonosc.osc_message import OscMessage, ParseError
from AbletonOSC.pythonosc.osc_bundle import OscBundle
from AbletonOSC.pythonosc.osc_message_builder import OscMessageBuilder, BuildError

import re
import errno
Expand Down
43 changes: 43 additions & 0 deletions abletonosc/track.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Tuple, Any, Callable, Optional
import Live
from .handler import AbletonOSCHandler


Expand Down Expand Up @@ -108,6 +109,48 @@ def track_delete_clip(track, params: Tuple[Any]):

self.osc_server.add_handler("/live/track/delete_clip", create_track_callback(track_delete_clip))

#--------------------------------------------------------------------------------
# Insert device by URI/name
# Usage: /live/track/insert_device <track_index> <device_uri> [device_index]
# Example: /live/track/insert_device 0 "Reverb" -1
#--------------------------------------------------------------------------------
def track_insert_device(track, params: Tuple[Any]):
device_uri = str(params[0])
device_index = int(params[1]) if len(params) > 1 else -1
self.logger.info("Inserting device '%s' at index %d" % (device_uri, device_index))

# Use the browser to load the device
application = Live.Application.get_application()
browser = application.browser

# Search for the device in available items
# Try instruments first, then audio effects, then midi effects
search_locations = [
browser.instruments,
browser.audio_effects,
browser.midi_effects,
browser.drums,
browser.sounds,
]

device_item = None
for location in search_locations:
for item in location.children:
if item.name == device_uri or device_uri in item.name:
device_item = item
break
if device_item:
break

if device_item:
browser.load_item(device_item)
return (len(track.devices) - 1,)
else:
self.logger.warning("Device not found: %s" % device_uri)
return (-1,)

self.osc_server.add_handler("/live/track/insert_device", create_track_callback(track_insert_device))

def track_get_clip_names(track, _):
return tuple(clip_slot.clip.name if clip_slot.clip else None for clip_slot in track.clip_slots)

Expand Down
1 change: 1 addition & 0 deletions tmpclaude-2f62-cwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/c/Users/drane/ableton-mcp/AbletonOSC
1 change: 1 addition & 0 deletions tmpclaude-fb7e-cwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/c/Users/drane/ableton-mcp/AbletonOSC