How to chek if MixerBankChannel exists?

Is there any way to know if the current channel actually exists? I want to send some kind of placeholder to empty TouchOSC buttons, but mOnTitle/ColorChange don’t want to send anything if there is no channel.

    for (var i = 0; i < 40; ++i) {  // Mapping channels
        var hostMixerBankChannel = hostMixerBankZone.makeMixerBankChannel();
        var btnTrack = Buttons['btnTrack' + (i + 1)];
        var btnMute = Buttons['btnMute' + (i + 1)];
        var btnSolo = Buttons['btnSolo' + (i + 1)];

        btnTrack.VUMeter = surface.makeCustomValueVariable('VUMeter' + (i + 1));

        page.makeValueBinding(btnTrack.VUMeter, hostMixerBankChannel.mValue.mVUMeter);

        makeVUMeter(btnTrack);

        page.makeValueBinding(btnTrack.surfaceValue, hostMixerBankChannel.mValue.mSelected);
        page.makeValueBinding(btnMute.surfaceValue, hostMixerBankChannel.mValue.mMute);
        page.makeValueBinding(btnSolo.surfaceValue, hostMixerBankChannel.mValue.mSolo);
    }

I recall such behaviour in CB12. But this changed in CB14.
Here’s a tested script, properly logging the titles:

var midiremote_api = require('midiremote_api_v1')

var deviceDriver = midiremote_api.makeDeviceDriver("Test","Check Empty Channels","m.c")

var midiInput = deviceDriver.mPorts.makeMidiInput("anInput")
var midiOutput = deviceDriver.mPorts.makeMidiOutput("anOutput")

var detectionUnit=deviceDriver.makeDetectionUnit()

detectionUnit.detectPortPair(midiInput, midiOutput)
    .expectInputNameEquals("your midi input port name")
    .expectOutputNameEquals("your midi output port name")

var surface=deviceDriver.mSurface
var mapping=deviceDriver.mMapping

var buttons=[]

for(var i=0;i<40;i++){

    var button=surface.makeButton(i,0,1,1)
    button.mSurfaceValue.mMidiBinding
        .setInputPort(midiInput)
        .bindToControlChange(0,i)

    buttons.push(button)

    buttons[i].mSurfaceValue.mOnTitleChange=function(activeDevice,arg1,arg2){
        console.log(""+this.i+" arg1="+arg1+" arg2="+arg2)
        
    }.bind({i})

}

var page=mapping.makePage("page")

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

for(var i=0;i<40;i++){

    var channel=bankZone.makeMixerBankChannel()
    page.makeValueBinding(buttons[i].mSurfaceValue,channel.mValue.mSelected)
    
}
1 Like

Thank you. I tried a lot, but I could not get mOnTitleChange to work correctly with “surface value”, but found it works surprisingly well with “mapping”

This works with all the titles on all the mappings

Controller.prototype.listenTitle = function (mapping, targetName, targetNumber) {
    var self = this;

    this.listenedTitle = null;
    var newTitle = 'empty..';

    this.targetName = targetName || this.targetName;
    this.targetNumber = targetNumber || this.targetNumber;
    mapping.mOnTitleChange = function (context, am, t1, t2) {
        if (((typeof t1 != 'string') && (typeof t2 != 'string'))
            || (t1 === '' && t2 === '')
            || (t1 === '' && typeof t2 === 'undefined')) {
            newTitle = 'empty..';
            self.sendPlaceholder(context);
            if (self.VUMeter) {
                // console.log(self.name + ' >>> Need to clear VU');
                self.sendVUMeter(0, context);
            }
        }
        else if (typeof t1 != 'string') newTitle = t2;
        else if (typeof t2 != 'string') newTitle = t1;
        else if (t1 != '') newTitle = t2;

        if (!self.listenedTitle || self.listenedTitle != newTitle) {
            self.listenedTitle = newTitle;
            self.sendTitle(newTitle, context);
        }
    }
}

Strange.