[chuck-users] simple distortion/clipping
eduard.aylon at gmail.com
Sat Dec 15 05:20:30 EST 2007
> I've been trying to figure out how to do some simple distortion /
> clipping in Chuck.
> I'm not sure I fully understand the GenX objects. Is this the best
> way to do it?
Can you show your patch?
Clipping involves waveshaping, so you should know the expression of
the clipping function (i.e. x-x^3/3) and substitute x with audio
samples. Possibly, with GenX functions you could multiply your
samples at time t with your GenX sample at time t but you should
hardclip your output so it does not exceed 1. Otherwise you get
unexpected behaviour as you say:
> I find my audio output significantly degrades (i.e., sound
> pops, goes silent, or makes strange unpleasant noises) when I exceed
> this limit, so I always have to fight to keep it within the correct
You could try this. Don't know if it's the best way, but it's some
fun float softclip( float x )
if( x > 1. ) return 2./3.;
if( x < -1. ) return -2./3.;
fun float hardclip( float x )
if( x < -1. ) return -1.;
if( x > 1. ) return 1.;
adc => Impulse imp => Gain vol => dac;
10 => adc.gain; // pre amplifying input signal, Change accordingly
1./adc.gain() => vol.gain; // keep same headroom. you can skip this.
while( now < later )
hardclip( adc.last() ) => imp.next;
// softclip( adc.last() ) => imp.next
1::samp => now;
Plug-in your guitar, now! There may be some errors, as I have not
execute the patch.
Alternatively, you may use atan(x) for waveshaping instead of x-x^3/3.
hope it helps,
More information about the chuck-users