Storing a reference to a specific track?

Post Reply New Topic
RELATED
PRODUCTS

Post

I have a custom class in a Bitwig extension which has a member variable for a specific track. When the class is instantiated I set the variable like so:

this.track = trackBank.getChannel(0);

I know that 0 is the desired track because I just created the track at position 0.

However, it seems that when another track is created, this variable still references the track that is currently at position 0 rather than the track that was at position 0 when the variable was set.

Is there any way to store a reference to an actual track and not to the track at a certain position?

I suppose I can work around it by creating new tracks after all of the existing tracks and storing the index, but it would be nice to have a reference to the track that doesn't rely on an index.

Post

melodylane wrote:I have a custom class in a Bitwig extension which has a member variable for a specific track. When the class is instantiated I set the variable like so:

this.track = trackBank.getChannel(0);

I know that 0 is the desired track because I just created the track at position 0.

However, it seems that when another track is created, this variable still references the track that is currently at position 0 rather than the track that was at position 0 when the variable was set.

Is there any way to store a reference to an actual track and not to the track at a certain position?

I suppose I can work around it by creating new tracks after all of the existing tracks and storing the index, but it would be nice to have a reference to the track that doesn't rely on an index.
getChannel(0) gives you the first channel in the Bank (not track #0)! When the bank moves the track changes.
If you want to fix on a track, you can create a cursortrack and pin it to the track you want.

Post

Thanks Moss! As I understand it, I can only create CursorTracks during initialization, but my extension may create an unknown number of tracks. I would need a CursorTrack for each new track.

I suppose I can just create a very large number of CursorTracks during initialization and hope that the user doesn't exceed this, but that's not ideal.

Post

melodylane wrote:I suppose I can just create a very large number of CursorTracks during initialization and hope that the user doesn't exceed this, but that's not ideal.
Exactly, I also would like to have a nicer solution for that.

But if you explain what you are trying to do, maybe I can tell you a better solution.

Post

moss wrote:
melodylane wrote:I suppose I can just create a very large number of CursorTracks during initialization and hope that the user doesn't exceed this, but that's not ideal.
Exactly, I also would like to have a nicer solution for that.

But if you explain what you are trying to do, maybe I can tell you a better solution.
I've been working on a VR interface for Bitwig. Instrument tracks are tied to modules which you can wire up to virtual MIDI controllers. So when MIDI comes out of a virtual controller, it first goes to the module it's connected to, and then the module sends the note on to the corresponding instrument track in Bitwig.

So basically I need to keep a reference to an instrument track for each of these modules that the user creates in order to send midi notes to the track. Later I may need the reference for other purposes like arming the track or browsing for presets.

EDIT: I tried the CursorTrack approach but it didn't seem to work. My procedure was:
1. Create a fairly large list of CursorTracks on initialization
2. Assign a free CursorTrack to a module when it is created
3. Create a new instrument track on channel 0 when the module is created
4. Get channel 0 by scrolling to 0 to it with TrackBank and then getting the first channel of the TrackBank
5. Select the channel with the CursorTrack
6. Pin the CursorTrack

All of the CursorTracks reference the track at position 0, so every time a new track is created they all reference that one.

Post

melodylane wrote: EDIT: I tried the CursorTrack approach but it didn't seem to work. My procedure was:
1. Create a fairly large list of CursorTracks on initialization
2. Assign a free CursorTrack to a module when it is created
3. Create a new instrument track on channel 0 when the module is created
4. Get channel 0 by scrolling to 0 to it with TrackBank and then getting the first channel of the TrackBank
5. Select the channel with the CursorTrack
6. Pin the CursorTrack

All of the CursorTracks reference the track at position 0, so every time a new track is created they all reference that one.
I just did a test and what you tried works only reliably if you have a large enough track bank (so #4 is the problem). Since that approach also requires an upper track limit you can go simply with a large track bank (e.g. 128 or 256). This should not be a performance problem.
I even had a 1024 bank in pre 2.0 scripts to follow the selected track.

Post

melodylane wrote:
moss wrote:
melodylane wrote:
But if you explain what you are trying to do, maybe I can tell you a better solution.
I've been working on a VR interface for Bitwig.
:clap: :clap: :clap: THAT escalated quickly :)
Bitwig 2.4 | Intel i9 7940X | Win10 | RME UCX | Focal SM9

Post Reply

Return to “Controller Scripting”