Old 08-15-2018, 12:29 AM   #1
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 39
Default Any way to read Midi messages using API

So i'm in the process of learning how to use the reaper graphics engine and to do that I'm working on a macro mapping panel similar to MPL's great Mapping Panel, but allows for unlimited # of macro's, each with their own unlimited # of parameters provided my unoptimized code doesn't implode reaper.

I'd really like to know if it's possible to read incoming midi messages in full.

I've looked pretty deeply (not really) to see if this is possible, found a work around MPL used in his mapping panel by editing track chunks to link user defined midi cc's. But I was hoping the all knowing powers of the forum could let me know if there is another way, preferably keeping fx parameters unlearned and allowing processing of the message to take place entirely within the script.

I tried using getactioncontext() with a defered script mapped to a cc shortcut and it looks like the deferred script is only ran once, so calling getactioncontext() every defer cycle seemed like a nice way to read incoming midi. You'd have to dedicate parameters to the script by assigning a bunch within the action list but that isn't so bad and you could write some logic to allow you to freely map the action list midi shortcuts to macros in the script. The problem is you can only read the value portion of the midi message.

Is there any way to around this, I imagine not yet. Hopefully midi is exposed in Reaper V6.
ausbaxter is offline   Reply With Quote
Old 08-15-2018, 09:14 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Midi-Messages from an item can be gotten from the Items themselves, namely ItemStateChunks. In there, you can read all MIDI-messages in the <Source tag.
There is a documentation in Cocko's-Wiki, though it's probably outdated:
https://wiki.cockos.com/wiki/index.p...nk_Definitions

Midi-Messages from devices can probably be gotten only in JSFX, as far as I know.
Unfortunately, there is currently no way to communicate between JSFX and Lua, beside using automation-parameters for communication(which would be more of a hack than a clean solution).
Get_action_context is too limited to really be useful for what you want to achieve.

We definately need more MIDI-access in Reaper's Api.

Dunno if SWS could do more about that and expose stuff to the API. As SWS is a C++-plugin, they usually have more access to Reaper's internals...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-15-2018, 07:42 PM   #3
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 39
Default

Thanks for the response mespotine!

Quote:
Originally Posted by mespotine View Post
We definately need more MIDI-access in Reaper's Api.

Dunno if SWS could do more about that and expose stuff to the API. As SWS is a C++-plugin, they usually have more access to Reaper's internals...
Agree with you here, I have a feeling its coming, dunno if its gonna be from SWS or the fine folks at Cockos. It would open up so much functionality and they already have some sort of architecture with OSCIIBOT (EEL), its just not integrated within Reaper yet.

I knew C++ would be the answer, but I'm so new to it. I wouldn't even know where to begin getting a C++/Reaper "Hello World" together. I've checked out MyReaperPlugin, but maybe i'll have to dive a bit deeper into it.
ausbaxter is offline   Reply With Quote
Old 08-15-2018, 07:53 PM   #4
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by ausbaxter View Post
I wouldn't even know where to begin getting a C++/Reaper "Hello World" together.
https://gist.github.com/cfillion/f32...63abb1eda41400

I don't think the REAPER API has a way to read incoming data from MIDI devices as they are received though. Perhaps a JSFX would work as a workaround (using hidden sliders to share data with a script...). To read existing MIDI items, there is MIDI_GetAllEvts in addition to the notes/CC functions.
cfillion is offline   Reply With Quote
Old 08-15-2018, 09:39 PM   #5
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,688
Default

Quote:
Originally Posted by ausbaxter View Post
I'd really like to know if it's possible to read incoming midi messages in full.
Do you mean realtime (vs stored) Midi messages ?
Do you mean incoming in a track ?

To see these messages in a Reaper script (vs a JSFX), you need to route them from the track to the Reaper "ControlPath" Midi stream by the "MidiToReaControlPath" VST.

-Michael
mschnell is offline   Reply With Quote
Old 08-15-2018, 10:33 PM   #6
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 39
Default

Quote:
Originally Posted by cfillion
I don't know how I haven't found this yet! Thank you so much!

Quote:
Originally Posted by cfillion
I don't think the REAPER API has a way to read incoming data from MIDI devices as they are received though. Perhaps a JSFX would work as a workaround (using hidden sliders to share data with a script...). To read existing MIDI items, there is MIDI_GetAllEvts in addition to the notes/CC functions.
Quote:
Originally Posted by mschnell
Do you mean realtime (vs stored) Midi messages ?
Do you mean incoming in a track ?
I realize I wasn't very specific with this. Ideally it would be any realtime midi messages coming from control enabled devices within preferences.

Quote:
Originally Posted by mschnell
To see these messages in a Reaper script (vs a JSFX), you need to route them from the track to the Reaper "ControlPath" Midi stream by the "MidiToReaControlPath" VST.
This seems like the best bang for your buck kind of thing, I might end up making this a good reason to get back into C++ though. Hopefully in the not to distant future the reascript api can expose these messages in a useful way. (Even if getactioncontext had 2 extra return values to read a full midi msg that'd be pretty powerful)
ausbaxter is offline   Reply With Quote
Old 08-16-2018, 05:37 AM   #7
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,688
Default

control enabled devices also send to the Control Path.

Hence here you don't need MidiToReaControl if you don't use JSFXes or VSTs to modify the midi stream.

For a somewhat similar purpose I do JSFXes to modify the Midi stream (of not control enabled devices) in a way that the Reaper scripts/extensions like it (i.e. just create CC messages from everything of interest), and then use MidiToReaControl to route that stream there.

- Michael

Last edited by mschnell; 08-16-2018 at 05:43 AM.
mschnell 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 04:52 PM.


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