I would like to know if the selected track is midi, audio, instrument, etc.
Is it possible to get the type of track that is selected with the remote midi api?
I have been searching for that in the API reference website, but I didn’t find it…
I would like to know if the selected track is midi, audio, instrument, etc.
Is it possible to get the type of track that is selected with the remote midi api?
I have been searching for that in the API reference website, but I didn’t find it…
On CB 13.0.51 and 14, you can try this:
var selTrackDA=page.mHostAccess.makeDirectAccess(page.mHostAccess.mTrackSelection.mMixerChannel)
var trackSelected=page.mHostAccess.mTrackSelection.mMixerChannel.mValue.mSelected
var trackSelectedCV=surface.makeCustomValueVariable("trackSelectedCV")
page.makeValueBinding(trackSelectedCV,trackSelected).mOnValueChange=function(activeDevice,activeMapping,value){
if(value==1){
//selected
var baseObjectID=selTrackDA.getBaseObjectID(activeMapping)
var objectUniqueName=selTrackDA.getObjectUniqueName(activeMapping,baseObjectID)
var trackType=objectUniqueName.replace(/\s?\d+$/, '')
console.log("type="+trackType)
}
}
Wow!!
It works perfectly!!
I would need two lifes to understand that code… but I will try to analyze it calmly!
Thanks a lot @m.c !!!
I just stumbled over this thread and first I have to say that it is really nice to see how supportive the community is. This is great.
As a side remark: Examples like this show what for sure cannot be the future of programming a remote controller. With all due respect for the API-Developers (they are not to blame imho): If such a piece of code is necessary to achieve a trivial result as required, we are in the late stone-age of software development. I mean, generally speakingt: The scripting language for programming Remotes is on an abstraction level that is shockingly low.
Again: I am NOT criticicing the API-developers, but the paradigms we are using in the third decade of the 2000th…it is simply absurd.
@m.c. do you know how to get all the track types of a bank and store them in a global array variable?
I’ve been trying for a while, but I’m going blind.
Here’s a part of the code I’m using.
The variable “bankTrackNames” contains the names of the four tracks in the bank.
My intention is to store the type value of each track in the variable “bankTrackTypes”
function sendSysexString(activeDevice,receivedString,sysexID,consolePrefix){
var sysexMessage=[0xF0,sysexID].concat(receivedString.split('').map(function(c){return c.charCodeAt(0)})).concat([0xF7])
midiOutput.sendMidi(activeDevice,sysexMessage)
console.log(consolePrefix + receivedString)
}
var mixerBankZone=page.mHostAccess.mMixConsole.makeMixerBankZone("mixerBankZone")
var qtyOfTracksPerBank=4
var bankTrackNames = []
var bankTrackTypes = []
for(var bankTrackIndex=0;bankTrackIndex<qtyOfTracksPerBank;bankTrackIndex++){
var bankTrack = mixerBankZone.makeMixerBankChannel()
// get name of every track of bank
bankTrack.mOnTitleChange=function(activeDevice,activeMapping,title){
var bankTrackId = this.bankTrackIndex
title = title.length==0 ? " " : title
bankTrackNames[bankTrackId+1] = title
var bankTrackNames_consoleLogPrefix = "Bank, Track " + (bankTrackId+1) + " - Name: "
sendSysexString(activeDevice,bankTrackNames[bankTrackId+1],bankTrackId+1,bankTrackNames_consoleLogPrefix)
}.bind({bankTrackIndex})
}
Thanks in advance!!
Isn’t this the same request as the one I replied here? MIDI REMOTE API: Get type of track? - #2 by m.c
Not the same, that code is for getting the type of track of the selected track.
Correct. So instead of having the direct access handling the selected track, we can have it handle the channels of the mixer bank zone. Everything else stays the same. Sorry, I’m off till Monday, so I cannot write any snippet (at least without checking it first on my system).
Yes, that is what I have been trying, but I can’t make it work.
I will wait to next week, of course! No problem!
Outside of the for block, place this:
var daMixer=page.mHostAccess.makeDirectAccess(mixerBankZone)
The bankTrack.mOnTitleChange can be altered like this:
bankTrack.mOnTitleChange=function(activeDevice,activeMapping,title){
var bankTrackId = this.bankTrackIndex
title = title.length==0 ? " " : title
bankTrackNames[bankTrackId+1] = title
var bankTrackNames_consoleLogPrefix = "Bank, Track " + (bankTrackId+1) + " - Name: "
sendSysexString(activeDevice,bankTrackNames[bankTrackId+1],bankTrackId+1,bankTrackNames_consoleLogPrefix)
var trackID=this.bankTrack.getRuntimeID(activeMapping)
var objectUniqueName=daMixer.getObjectUniqueName(activeMapping,trackID)
var trackType=objectUniqueName.replace(/\s?\d+$/, '')
bankTrackTypes[bankTrackId+1]=trackType
console.log("type of track "+(this.bankTrackIndex+1)+"="+trackType)
}.bind({bankTrackIndex,bankTrack})
Thanks a lot @m.c !!! It works like a charm !!!