rsjaffe / MIDI2LR

An application and plugin to remotely control Lightroom with a MIDI controller
http://rsjaffe.github.io/MIDI2LR/
GNU General Public License v3.0
689 stars 83 forks source link

Support for relative/absolute encoders #308

Closed mathieucarbou closed 7 years ago

mathieucarbou commented 7 years ago

For commands that relates to LR sliders (i.e. encoders), we can add a checkbox on MIDI2LR GUI at the right to set wheter the value is relative or absolute.

See: https://groups.google.com/forum/#!topic/midi2lr/p5Y0Nz6HARA

NB: Not all controllers support being configures in a way to send 0 or 127 depending if we turn left or right.

rsjaffe commented 7 years ago

Some time ago I changed the way the app and plugin communicated so that the plugin doesn't have any knowledge of the details of the particular MIDI control and the app doesn't have to know the control range--the app just sends a value between 0 and 1 for min and max and the plugin translates that to the allowable range.

To go to relative, we'd need to have the app save the state of the control--which we could do through a unordered_map<string,double> where string is the command string and double is the current state. Once we do that, we're not bound to 128 steps for relative encoders, but could use any arbitrary value (e.g., 1000 steps).

Currently, when data comes back from the plugin, we update the MIDI controller. With the map, when data comes back from the plugin, we'd update the map and update the MIDI controller.

Absolute controls would be sent straight to the plugin, as before. Relative controls would send a value relative to the current state as saved in the map.

rsjaffe commented 7 years ago

I think a new class for control state (that includes information about the type of control--e.g., relative/absolute, button/continuous, channel, control number, type (CC, note, etc.) would be useful.

rsjaffe commented 7 years ago

I'm starting by changing CommandMenu--working on getting it to recognize right mouse clicks, so that modifying the MIDI settings for a given command will be simplified.

rsjaffe commented 7 years ago

Data on how relative values work (from BC MIDI documentation) modes (from BC MIDI documentation) showing -2 -1 0 +1 +2 relative-1 twos complement 7# 7F 00 01 02 relative-2 binary offset 3E 3F 40 41 42 relative-3 sign and magnitude 42 41 00 01 02 (note that bit 6 is 0 for positive values, -1 for negative values, bits 1-5 are the value

14-bit showing MSB LSB relative -1 7F7E 7F7F 0000 0001 0002 relative-2 (offset from 4000) 3F7E 3F7F 4000 4001 4002 relative-3 (sign is in bit 6 of MSB) 4002 4001 0000 0001 0002

Probably need the following (+ info on NRPN)

enum struct RelAbs {
Absolute, TwosComplement, BinaryOffset, SignMagnitude };

enum struct ControlType {
PitchWheel, Note, ControlChange };
maf1000 commented 7 years ago

I'm interested in relative presets as well. In the Paddy world, I had some buttons assigned for + and - large and small values of exposure for example... just a preference in one workflow I had to make fixed step adjustments for certain things vs using the knobs. (I use a BCR2000). The Paddy settings required a dialog box for value assignments. https://www.youtube.com/watch?v=JQUtw9WSuLs&t=216s

katerlouis commented 5 years ago

What's the status here? I want to use my seaboard block as a controller– you could use the "glide" functionality perfectly as a relative fader.

rsjaffe commented 5 years ago

They’re supported. See https://github.com/rsjaffe/MIDI2LR/wiki/MIDI-Controller-Setup#controllers-that-send-relative-values-or-have-unusual-ranges