Old 10-12-2018, 04:57 PM   #1
Opcode 7
Human being with feelings
 
Join Date: Mar 2017
Posts: 79
Default Hooks for MIDI Notes On/Off

Hello! I'm new to REAPER Extensions, but I'm starting to wad through this example plugin source code :

https://github.com/elanhickler/MyReaperPlugin

and I'm wondering, is there a function I can hook, that will provide me with all the currently playing MIDI notes, for each track?

For example, say I want to use all this midi note information to display on the screen that -- Track 1 is playing a C Maj Chord, Track 2 playing E chord, etc...

Ive found the following functions in the reapler_plugin_functions.h,

REAPER_PLUGIN_DECLARE_APIFUNCS void (*kbd_OnMidiEvent)(MIDI_event_t *evt, int dev_index); // can be called from anywhere (threadsafe)
REAPER_PLUGIN_DECLARE_APIFUNCS const char* (*GetTrackMIDINoteName)(int track, int note, int chan);

but they seem more like things that can be called, rather than things can be 'hooked' and called when REAPER plays a MIDI note, you know? Is is possible to 'hook'/intercept things in REAPER extensions?

An example would be, say I want to transpose every midi note that plays up a semitone before it's sent to the instrument or plugin or external out, etc.

Last edited by Opcode 7; 10-12-2018 at 05:08 PM.
Opcode 7 is offline   Reply With Quote
Old 10-12-2018, 07:11 PM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Opcode 7 View Post
is possible to 'hook'/intercept things in REAPER extensions?
Only in very limited ways. The API functions that have names with "On_" are not callback functions you can set yourself to be called by Reaper. It has never been clear for me why they are named like that, but like you already discovered they are just functions to be called from your own code.

Most callback/hook functionality is only available by implementing a control surface. And even with those you may end up needing to implement a polling system to know when some particular things have happened. You can of course do polling also without implementing a control surface...(Using a GUI timer, for example.)

If you want to know about currently playing MIDI notes on tracks, you might want to implement a regular VST or Jesusonic plugin that analyses the notes but lets them pass through to the following instrument plugins on the track.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 10-12-2018 at 07:26 PM.
Xenakios is offline   Reply With Quote
Old 10-12-2018, 09:26 PM   #3
Opcode 7
Human being with feelings
 
Join Date: Mar 2017
Posts: 79
Default

Ah the legend himself! Thanks for your reply. I'm afraid for what I want to do putting a VST on each track isn't what I want :[

I was hoping I would beable to get the currently playing midi notes (either pre or post) sending them to the track, in a more global way.

Thanks!
Opcode 7 is offline   Reply With Quote
Old 10-13-2018, 02:06 AM   #4
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,773
Default

Quote:
Originally Posted by Opcode 7 View Post
when REAPER plays a MIDI note
What do you mean by this ? In my book, Reaper does not "play Midi Notes", it just manages Midi streams.

To digest and create Midi notes you would do a JSFX or a VST plugin (sitting in a track' FX chain and seeing the dedicated track's midi stream), not a Reaper Script or a Reaper extension (sitting in the guts of Reaper and seeing the Midi stream called "Reaper Control Path" which is completely independent of the tracks) .

-Michael
mschnell is offline   Reply With Quote
Old 10-13-2018, 05:55 AM   #5
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Opcode 7 View Post
I'm afraid for what I want to do putting a VST on each track isn't what I want :[
Sadly that's likely the solution you would have to go with. It does get tricky though if you want to have some kind of a global analysis of all the currently playing notes on all tracks. It's a pain to do VST or Jesusonic plugins that will reliably communicate between each other.

I suppose another possibility would be to do an extension plugin or script that scans what MIDI items and data inside them is currently under the playcursor. That wouldn't take into account things like MIDI transformation plugins instantiated on the tracks. It would just allow seeing the MIDI source data in the items. (And obviously wouldn't work for things like live MIDI inputs or plugins on tracks generating MIDI.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 10-13-2018, 11:34 AM   #6
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,773
Default

You can route all midi streams to a single dedicated track and place a VST there.

-Michael
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 02:28 AM.


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