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,609
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 online now   Reply With Quote
Old 10-14-2019, 03:13 AM   #2
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 231
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,639
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,906
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,906
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,609
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 online now   Reply With Quote
Old 10-17-2019, 12:13 AM   #7
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 231
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,639
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, 7 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,609
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 online now   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,609
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 online now   Reply With Quote
Old 10-23-2019, 02:20 PM   #11
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,639
Default

No worries, it's a CMake project and I'm having a bit of trouble getting it working on Linux. I'll post it when I've worked that out!
snooks is offline   Reply With Quote
Old 10-26-2019, 09:37 AM   #12
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,639
Default

It turned out it was just a mismatch between the reaper_plugin_functions files with the older Linux installation, here's a link to the project...

https://mega.nz/#!ipMjXCSY!MWF5Cs7Io...so1MgxKBCT9YVY

You can Open Folder in VS2019, select the CMakeLists.txt file as the Startup Item and build directly from there (or just use CMake normally).

For Linux builds using VS2019:

- install openssh, build-essential, cmake 3.11 on remote Linux
- run "sudo service ssh start" after logging on to Linux
- in VS, add the remote Linux machine up in Tools->Cross Platform

Now just select Linux-x64-Release (or Debug) from dropdown in VS to build.
snooks is offline   Reply With Quote
Old 10-28-2019, 09:47 AM   #13
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,609
Default

Awesome! Thanks, you're a hero Snooks
Does this also work on Mac?
__________________
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 online now   Reply With Quote
Old 10-28-2019, 02:45 PM   #14
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,639
Default

No worries, the code will work on macOS but the build file needs set up for it. I don't have "Apple branded hardware" so can't set it up and test it without breaking the law or paying money so you'll need to count me out on that one.
snooks is offline   Reply With Quote
Old 10-29-2019, 07:00 AM   #15
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,609
Default

No problem, we'll try to make it work on Mac.
__________________
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 online now   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 03:31 PM.


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