MIDI Remote API, get track name and time/bars&beats?

Hi,
I’m kind of in the start of considering learning some javascript and writing a script for the Behringer X-Touch One.

To make this, I need to figure out 2 things really.
How do I grab the name of a selected track from cubase? I was skimming docs and I couldn’t see for sure a way to do this? Am I missing something super obvious?
Secondly, can I get the current project time in time/beats easily?

Basically what I am thinking is using the MCU mode on the X-Touch One, and translating what I need.
Why MCU, and not generic midi mode on it?
I want fine control of the fader, as mcu sends pitchbend, whereas normal midi sends 7-bit midi. I already did some proof of concept stuff here translating pitchbend to 14-bit midi in a python script, so I know it’ll work, and I saw that you can bind pitchbend using the api anyway, so I could forego that conversion entirely if I use the api I reckon.
Secondly, I want to be able to use the lcd display for track name, and I want to make use of the time/beats&bars display of the controller as well. This can be accessed in both midi and mackie mode, so this isn’t a deal breaker.

This part is me also wildly assuming I can send sysex to my controller, I can right?

Hi @Shor, there is a non-intuitive way that works:

var textDisplayValue = surface.makeCustomValueVariable('textDisplayValue')
textDisplayValue.mOnTitleChange = function(activeDevice, objectTitle, valueTitle) {
    console.log(objectTitle)
}

page.makeValueBinding(textDisplayValue, page.mHostAccess.mTrackSelection.mMixerChannel.mValue.mVolume)

1 Like

Oh that is great.
Non-intuitive is my middle name :laughing:

Thank you! I will have to setup a development environment and start testing things now.

1 Like

Oh any idea on the other question?
I.e. retrieve information about the project time? Since my controller has the time display, it’d be neat to be able to fill that from Cubase as well… I can imagine this being trickier, but worth a shot if possible.

I gladly work with non-intuitive and creative ways to solve it if possible :slight_smile:

Hi.@Shor, project time is not yet available in the API. But it’s a very reasonable request. I’ll have a look. Thanks!

2 Likes

Fantastic!
Btw I had a quick go over my lunch break and damn this is lovely to work with.
I started my proof of concept control script, and it was quite straight forward to get going with the guide.

However, not to pollute this thread with [these are all my problems help me], but this is my problem, please help me :laughing:
I set up a quick script for my Behringer X-Touch One in mackie control mode ( so fader sends and listens to pitch), and i bound that to the selected channel volume.
It “sort of” works. If I change the volume from cubase, or my other controllers, the fader on my X-Touch listens and follows accordingly, however, when I use the actual fader on the X-Touch, Cubase only listens sporadically at best…so the behaviour is like this:
I sweep fader
Cubase updates 1 or at best 2 times across the sweep, but it definitely does not follow. Is the pitchbend functionality not quite there yet? I noticed the pitch bend wont get recognized if I just work with the GUI for midi editor, it can only be set in the scripts so far it looks like.
I found that if I sweep really slowly, it updates a little bit more frequently… it’s as if there’s a throttling on the input (since well pitch will send a ton of information, making that quite reasonable).
Any advice on this? Is there a setting I need to do?
I have it set up to jump to value, and again, if I change volume from anywhere else in Cubase it follows on my controller, but controller can’t control the volume correctly.

Just replying to myself… I got the reply here, and I was being a dummy about the volume.
Just remove midiOut from the control…because why do I need that when I’m already talking to cubase directly…duh!

Wouldn’t that also disable the legitimate receiving of new CC values, when you change focus to a different plugin, or select a different track?

No,
The output is not needed in this case, as we speak with Cubase through the API, not midi. So sending midi out, and essentially back to ourselves is not needed.
We need to listen to midi in to receive changed values from Cubase, but when sending from the device, we are already talking to Cubase with the API.
That’s how I understand it right now at least, but tonight or tomorrow morning when I get free time I can confirm how it works. I may be wrong in how I understand it, but yeah…time or Jochen will tell for sure, whatever happens first :smiley:

Oh this didn’t work at all actually…replying in other thread.

Take a look here for an explanation:

1 Like

Thanks for the reply, this looks like you did a really big deep dive.
Will read through this in a bit when I’m done with work and see if I can catch any obvious easy fixes for my situation.

I’m still a bit curious how this didn’t work “out of the box” the way I set it up, even if I understand the feedback situation that is happening. You did post some interesting notes regarding the mOnProcessValueChange though that might be my problem.

@Jochen_Trappe , this code worked great in 12.0, but seems to be broken in 12.0.20. It causes the script to come up in a bad state. I can hit bank prev a couple times and come out of the bad state, but on script refresh it always goes to a bad state. If I comment out this section of code, all is fine (other than I don’t get the track names)

bad state = all the colors on the knobs go to an uncolored state and mOnPrcessValueChange and mOnDisplayValueChange do not respond. Changing sub pages or changing banks seems to “colorize” the knobs again and everything starts responding normally. I did not have this issue in 12.0 and I don’t think I had it in 12.0.10. Only 12.0.20.

EDIT: I changed where I was implementing this and it no longer hangs. There is one little glitch where after the first bank change, mOnDisplayValueChange does not get called but on all subsequent bank changes it does get called.

Ron

With this I tried to generate a trigger when the track is changed, but this does not work for me. The event mOnTitleChange is executed only 1x when loading the script, but after that not anymore when I change from track to track, although the track titles are all different. What am I doing wrong?

Can you post the part of your code?

I defined this Variable:

upperButtons.var_DisplayValue
    = deviceDriver.mSurface.makeCustomValueVariable("DisplayValue")

I made the HostBinding like this:

page.makeValueBinding(upperButtons.var_DisplayValue,
    page.mHostAccess.mTrackSelection.mMixerChannel.mValue.mVolume)

I defined this Event:

upperButtons.var_DisplayValue.mOnTitleChange 
= function(context, objectTitle, valueTitle) {
    console.log("objectTitle = " + objectTitle + ", valueTitle = " + valueTitle)
}

When I load the midi remote script, I see this console message:
objectTitle = Audio 01, valueTitle = Volume

So the Event was triggered correctly for one time.

But when I change the selected track in Cubase (this is changing the objectTitle), the Event will be not triggered of that, so there are no more console messages.
What I need, is an Event, which is triggered, when the selected track in Cubase is changed, because I must do some initializations for other functionalities when the selected track is changed.

Though it shouldn’t matter, can you try setting up a dummy assignment to the mSelected host value and check if the mOnTitle for this new custom var fires?

I’ve tried that too, but it doesn’t work that way either.

I suspect there are duplicates somewhere.
You can give a try to the native code:


page.mHostAccess.mTrackSelection.mMixerChannel.mValue.mVolume.mOnTitleChange = function (activeDevice, activeMapping, objectTitle) {
        
        console.log(objectTitle)

}
1 Like

Good idea. With this it works… :grinning:

1 Like