realearn icon indicating copy to clipboard operation
realearn copied to clipboard

Suggestion : ease target over time

Open gthibert opened this issue 3 years ago • 3 comments

Hi,

First ReaLearn is incredible, and realy powerful! A huge thanks for your work!

Here's my suggestion : it would be awesome if ReaLearn could "ease" a target value over a period of time.

One simple usage of this would be that, on the press on a button, a fade-in or fade-out could be automated. The target value (track volume from x dB to y dB) could be reached in x milliseconds.

I managed to do something similar by activating a mapping that uses the "Reaper: timer" source (at 100 ms) with "Incremental button" mode. One of the downside of this is that there's no easy way to deactivate the mapping once the target value as been reached, and the timer will keep send the max value.

In BrainModular Usine, this is called a Data smoother (transforms abrupt value transition into more progressive transition).

licecap

gthibert avatar Jul 28 '22 04:07 gthibert

Hi! It's a little bit hidden but this is already possible to some degree: https://github.com/helgoboss/realearn/issues/593#issuecomment-1151426825

helgoboss avatar Jul 28 '22 05:07 helgoboss

Ok thanks!

I'm trying to simply delay a trigger, and I did this :

y = rel_time > 2000 ? x: none;

But is there a way to return "stop", after returning "x"? I did this, but does'nt seem optimal :

y = rel_time > 2000 ? (rel_time>2100 ? stop : 0.5): none;

Also, it seems like x is always 1, no matter what the max target is setted to, But with this simple code, x returns the correct max target value :

y = x

gthibert avatar Aug 02 '22 03:08 gthibert

x always corresponds to the incoming control value (e.g. fader position or whether button is pressed/released).

Mmh, I see the problem and what you would like to do. Unfortunately, the code in the transformation formula doesn't have any concept of a "sequence" ... like do "stop" after returning "x". It simply gets executed repeatedly and has access to the variables, no higher magic there. As you already found out ("doesn't seem optimal"): If you want to fire just once and then stop, it's unreliable to use the rel_time variable, see also my statement here: https://github.com/helgoboss/realearn/issues/593#issuecomment-1151647213.

I think even with the rel_count variable mentioned in the statement, your case wouldn't quite work. You would have something like y = rel_count < 60 ? none : (rel_count == 60 ? 0.5 : stop). It would fire once and then stop, guaranteed. But you would rely on the fact that the invocation happens approximately each 30ms - and that's not good because it could change anytime, also depending on the machine. So it could be that the delay duration varies quite much, depending on machine and REAPER settings and ReaLearn version.

In your particular case, the following formula might do the trick: y = rel_time > 2000 ? (y != 0.5 ? 0.5 : stop) ... so you just check if the target already has the desired value and then stop.

For other more complicated cases, it might be cool to be able to do this: y = rel_time < 2000 ? none : 0.5 + stop. Maybe I could make it work that way.

helgoboss avatar Aug 28 '22 17:08 helgoboss

This is now possible! y = rel_time < 2000 ? none : stop(0.5)

helgoboss avatar Sep 12 '22 15:09 helgoboss