From 7f8536b4a6d7fd06b1cd4929f548d241183c09cd Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 16 Apr 2012 17:09:49 +0200 Subject: initial import of files relevant for noise project --- lib/Clipper.ck | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/Clipper.ck (limited to 'lib/Clipper.ck') diff --git a/lib/Clipper.ck b/lib/Clipper.ck new file mode 100644 index 0000000..c11d3c2 --- /dev/null +++ b/lib/Clipper.ck @@ -0,0 +1,18 @@ +/* + * clip signal within -1 to 1 with simple UGens + */ +public class Clipper { + Gain input; // chuck input signal to this + Gain output; // chuck this out to have the result + + Step one; 1 => one.next; + input => HalfRect a; + one => a; // calculate a from HalfRect(input + 1) + one => Gain two; 2 => two.gain; + -1 => a.gain; + a => HalfRect b; + two => b; // calculate b from HalfRect(2 - HalfRect(input + 1)) + -1 => b.gain; + one => output; + b => output; // the result we want: 1 - HalfRect(2 - HalfRect(input + 1)) +} -- cgit v1.2.3