leolabs / ableton-js

Control Ableton Live with Node.js
MIT License
368 stars 46 forks source link

Feature: session highlighting with red ring #123

Open kkerti opened 6 days ago

kkerti commented 6 days ago

I have started to extend the codebase with the session ring creation feature of the Live API. I tried my best to follow the code pattern laid down by @leolabs and on the typescript side I think I nailed it, but the python side is not my strong suit. I wanted to open this PR early, so I can give visibility for this development and also get feedback.

Overview

This project is by far the best when it comes to controlling Live through javascript environments (nodejs and typescript). My goal was to utilise this package to give the intech studio Grid MIDI controllers greater control over Ableton. I could've used other tool for the job, but I like the idea of basing this integration on an open source tool, where the code for the integration itself can be easily altered, javascript fits better the ecosystem around Grid.

Controlling a red ring was also requested by others in this discussion here: #114

Status

I have created two functions, setup_session_box, set_session_offset and put them under the Session handler. The ns namespace for the functions is session. I think this naming is misleading, as really what I'm doing here is calling methods on the ControlSurface instance, which has the session property.

In the handler object where AbletonJS initialises everything, the Session class gets assigned. I don't like the fact that here I just lazily pass in the self, which contains the reference to the ControlSurface for self.session, probably I should pass self.session, but on the other hand set_highlighting_session_component exists on ControlSurface.

# the handler extended with session
self.handlers = {
  "session": Session(c_instance, self.socket, self)
}

To do...

Get feedback, if this can be truly a part of ableton-js! And also check if the newer APIs are any better, like using this:

from ableton.v2.control_surface.component import { SessionRingComponent }

I have added two tests for creating the session ring itself and also moving the session ring. Tested with Ableton Live 11.

what-the-diff[bot] commented 6 days ago

PR Summary

kkerti commented 1 day ago

I just removed the unused property and also ran prettier with prettier --config .prettierrc -w src/. I think it's worth adding this to readme and also I'm not sure if the prettier config should be applied to the python code as well. Thank for checking it out!