host.getRootTrackGroup() .js Help?

Post Reply New Topic
RELATED
PRODUCTS

Post

Ok... so i'm wanting to see all the tracks that are in my the opened project. but i have little clue what this object is that is returned by project.getRootTrackGroup()

Code: Select all

var project = host.getProject();
var rootTrack = project.getRootTrackGroup();
Great! so I look up in the API Documentation that comes with bitwig. search for getRootTrackGroup().

Code: Select all

Track getRootTrackGroup	(		)	
Returns an object that represents the root track group of the active Bitwig Studio project.

Returns
the root track group of the currently active project
Since
API version 1
what I'd really like to know the member functions and properties of this "object". This has happened to me before but I couldn't wrap my head around it to ask it clearly.

So how to derive what the object that is returned? and what functions/properties are on it?

And maybe i'm wrong but it seems like there are no properties of objects in the bitwig controller script api. Its just function calls on function calls. So to get a "property" of on object it goes something like this... itemCount() returns an integer Value object... which you also must markInterested() or addValueObserver(). and only then can you "get" the property.

this.trackbank.itemCount().get() instead of this.trackbank.itemCount

ok and back to my original question... how do i explore all the properties or see what type of object the getRootTrackGroup() returns?

if i print the object with println()... i get this...

Code: Select all

RootControlSurfaceObject/ProjectProxy(Project)/RootTrackGroupProxy
And thats as far as I can get right now... if i figure it out I'll post here. :D
---------------------------------------------------------------
http://kirkwoodwest.com/

Post

One basic thing to understand is that you have to register for property data, you can not simply call a
getter to get a value.

The method you ask about has IMHO so far the only application to compare the parent of a track to this top class to find out if you are on the top level.

Another tip: simply search the source code of DrivenByMoss. If the function is not in there it is probably not used so far :-)
For accessing tracks you need to create a track bank. You can see multiple options in the class ModelImpl (from DBM) starting line 87.

Post

Thanks Moss! Ahh ok. i see this here... I'm digging through DrivenByMoss. and its so cool you make this available.

I should probably clarify why i'm wanting to to do this... I'm attempting to make a very specific control configuration for a project. I'm attempting to make some sort of "locking" mechanism for my midi controller. My idea was to do this with names so it would autofind the channels(based on name) and configure all the mappings. As well as move any cursor devices to that track to control things like EQ/FILTER/EFFECTS.

It seems to take a couple seconds to initialize everything after song load... so this function doesn't return the actual item count until a little bit after my script reloads. and certainly not in init().

Code: Select all

this.trackbank.itemCount().get() 
doesn't return the channel count in trackbank for some time...

i'm pretty sure this can't happen in init() any ideas when to execute the procedure?

As much as i'd like to figure out how to do this within the bitwig API... I'm begining to think this is not the direction I should be heading. I Maybe I need to look into using the project preferences to make project specific configurations.
---------------------------------------------------------------
http://kirkwoodwest.com/

Post

The create methods only work in init(). Previously, there was no work around for this but since 3.1.3 the settings getters finally return the stored value already in init().

The whole API works asynchroneously and you need to be prepared for that! The reason is that Bitwig is optimized for realtime, which means audio first. When there is time you get an update to the API. For the startup, I added a delay of 2 seconds. For this use the ControllerHost.scheduleTask method.

Post

Ok now that is fresh! I got the host.scheduleTask() game on!... And now it seems that init() is only called when the script loads. maybe I'm looking for a way to know when a new project is loaded.

and another thing i'm observing in relation to this... how is the control script managed per bitwig project? It seems like the createMainTrackBank().scrollPosition() is reset when navigating between tracks. (Also, sorry i don't know how to best describe this object and its method because I don't know the object type it returns in js :) )
---------------------------------------------------------------
http://kirkwoodwest.com/

Post

hydrogxn wrote: Wed Apr 08, 2020 7:02 pm Ok now that is fresh! I got the host.scheduleTask() game on!... And now it seems that init() is only called when the script loads. maybe I'm looking for a way to know when a new project is loaded.
The only way I know is monitoring the project name:

Application.projectName ()
hydrogxn wrote: Wed Apr 08, 2020 7:02 pm and another thing i'm observing in relation to this... how is the control script managed per bitwig project? It seems like the createMainTrackBank().scrollPosition() is reset when navigating between tracks. (Also, sorry i don't know how to best describe this object and its method because I don't know the object type it returns in js :) )
The script is running all the time. Your observers and banks are updated accordingly. Maybe simply add some println to the observers to understand what is going on.

Post

Dude so pumped and my code is sooooo funky now!!! This help is so useful moss!
moss wrote: Thu Apr 09, 2020 8:29 am The only way I know is monitoring the project name:

Application.projectName ()
This was my interprestation of your suggestion to observe the document change. finally getting the hang of the documentation and how the API is implemented.

Code: Select all

app = host.createApplication();
app.projectName().addValueObserver(projectNameChanged);
Its interesting about the asynconicity. We had a similar issue with using Lua Script to drive our video game engine. So I'm familiar with this type of thing. We had some pretty smart people that were able to figure out how to keep the different systems together while all the designers were making the funky code.

I'm already experiencing some performance issues related to the midi callbacks so i'll probably switch over to Java soon once I get a couple more of my investigations done.

But so far I was able to make 4 track banks that autotarget track names when the document switches and also pin the cursor to the first device on those tracks! super slick. I'm really really bad at github ( i use the gui :dog: )but will make an effort to at least drop these files on there so people can see my funky code.

I'm glad i'm going thru this painful process of learning another language/framework... maybe the 4th framework I learned since starting this midi system I'm putting together. AND its been the most simple to grok so far thanks to you. :hug:
---------------------------------------------------------------
http://kirkwoodwest.com/

Post Reply

Return to “Controller Scripting”