Latest News: Bitwig Updates Bitwig Studio to 5.2
Storing a reference to a specific track?
-
- KVRer
- Topic Starter
- 10 posts since 8 Oct, 2017
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.
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.
- KVRAF
- 4145 posts since 13 May, 2004
getChannel(0) gives you the first channel in the Bank (not track #0)! When the bank moves the track changes.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.
If you want to fix on a track, you can create a cursortrack and pin it to the track you want.
-
- KVRer
- Topic Starter
- 10 posts since 8 Oct, 2017
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.
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.
- KVRAF
- 4145 posts since 13 May, 2004
Exactly, I also would like to have a nicer solution for that.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.
But if you explain what you are trying to do, maybe I can tell you a better solution.
-
- KVRer
- Topic Starter
- 10 posts since 8 Oct, 2017
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.moss wrote:Exactly, I also would like to have a nicer solution for that.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.
But if you explain what you are trying to do, maybe I can tell you a better solution.
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.
- KVRAF
- 4145 posts since 13 May, 2004
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.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 even had a 1024 bank in pre 2.0 scripts to follow the selected track.
-
meta-redundant meta-redundant https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=406307
- KVRist
- 51 posts since 16 Oct, 2017 from Los Angeles, CA USA
THAT escalated quicklymelodylane wrote:moss wrote:I've been working on a VR interface for Bitwig.melodylane wrote:
But if you explain what you are trying to do, maybe I can tell you a better solution.
Bitwig 2.4 | Intel i9 7940X | Win10 | RME UCX | Focal SM9