jtackaberry / reaticulate

An articulation management system for REAPER
Other
101 stars 47 forks source link

Add middle C offset option to track #164

Closed louisfeng closed 2 years ago

louisfeng commented 2 years ago

Add an option to the track options to set an offset to the middle C relative to the C4 standard. Some VST expect middle C map to C3. So note keyswitch should be offset by 12.

This PR does not quite work yet, I want to get some feedback first before I spend too much time. A few things I don't know how to do. For example, how do I see the log outputs for debugging?

The idea is fairly simple:

  1. we want this to be a track specific feature because some VST assumes C maps to C4, some assumes C3.
  2. allow user to specify how the note based on C4 (standard) should mapped to. Options provided are C3 (-1 octave), C4 (no change), C5 (+1 octave).
  3. During sync_banks_to_rfx() call, we offset the note to be trigged by this track specific offset, i.e. offset * 12.
  4. When user make a change to this selection, we call sync_banks_to_rfx() to update.

Also probably should update note_to_name() to reflect this offset.

Not sure what I'm missing, but it does not seems to work yet.

jtackaberry commented 2 years ago

Well, first of all, I'm delighted to see a PR that's for actual code. These are quite rare. :) And the coding style is spot on, too. (Your onchange handler in trackcfg.lua references rtk.current rather than rfx.current in a couple lines though, so that's certainly a logic issue. Also, to enable debug logs, go into Reaticulate's settings and scroll to the bottom: you can change the log level to debug there.)

But before I encourage you to work on this further, I'd really like to understand the use case more, and specifically what problem we're trying to solve. Like I mentioned in #163, the output events reference note numbers, not note names, and these are unambiguous regardless of whether a particular VI sees middle C as C3 or C4. And this is independent of what REAPER's octave name display offset setting.

Note 12 is always note 12 (for example). Whether REAPER uses C4 for middle C and the VI uses C3, the numeric note value is consistent.

So the only thing I can see this being used for is to tailor the status bar message when you hover over the articulation in Reaticulate, to show the note name according to the VI's expectation of middle C rather than REAPER's configuration, but I'm not entirely sure this is actually less confusing, and in any case I'm not convinced it's worth the effort of additional logic and a surfacing a user-configurable per-track setting just for note name display purposes on the status bar.

But if there's actual functionality that's not working, could you elaborate further?

louisfeng commented 2 years ago

Thanks @jtackaberry for pointing out the error. So here is what I think the problem is. VSTs like OPUS assumes middle C is mapped to C3, while VSL assumes middle C mapped to C4 (by default). While the note number in the Reaper MIDI world does not change, their name does change:

Middle C -> C3: C0 = 24 Middle C -> C4: C1 = 24

On our physical MIDI keyboard, we press middle C it always map to the same key number even though their name changed.

However from Reaper/Reaticulate to the VST, the name does seem to matter. I recorded a short clip to show how this impacts the key switches between the two VST: https://youtu.be/cBHfCzd7Kvg

So it seems either Reaper or the VST's does some translation based on the preference setting (0 or -1 as the video shows).

I think the purpose of this feature is allow some VSTs which do not have the setting to change the key mapping (like OPUS) to properly get the right key signal when the middle C is mapped to a different octave. This is useful so that people don't have to edit the default key switches one by one.

jtackaberry commented 2 years ago

Thanks for the video @louisfeng . I understand the problem demonstrated, but I'm just not sure how it applies to Reaticulate. After all, Reaticulate wasn't involved in your demonstration.

When you define an articulation in Reaticulate that uses a note-based output event, the note is numeric. So my earlier point was that activating an articulation works regardless of what either the VI or REAPER calls middle C. That is, if note 12 activates the staccato articulation, say, it doesn't matter if REAPER uses C4 and the VI uses C3 as middle C.

The VKB will certainly disagree, as you showed, but the VKB isn't part of Reaticulate. Is that ultimately the problem you're trying to solve? The disagreement between the VKB and the different virtual instruments? Or was there something actually broken within Reaticulate itself? That's the part I'm confused about.

