Get the index of the selected track

Post Reply New Topic
RELATED
PRODUCTS

Post

I am trying to get the index of the selected track but there are a couple of things I can't get my head round...

1) If I add addIsSelectedObserver to ClipLauncherSlots in my TrackBank then I get the index of the selected/deselected scene but it does not give me the index of the selected/deselected track (I was expecting a x/y reference not just an x reference).

2) If I add addIsSelectedObserver to a Track in my TrackBank it only gives me a true of false (selected/deselected) and not the index of the track.

I am sure this is an easy problem - I just can't seem to find the fix at the mo - any help much appreciated. Thanks!

Post

Can you outline what you want to do?

If you want to work with a single track selection, it's usually best to use a cursor track, which is following your selection.

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream | Instagram | YouTube

Post

Hi Tom thanks for your help - I have looked at cursor tracks but struggled to get where I wanted to get to.

My goal is to increment the slot selection downwards by one track when I select a particular midi cc. When slot selection reaches the last track I want the next selected slot to be on the first track - so it cycles round.

Thanks.
Tim

Post

You could maybe use a mainTrackBank for that, with one track and one scene, then you could scroll the track up and down with scrollTracksUp and ...Down and move the slot with scrollScenesUp and ...Down.

The mainTrackBank only consideres normal tracks, not effects and the master - if that is not what you want, you can use a normal trackBank.

Then you use an addCanScrollTracksDownObserver to find out if you reached the lower limit and when this is false and the CC is pressed again, you use scrollToTrack(0) to jump to the first track again.

The same scrolling can be done for scenes as well.

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream | Instagram | YouTube

Post

That's a limitation / conceptual problem of the current API. You have to register the observers on EVERY tracl of the trackbank. That's why there is no index and no y.
I already suggest to add indexed observers to reduce the number of observers.

Post

I guess after the 1.1 stress is back down a bit again we can see how to improve this area further. There are so many changes now, but some basics still are harder to do than necessary. I just ran into some such things with the faderport script.

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream | Instagram | YouTube

Post

When re-reading I now guess I misunderstood the question a bit.
To get the selected track in the _GUI_ you can indeed use a dummy cursor track and update the position of a track bank by using an observer on that cursorTrack.addPositionObserver. But that doesn't work for Clips in the Cliplauncher and I have found no way to get the currently selected clip in the GUI, since there is no cursorSlot or something like that.
I discussed that recently with Volker and we will look into this when the dust has settled on 1.1.

I hope there is at least some nourishment in my answers, otherwise please elaborate ;-)

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream | Instagram | YouTube

Post

Hi Tom I had a go at implementing your suggestions and I think I have almost cracked it although I am now having some issues with slot selection in the UI.

You can see in the code below I have a track and a scene position observer which should update the UI slot selection however for some reason this only works when I change track on scene 0. I am using a 1x1 main track bank (as per your suggestion) and so I know that my current track is always going to be mainTrackBank.getChannel(0).

If you have any ideas on this bit I would be really grateful.

Code: Select all

mainTrackBank.addChannelScrollPositionObserver(addChannelScrollPositionObserverCallback, 0);
mainTrackBank.addSceneScrollPositionObserver(addSceneScrollPositionObserverCallback, 0);

function addChannelScrollPositionObserverCallback(theTrackIdx) {	
	mainTrackBank.getChannel(0).getClipLauncherSlots().select(theSceneIdx);
}

function addSceneScrollPositionObserverCallback(theSceneIdx) {
	mainTrackBank.getChannel(0).getClipLauncherSlots().select(theSceneIdx);
}

Post

Doh! my error - now its working! :)

scene index is always 0 too as this is 1x1 bank...

Code: Select all

mainTrackBank.addChannelScrollPositionObserver(addChannelScrollPositionObserverCallback, 0);
mainTrackBank.addSceneScrollPositionObserver(addSceneScrollPositionObserverCallback, 0);

function addChannelScrollPositionObserverCallback(theTrackIdx) {   
   mainTrackBank.getChannel(0).getClipLauncherSlots().select(0);
}

function addSceneScrollPositionObserverCallback(theSceneIdx) {
   mainTrackBank.getChannel(0).getClipLauncherSlots().select(0);
}

Post Reply

Return to “Controller Scripting”