summaryrefslogtreecommitdiff
path: root/lib/Clipper.ck
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-04-16 17:09:49 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-04-16 17:09:49 +0200
commit7f8536b4a6d7fd06b1cd4929f548d241183c09cd (patch)
treee26f0579bc0988b4861e2da7582244121972442f /lib/Clipper.ck
downloaddigitale-debutanten-7f8536b4a6d7fd06b1cd4929f548d241183c09cd.tar.gz
initial import of files relevant for noise project
Diffstat (limited to 'lib/Clipper.ck')
-rw-r--r--lib/Clipper.ck18
1 files changed, 18 insertions, 0 deletions
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))
+}