Allow midi mapping on canvas views & specify MIDI input devices for mappings

Hi, I wanted to mention a couple of things about the MIDI mapping API (R3.5.3).

  1. In the documentation, it seems that the following is missing from the views:

---@field midi_mapping ControlMidiMappingString?

It only appears in link.lua.

  1. Could midi_mapping also be available for canvas?

  2. add_midi_mapping accepts the name and invoke fields. It returns the variable message in invoke. Could this function also return device name, which would be the name of the device receiving the MIDI signal?

I would like to use something like this:

:add_midi_mapping{
  name="the_name",
  invoke=function(message,device_name)
  ..

midi mappings are right now only available for controls: something you can click on or interact in other ways. A canvas with mouse hooks can act like a control, but by default it acts like a static non-interactive view.

I’ll check if making it a control has unwanted side-effect. If not, that should be possible to add, yes.

I don’t think that’s a good idea unless we make this an option for all MIDI mappings. Not just those added from the Lua API. However, you would also need the ability to display and change the MIDI devices that these mappings are linked to in the UI. That’s quite likely out of scope because that complicates things a lot. We’d need to save the used MIDI mapping device for every single mapping in the document (songs/instrument) then too.

As it is now, couldn’t this be achieved?

function renoise.Midi.create_input_device(device_name, callback, sysex_callback) end

In other words, being able to print the device name before executing the add_midi_mapping invoke. This way, a tool could know which device is being used in this context.

Would this be possible?