this is the custom module so far:
var buttonGrid, labelTexts;
var buttons = {
'b1': '/b1/show','b2': '/b2/show','b3': '/b3/show','b4': '/b4/show','b5': '/b5/show','b6': '/b6/show','b7': '/b7/show','b8': '/b8/show','b9': '/b9/show','b10': '/b10/show',
'b11': '/b11/show','b12': '/b12/show','b13': '/b13/show','b14': '/b14/show','b15': '/b15/show','b16': '/b16/show','b17': '/b17/show','b18': '/b18/show','b19': '/b19/show','b20': '/b20/show',
'b21': '/b21/show','b22': '/b22/show','b23': '/b23/show','b24': '/b24/show','b25': '/b25/show','b26': '/b26/show','b27': '/b27/show','b28': '/b28/show','b29': '/b29/show','b30': '/b30/show',
'b31': '/b31/show','b32': '/b32/show','b33': '/b33/show','b34': '/b34/show','b35': '/b35/show','b36': '/b36/show','b37': '/b37/show','b38': '/b38/show','b39': '/b39/show','b40': '/b40/show',
'b41': '/b41/show','b42': '/b42/show','b43': '/b43/show','b44': '/b44/show','b45': '/b45/show','b46': '/b46/show','b47': '/b47/show','b48': '/b48/show','b49': '/b49/show','b50': '/b50/show',
'b51': '/b51/show','b52': '/b52/show','b53': '/b53/show','b54': '/b54/show','b55': '/b55/show'
}
var labels = {
'b1': '/b1/label','b2': '/b2/label','b3': '/b3/label','b4': '/b4/label','b5': '/b5/label','b6': '/b6/label','b7': '/b7/label','b8': '/b8/label','b9': '/b9/label','b10': '/b10/label',
'b11': '/b11/label','b12': '/b12/label','b13': '/b13/label','b14': '/b14/label','b15': '/b15/label','b16': '/b16/label','b17': '/b17/label','b18': '/b18/label','b19': '/b19/label','b20': '/b20/label',
'b21': '/b21/label','b22': '/b22/label','b23': '/b23/label','b24': '/b24/label','b25': '/b25/label','b26': '/b26/label','b27': '/b27/label','b28': '/b28/label','b29': '/b29/label','b30': '/b30/label',
'b31': '/b31/label','b32': '/b32/label','b33': '/b33/label','b34': '/b34/label','b35': '/b35/label','b36': '/b36/label','b37': '/b37/label','b38': '/b38/label','b39': '/b39/label','b40': '/b40/label',
'b41': '/b41/label','b42': '/b42/label','b43': '/b43/label','b44': '/b44/label','b45': '/b45/label','b46': '/b46/label','b47': '/b47/label','b48': '/b48/label','b49': '/b49/label','b50': '/b50/label',
'b51': '/b51/label','b52': '/b52/label','b53': '/b53/label','b54': '/b54/label','b55': '/b55/label'
}
module.exports = {
oscInFilter:function(data)
{
var {address, args, host, port} = data
if (host === 'midi' && port === 'MCUtoOSC' && address === '/sysex') {
if (args[0].value.includes('f0 00 00 66 14 12')) {
send('midi', 'OSCtoMCU', '/note', 1 ,44 ,127);
// CUBASE TRACKS HEX TO ASCII STRING
var input = args[0].value.split(' ').splice(7 ,35);
input.pop();
input = input.join('');
var trackname = '';
for (var n = 0; n < input.length; n += 2) {
trackname += String.fromCharCode(parseInt(input.substr(n, 2), 16));
}
console.log(trackname)
// RECEIVE TRACKNAMES IN OSC DYNAMICALLY
if (trackname) {
receive('/EDIT', 'trackname', {value: trackname})
}
/*********** GENERATING EXPRESSION MAPS DYNAMCALLY - YESSSSS!!!!!! ************/
const path = nativeRequire('path');
const fs = nativeRequire('fs');
const xml2js = nativeRequire('xml2js');
const glob = nativeRequire('glob');
const mapFiles = glob.sync(path.join(__dirname, '../../Steinberg/Expression Maps/*.expressionmap'));
const trackID = (trackname.match(/[0-9]{4}$/) || [])[0] //
async function buildMap() {
artArr = [];
artColor = [];
for (const mapFile of mapFiles) {
if (mapFile.includes(trackID)) {
const parser = new xml2js.Parser({
explicitArray: false,
mergeAttrs: true
}); // 'mergeAttrs: true' was essential
console.log('Selected Map: ' + mapFile);
const data = await fs.promises.readFile(mapFile);
const result = await parser.parseStringPromise(data);
const art = result.InstrumentMap.member[1].list.obj;
for (let i = 0, len = art.length; i < len; i++) {
artArr[i] = art[i].member[1].string.value
artColor[i] = art[i].int.value
}
// once we've run this inner for loop once, we can't
// run it again because it will overwrite values in
// artArr and artColor, so we break the outer for loop
break;
}
}
return { artArr, artColor };
}
buildMap().then(result => {
// use your results here
console.log('TRACKID: ' + trackID);
/************* BUTTONS GENERATING DYNAMICALLY - YESSSSSS!!! AGAIN ****************/
buttonGrid = artArr.length
labelTexts = Object.values(artArr);
for (i = 0; i < buttonGrid; i++)
{
var label = labelTexts[i]
receiveOsc({address: Object.values(buttons)[i], args: [{type: 'i', value: 1}]})
receiveOsc({address: Object.values(labels)[i], args: [{type: 's', value: label}]})
}
for (i = buttonGrid; i < 55; i++)
{
receiveOsc({address: Object.values(buttons)[i], args: [{type: 'i', value: 0}]})
}
return
}).catch(err => {
console.log(err);
});
}
}
// CUBASE BEATS & BARS
if (host === 'midi' && port === 'MCUtoOSC') {
var [channel, control, value] = data.args.map(x=>x.value)
if (control > 63 && control < 74) {
var digit = 73 - control,
msb = value >> 4,
val = value & 0xF
if (msb >> 2) val += '.'
if (!(msb & (1 << 1))) val = ''
// digit -> digit
// val -> digit's value
// assuming 10 text widgets with incrementing preArgs
receive('/timecode', digit, val)
return
}
}
return data
},
}