Old 10-12-2019, 12:08 PM   #1
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,565
Default Docs: How2StuffMIDIMessage-function and a request to extension-developers

A user had a request for Ultraschall, which involved sending MIDI-messages.
And one of the things I looked at to solve the request, was the function StuffMIDIMessage.

So, long story short: I documented, how StuffMIDIMessages works, so you can actually use it to its fullest.

One of the interesting things is, that Reaper doesn't differentiate between MIDI and keyboad-shortcuts, means,
you can adress them both, as long as you choose the right message.
That means, you can send MIDI-messages, like notes, cc, pc, pitchbend, including velocity to different areas.
And even more, you can send MIDI-messages to be treated as "Actions started by MIDI-shortcut" to Reaper, too.
Another funfact:
you can send midi AND computer-keyboard-shortcuts to the Add Shortcuts/Find Shortcuts-dialogs of the Actionslist.

For more information, read the full documentation over here:
https://github.com/Ultraschall/ultra...ssage-docs.txt

To get all possible MIDIMessages, have a look into this ini-file, where I tried to include all of them:
https://raw.githubusercontent.com/Ul...ch_Windows.ini

They are stored like:

modifier_keynotevalue_velocity=shortcut in plaintext

as some are not printable characters, there's also a second one:

modifier_keynotevalue_velocity_StringAsHex=shortcu t as hexadecimalstring(convert it back into ascii-values to get the original text)

They should be fairly complete.

Velocities are just stored with 1, with the exception for modifier 255 and key_note_value 232, who store the MediaKbd-shortcuts(read the docs for more info about that).

And now my request:
As StuffMIDIMessage allows sending keyboard and MIDI-shortcut to the Add Shortcuts-Dialog, I would love to request, that someone of you exposes Reaper's own functions: CountActionShortcuts, DeleteActionShortcut, DoActionShortcutDialog, GetActionShortcutDesc

With them, I could code functions, who could add shortcuts via scripts.
And not only that: it would be possible to code stuff like keyboard-layout-presets.
So, let's say, you have three screensets, one for Recording, one for Mixing, one for Video, changing between them could also change the keyboard-layout to the shortcuts more needed for the specific usecase.
Would be fiddly to code, but possible, assuming, the aforementioned functions were exposed somehow.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635

Last edited by mespotine; 10-12-2019 at 12:19 PM.
mespotine is offline   Reply With Quote
Old 10-14-2019, 03:13 AM   #2
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 215
Default

Thanks again Mespotine! I had to fiddle with this for the first time and i couldnt have succeeded without your detailed documentation.

You rock
reapero is offline   Reply With Quote
Old 10-16-2019, 03:03 AM   #3
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,636
Default

Good detective work there!

The only way to get a KbdSectionInfo pointer appears to be by using SectionFromUniqueID. I don't know how this works (is it a new unique ID or is there a list somewhere?) so if you or somebody else knows I could could wrap the functions up for you.

edit: in fact, I could just wrap that one up too and forget about not having a clue what it does!
snooks is offline   Reply With Quote
Old 10-16-2019, 03:27 AM   #4
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,867
Default

Quote:
Originally Posted by mespotine View Post
A user had a request for Ultraschall, which involved sending MIDI-messages.
And one of the things I looked at to solve the request, was the function StuffMIDIMessage.

So, long story short: I documented, how StuffMIDIMessages works, so you can actually use it to its fullest.

One of the interesting things is, that Reaper doesn't differentiate between MIDI and keyboad-shortcuts, means,
you can adress them both, as long as you choose the right message.
That means, you can send MIDI-messages, like notes, cc, pc, pitchbend, including velocity to different areas.
And even more, you can send MIDI-messages to be treated as "Actions started by MIDI-shortcut" to Reaper, too.
Another funfact:
you can send midi AND computer-keyboard-shortcuts to the Add Shortcuts/Find Shortcuts-dialogs of the Actionslist.

For more information, read the full documentation over here:
https://github.com/Ultraschall/ultra...ssage-docs.txt

To get all possible MIDIMessages, have a look into this ini-file, where I tried to include all of them:
https://raw.githubusercontent.com/Ul...ch_Windows.ini

They are stored like:

modifier_keynotevalue_velocity=shortcut in plaintext

as some are not printable characters, there's also a second one:

modifier_keynotevalue_velocity_StringAsHex=shortcu t as hexadecimalstring(convert it back into ascii-values to get the original text)

They should be fairly complete.

Velocities are just stored with 1, with the exception for modifier 255 and key_note_value 232, who store the MediaKbd-shortcuts(read the docs for more info about that).

And now my request:
As StuffMIDIMessage allows sending keyboard and MIDI-shortcut to the Add Shortcuts-Dialog, I would love to request, that someone of you exposes Reaper's own functions: CountActionShortcuts, DeleteActionShortcut, DoActionShortcutDialog, GetActionShortcutDesc

With them, I could code functions, who could add shortcuts via scripts.
And not only that: it would be possible to code stuff like keyboard-layout-presets.
So, let's say, you have three screensets, one for Recording, one for Mixing, one for Video, changing between them could also change the keyboard-layout to the shortcuts more needed for the specific usecase.
Would be fiddly to code, but possible, assuming, the aforementioned functions were exposed somehow.
Would a command line program sendmidi.exe help, as those exist as well?
TonE is offline   Reply With Quote
Old 10-16-2019, 03:39 AM   #5
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,867
Default

Quote:
Originally Posted by mespotine View Post
With them, I could code functions, who could add shortcuts via scripts.
And not only that: it would be possible to code stuff like keyboard-layout-presets.
So, let's say, you have three screensets, one for Recording, one for Mixing, one for Video, changing between them could also change the keyboard-layout to the shortcuts more needed for the specific usecase.
Would be fiddly to code, but possible, assuming, the aforementioned functions were exposed somehow.
I guess this would be also compatible with this concept, saving everything as external .txt files, see https://forum.cockos.com/showthread.php?t=226038
TonE is offline   Reply With Quote
Old 10-16-2019, 12:38 PM   #6
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,565
Default

Wouldn't help, as sending Midi messages isn't the problem in Reaper.
Opening the Add Shortcut To Action-Dialog is my main problem. All other attempts using SWS or JS-extension failed.
__________________
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 10-17-2019, 12:13 AM   #7
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 215
Default

So..this stuffMIDImessage cant send Sysex right?
reapero is offline   Reply With Quote
Old 10-17-2019, 01:40 PM   #8
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,636
Default

Here's an extension with those functions in it, plus SectionFromUniqueID to get the pointer. You need to pass a size of the string buffer to the last parameter of GetActionShortcutDesc, so maybe 25 or whatever it takes.

reaper.US_*

I should say big props to cfillion for his metaprogramming magik API wrapping code. It works really well and is super easy to use!
Attached Files
File Type: zip reaper_ultrashall.zip (17.2 KB, 5 views)
snooks is offline   Reply With Quote
Old 10-21-2019, 09:23 AM   #9
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,565
Default

Ooohhh...nice Thank you very much.

Would it be possible sharing the code as well and would it be ok, if we add your code to our own plugin(which will at some point become part of my Ultraschall-API as well)?


Oh, and where did you find cfillions code? I would love to add that as useful resource into the Reaper-Internals-thread.
__________________
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 10-21-2019, 09:24 AM   #10
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,565
Default

Quote:
Originally Posted by reapero View Post
So..this stuffMIDImessage cant send Sysex right?
Don't know. I'm not that familiar with MIDI in general, but Notes, CC, PC and Pitch works without a problem. Beyond that, I have no idea.
__________________
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
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 05:35 AM.


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