[linux-audio-dev] Diode wave shaper (LADSPA plugin)?

Alfons Adriaensen fons.adriaensen at alcatel.be
Mon Aug 16 10:13:51 UTC 2004


On Mon, Aug 16, 2004 at 07:49:36PM +1000, Erik de Castro Lopo wrote:

> Its actually rather simple (first year EE):
> 
>     static inline double
>     diode_clip (double input, double clip_level /* should be positive */)
>     {   if (input > clip_level)
>             return clip_level ;
>         if (input < -clip_level)
>             return clip_level ;
>         return input ;
>     }

This is a bit too simple. The diode circuit does not perform hard
clipping when driven at moderate levels.

Something like 

  out = tanh (in)       (or tanhf() if available)

or

  out = in / sqrt (1 + in * in) 

with some scaling of in and out will come very close
to the real behaviour. Alternatively change the '1' in
the sqrt to some other constant to set the normal
operation levels.

-- 
FA









More information about the Linux-audio-dev mailing list