Hi,

Slightly surprisingly, I couldn't find one in the libraries when I had
a look just now, though perhaps it's there under a different name.
However, it's quite easy to define:

clip(rangemin, rangemax) = max(rangemin) : min(rangemax);

min and max are builtin functions which choose the min and max of
their two inputs respectively. When your input passes through min, it
will output whichever is the smaller of your input and its other
input, rangemax, which has the effect of limiting the signal to be no
greater than rangemax; similarly for max and rangemin.

Hope that helps,
James


On 1/26/22, Autumn Cheney via Faudiostream-users
<faudiostream-users@lists.sourceforge.net> wrote:
> what i'm looking to do is "clip" a value (like a signal or hslider value) to
> a certain range
>
> for example, if the range is set to 1-0, and the input value goes above 1,
> the output value should stay at 1. likewise, if the input goes below 0, the
> output should stay at 0. and of course, if the input is between 0 and 1, it
> should output that value
>
> i'm sure i could figure out how to do this using other functions (probably
> not lol) but i was wondering if faust already has a function like this
>
> thanks in advance,
>
> a cheney


_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to