Klang C++ 0.7.15
Language Reference (draft)
Loading...
Searching...
No Matches
clamp

Language Guide / Functions · Generated namespace reference

clamp

klang::clamp

Restricts a value to a lower and upper bound.

The incoming sample supplies the value. Pass the lower and upper bounds in order. On audio samples this can produce hard clipping distortion. clip is an alias.

-1-0.5-0.5-0.25000.50.2510.5ResultInput x
clamp(x, −0.5, 0.5)

Based on std::clamp.

Direct call

const signal limited = clamp(sample, -0.5, 0.5);

Signal flow

const signal limited = sample >> clamp(-0.5, 0.5);