Clip voltage to a specific nonsymmetric range...?

An ongoing source of amusement for me with VCV Rack is that I quite often know how to do something specific with control values in SuperCollider or Pure Data, but I can’t find the corresponding analog-style module.

Example: I’m getting accelerometer data from my phone, massaging them in Pd (because converting the raw data into angles of rotation requires functions like arcsin, pretty sure there’s no module for that) and then sending MIDI over to Rack. 0 = 90 degrees rotation in one direction, 127 = 90 degrees in the other. 64 = neutral. In voltages, that’s +5V = neutral, +0 = 90 one way, +10 = 90 the other way.

Now I want to use part of the range along one axis to increase a filter frequency – that is, I want to use +5 - +10V, but I want to clip off the lower part of the range.

In SC/Pd, this is stupidly simple: max(controlVoltage, 5) and bang, everything below 5 is clipped off, everything above is untouched.

In Rack, I can find e.g. Bogaudio CLPR which… assumes a symmetric range about 0. There’s no independent control over upper and lower bounds. I suppose I can use multiple offsets (e.g. 0-10 range offset to -10 to 0, then clip -5 to +5 leaving -5 to 0, then offset back up)… but… like, really?

Is there a cookbook anywhere of these really-really-simple math operations that are not so simple in modules? People must have solved these problems.

(I use Rack with students… these particular students don’t get into programming at all, but some of them will approach Rack.)


How about this?

Something like the Orange Line::Fence module?

1 Like

Look at the Formula module to be able to use asine and custom math expressions.

By the way what you want is a clamp function, it can be made by combining a max and a min (which you could do with many different modules)

min(range_maximum, max(range_minimum, value))

Edit: I realize you might just need a max. This one looks simple and does it all…

Thanks, all. Any and all of the above would do it.

I guess it’s a terminology thing – I did search for “max” but only found modules that would report min/max values. “Clamp” would have been a better search term but this term isn’t used in the programming environments I use (it’s clip or min or max), so I hadn’t guessed it.


1 Like

As the previous responses show, there are lots of options. Here are some more:

For general, arbitrarily complex math, the new docB Formula One module offers better performance (lower CPU), more inputs (5), more controls (5), and more outputs (3), then the Frank Buss Formula.

The best performing general math utilities I have found are the Submarine A0-XXX series (arithmetic operators). They do not have as many functions as Formula or Formula One, but there are still a great many. It can be a bit confusing to work with though. But of particular interest is the diminutive A0-101 that allows you to do a single math operation, including min or max, or trig functions, only using 2hp.

There are additional dedicated min/max modules, including

and of course the jack of all trades, Rampage, with its Min and Max outputs

1 Like

In c++17 there is a std::clamp()!

This is what popped into my mind first, too.

I tend to use this as it feels more ‘modular’ like to me and less scientific than some of the other options

it’s my main go to when trying to for instance keep an oscillator voltage inside a two and a half octave range

To sum up:

  • Fence (Orange Line)
  • Formula (Frank Buss)
  • Formula One (docB)
  • Clamp (Bark)
  • AO-101 (Submarine)
  • SUMS (Bogaudio)
  • Quad Logic (Bark)
  • Rampage (Befaco)

Normaliser (noobhour) I suspect is something a bit different from these but useful.

Thanks for all the tips!


1 Like

And now that you have some ideas what to to search for, I’m sure you can find others if you try. But that list is certainly more than enough.

It is different. Rather than hard-clamp to a range it attenuates inside a range. So, depends on what you need:

Two different ways to restrict a signal: