[Midi Remote] Specify fixed channel number/numbers for faders in script

Hi there!
Let’s say I have a track named “MONITOR”, and it’s channel number is 359
How do I simply specify channel 359 in the mapping for a fader?
My current code is like this:

function createMonitorFaders() {
    var monitorFaders =[]
    for(var monitorIndex = 0; monitorIndex < monitorNum; ++monitorIndex) {
        var monitorFader = deviceDriver.mSurface.makeFader(monitorIndex * 2 + 0.5, 2, 1, 6)

        monitorFader.mSurfaceValue.mMidiBinding
            .setInputPort(midiInput).setOutputPort(midiOutput)
            .bindToControlChange (9, 17 + monitorIndex);

        monitorFaders.push(monitorFader)
    }

    var monitorPage = deviceDriver.mMapping.makePage('Monitor Page')
    var monitorMixerBankZone = monitorPage.mHostAccess.mMixConsole.makeMixerBankZone()
        .excludeInputChannels()
        .excludeOutputChannels()

    for(var monitorIndex = 0; monitorIndex < monitorNum; ++monitorIndex) {
        var monitorMixerBankChannel = monitorMixerBankZone.makeMixerBankChannel()        
        var monitorFaderSurfaceValue = monitorFaders[monitorIndex].mSurfaceValue

        monitorPage.makeValueBinding(monitorFaderSurfaceValue, monitorMixerBankChannel.mValue.mVolume)
    }
}

Unfortunately it does not even control any track volume, not to mention controlling a track volume with specific channel number…
I don’t know what went wrong to make it not mapped to anything(cubase midi remote surface is saying the faders are mapped to nothing at all)

And I’d really rather just say 359 in the code and it map to that channel than try finding the track in cubase midi remote mapping assistant :face_holding_back_tears:
Thanks in advance!

I actually checked out this post before, but I found the solution not really suit my case.

  1. I’m too stupid to see where exactly do the code specify the channel numbers for the control to map to.
  2. In my case, my tracks are all lined up and their channel number is quite big, so generating “Max+1” number of faders can really look messy. I think what I’m trying to achieve is to simply assign any fader to a fixed, let’s say “359” channel without generating the faders for the 1-358 channels

Hi, this may help:

var midiremote_api = require('midiremote_api_v1')

var deviceDriver=midiremote_api.makeDeviceDriver("Test","Set Faders To Tracks By Name","m.c")

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

var detectionUnit=deviceDriver.makeDetectionUnit()
detectionUnit.detectPortPair(midiInput,midiOutput)
    .expectInputNameEquals("midi input")
    .expectOutputNameEquals("midi output")


var surface=deviceDriver.mSurface

var faders=[]

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

    var fader=surface.makeFader(i,0,1,5)
    fader.mSurfaceValue.mMidiBinding
        .setInputPort(midiInput)
        .bindToPitchBend(i)

    faders.push(fader)

}

var tracksNumberPerBank=256

var allTracksCustomVars=[]

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

    allTracksCustomVars.push(surface.makeCustomValueVariable("customVar"+i))

}

var page=deviceDriver.mMapping.makePage("bypass")

var mixerBankZone=page.mHostAccess.mMixConsole.makeMixerBankZone("mixerBankZone")

var tracks=[]

var tracksNames=[]
var chosenIndexes=[]
var finalTracks=[]
var comingFromMonTitle=false 
var searchTerm="Monitor"

for(var trackNumber=0;trackNumber<tracksNumberPerBank;trackNumber++){

    var track=mixerBankZone.makeMixerBankChannel()
    tracks.push(track)

    track.mOnTitleChange=function(activeDevice,activeMapping,title){

        var indexSelected=0 
        
        if(title.indexOf(searchTerm)!=-1){

            indexSelected=1
        
        }
        
        var id=this.trackNumber
        tracksNames[id]=title 
        chosenIndexes[id]=indexSelected
        comingFromMonTitle=true 
    
    }.bind({trackNumber})

}

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

    page.makeValueBinding(allTracksCustomVars[i],tracks[i].mValue.mVolume)

}


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

    faders[i].mSurfaceValue.mOnProcessValueChange=function(activeDevice,value,diff){

        if(this.i<finalTracks.length){

            var realTrack=finalTracks[this.i]
            allTracksCustomVars[realTrack].setProcessValue(activeDevice,value)

        }

    }.bind({i})

}

deviceDriver.mOnIdle=function(activeDevice){
  
    if(comingFromMonTitle){

        finalTracks=[]

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

            if(chosenIndexes[i]==1){

                finalTracks.push(i)

            }

        }

        //here is a good place to send track names 

        comingFromMonTitle=false 

    }

}

+1 as a feature request that doesn’t require code. You should be able to lock faders to channel numbers or names without having to learn how to code. It isn’t perfect, but this does work to some degree with the Generic Remote.

This is already achievable using the mapping assistant. You can always assign whichever fader to the volume of a specific track in a project. Just right click on its volume graphical element and choose “Pick for MIDI Remote Mapping: Volume” and then select the control you want.

Hmmm, I’ll have to try that. In the past, every time I’ve tried to assign specific faders, they show up in a fader bank and move like I was using an old HUI controller.

That’s amazing!! Thank you so much :smiley:

Strange, I always can assign fader to a specific track slot using mapping assistant, never encountered this

This is so clean and clear, totally beat my previous approach :joy:
So if I’m not understanding wrong, you still have to kinda bind every track to a “variable”, then somehow bind the 8(or whatever number) faders to the monitor tracks only?

Yes, we bind all tracks’ volume to custom variables (they’re elements with no UI representation). And then in the 8 faders’ mOnProcessValueChange event, we take their values (of the faders) and send them to whichever custom variables are assigned to the tracks that match the filter set.