Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 11-12-2019, 03:56 PM   #1
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default Extend custom notation to include metadata

Feature Idea

Add the ability for custom notation events (those stored in reaper-notation.ini) to include metadata to be passed in the MIDI text event. The metadata isn't otherwise visible to the user.

Rationale
  • Allows JSFX to perform some action based on the metadata which could be a numeric value for easier processing (easier than strings at least).
  • By decoupling the user-visible text from a value that controls JSFX behavior, it means the text can be renamed without breaking the JSFX.


Proposal

Current custom notation entries in reaper-notation.ini look like:

Code:
CUSTOM harmonics "0xE114 harmonics"
The first parameter appears in the piano roll and the MIDI event. The second parameter controls how the notation editor presents the articulation in terms of icon and/or text.


The corresponding MIDI event looks like:

Code:
FF 0F <variable-length-quantity> NOTE 0 64 custom harmonics
Note 64 on MIDI channel 1 just being an example note in this case, which we'll use below too.


We could add an optional third parameter to this line which could be:
  1. A hex value (as a string prefixed with 0x which otherwise contains only hex digits) which is treated as a 32-bit integer and encoded in the MIDI event as 4 bytes with big endian byte order (standard MIDI)
  2. A string which is passed literally in the text event

When this parameter is specified, the text event will contain, appended after the notation text, a null (\x00), followed by the literal string 'META ' followed by the metadata value encoded either as a string or as a 4 byte value.

Below are some examples. For brevity, the MIDI outputs exclude the 'FF 0F <variable-length-quantity>" header of the meta event.


A line in reaper-notation.ini of:
Code:
CUSTOM harmonics "0xE114 harmonics" 0x0a
Would emit:

Code:
NOTE 0 64 custom harmonics 00 META 00 00 00 0A

# Python string to disambiguate
'NOTE 0 64 custom harmonics\x00META \x00\x00\x00\x0a'

A line in reaper-notation.ini of:

Code:
CUSTOM harmonics "0xE114 harmonics" foobar
Would emit:

Code:
NOTE 0 64 custom harmonics 00 META foobar

# Python string to disambiguate
'NOTE 0 64 custom harmonics\x00META foobar'

A line in reaper-notation.ini of:

Code:
CUSTOM harmonics "0xE114 harmonics" "foobar baz"
Would emit:

Code:
NOTE 0 64 custom harmonics 00 META foobar baz

# Python string to disambiguate
'NOTE 0 64 custom harmonics\x00METAfoobar baz'

Last edited by tack; 11-12-2019 at 04:07 PM.
tack is offline   Reply With Quote
Old 11-13-2019, 04:07 AM   #2
bFooz
Human being with feelings
 
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
Default

+1!

Mine FR: https://forum.cockos.com/showthread....16#post2193416
bFooz is offline   Reply With Quote
Old 11-13-2019, 06:07 AM   #3
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,749
Default

I can see wanting to encode other information in the notation data. We should be able to add a notation attribute for user data that doesn't get displayed.

Associating more information with custom notation types feels less solid though. It seems like it should be the script's job to maintain an association between custom notation types and performing particular actions. It doesn't feel right for REAPER to store user information that always has a 1:1 association with data it's already storing.
schwa is offline   Reply With Quote
Old 11-13-2019, 06:26 AM   #4
bFooz
Human being with feelings
 
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
Default

Tack, could you give a specific work example how would this be used?

I guess it would be useful for a playback engine that would be enabled by custom data to see what's coming next. E.g. when needed to create a slide, the jsfx could see the final note.
bFooz is offline   Reply With Quote
Old 11-13-2019, 07:15 AM   #5
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

Quote:
Originally Posted by schwa View Post
It doesn't feel right for REAPER to store user information that always has a 1:1 association with data it's already storing.
It was actually this 1:1ness that made me first think of adding it as an attribute to the current custom notation type, since in my use case they would always be coupled.

But I understand your point, especially in the context of bFooz's FR, where there many use cases for general notation userdata unrelated the the current custom notation type. However, IMO it's important to be able to anchor userdata to something the user is able to interact with and move around in the piano roll: for example a note, or track-level notation event.

Let's take a step back to review my specific use-case, where I'm evaluating the idea of using custom notation in Reaticulate instead of program changes.

