summaryrefslogtreecommitdiff
path: root/chugins
diff options
context:
space:
mode:
Diffstat (limited to 'chugins')
-rw-r--r--chugins/Makefile3
-rw-r--r--chugins/SoftClipper.cpp28
2 files changed, 30 insertions, 1 deletions
diff --git a/chugins/Makefile b/chugins/Makefile
index 0aee682..f577e10 100644
--- a/chugins/Makefile
+++ b/chugins/Makefile
@@ -3,8 +3,9 @@ CFLAGS ?= -O3
CFLAGS += -fPIC
CPPFLAGS += -I/usr/include/chuck -D__UNIX_JACK__ -D__LINUX_JACK__
CXXFLAGS += $(CFLAGS)
+LDFLAGS += -lm
-all : Clipper.chug
+all : Clipper.chug SoftClipper.chug
%.chug : %.o
$(CXX) -shared $(LDFLAGS) -o $@ $^
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;
+}