# Lemur: How to change with scripting midi controller & channel



## marcodistefano

Hi all,

I have a template where I have only one switch button set to controller change

I would like to be able to change within a script the controller and channel that this switch send

any of you know if possible?

Thanks in advance


----------



## pmcrockett

It's possible. You do it by using the _ctlout_, _noteout_, or _midiout_ commands (manual page 131) within the script to send MIDI messages instead of using the mapping panel to define MIDI messages. For example, if you wanted to send a value of 64 on CC1 on channel 1 when button ControlSwitch was pressed and a value of 64 on CC2 on channel 2 when it was unpressed your code might look like this (with Execution set to _On Expression ControlSwitch.x_):


Code:


if (ControlSwitch.x == 1)
{
        ctlout(0, 1, 64, 1); //target 0, channel 1, value 64, CC1
}
else
{
        ctlout(0, 2, 64, 2); //target 0, channel 2, value 64, CC2
}


----------



## marcodistefano

pmcrockett said:


> It's possible. You do it by using the _ctlout_, _noteout_, or _midiout_ commands (manual page 131) within the script to send MIDI messages instead of using the mapping panel to define MIDI messages. For example, if you wanted to send a value of 64 on CC1 on channel 1 when button ControlSwitch was pressed and a value of 64 on CC2 on channel 2 when it was unpressed your code might look like this (with Execution set to _On Expression ControlSwitch.x_):
> 
> 
> Code:
> 
> 
> if (ControlSwitch.x == 1)
> {
> ctlout(0, 1, 64, 1); //target 0, channel 1, value 64, CC1
> }
> else
> {
> ctlout(0, 2, 64, 2); //target 0, channel 2, value 64, CC2
> }


Thank you!

Each of my cubase track sends on selection a specific polypressure to Lemur which I use to identify the track.
So my lemur template changes dynamically on selecting a track in Cubase.

I would like to use this single button to enable the selected track in VEPRO.
So when the track is selected I need to change the controller and channel of the switch, so that if later I will click it the right automation will be triggered.

I think the best to do it, following your example is to store into variables the channel and controller when the midi event of a track being selected in cubase is received, and then use these variables on execution as in your script.

Do you think is the correct approach?

Is there a way to change the controller and channel (as if I was changing in the UI) of the switch so that I don't need to have another script on execution?

Thanks
Marco


----------



## Mihkel Zilmer

Hi Marco,

Technically what you want is quite easy to achieve. As incoming MIDI_ARGS are used to define the track selection, you can save that data in a global variable (in the MIDI_IN script), and then have the button use that variable to transmit the specific data.

But I have a question - why would you need this extra step? In my template, I have a single button always transmitting CC125. Each track in Cubase is set to its own VEPRO MIDI Port and Channel already, so once I press the button, CC125 gets sent out on that Port & Channel. 

Cheers,
Mihkel


----------



## marcodistefano

Mihkel Zilmer said:


> Hi Marco,
> 
> Technically what you want is quite easy to achieve. As incoming MIDI_ARGS are used to define the track selection, you can save that data in a global variable (in the MIDI_IN script), and then have the button use that variable to transmit the specific data.
> 
> But I have a question - why would you need this extra step? In my template, I have a single button always transmitting CC125. Each track in Cubase is set to its own VEPRO MIDI Port and Channel already, so once I press the button, CC125 gets sent out on that Port & Channel.
> 
> Cheers,
> Mihkel


Hi Mihkel,
as you know I am extending your template and thanks for sharing it. This part is one I completely developed myself, so not included in your template and is about controlling the enabled tracks in VEPRO.

I want to have one single button to enable/disable the tracks inside VEPRO depending on the cubase selection. As far as I know it is impossible to do this with just one CC?

The way I do it now is with several switches (and that would like to improve having one single button)

in my generic remote setup I have one entry for each cubase track (corresponding to one VEPRO channel) each triggered by a different CC/channel (and linked to the lemur one)
Each of this entry triggers an event in VEPRO (always a different one)
In the automation panel of VEPRO I map each of this entry with the enable/disable of the track
In Lemur I have a page with switches, each sending a specific CC/channel so I can choose the track to enable/disable
Look here to see it in action


Are you aware of a method to do this with one single button?

thanks
Marco


----------



## Mihkel Zilmer

Sure - I explained it in my video #10 last year. It takes 2 buttons - one to enable, one to disable each VEPro channel.

