From 46e77b128373ad7d10e004e790f1ff4d4021d4af Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 18 Dec 2012 20:55:49 +0100 Subject: added "soft" clipper based on arcus tangens --- chugins/Makefile | 3 ++- chugins/SoftClipper.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 chugins/SoftClipper.cpp (limited to 'chugins') 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 + +#include +#include + +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; +} -- cgit v1.2.3