We have these needs:
  1. Ability to set articulations (read: send keyswitches to patches) for specific notes
  2. Ability to set articulations independent of notes at arbitrary positions
  3. Readable display in the piano roll concisely showing articulation changes
  4. A downstream JSFX processes the articulation change by some numeric identifier, different than what the user sees in the piano roll
  5. Preferably: the user can rename the articulation (e.g. to fix a typo) without the need to scrub the entire project to surgically replace affected events in all MIDI items.

Program changes are actually very nicely suited for this use case. All but the first one are neatly addressed. But it's that first case -- perhaps the most common case for articulation control -- that's very cumbersome today in Reaticulate, especially in light of the current general UX with managing program changes in Reaper.

Another key gap worth addressing is providing better integration with the notation view. (Currently this isn't something Reaticulate tries to do at all.)

The idea being proposed (in one form or another) is to allow Reaticulate to replace program numbers currently used (bank MSB/LSB is immaterial to Reaticulate) with some notation userdata visible to the JSFX for processing both note-specific articulations and general track-level articulations.

I see these challenges:
  1. Lack of machine-friendly user-transparent userdata that could be used to control a JSFX (under discussion here in this thread)
  2. the piano roll view for notation data is clunkier than program changes, as they are prefixed with "custom" (or "articulation"). It'd be nice to be able to hide those prefixes, especially since when you have a several of them close together all you see is the prefixes.
  3. The renaming use case (#5 above) is much trickier with custom notations. Today with program changes, we have Reabanks that map program number to program name and it's easy to edit program names after-the-fact. The number abstracts the program name. Custom notations don't have this indirection. Not impossible to overcome, but a lot more heavy lifting for the script to do.
  4. My proposal here to tie userdata to custom notation types was also compatible with #2 and #3 above. Decoupling userdata from some other existing event that is visible to the user risks that userdata becoming orphaned/desynced.

I don't think it's workable to have hidden, standalone custom notation type for userdata. (I'm not sure if that was actually your thought, schwa, but just in case.) The userdata really does need to be attachable to something the user can directly interact with.

As for the API, I don't have any specific suggestions. I'll need to familiarize myself with the current API for notation.
tack is offline   Reply With Quote
Old 11-13-2019, 08:10 AM   #6
bFooz
Human being with feelings
 
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
Default

Quote:
Originally Posted by tack View Post
it's important to be able to anchor userdata to something the user is able to interact with and move around in the piano roll
+1. This was at the basis of my FR as well. I might have not defined it so clearly but this was the functionality I had in mind.
bFooz is offline   Reply With Quote
Old 11-13-2019, 10:36 AM   #7
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,749
Default

The next +dev build will support adding user data to track or note notation via API, and the data can be anything (binary, quoted string, etc), via MIDI_SetTextSysexEvt or MIDI_SetEvt.

Code:
\xFF\x0FNOTE 0 60 articulation staccato user \x01\x02\x03
\xFF\x0FTRAC dynamic fff user 8675309
\xFF\x0FNOTE 0 60 user "foo bar 666"
or whatever.
schwa is offline   Reply With Quote
Old 11-13-2019, 10:45 AM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

@schwa

Niiice...

I love the recent metadata-additions to Reaper

Any chance for such things for markers and regions as well?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 11-13-2019, 12:11 PM   #9
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

Quote:
Originally Posted by schwa View Post
The next +dev build will support adding user data to track or note notation via API, and the data can be anything (binary, quoted string, etc), via MIDI_SetTextSysexEvt or MIDI_SetEvt.
This sounds great! Is it possible to guarantee user data is always last in the text event?

Quote:
Originally Posted by mespotine View Post
I love the recent metadata-additions to Reaper
Oh, do we have track-level userdata nowadays? I'm storing userdata in the per-track JSFX (sharing via gmem) but a native approach would be a lot cleaner for sure.
tack is offline   Reply With Quote
Old 11-13-2019, 01:45 PM   #10
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

https://mespotin.uber.space/Ultrasch...ackInfo_String
should be it for tracks and

https://mespotin.uber.space/Ultrasch...opeInfo_String
for envelopes.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 11-13-2019, 01:59 PM   #11
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

Quote:
Originally Posted by mespotine View Post
Damn, wish I would have paid attention to that. Would have saved me a pile of work and hacks.

Thanks!
tack is offline   Reply With Quote
Old 11-13-2019, 02:05 PM   #12
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Yeah, a great addition if track notes aden't sufficient
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada 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 10:42 AM.


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