Midi Message

Hello,

it is clear how to define a midi mapping to a controller as it is well documented. E.g.:

  
 vb:button {   
 id = 'mybutton'  
 width = 120,  
 text = "Custom Mapping",  
 midi_mapping = "com.renoise.ExampleToolGui:Example MIDI Mapping"  
 }  
  

and then define a midi-mapping with the above defined invoke function.

But when the user now assigns say Midi CC50 to the gui controller ‘mybutton’. How do I get this value (or the assigned message) in Lua?

vb.views['mybutton'].midi_mapping  
``` returns just the name: "com.renoise..."

If you assign a controller using midi CC 50 to the button, the midi message should simply trigger the function, but i don’t see a notifier function attached to your snippet above so hence, nothing will be triggered.

You can also use a different approach and simply read the messages from the Midi device itself through lua. (The device should then not be assigned as input device in the Renoise Midi Preferences though!)

See exampletool.gui for an example callback:

There’s no way to access the CC number that the user has bound to the view. The questions is why you want/need to do so?

MIDI mappings are not just CC’s. They can also be Notes. CCs and Notes have various modes, various settings that are done in the MIDI mapping dialog: relative modes, how to deal with velocity to treat them like booleans and so on.

So you won’t get access to CC numbers, velocity, note values CC values. Instead, Renoise handles the “how to treat the MIDI message” for you, depending on the various options and only passes an abstract “TriggerMessage” object to your callbacks.

If want to trigger an action (like what a button press does), use:

  
if message:is_trigger() then  
 -- do something  
end  
  

If you want to set something on/off, use:

  
if message:is_switch() then  
 some_state = message.boolean_value  
end  
  

If you want to change a value, use:

  
if message:is_rel_value() then  
 some_value += message.int_value  
elseif message:is_abs_value() then  
 some_value = message.int_value  
end  
  

Thanks for the help. :)
I have already implemented the midimapping with the callback-method.
I wanted to get the assigned CC number because I thaught I need it to reflect the current state of my sequencer (which lights are on/off) to the midi-controller. When the view in the sequencer in renoise changed, I wanted to update the lights on the hardware-controller. I thaught I need the same controller which were assigned via midi mapping to change the state of the light of a button of the controller. But after some investigating, I found out that the most hardware-controller (like the launchpad) have special, own midi messages to control their interface.
So my initial question is obsolete now, but good to know now that it is not possible in a direct way, but I think vv’s approach would work.