Python script to trigger a specific clip slot
Python script to trigger a specific clip slot
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
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
Re: Python script to trigger a specific clip slot
Go to preferences and remove Select on Launch tick for your options...
Cheers
D
Cheers
D
Re: Python script to trigger a specific clip slot
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.
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.
Re: Python script to trigger a specific clip slot
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 and with its calls to the API-method .
If you want to use the _Framework-Classes, then the ClipSlotComponent might be interesting to look at. You can register a launch-button via. I haven’t done anything with the ClipSlotComponent though, so I do not know how to best put it to use.
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
Code: Select all
build_midi_map
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)
Re: Python script to trigger a specific clip slot
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...
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
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...
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
Re: Python script to trigger a specific clip slot
You can loop through all tracks like this (beware, untested):
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
for track in song().tracks:
if track.name == "foobar":
# do something with list of clipslots
track.clipslots[0].fire()
Code: Select all
len([track for track in song().tracks])
Re: Python script to trigger a specific clip slot
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
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
Re: Python script to trigger a specific clip slot
Sweet! after a few modifications it works like a charm!
Here is what I ended up with:
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
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 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
-
- Posts: 21
- Joined: Tue Sep 27, 2016 10:34 pm
Re: Python script to trigger a specific clip slot
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.
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.