summaryrefslogtreecommitdiff
path: root/chugins/SoftClipper.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-12-18 20:55:49 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-12-18 20:55:49 +0100
commit46e77b128373ad7d10e004e790f1ff4d4021d4af (patch)
tree202cec07ab007396ab489bad96349ca4cbcd6dc0 /chugins/SoftClipper.cpp
parenta7278be9668c5f09165f7a673a54dfff324a65a2 (diff)
downloaddigitale-debutanten-master.tar.gz
added "soft" clipper based on arcus tangensHEADmaster
Diffstat (limited to 'chugins/SoftClipper.cpp')
-rw-r--r--chugins/SoftClipper.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/chugins/SoftClipper.cpp b/chugins/SoftClipper.cpp
new file mode 100644
index 0000000..d702576
--- /dev/null
+++ b/chugins/SoftClipper.cpp
@@ -0,0 +1,28 @@
+#include <math.h>
+
+#include <chuck_dl.h>
+#include <chuck_def.h>
+
+CK_DLL_TICK(clipper_tick);
+
+CK_DLL_QUERY(SoftClipper)
+{
+ QUERY->setname(QUERY, "SoftClipper");
+
+ QUERY->begin_class(QUERY, "SoftClipper", "UGen");
+ QUERY->add_ugen_func(QUERY, clipper_tick, NULL, 1, 1);
+ QUERY->end_class(QUERY);
+
+ return TRUE;
+}
+
+CK_DLL_TICK(clipper_tick)
+{
+#ifdef __CHUCK_USE_64_BIT_SAMPLE__
+ *out = atan(in * 2.)/M_PI_2;
+#else
+ *out = atanf(in * 2.)/M_PI_2;
+#endif
+
+ return TRUE;
+}