17.01.2013 Views

musicdsp.org source code archive - WSInf

musicdsp.org source code archive - WSInf

musicdsp.org source code archive - WSInf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Soft saturation (click this to go back to the index)<br />

Type : waveshaper<br />

References : Posted by Bram de Jong<br />

Notes :<br />

This only works for positive values of x. a should be in the range 0..1<br />

Code :<br />

x < a:<br />

f(x) = x<br />

x > a:<br />

f(x) = a + (x-a)/(1+((x-a)/(1-a))^2)<br />

x > 1:<br />

f(x) = (a+1)/2<br />

Comments<br />

from : graue@oceanbase.<strong>org</strong><br />

comment : This is a most excellent waveshaper.<br />

I have implemented it as an effect for the music tracker Psycle, and so far I am very pleased with the results. Thanks for sharing this knowledge, Bram!<br />

from : brobinson@toptensoftware.com<br />

comment : I'm wondering about the >1 condition here. If a is 0.8, values 1 are clamped to 0.9 (there's a gap)<br />

If you substitute x=1 to the equation for x>a you get: a+((1-a)/4) not (a+1)/2<br />

Have I missed something or is there a reason for this?<br />

(Go easy I'm new to all of this)<br />

from : kibibu@gmail.com<br />

comment : Substituting x=1 into equation 2 (taking many steps)<br />

f(x) = a + (x-a)/(1+ ((x-a)/(1-a))^2)<br />

= a + (1-a)/(1+ ((1-a)/(1-a))^2)<br />

= a + (1-a)/(1+ 1^2)<br />

= a + (1-a)/2<br />

= 2a/2 + (1-a)/2<br />

= (2a + 1 - a) /2<br />

= (a+1) / 2<br />

from : <strong>musicdsp</strong>[at] Nospam dsparsons[dot]co[dot]uk<br />

comment : You can normalise the output:<br />

f(x)'=f(x)*(1/((a+1)/2))<br />

This gives a nice variable shaper with smooth curve upto clipping at 0dBFS

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!