Old 09-11-2019, 08:37 AM   #1
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleň, Sweden)
Posts: 960
Default How To Intercept/Manipulate MIDI Controller Data ?

I hope this isn't a crazy/stupid question.

I know how to write a JSFX to read MIDI input going to a track and have the JSFX manipulate the MIDI data in some way.

Is there a way to do something similar for MIDI data that is being sent to plugins via the MIDI learn function? I want to intercept it and alter it before it gets to the plugin.

Or maybe you can suggest a different solution to my problem:

I have a MIDI controller with endless rotary encoders, which I have assigned to knobs in a plugin using relative increment/decrement mode. The encoders send out roughly 100 increment (or decrement) commands for each 360░ turn of the encoder.

The VST knob I want to control goes from 0.0 to 100.0 in 0.1 steps, so there are 1000 steps from the minimum value to the maximum value. Thus it takes roughly 10 full 360░ turns of the rotary encoder to go from the minimum value to the maximum value. With my slow fingers, it takes me roughly 5-6 seconds to turn the encoder 10 full turns, which is WAY too slow to get decent control of the plugin parameters.

I would like to intercept the MIDI data from the controller, and measure the time between successive increment (or decrement) events. If the time between events is short, it means the encoder is being turned quickly. The shorter the time between events, the faster the encoder is being turned. When the encoder is being turned really fast, I would like to output extra increment (or decrement) events to create a pseudo acceleration factor for the encoder. At high acceleration, I could have it output maybe 9 extra events for every one it receives, which would result in 1000 increment (or decrement) events for a single very fast turn of the encoder. That would give me the kind of quick control I want for the plugin knobs.

I know how I would write this as a JSFX to intercept MIDI data going to a track. I just don't know how I would write something to intercept MIDI learn data before it gets to a plugin. Could I do it with a Lua script that is continuously running in the background? If so how? (I'm familiar with Lua scripts, but not with using them to intercept and manipulate MIDI controller data).
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700

Last edited by lunker; 09-11-2019 at 08:42 AM.
lunker is offline   Reply With Quote
Old 09-11-2019, 12:10 PM   #2
kenm
Human being with feelings
 
Join Date: Dec 2011
Location: San Jose, CA, USA
Posts: 84
Default

Subscribed.

I too am interested in doing something similar. I'm trying to integrate a Presonus ATOM pad controller with Reaper and I need to be able to pre-process the MIDI data coming from it. So far I've only been able to locate CreateMIDIInput() which is only available in the C++ API.
kenm is offline   Reply With Quote
Old 09-11-2019, 12:43 PM   #3
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,245
Default

JSFX are just effects, so they can't reach outside the normal signal flow to grab the MIDI before it hits the track. You could, however, have your effect as an input FX on the track to allow reading/rewriting the MIDI before it's recorded.
Lokasenna is online now   Reply With Quote
Old 09-11-2019, 12:57 PM   #4
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleň, Sweden)
Posts: 960
Default

Thanks. Yes, I realize that JSFX is not what I need in this situation. The MIDI controller is not assigned to send data to any tracks.

But is there a different/ReaScript way to do the same type of thing that a JSFX would do, only have it apply to controller data going straight to a plugin via MIDI learn?
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700
lunker is offline   Reply With Quote
Old 09-11-2019, 01:15 PM   #5
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,245
Default

I don't think so - ReaScripts don't have access to incoming MIDI at all.
Lokasenna is online now   Reply With Quote
Old 09-11-2019, 01:21 PM   #6
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleň, Sweden)
Posts: 960
Default

OK. I wasn't sure if ReaScript could or not.

Do you know if a C++ extension to Reaper would be able to intercept this kind of MIDI input? I think writing something like that is probably outside my range of interest. But if it's possible ...
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700
lunker is offline   Reply With Quote
Old 09-11-2019, 01:22 PM   #7
ThrashJazzAssassin
Human being with feelings
 
ThrashJazzAssassin's Avatar
 
Join Date: Oct 2010
Location: Scotland
Posts: 357
Default

You could process your MIDI using a JSFX then send it to REAPER's control path using MIDItoReaControlPath https://forum.cockos.com/showthread.php?t=43741
__________________
TJA MIDI JSFX | REAPER-OSC-panels | erthoide
ThrashJazzAssassin is offline   Reply With Quote
Old 09-11-2019, 01:29 PM   #8
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleň, Sweden)
Posts: 960
Default

Thanks! Yes, this looks like it would do the trick.

I was aware of ReaControlMIDI, but not MIDItoReaControlPath.
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700
lunker is offline   Reply With Quote
Old 09-11-2019, 01:37 PM   #9
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,557
Default

You could also use gmem for communicating between JSFX and Lua, so getting the MIDI-stuff and sending it to Lua would be possible.

