Python script to trigger a specific clip slot

Discuss music production with Ableton Live.
Post Reply
RegD
Posts: 46
Joined: Sat Nov 30, 2013 4:54 pm

Python script to trigger a specific clip slot

Post by RegD » Fri Jun 20, 2014 10:39 am

Hi there!

Do you guys know if it is possible to assign a button on a controller to a specific clip slot (say 1st top slot of the track named 'test') no matter how many tracks are in the Live set and regardless of the location of the track 'test' within that set?

I would like to achieve this with a Python script because if you just use the mapping editor in Live then the track 'test' gets selected and this is something I do not want (the clip is actually not music but a midi function).

Thanks to all

S4racen
Posts: 5836
Joined: Fri Aug 24, 2007 4:08 pm
Location: Dunstable
Contact:

Re: Python script to trigger a specific clip slot

Post by S4racen » Fri Jun 20, 2014 11:32 am

Go to preferences and remove Select on Launch tick for your options...

Cheers
D

RegD
Posts: 46
Joined: Sat Nov 30, 2013 4:54 pm

Re: Python script to trigger a specific clip slot

Post by RegD » Mon Jun 23, 2014 8:57 pm

Sweet! thx for the info.

If anybody knows how to assign a button on a controller to a specific clip slot in Live with Python scripting, I'll still be interesting as it could open up some possibilities.

wiffbi
Posts: 238
Joined: Wed Aug 18, 2004 4:53 pm

Re: Python script to trigger a specific clip slot

Post by wiffbi » Tue Jun 24, 2014 7:23 pm

Accessing clipslots with Python Scripting is not that hard. You can access them via song.tracks[index].clipslots[index] or song.scenes[index].clipslots[index]

Have a look at the Live Object Model:
http://cycling74.com/docs/max5/refpages ... model.html

The more difficult thing is to get a basic MIDI Remote Script working. A lot of the available ones are based on the _Framework-Classes, which make some things easier, but in your case probably make it harder. So for a basic MIDI Remote Script, have a look at my SelectedTrackControl (http://stc.wiffbi.com), especially the code in the main file:

https://github.com/wiffbi/Selected_Trac ... Control.py

For you, important are the methods

Code: Select all

receive_midi
and

Code: Select all

build_midi_map
with its calls to the API-method

Code: Select all

Live.MidiMap.forward_midi_note(script_handle, midi_map_handle, channel, note)
.

If you want to use the _Framework-Classes, then the ClipSlotComponent might be interesting to look at. You can register a launch-button via

Code: Select all

set_launch_button(button)
. I haven’t done anything with the ClipSlotComponent though, so I do not know how to best put it to use.

RegD
Posts: 46
Joined: Sat Nov 30, 2013 4:54 pm

Re: Python script to trigger a specific clip slot

Post by RegD » Wed Jun 25, 2014 4:44 pm

Thanks wiffbi, this is great!

But I've got to admit my Python programming skills are basic so I shall use the _Framework classes. The most exploratory I can do is an override of these... :oops:

Would you know how to make sure that the slot of the right track is launched?
I was thinking of doing a for loop in which I get the name of the track and compare it to the name of the track I am interested by...
Do you know the syntaxe of Live.Track.Track.name?
Is there a way to know how many tracks are in the mixer? (for the range of the for loop)

Thanks
R

wiffbi
Posts: 238
Joined: Wed Aug 18, 2004 4:53 pm

Re: Python script to trigger a specific clip slot

Post by wiffbi » Thu Jun 26, 2014 10:00 am

You can loop through all tracks like this (beware, untested):

Code: Select all

for track in song().tracks:
    if track.name == "foobar":
        # do something with list of clipslots
        track.clipslots[0].fire()
Regarding number of tracks in the mixer: you do not need to know as you can iterate over the list of tracks with a simple for … in -loop. It should be possible to get the number of tracks via len(song().tracks), but in Live 9 the tracks-propertiy changed to a custom "Vector"-class, which at least does not allow Python list concatenation. I have not tested, whether that Vector-class works with len(). But you could always convert it to a list:

Code: Select all

len([track for track in song().tracks])

RegD
Posts: 46
Joined: Sat Nov 30, 2013 4:54 pm

Re: Python script to trigger a specific clip slot

Post by RegD » Sat Jun 28, 2014 4:51 pm

Hi wiffbi,
Thanks a lot! I am all excited about it and going to give it a go now.
Sorry I should have mentionned earlier but I am using live 8 so I should not have the issue about the vector class..
R

RegD
Posts: 46
Joined: Sat Nov 30, 2013 4:54 pm

Re: Python script to trigger a specific clip slot

Post by RegD » Sat Jun 28, 2014 9:27 pm

Sweet! after a few modifications it works like a charm!
Here is what I ended up with:

Code: Select all

for track in self.song().tracks:
    if track.name == "the_right_track":
        if (some condition):
            track.clip_slots[0].fire()
        else:
            track.stop_all_clips() 
This function enables me to switch on and off the Live metronome together with a LED metronome with only one button (the specific slot sends MIDI out to my controller, lightening LEDs)
This also enabled me to resample with one button: I've got my resample track set, when I press the "resample" button of my controller Live records on the first slot. When I press again it stops. When I press once more it records on the next slot and so forth. This is great not to disturb the workflow.

Thanks a lot, you made my day!
R

infinitystairs
Posts: 21
Joined: Tue Sep 27, 2016 10:34 pm

Re: Python script to trigger a specific clip slot

Post by infinitystairs » Mon Dec 12, 2016 9:34 pm

Thanks for the great tips. I have modified Selected Track Control to be able to select specifically-named tracks with midi.

If a track is part of a group, and that group is folded shut, is there a way to tell that subtrack's parent track to unfold? I can access my selected track's .is_visible property to know that it is hidden, but I can't figure out how to access the group track that contains it to set its .fold_state property to false.

Post Reply