summaryrefslogtreecommitdiff
path: root/lib/ClipperGraph.ck
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ClipperGraph.ck')
-rw-r--r--lib/ClipperGraph.ck20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/ClipperGraph.ck b/lib/ClipperGraph.ck
new file mode 100644
index 0000000..86e6183
--- /dev/null
+++ b/lib/ClipperGraph.ck
@@ -0,0 +1,20 @@
+/*
+ * clip signal within -1 to 1 with simple UGens
+ */
+public class ClipperGraph extends ChubgraphStd {
+ /* calculate a from HalfRect(inlet + 1) */
+ Step __one; 1 => __one.next;
+ inlet => HalfRect __a;
+ __one => __a;
+
+ /* 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;
+}