Is it possible to have multiple midi targets in a single widget. I have a OSC listener @{midi_target}
that enables me to set the target of a widget but I have a different Midi channels for in and out and I want to send or receive midi for these channels into and out of the widget.
Is this possible?
Multiple targets can be set for a widget with this syntax:
[
"midi:a",
"midi:b"
]
Thanks, I'm halfway there on this.
I have a Matrix widget that I set the props such as this:
{
"padding": -1,
"preArgs": "#{$}",
"address": "/timecode",
"target": "@{midi_target}",
"alphaFillOff": "#{[3,4,7,8,9].includes($) ? 0.15 : 0.2}"
}
and I have in my custom module:
var globalMIDItarget = [ "midi:MCU_To_OSC", "midi:MCU_From_OSC" ]
// set midi target in interface
app.on('sessionOpened', ()=>{
receive('/SET', 'midi_target', globalMIDItarget)
console.log('Global midi target set as ' + globalMIDItarget)
})
but whilst I get the console log as follows the MIDI I/O is not working.
If I change the "target": "@{midi_target}",
in the props
to
"target": [ "midi:MCU_To_OSC", "midi:MCU_From_OSC" ]
this works but I can't seem to get it to work if I set it globally.
It should work but there's a bug in the resolution of the property, it's fixed in sources already. Until next release you should be able to circumvent the issue by removing the quotes around @{midi_target}
.
In the widget props
like this?
{
"padding": -1,
"preArgs": "#{$}",
"address": "/timecode",
"target": @{midi_target},
"alphaFillOff": "#{[3,4,7,8,9].includes($) ? 0.15 : 0.2}"
}
Thanks
Just wondering if that release is imminent… I have a lot of widgets that I’m going to have to go through and change to the workaround so I don’t want to do that if I only have to wait a few days or so…
Great!
Yours, in anticipation…
So I have got this working by including this in the custom module but have hit a stumbling block which I will explain below.
Custom Module Code
//Core MIDI Ports
var coreCubase_from_OSC = 'OSCMIDICONTROL'; //BASE MIDI PORT FOR DIRECT FUNCTIONS FROM OSC
var coreCubase_to_OSC = 'OSCMIDICONTROL'; //BASE MIDI PORT FOR DIRECT FUNCTIONS FROM CUBASE'
MCU_DEVICE_To_OSC = 'MCU_To_OSC' //Mackie Control port from Cubase to OSC
OSC_DEVICE_To_MCU = 'MCU_From_OSC' //Mackie Control Port from OSC back to Cubase
var core_Cubase_Target = `[ "midi:${coreCubase_to_OSC}", "midi:${coreCubase_from_OSC}"]`
var MCU_midi_target = `[ "midi:${MCU_DEVICE_To_OSC}", "midi:${OSC_DEVICE_To_MCU}"]`
// set midi target in interface
app.on('sessionOpened', () => {
console.log("Setting Global MIDI Targets...")
//Set MACKIE MIDI PORT
receive('/SET', 'MCU_midi_target', MCU_midi_target)
console.log("MCU MIDI Target device set as " + MCU_midi_target)
///SET CUBASE GENERAL COMMAND MIDI PORT
receive('/SET', 'core_cubaseMIDI_target', core_Cubase_Target)
console.log("Core Cubase MIDI Target device set as " + core_Cubase_Target)
})
This works fine for the MCU midi when I run the OSC session but not for the cubase midi target and when I open the session on another machine there is a bit of a delay and eventually the MCU responds (probably a handshake thing which I can look at resolving) but again for cubase target there are no midi messages sent when I interact with the touch screen - if I touch a button then OSC console is silent and no messages are passed to Cubase MIDI in.
In short - the MCU target is set but not the cubase one.
Edit : retested and amended the problem statement
One thing I don't understand is why you need to connect a widget to both MCU_To_OSC and MCU_From_OSC, these sound like the in and out of the same target and there's no reason to send midi messages to both of them in that case. What's your server's midi config exactly ?
A proper config could look like this:
MCU:mcu_to_osc,osc_to_mcu CUBASE:cubase_to_osc,osc_to_cubase
Then setting a widget's target to midi:MCU
would be fine to send midi to the MCU and receive from it.
Note: the input and output ports in the config can be strings instead of numbers (see MIDI configuration - Open Stage Control). In above example, MCU would take as input the first port that contains "mcu_to_osc" in its name.
(see also this post)
So reasoning behind the multiple targets is complicated but primarily because I need to isolate the i/o at cubase end or I end up with feedback loops.
my midi config at server end is:
OSCMIDICONTROL:21,22 MCU_To_OSC:15,-1 MCU_From_OSC:-1,17 mtc sysex
I wondered if this was because I was creating the same midi target twice in the widget so have amended the above code to:
var core_Cubase_Target = `"midi:${coreCubase_from_OSC}"`
var MCU_midi_target = `[ "midi:${MCU_DEVICE_To_OSC}", "midi:${OSC_DEVICE_To_MCU}"]`
// set midi target in interface
app.on('sessionOpened', () => {
console.log("Setting Global MIDI Targets...")
//Set MACKIE MIDI PORT
receive('/SET', 'MCU_midi_target', MCU_midi_target)
console.log("MCU MIDI Target device set as " + MCU_midi_target)
///SET CUBASE GENERAL COMMAND MIDI PORT
receive('/SET', 'core_cubaseMIDI_target', core_Cubase_Target)
console.log("Core Cubase MIDI Target device set as " + core_Cubase_Target)
})
But again the listener in the widget doesn't seem to be updated:
And I have tested putting this in the target:
and this works but I wanted to create a way to amend all the targets easily if I change my midi device routing....
and I have tried using this in the custom module with the listener as above in place but this doesn't work as follows:
var core_Cubase_Target = 'midi:OSCMIDICONTROL' //TREID SETTING THIS DIRECTLY HERE
var MCU_midi_target = `[ "midi:${MCU_DEVICE_To_OSC}", "midi:${OSC_DEVICE_To_MCU}"]`
// set midi target in interface
app.on('sessionOpened', () => {
//Set MACKIE MIDI PORT
receive('/SET', 'MCU_midi_target', MCU_midi_target)
///SET CUBASE GENERAL COMMAND MIDI PORT
receive('/SET', 'core_cubaseMIDI_target', core_Cubase_Target)
})
You can connect to two different loopMidi port with a single target in open stage control (see linked post above). Open stage control does not generate midi feedback loops.
Anyway your solution should work, but I'm realizing now you may have written @{core_cubaseMIDI_target} without creating a widget with core_cubaseMIDI_target
as id. The @{} syntax does not create a listener, it retrieves the value of an existing widget.
Thanks brilliant - I missed this crucial step - I've added a variable widget called core_cubaseMIDI_target
and now it all works as planned.