3

I have a driver using a scripted expression: var*2. It's working great but the values it's outputting range from .005 up to about 1.5. I'd like to limit the range of the output to something like a minimum of .5 to a maximum of 1.25. Is it possible to do this within the expression itself?

Edit: A little more information, I'm trying to use a sound file to drive a particle value. "Bake Sound to F-Curves" provides me with a non editable F-curve so I'm trying to use a driver to increase the amplitude of the baked F-Curve.

Ironlion
  • 417
  • 3
  • 14
  • Related https://blender.stackexchange.com/questions/39231/whats-the-range-of-values-on-a-sound-baked-f-curve – batFINGER Mar 02 '19 at 05:46
  • Thanks, I had looked over that. I'm just wondering if there's a simple expression that can be written that sets a min and max value. – Ironlion Mar 02 '19 at 06:21

1 Answers1

5

Min max

Use the expression min(max(v, 0.5), 1.25) or its dual max(0.5, min(v, 1.25)) where v is the driver variable (sound curve value)

>>> v = 0.05
>>> min(max(v, 0.5), 1.25)
0.5

>>> v = 3
>>> min(max(v, 0.5), 1.25)
1.25

>>> v = 1.1
>>> min(max(v, 0.5), 1.25)
1.1

If you wish to double the variable v simply replace v with 2 * v in expression.

I would recommend you normalize the values in some way What's the range of values on a sound-baked f-curve?

Related

How to set driver distance max and min influence?

batFINGER
  • 84,216
  • 10
  • 108
  • 233