I’m trying to trigger Key Commands via this code
// ----------------------------------------------------------------------------
// SURFACE
// ----------------------------------------------------------------------------
var surface = deviceDriver.mSurface
var slotSelectButtons = []
var keyCommandsObj = []
for (var s = 0; s < 16; s++) {
var btnSlot = surface.makeButton(s, 0, 1, 1)
btnSlot.mSurfaceValue.mMidiBinding.setInputPort(midiInput).bindToNote(1, s)
slotSelectButtons.push(btnSlot)
}
var dummyFader = surface.makeFader(0, 0, 0, 0)
dummyFader.mSurfaceValue.mMidiBinding.setInputPort(midiInput).bindToPitchBend(12)
dummyFader.mSurfaceValue.mOnProcessValueChange = function (activeDevice, value, diff) {
var kcIndex = Math.round(value * 16383)-8192
console.log("[Assistant] Command: " + keyCommands[kcIndex].category + " - " + keyCommands[kcIndex].command)
keyCommandsObj[kcIndex].setProcessValue(activeDevice, 1)
}
// ----------------------------------------------------------------------------
// MAPPING
// ----------------------------------------------------------------------------
function makePageWithDefaults(name) {
var page = deviceDriver.mMapping.makePage(name)
var kcInit = false
if (!kcInit) {
for (var i = 0; i < keyCommands.length; i++) {
var kc = keyCommands[i]; // { index, category, command }
var obj = surface.makeCustomValueVariable('kcObj' + kc.index);
page.makeCommandBinding(obj, kc.category, kc.command)
keyCommandsObj.push(obj);
}
kcInit = true
}
return page
}
Key Commands.xml parsed into JS object (var keyCommands = require(‘./keyCommands’))
module.exports = [
{ index: 0, category: "Preferences", command: "Controls - Value Box/Time Control Mode" },
{ index: 1, category: "Preferences", command: "MediaBay - Scan Folders only when MediaBay is open" },
{ index: 2, category: "Preferences", command: "MediaBay - Scan unknown File Types" },
………
{ index: 3228, category: "Process Plug-in", command: "132A82E52E2548ED8D1384E92C1C8B0E" }
];
So, it’s kinda big object, but everythyng works fine, exept one thing - Cubase interface starts lagging when track selection chenges. It didn’t happen without makeCommandBinding, but, oc, not working then