Add_Midi_Mapping

I don’t quite understand how to use add_midi_mapping in my script.
Does anyone have an example of how to use it?

here’s a tiny example, of allowing midi_mapping to control groove_settings in song_settings:

--Groove Amount#1  
--We add a midimapping and call it by something which we can then find in MidiMapping Learn-mode  
renoise.tool():add_midi_mapping{name = "Global:Groove Settings:Groove#1",  
--We invoke a function, and the "message" appears to be something received by the midimapping  
invoke = function(message)  
--some methods of shortening stuff down in preparation of delivering the script the required numbers to make it work  
local s=renoise.song()  
local resulta=nil  
local ga=s.transport.groove_amounts  
--We make Song Settings visible in the lower bottom  
renoise.app().window.active_lower_frame=4  
--We enable groove_settings tickbox  
if not renoise.song().transport.groove_enabled then renoise.song().transport.groove_enabled=true end  
--Processing of midi-message so that it is converted to function within 0.00-1.00 (the script receives 1 - 127 so first divide by 100 to get to 1.27, then convert everything above 1.00 to 1.00)  
resulta=(message.int_value/100)  
if resulta>1.0 then resulta=1.0 end  
--talking to the groove_amounts table, with the processed Resulta, and making sure the other table-grooveamounts-contents stay the same.  
renoise.song().transport.groove_amounts = {resulta, ga[2], ga[3], ga[4] }  
 end}  
  

I hope this helps somehow. I ripped the message / message.int_value stuff form somewhere else so I’m not much help there.

I found this quite hard to read actually, I’ve redone it to be an extremely simple example. Hope you don’t mind.

  
renoise.tool():add_midi_mapping{  
 name = "Global:Groove Settings:Groove #1",  
 invoke = function(midi_message)  
 renoise.song().transport.groove_amounts[1] = midi_message.int_value/127  
 end  
}  
  

The above midi map will appear in the midi mappings list under “Global -> Groove Settings -> Groove #1”. It will set the groove amount (ranges from 0 to 1) to the CC equivalent. Midi CC (controller change) messsages are 7 bit (0 to 127) so we divide by 127 to make the maximum value 1 and utilise the entire range of the controller.

To assign it to a viewbuilder control (e.g. a ViewBuilder:Rotary) you simple set the controls .midi_map value to the midi map name (“Global:Groove Settings:Groove #1”).

Hope this helps.

mxb: that actually broke everything. the other groove_amounts must be set, otherwise the info isn’t passed on to the table.

But the simplification does work, so with this, it works:

renoise.tool():add_midi_mapping{name = "Global:Groove Settings:Groove #1",  
 invoke = function(midi_message)  
 local ga=renoise.song().transport.groove_amounts  
 renoise.app().window.active_lower_frame=4  
 if not renoise.song().transport.groove_enabled then renoise.song().transport.groove_enabled=true end   
 renoise.song().transport.groove_amounts = {midi_message.int_value/127, ga[2], ga[3], ga[4]}  
 end}