/* Algorithm taken from the blog post: http://electro-music.com/forum/topic-19287.html Uses basic waveshaping to perform soft clipping with a transfer function of : y = x / (1 + abs(x)) */ public class Distortion extends MyUGen { in => Gain i => FullRect abs_i; // calculate 1 + abs(source) to use as the divisor abs_i => Gain divisor; Step one => divisor; 1 => one.next; i => Gain division; divisor => division; 4 => division.op; // Set to division mode // Defaults to 50 gain 50.0 => i.gain; division => out; fun void gain(float gain) { gain => i.gain; } } /* adc => Gain in; Gain out => dac; 100.0 => in.gain; Distortion d; in => d.chuck => out; 1::day => now; */