This would be more direct but you would need to take care of synchronization, as JSFX are more often updated than background-ReaScripts afaik.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 09-11-2019, 01:50 PM   #10
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleň, Sweden)
Posts: 960
Default

Thanks.

Can Lua output the altered MIDI back into the "MIDI controller" data stream, so that the plugin controls see it? I'm kind of guessing it can't, based on responses above. But if it can, I don't know how to do it.

Definitely MIDItoReaControlPath can do what I want, so I'll probably pursue that option first. But if there's a way to do it with Lua, I'd like to learn how.
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700

Last edited by lunker; 09-11-2019 at 02:12 PM.
lunker is offline   Reply With Quote
Old 09-11-2019, 10:41 PM   #11
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 7,883
Default

Quote:
Originally Posted by lunker View Post
Definitely MIDItoReaControlPath can do what I want, so I'll probably pursue that option first.
You might want to take a look at the sticky thread in the "Live" forum. Several things that can be done by processioning Midi messages to control Reaper are described there.

It's good to keep in mind that within Reaper there are two separate paradigms of signal flow: "Realtime" happens within tracks (Midi and Audio), "GUI" happens in the guts of Reaper (the "Reaper Control Path"). "Realtime" uses a bunch of operating system threads, while the "GUI" uses a single dedicated Thread for all it's work. JSFXes obviously live in the realm of "Realtime" (sauf the GUI part in their code), Reaper scrips (any language) live in the GUI. Reaper actions completely live in the GUI. "Learn" in fact does not digest Midi messages (even though it appears to), but Reaper Control Path messages (that can be derived from Midi messages) and hence lives in the "GUI" thread.

Hence obviously a (LUA) script can't receive (realtime) Midi. I do suppose using the Reaper API in LUA should allow for generating Reaper Control Path messages that might be "Learned" by some Reaper internal functionality, but I did not try this myself.

Clear as mud ?

-Michael

Last edited by mschnell; 09-11-2019 at 11:36 PM.
mschnell is offline   Reply With Quote
Old 09-12-2019, 08:33 AM   #12
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleň, Sweden)
Posts: 960
Default

Thanks. Yes, clear.

I perhaps did not know the correct terminology to use. My question was about whether there is a way to intercept/manipulate the "Control Path" data.

I see now that there are some alternatives that can be done by routing the MIDI to a track, altering the data, and the routing it back to the control path. That is acceptable. I was hoping to avoid having to create a track for the controller, but it's not a big deal. In the long run, it may actually be useful to have the controller assigned to different "control" tracks, each with its own FX to alter the MIDI (since different plugins will have different ranges for their knobs, and I might want different acceleration factors for different tracks). Time will tell ...

Anyway, thank to everyone who chimed in with advice and suggestions.
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700
lunker is offline   Reply With Quote
Old 09-12-2019, 10:24 AM   #13
azslow3
Human being with feelings
 
Join Date: Nov 2017
Location: Heidelberg, Germany
Posts: 710
Default

Why not use ReaLearn for the task? It supports step size per assignment.
azslow3 is online now   Reply With Quote
Old 09-12-2019, 03:08 PM   #14
ThrashJazzAssassin
Human being with feelings
 
ThrashJazzAssassin's Avatar
 
Join Date: Oct 2010
Location: Scotland
Posts: 357
Default

Quote:
Originally Posted by azslow3 View Post
Why not use ReaLearn for the task? It supports step size per assignment.
I've found ReaLearn doesn't play nicely with accelerated rotary encoders, but can't say I've had much success using them with Reaper's native learn either.

The best accelerated encoders I've tried are Nektar encoders with their custom control surface extension; and Komplete Control<->VST plugin.
__________________
TJA MIDI JSFX | REAPER-OSC-panels | erthoide
ThrashJazzAssassin is offline   Reply With Quote
Old 09-12-2019, 10:26 PM   #15
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 7,883
Default

Do you want to just use accelerated encoder provided by the hardware device, or do you want to create the acceleration functionality from native encoders by your programming ?

-Michael
mschnell is offline   Reply With Quote
Old 09-13-2019, 11:11 AM   #16
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleň, Sweden)
Posts: 960
Default

Hi Michael,

The encoder itself doesn't have any acceleration. I want to intercept the MIDI data from the encoder and create acceleration by sending extra events based on how fast I turn the encoder.
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700
lunker is offline   Reply With Quote
Old 09-13-2019, 11:12 AM   #17
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleň, Sweden)
Posts: 960
Default

Quote:
Originally Posted by azslow3 View Post
Why not use ReaLearn for the task? It supports step size per assignment.
I'll look into that. I'm not familiar with ReaLearn, and have just been using the native MIDI learn interface.

ReaLearn might be the solution I am looking for!
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700
lunker is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.