|
|
|
03-03-2021, 02:43 PM
|
#1
|
Human being with feelings
Join Date: Jan 2011
Posts: 610
|
Custom midi script doesn't work right with my new interface
Several years ago, someone (I *think* it was Lokasenna) kindly made me a custom script action which I put in my toolbar; when I create a new track and click the action's icon, the track is armed and the input is set to midi with the correct monitoring status. Now, with my new audio interface (which is also the new midi interface), it works except for the midi assignment, which doesn't work. I have to change the input to the correct device manually. I have looked at the .lua script but I don't see any mention of a specific midi device and I can't figure out how to edit it to get it working.
Hoping someone can chime in here.
Here is the script:
-- Set the selected track(s) to MIDI input
local midi_channel = 0
-- Get the number of selected tracks
local num_tracks = reaper.CountSelectedTracks()
-- If we don't have any selected tracks, abort the script
if num_tracks == 0 then
return
end
-- Keeps Reaper's undo history tidy
reaper.Undo_BeginBlock()
-- The selected tracks are numbered from 0
for i = 0, num_tracks - 1 do
-- Get the track's info
local track = reaper.GetSelectedTrack(0, i)
--[[
reaper.SetMediaTrackInfo_Value( tr, parmname, newvalue )
I_RECINPUT : int * : record input.
<0 = no input,
0..n = mono hardware input,
512+n = rearoute input,
1024 set for stereo input pair.
4096 set for MIDI input,
if set then low 5 bits represent channel (0=all, 1-16=only chan),
then next 5 bits represent physical input (63=all, 62=VKB)
]]--
reaper.SetMediaTrackInfo_Value(track, "I_RECINPUT", 4096 + 32 + midi_channel)
end
reaper.Undo_EndBlock("Set the selected track(s) to MIDI input", 1)
|
|
|
03-03-2021, 03:42 PM
|
#2
|
Human being with feelings
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleå, Sweden)
Posts: 2,009
|
Code:
--[[
reaper.SetMediaTrackInfo_Value( tr, parmname, newvalue )
I_RECINPUT : int * : record input.
<0 = no input,
0..n = mono hardware input,
512+n = rearoute input,
1024 set for stereo input pair.
4096 set for MIDI input,
if set then low 5 bits represent channel (0=all, 1-16=only chan),
then next 5 bits represent physical input (63=all, 62=VKB)
]]--
reaper.SetMediaTrackInfo_Value(track, "I_RECINPUT", 4096 + 32 + midi_channel)
Looks like it is hard-coded to use MIDI device 32, which must be for your old MIDI interface.
I'm not good enough at this to know how to tell how to identify which number to use for your new MIDI interface.
Someone smarter may have an answer soon. If not, you can always plug in different numbers from 0 to 61, and see which one works for your new interface:
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700
|
|
|
03-03-2021, 04:14 PM
|
#3
|
Human being with feelings
Join Date: Aug 2015
Posts: 2,969
|
Quote:
Originally Posted by lunker
reaper.SetMediaTrackInfo_Value(track, "I_RECINPUT", 4096 + 32 + midi_channel)
[/code]
Looks like it is hard-coded to use MIDI device 32, which must be for your old MIDI interface.
|
Hang on... That's a bitfield isn't it? If the low 5 bits are channel, then the "32" is physical input 1 isn't it? And 64 -> input 2, 96 ->3 etc? Or is my maths letting me down?
i.e. input << 5 (or input *32, if you like) I dunno if they're zero indexed I guess there's an input '0'?
__________________
it's meant to sound like that...
Last edited by jrk; 03-03-2021 at 04:20 PM.
|
|
|
03-03-2021, 04:23 PM
|
#4
|
Human being with feelings
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleå, Sweden)
Posts: 2,009
|
Yes, you’re right. I didn’t fully think my reply through. Shame and embarrassment!
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:20 AM.
|