louisfeng commented 2 years ago

I did some more experiment, and I see your point. Indeed, when I press my physical midi key on my keyboard, they map to the same key in VSTs even though they have different names, i.e. C3 in OPUS, and C4 in VSL. Reaticulate also seems to behave the same, note 24 map to C0 in Opus and C1 in VSL.

This was very confusing :). So essentially we can't treat key switch in VSTs by their name, we rather need to figure out the underlying key # assuming middle C map to C4. So if a VST shows a key switch for C0, C#0, if its middle C is C3, then the key note number of C0 is actually 24, not 12 (C0 in the middle C = C4 world).

louisfeng commented 2 years ago

So I wonder is this a widely accepted practice in the music world? I'm a noob so this was confusing to me. I.e., does it make sense to follow the note name of a VST rather then derive the underlying key #? So a user would visually follow whatever the VST setting looks like C0 is 12 (in middle C=C4) world. So I would use note:12 in the reabank file. But because the VST actually uses middle C= C3, the track set this setting, then Reaticulate will offset 12+12=24?

louisfeng commented 2 years ago

I think this is essentially what the Sychron player setting is doing, it does not change the underlying note # when changing middle C from C4 to C3. However the key switch name changed from C1 to C0.

This a setting missing in Opus and who knows whether my other library has this is offset config. Reaticulate could be able to solve this for all the VSTs. So we have a consistent mapping from key switch name to the key #.

jtackaberry commented 2 years ago

So I wonder is this a widely accepted practice in the music world? I'm a noob so this was confusing to me.

You're not wrong to be confused. I wouldn't say "widely accepted" so much as "begrudgingly tolerated out of helplessness." :)

Once upon a time, there were competing standards, where Yamaha used C3 and Roland used C4 (or maybe that was vice versa -- who can keep track!). Nowadays C4 is more generally accepted as middle C, but you see enough C3s in the wild even here in the 2020s.

At least we can say this confusion isn't unique to REAPER, and the question of which note numbers to use for which articulations isn't unique to Reaticulate. Cubase expression maps, for example, face the same challenge.

The way I deal with this is to use a ReaControlMIDI plugin on the track before the instrument, enable logging, hit notes on my MIDI keyboard until I manage to activate the articulation I'm looking for, and then grab the actual note number in the ReaControlMIDI log. This is the note I use in the Reaticulate output event.

Reaticulate could be able to solve this for all the VSTs. So we have a consistent mapping from key switch name to the key #.

The only place the note name is surfaced in Reaticulate itself is the status bar message when you hover over the articulation with the mouse. And as I mentioned before, I'm not sure it's worth the effort to add this level of extra configuration just to tailor the status message for this case.

Outside of Reaticulate's little world, in the bigger world of REAPER at large, the C3 vs C4 configuration manifests in the VKB as well as the MIDI editor.

It's not out of the question that Reaticulate tries to smooth over REAPER's own native warts -- there's lots of cases where we do this today -- but, you know, I'm not sure I philosophically agree with doing that in this case.

The way this would have to be implemented is that when you select a track, Reaticulate dynamically modifies REAPER's global middle C offset setting. Even assuming this is something that can be modified dynamically by scripts, is it really a UX improvement for the VKB note names to shift around as different tracks are selected? Isn't it better for REAPER to present a consistent naming scheme in the VKB, even if the underlying VI has a different notion of middle C?

As a composer, you are likely to be anchored to one convention or the other. So if you're accustomed to middle C as C4, you would want to see that in the MIDI editor regardless of the track, even if it disagrees with the underlying virtual instrument on that track. In fact, many users find that once they have Reaticulate setup, they never even need to open the VI during normal composition workflows, so the discrepancy is only an early annoyance during initial track setup -- and for users who just grab bank files created by someone else, they may never encounter the discrepancy at all.

louisfeng commented 2 years ago

Thanks for the tip on ReaControlMIDI. I think as long as it's well understood, I can live with it :).

jtackaberry commented 2 years ago

Cheers @louisfeng.