MapWidgetToPlugin equivalent for Midi Out Block?

Hit a bit of a road block with a script, hoping I can get some assistance. To simplify the explanation I have a MIDI controller with a knob and a fader.

The fader is mapped to a MIDI Out block and initially I have it mapped to the parameter CC1. I move the fader and values are sent out the MIDI block on CC1. No problem there.

I want to write a script where the knob changes which CC the fader sends on. I have the knob assigned to a widget and I have the given the widget a GPScript Name in the Advanced tab.

I was planning to use the MapWidgetToPlugin function, but I get the error saying there is no plugin with the name of the MIDI Out block. Clearly, the MIDI Out block is not a plugin.

I searched through the functions in the manual hoping to find something like MapWidgetToMidiOutBlock, etc, but I can’t find anything. Is the only option to use the SendNowExternal function? I’m intimidated by how to write a midiMessage I guess.

Thanks!

From the doc:

MapWidgetToPlugin( < w : Widget > , < plugin : Block > , < parameterNumber : Integer > )

You need to define a handle for the widget and for the plugin. The MIDI out block IS a plugin.

But in my opinion, it would be much better to use a Scriptlet with two parameters assigned to widgets and controller by your controller: a CC# parameter and a CC value parameter. This Scriptlet output would then simply fed into the MIDI out block.

1 Like

This! :+1:

1 Like

I thought I was defining variable for the either, but I was getting an error when I compiled for some reason I couldn’t figure out, but…

…this was definitely the solution. I understand the value of scriptlets better now. Thanks, I got it working!

It would be nice if you could share your Scriptlet to the community :wink:

1 Like

Happy to!

var
   CC_Channel_Selector : Subrange Parameter 0..127 = 0 //Assign a widget for selecting the CC # to this parameter
   CC_Value : Subrange Parameter 0..127 = 0 // Assign a widget for sending the CC value to this parameter
   
On ParameterValueChanged matching CC_Value
    SendNow(MakeControlChangeMessage (CC_Channel_Selector, CC_Value))
End

1 Like