View Single Post
Old 01-19-2017, 01:30 AM   #21
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: Berlin
Posts: 11,817
Default

And here it is.

It's pretty custom, but should be adaptable with little work.

The code is below. You can download the script here:
https://stash.reaper.fm/29565/mft_bankcontrol_1.lua

There's some extra config information on the page for the downloadable version.

target_devices are what I called my two Midi Fighter Twisters. I have not found a way to hack the firmware yet, to give them unique names out of the box.

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
__________________
Using Latch Preview (Video) - Faderport 16 setup for CSI 1.1 , CSI 3.10
Website
"My ego comes pre-shrunk" - Randy Thom

Last edited by airon; 01-19-2017 at 01:58 AM.
airon is offline   Reply With Quote