Need a Midi Remote kickstart ... How to get a track name from Cubase and send it to device?

I mange to create typical control elements like knobs and faders via Java Scripting (which is new to me), but I am having major difficulties to get into creating deeper things! The thing I am missing is enough examples to see how those things work. That is why I wanted to ask, if somebody could help me to create a small example, that could help me to warp my head around some things …

I don’t use an actual hardware controller for this learning project, but rather the application Max (MSP), where I can create virtual midi ports or control elements. But that shouldn’t make any difference AFAIK.

My goal is this: I want to send the track name (the actual word(s)) of the last track selected in Cubase as a SysEx message to Max. In Max I want to then display the track name in a text field (this I know how to do!).

I can somehow see how to send a sysex message, but I have no clue how to gather the name of the selected track and how to convert that into hexadecimal, which it must be in oded to be sent as SysEx!

If possible, I would also like to have the track name appear on the Cubase Midi API surface. I suppose, that is what the object ‘SurfaceLabelField’ is for. But I don’t get how to even write anything on that label from the scripting manual.

This is the blank script. Would anyone be so kind to add the lines of code that would get me into the right direction? Thanks!

//-----------------------------------------------------------------------------
// 1. DRIVER SETUP - create driver object, midi ports and detection information
//-----------------------------------------------------------------------------

var midiremote_api = require('midiremote_api_v1')

var deviceDriver = midiremote_api.makeDeviceDriver('XCoding', 'TestControl', 'AuthorX')

var midiInput = deviceDriver.mPorts.makeMidiInput()
var midiOutput = deviceDriver.mPorts.makeMidiOutput()

// thes are the midi in and out ports used. Note: those are virtual (IAC), but that seems to work.
deviceDriver.makeDetectionUnit().detectPortPair(midiInput, midiOutput)
    .expectInputNameEquals('IAC2Cubase IN')
    .expectOutputNameEquals('IACFromCubase OUT')
    
deviceDriver.makeDetectionUnit().detectPortPair(midiInput, midiOutput)
    .expectInputNameEquals('IAC2Cubase (MIDI IN)')
    .expectOutputNameEquals('IACFromCubase (MIDI OUT)')


//-----------------------------------------------------------------------------
// 2. SURFACE LAYOUT - create control elements and midi bindings
//-----------------------------------------------------------------------------

// The fader is a test and it worked, the Label is where I want to track name to go.
var fader1 = deviceDriver.mSurface.makeFader(0, 0, 1, 6)
var Label1 = deviceDriver.mSurface.makeLabelField (1, 1, 4, 1)


// bind midi ports to surface elements
fader1.mSurfaceValue.mMidiBinding
    .setInputPort(midiInput)
    .setOutputPort(midiOutput)
    .bindToControlChange (0, 1) // channel 0, cc 1



//-----------------------------------------------------------------------------
// 3. HOST MAPPING - create mapping pages and host bindings
//-----------------------------------------------------------------------------

// create at least one mapping page
var page = deviceDriver.mMapping.makePage('Example Mixer Page')

// create host accessing objects
var hostSelectedTrackChannel = page.mHostAccess.mTrackSelection.mMixerChannel

Hi,

Does this help?

for (var i = 0; i < tracksCount; ++i) {
	var name = surfaceElements.knobStrips[i].objectTitle
	printToDisplay(name)
}

Hi Martin, thanks for the tip! Just pasting this into the script causes errors in the script. Either this is because your code needs other modifications to the rest of the script I do not understand yet or there just are some mistakes. I will try to understand what could be missing, but it will take me some time.

It would be great, however, is you or someone else could just post a snippet that I could simply paste into the script that would work, so that I can understand how it works and from there get into how this scripting language generally works.

I am by no means a programmer, but I learned some Kontakt scripting, which is fairly easy to learn, as there are many examples your can study to understand the scripting language. With this remote API, it is rather complicated and frustrating, For most example scripts that you can find, you would need that hardware controller to really test it and learn from modifications you apply. Also, the way the language works is not explained anywhere. I suppose you need to learn Java, first. I did a crash course, however, I still do not really get how to put anything together. I would be really great, if Steinberg could make it a little easier for non-programmers to get into it more intuitively.

Hi,

You are right, this is not final code. You need to get the objectTitle of your track’s Volume parameter.

Java and JavaScript aren’t the same thing, don’t waste time learning Java. There are plenty of tutorials about JS online. You don’t have to get really advanced knowledge on JS to use the API but you at least need to learn about function syntax and closures.

And you also can play with existing scripts to learn a bit more. Don’t be scared to tweak them a bit.

Cheers,

Thomas

1 Like

Sorry, but at this point, I cannot do it with that hint. Visual Code gives me the errors entering your code in my patch:

  1. Cannot find name ‘tracksCount’.ts(2304)
  2. Cannot find name ‘surfaceElements’. Did you mean ‘MR_SurfaceElement’?ts(2552)
  3. Cannot find name ‘printToDisplay’.ts(2304)

I suppose the only way at this point would be having an example that just Warks as it is, and from that I could start learning. Or I will figure it out at some point, but right now, it is simply to much I don’t get at all,

Yes, I menat a beginner tutorial in Java script. I was not aware of Java being something else, but good to know! I watched some 1 hour tutorial and that was pretty easy to understand, but I still don’t understand a lot about the syntax about the Remote API. I guess I will have to check more tutorials before starting into Remote API.

But I still think the documentation could be a lot better! I mean, Kontakt scripts manual is not exactly though … but at least every variable and function there is explained in a few sentences and with one or two examples. Here, you mostly get a list of functions and variables with hardly any explanation … I still haven’t figured out where even to find the parameter I am looking for (track name). Even with the hint from Martin. :slight_smile:

Hi,

Yes, this is my internal method in the code.

This is internal object. It is in use in almost any MIDI Remote factory (Steinberg) script.

This is my internal method to print the result to the Mackie C4 display.

Ok, Martin! But how is this code snippet going to help me, if there are all of these dependencies, I couldn’t possibly know how to figure out? Isn’t there a more constructive way of adding a code snippet to my example script (without any dependencies!), that will help me understand what I must learn in order to reach my goals?

Hi,

Does this help to you?

selectedTrackLabel = surface.makeLabelField(0, 0, 16, 1)

...

function makeSelectedTrack() {
	var page = deviceDriver.mMapping.makePage('Selected Track Page')
	page.setLabelFieldHostObject(selectedTrackLabel, page.mHostAccess.mTrackSelection.mMixerChannel)

	return page
}

var pageSelectedTrack = makeSelectedTrack()