 |
Variable-hardness clipping function
References : Posted by Laurent de Soras Linked file : laurent.gif
Notes : k >= 1 is the "clipping hardness". 1 gives a smooth clipping, and a high value gives hardclipping.
Don't set k too high, because the formula use the pow() function, which use exp() and would overflow easily. 100 seems to be a reasonable value for "hardclipping"
Code : f (x) = sign (x) * pow (atan (pow (abs (x), k)), (1 / k));
|
Comments
Added on : 14/11/03 by antiprosynthesis[ AT ]hotmail[ DOT ]com Comment : Use this function instead of atan and see performance increase drastically :)
inline double fastatan( double x )
{
return (x / (1.0 + 0.28 * (x * x)));
}
Added on : 16/07/04 by spam[ AT ]musicdsp[ DOT ]org Comment : The greater k becomes the lesser is the change in the form of f(x, k). I recommend using
f2(x, k2) = sign(x) * pow(atan(pow(abs(x), 1 / k2)), k2) , k2 in [0.01, 1]
where k2 is the "clipping softness" (k2 = 0.01 means "hardclipping", k2 = 1 means "softclipping"). This gives better control over the clipping effect.
Added on : 12/08/04 by notinformed[ AT ]nomail[ DOT ]org Comment : Don't know if i understood ok , but, how can i clip at diferent levels than -1.0/1.0 using this func? tried several ways but none seems to work
Added on : 14/08/04 by xeeton[AT]gmail[DOT]com Comment : The most straightforward way to adjust the level (x) at which the signal is clipped would be to multiply the signal by 1/x before the clipping function then multiply it again by x afterwards.
Added on : 09/10/04 by cschueler[at]gmx[dot]de Comment :
Atan is a nice softclipping function, but you can do without pow().
x: input value
a: clipping factor (0 = none, infinity = hard)
ainv: 1/a
y = ainv * atan( x * a );
Added on : 28/05/06 by scoofy[ AT ]inf[ DOT ]elte[ DOT ]hu Comment : Even better, you can normalize the output using:
shape = 1..infinity
precalc:
inv_atan_shape=1.0/atan(shape);
process:
output = inv_atan_shape * atan(input*shape);
This gives a very soft transition from no distortion to hard clipping.
|
Add your own comment
Comments are displayed in fixed width, no HTML code allowed! |
|
|
 |
|