Channel & port assignment is defined by selected track (if you are using channel values in your Expression Maps - don't worry - Expression Map channels override the channel selection in Cubase).
CC value never changes. VEPro automation mapping is set up accordingly and responds to individual port & channel numbers.

For more information, check my video:


And also the conversation here:
https://vi-control.net/community/th...pression-maps-added.65157/page-2#post-4151567

And I am not sure if I ever posted a version of the template with enable & disable buttons, but I did send it to a couple of people privately.. here it is again:


----------



## marcodistefano

Mihkel Zilmer said:


> Sure - I explained it in my video #10 last year. It takes 2 buttons - one to enable, one to disable each VEPro channel.
> 
> Channel & port assignment is defined by selected track (if you are using channel values in your Expression Maps - don't worry - Expression Map channels override the channel selection in Cubase).
> CC value never changes. VEPro automation mapping is set up accordingly and responds to individual port & channel numbers.
> 
> For more information, check my video:
> 
> 
> And also the conversation here:
> https://vi-control.net/community/th...pression-maps-added.65157/page-2#post-4151567
> 
> And I am not sure if I ever posted a version of the template with enable & disable buttons, but I did send it to a couple of people privately.. here it is again:



Thanks Mihkel

if I can make this work it will be a huge improvement for my workflow!
I will watch the video as soon as I can and make a test at home

Thanks again for sharing your knowledge! +1

Kind Regards
Marco


----------



## Mihkel Zilmer

You're welcome!

The video does not go into very much detail so if you get stuck somewhere let me know.


----------



## Nite Sun

Mihkel Zilmer said:


> Channel & port assignment is defined by selected track (if you are using channel values in your Expression Maps - don't worry - Expression Map channels override the channel selection in Cubase).
> CC value never changes. VEPro automation mapping is set up accordingly and responds to individual port & channel numbers.



Hi Mihkel. Slightly confused on this point. If an instrument uses expression maps that define channel value changes does VEPro automation mapping need to be set up for all of the channels that are used by that instrument (in order to catch enable/disable commands when the instrument is transmitting midi on a different channel)?


----------



## Mihkel Zilmer

Nite Sun said:


> Hi Mihkel. Slightly confused on this point. If an instrument uses expression maps that define channel value changes does VEPro automation mapping need to be set up for all of the channels that are used by that instrument (in order to catch enable/disable commands when the instrument is transmitting midi on a different channel)?



If you want to use Enable & Disable buttons regardless of which Expression Map slot you have selected currently, then you will need a separate VEPro automation mapping for each MIDI channel used by the instrument, since the Expression Map overrides the track MIDI routing settings.

But setting up automation mappings in VEPro is rather time-consuming, so personally I couldn't be bothered to set this up for each instrument that uses multiple channels - I have my VEPro automation mapping matching the channel used by slot #1, and switch back to that slot when I want to Disable a channel - see attached screenshot. It's just one more button tap for disabling channels.. and for enabling works straight away as I've always gone back to slot #1.


----------



## Nite Sun

Thanks, that makes sense. I'm leaning toward using keyboard shortcuts instead of lemur for enabling/disabling VEPro instruments. The idea would be to have two shortcuts that do the following:

Shortcut 1 (Enable):
1) Enable the selected (disabled) track in Cubase
eset (Command>Audio>Disable/Enable Track --- confusingly under the audio menu but does also apply to MIDI and instrument tracks)
2) Send note-on C-2 to trigger expression map slot 1, thus resetting any Expression Map defined channel changes to default (possibly not necessary as I'm guessing expression map slots are reset to default when a track is enabled for the first time)
3) Send out a value of 127, CC125 (which enables the instrument in VEPro) on the selected track

Shortcut 2 (Disable):
1) Send note on C-2 to trigger expression map slot 1, thus resetting any Expression Map defined channel changes to default
2) Send out a value of 0, CC125 (which disables the instrument in VEPro) on the selected track
3) Disable the selected (enabled) track in Cubase

Enabling/disabling tracks in Cubase would serve as a useful visual guide as to what is enabled/disabled in VEPro. Do you know of a way that this could be done with macros/PLE/generic remote? Is it even possible to trigger note-on and CC events with macros/PLE? Would there need to be a pause between commands for them to execute correctly?

P.S. sorry for hijacking this thread, but i've been wondering about this for a long time


----------



## Mihkel Zilmer

I might be wrong, but I am pretty sure you need a third party MIDI capable piece of software to do what you want to do.
Cubase doesn't have a built in method of sending out a specific MIDI message from a keyboard shortcut. You definitely can't do it with PLE, and I don't think it is available in Generic Remote either.

I would need to test to confirm, but I think Lemur could do this - sending several messages from one button is easy, and also a Generic Remote could be set up to Enable & Disable the actual track.

Or you could probably get this going with BOME Midi Translator, which has options to send MIDI messages from keystrokes.


----------



## Nite Sun

I thought that might be the case. If the track was disabled in Cubase wouldn't lemur have trouble addressing it? I was hoping that Generic remote might be able to send note-on and CC upon the enable/disable command but perhaps that's beyond the capabilities of Cubase.


----------



## Nite Sun

BOME midi translator looks like the way to go, Thanks for the heads up


----------



## Mihkel Zilmer

Nite Sun said:


> If the track was disabled in Cubase wouldn't lemur have trouble addressing it?



Precisely! Just did some testing to get the 3 part functionality you wanted - can't get the final step to work with Lemur. 

Getting a Lemur button to send two values - to jump back to slot #1 and then to Enable & Disable corresponding VEPro channel is no problem, nor is setting up Generic Remote to respond to a CC and Disable the Cubase track itself. But, once the track is Disabled in Cubase then its MIDI input is also disabled. Therefore the Lemur button can no longer re-activate it.


----------



## Mihkel Zilmer

Nite Sun said:


> Enabling/disabling tracks in Cubase would serve as a useful visual guide as to what is enabled/disabled in VEPro.



Beware though - if you are using MIDI sends, then their routing gets lost once you save & quit with disabled MIDI tracks, then relaunch Cubase and enable the tracks. It's a known bug, and has been reported - and is supposedly on their list to be fixed in 9.5.30


----------



## Nite Sun

Haha, yes - that was me reporting the bug on the Steinberg forums!


----------



## pmcrockett

marcodistefano said:


> Is there a way to change the controller and channel (as if I was changing in the UI) of the switch so that I don't need to have another script on execution?


Not possible, as far as I know. Once you get into advanced MIDI scripting, you pretty much have to abandon the mapping panel.


----------



## marcodistefano

pmcrockett said:


> Not possible, as far as I know. Once you get into advanced MIDI scripting, you pretty much have to abandon the mapping panel.


ok thanks


----------



## ChesLans

Hi...i am a new user here. As per my knowledge as incoming MIDI_ARGS are used to define the track selection, you can save that data in a global variable, and then have the button use that variable to transmit the specific data.

turnkey pcb assembly


----------

