[MIDI Remote API]Get All Track Names At Once Using Midi Remote Script?

Hi there!
I’ve been wondering, if this is possible:
Whenever a new track is created, or a track is deleted, or a track is renamed in the project, the midi remote script will send the latest track name list to a specific midi port.
I know that getting track name of a single track and send it out can be done like this:

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

    // Convert the string into bytes using UTF-8 encoding
    var stringBytes = [];
    for (var i = 0; i < objectTitle.length; i++) {
        stringBytes.push(objectTitle.charCodeAt(i));
    }

    // Create the SysEx message
    var sysexMessage = [0xF0]; // Start of SysEx
    // Add manufacturer or device ID if needed
    sysexMessage.push(0x7E); // Example manufacturer ID
    sysexMessage.push(0x00); // Example device ID
    // Add other necessary bytes for your specific message format
    sysexMessage.push(0x06); // Example byte
    sysexMessage.push(0x01); // Example byte
    // Append the bytes representing the string
    sysexMessage = sysexMessage.concat(stringBytes);
    sysexMessage.push(0xF7); // End of SysEx

    // Send the SysEx message
    midiOutput.sendMidi(activeDevice, sysexMessage);
};

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

But how do I make the script get multiple track names at once?

I also know that the Komplete Kontrol MK2 can get 8 track names at once from cubase(sysex message), so it’s definitely possible to get multiple track names at once(even more than 8 tracks).

I’m completely new to MIDI Remote API so please forgive me if I say something foolish :face_holding_back_tears:

Hi,

You have to let the script iterate over all the tracks. Unfortunately, Cubase doesn’t return the track’s ID. So the tricky part is to find out, when the script reaches the latest track. The only way, I can imagine is, to choose some more track parameters (Name, Color, Volume, Pan maybe the Inserts…) and compare. If all the chosen parameters are the same as the previous track, the script expects, that was the last track, so it returns from the for loop.

1 Like

Thanks! I thought of iterate through all the tracks actually. So should I somehow make the script “select” every track to get all of the track names? Or is there a cleverer way?

Hi,

You don’t have to select the track. You can use the Mixer Banks for example.

1 Like

Not sure what you mean by this, probably all tracks?
Anyway, you can create a mixer bank zone and send the track names using their index in this bank zone.

var mixerBankZone=page.mHostAccess.mMixConsole.makeMixerBankZone("mixerBankZone")
mixerBankZone
    .excludeInputChannels()
    .excludeOutputChannels()

var tracksNumberPerBank=256

for(var trackNumber=0;trackNumber<tracksNumberPerBank;trackNumber++){
    var track=mixerBankZone.makeMixerBankChannel()
    track.mOnTitleChange=function(activeDevice,activeMapping,title){
        var trackIdInTheBankZone=this.trackNumber
        //send the track name here 
    }.bind({trackNumber})
}

2 Likes

hmmm, I think my current code only returns the track name(the object title) when manually select a track(it’s triggered by “mOnTitleChange”). I have no idea how to get track names using bank change or something like that(cubase just return some controller data when bank change happens)

I’ll try it out! Thanks!!
I mean the “latest track” by “if any track name is modified, it send all of the track names again”, but it seem to be impossible now

When a track name is modified, the mOnTitleChange for this track (belonging to the mixer bank zone) will get triggered, so you can send its altered name to your device.

Ah I see! Thanks again :smiley:

Is this your controller? If so, you can always try my script for it, and alter portions of the code for your needs or even just copy/paste them to your own implementation.

Ohh, Thank you so much!
Yes that’s my controller, I actually saw your post of your script and downloaded the script yesterday, but I did not get the time to learn it deeply yet. Really brilliant though!
BTW, it seem that the “.midiremote” file cannot be easily opened with any IDE, I don’t really know how to view your script code :disappointed_relieved:

After you import it to cubase using the midi remote manager, a folder containing the source code will be generated and the midi remote will point you there, no worries.

Hi,

Btw, I don’t see much use cases for the “Get All Track Names” feature. On the hardware, you will be always limited by the number of the controllers, so you don’t need to see all tracks at all. And even if you would like to select a dedicated track from the list, the list has limited number of lines. Then you have to scroll. So again, you can ask Cubase just for this limited number of tracks to display in the list.

Or am I missing something?

Oh that’s how it works, nice! Thanks again :smiley:

Yes, the “Get All Track Names” feature doesn’t have much usage normally. It is just a work around for trying to update my template tracks(add or remove) without manually changing the midi remote channel number settings.

I was using open stage control and generic remote for controlling certain track(let’s call it Monitor) volume, and it was all working perfectly until… A new track is added before the Monitor track. So turns out cubase is using channel number(the order number of tracks) to locate any track, the downside to that is whenever the order is messed up, my Generic Remote preset has to change as well.(All because of cubase not willing to send out track id data of course :disappointed_relieved:)

So I’ve been thinking, if I can get all of the track names and log them down, I can calculate the channel number for each of them, and then let’s say the monitor is the 34th track name in the list, the channel number of it should be 33, and then I can dynamically generate a json file for my Midi Remote script to read, so it’ll know the exact channel number for Monitor regarding any track order change.

But I guess I’ll have to reload the script every time when I change track order right? That’d be quite painful to be honest

Hi,

You don’t have to reload the script in this case. The tracks in the given Bank Zone change and your hardware will recognize it. Then you can inspect the tracks again.

Isn’t it possible to put your Monitor track to the very beginning? This might be easier for the script then.

Yes that’s actually the easiest solution~
But if I can get track names dynamically, everything will be more flexible I guess :smiley:

Hi there!
I just tested the code, it’s perfect for sending track names! But it seem that it’s not sending the messages in the original order of the track :cry: Can I somehow also get the channel number of each track, or is there a way to make the track name sent retain the original order?

Nevermind~ It turns out all I need is to use the

trackNumber

:joy: it’s representing the number of the track in the bank

It’s an asynchronous process, so the order is not always the same.

You can always create an array of the track names, and send them in a proper timing, for example if I remember correctly, you can use the mOnIdle event for that (Cubase 13).

Nope, it adds overhead. My suggestion is to keep it simple by following @Martin.Jirsak 's hint.

Anyway, you can have multiple mixer bank zones, and you can include/exclude types of tracks for each one. You may want to have a look at the includeWindowZoneLeftChannels and includeWindowZoneRightChannels properties of the mixerBankZone and perhaps set your monitor track to one of these zones.