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