Hello! I’m having some trouble reassigning a MIDI device via a parameter I’ve set up. Long story short…it doesn’t work. Here’s what I’m working with at the moment:
I define two variables - one for each MIDI device I’m trying to use - and assign them like so:
local m_out = midi.connect()
local m_in = midi.connect()
I’ve declared the parameter for each like so:
params:add{type = "number",
id = "midi_in_device",
name = "midi in device",
min = 1,
max = 4,
default = 2,
action = function(value) m_in = midi.connect(value) end
}
params:add{type = "number",
id = "midi_out_device",
name = "midi out device",
min = 1,
max = 4,
default = 1,
action = function(value) m_out = midi.connect(value) end
}
Now when I try to change which device each variable is assigned to, nothing happens. Norns doesn’t complain about anything, it just doesn’t seem to work.
I did employ some very sophisticated debugging in the params action function via:
print("Hello, the value is: "..value)
…and am definitely seeing the right values in there.
Also, I tried declaring each variable with a device number like this and it works fine:
local m_out = midi.connect(1)
local m_in = midi.connect(2)
…but trying to change the devices just doesn’t do anything. The values change but the devices aren’t being reassigned. 
Oh and I noticed in study 4 there are references to m:disconnect() and m:reconnect(n) but I think those are deprecated? No mention of them in the API doc and Norns was displeased with my attempts to call them.
I feel like I’m missing something really simple here and a new pair of eyes might help. Thanks for your time!