Got it done. Thank you.
The folks at Cockos were nice enough to add an API function that I can use to send a midi message directly to a midi device that Reaper knows about. It's available in the latest v5.33pre1 and up in Reapers pre-release forum section.
Thus, I wrote a Lua script(you can write stuff in EEL, Lua, Python or C++) that scans the list of available devices, picks up the ones I want and sends them the message. I had to create one script per bank-choice command. Those could then be fired off by any trigger in Reaper, such as keyboard shortcuts, midi notes, midi CC messages, OSC messages or even other scripts.
Right now I have some buttons on an X-Touch Mini changing banks, though I might go for the encoder presses. Changing those assignments is easy.
Here's the script, which I'm posting in the forum in a moment in this thread on the JS/Scripting section of Reaper forum. It's also downloadable here: http://stash.reaper.fm/29565/mft_bankcontrol_1.lua
As you can see, my two Twisters are named "Twister1" and "Twister2". This is what Reaper calls them, and I changed that in the Preferences / Midi Devices / Midi Output device list. Just right-click on the entry and change it there. If you want to do this too, don't forget to enable output to the device as well.
Now I need to figure out how to get feedback out to the Twisters. That's gonna be a handful.
Code:
-- Send midi note message to target device(s)
-- requires Reaper 5.33pre1 or higher
-- Target Configuration --
local midichan = 4
local mftbank = 1 -- Midifighter Twister Bank
local vel = 127
local target_devices = { "Twister1" , "Twister2" }
--Target Configuration end --
msg_flag = false;
function msg(val) ; if msg_flag then ; reaper.ShowConsoleMsg(tostring(val).."\n");end;end
function msgclr() ; if msg_flag then ; reaper.ShowConsoleMsg("");end;end
local i,k = 0 , 0
local target_devnum = {} -- array to collect device numbers
local mdev_outno = reaper.GetNumMIDIOutputs() -- grab number of midi outputs in Reaper
msgclr()
msg("Midi Outs Reaper: " .. mdev_outno)
msg("Stepping through devices...")
for k=1, #target_devices, 1 do
for i=1, mdev_outno, 1 do
retval, mdev_name = reaper.GetMIDIOutputName(i, "")
if retval then
if string.find(mdev_name,target_devices[k]) then -- check for target device name(s)
target_devnum[k] = i -- add device number to list
msg("Device found. No." .. i .. " " .. mdev_name .." matches " .. target_devices[k])
end
end
end
end
for i=1, #target_devnum, 1 do
reaper.StuffMIDIMessage( target_devnum[i]+16,
'0x9'..string.format("%x", midichan-1), -- NoteOn
mftbank-1, -- MIDI note (bank-1 for MidiFighterTwister)
vel) -- MIDI velocity
-- later we'll add a command execution list
retval, mdev_name = reaper.GetMIDIOutputName(target_devnum[i], "")
msg("Sent note to " .. mdev_name)
end
Bookmarks