From cf7f80e969f9bde04883fa155ad37e90aba19449 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 30 Aug 2012 15:04:06 +0200 Subject: implement Clipper as Chubgraph (simplifying usage) also make members pseudo-private by appending "__" --- lib/Clipper.ck | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/Clipper.ck b/lib/Clipper.ck index c11d3c2..eb45ea2 100644 --- a/lib/Clipper.ck +++ b/lib/Clipper.ck @@ -1,18 +1,20 @@ /* * 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 +public class Clipper extends ChubgraphStd { + /* calculate a from HalfRect(inlet + 1) */ + Step __one; 1 => __one.next; + inlet => HalfRect __a; + __one => __a; - 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)) + /* calculate b from HalfRect(2 - HalfRect(inlet + 1)) */ + Step __two; 2 => __two.next; + -1 => __a.gain; + __a => HalfRect __b; + __two => __b; + + /* the result we want: 1 - HalfRect(2 - HalfRect(inlet + 1)) */ + -1 => __b.gain; + __one => outlet; + __b => outlet; } -- cgit v1.2.3