Permalink
Browse files

ABRev

  • Loading branch information...
spencersalazar committed Aug 24, 2012
1 parent 337b1ee commit 73150401bc8fd40c7c19c5f0cabbd9fe8bafd681
Showing with 243 additions and 0 deletions.
  1. +113 −0 ABRev/ABRev.cpp
  2. +110 −0 ABRev/makefile
  3. +8 −0 ABRev/makefile.linux
  4. +6 −0 ABRev/makefile.osx
  5. +6 −0 ABRev/makefile.win32
View
@@ -0,0 +1,113 @@
+
+
+#include "chuck_dl.h"
+#include "chuck_def.h"
+
+#include <stdio.h>
+#include <limits.h>
+
+
+CK_DLL_CTOR(abrev_ctor);
+CK_DLL_DTOR(abrev_dtor);
+
+CK_DLL_MFUN(abrev_setParam);
+CK_DLL_MFUN(abrev_getParam);
+
+CK_DLL_TICK(abrev_tick);
+
+t_CKINT abrev_data_offset = 0;
+
+
+class ABRev
+{
+public:
+
+ ABRev(float fs)
+ {
+ m_param = 0;
+ }
+
+ SAMPLE tick(SAMPLE in)
+ {
+ return in;
+ }
+
+ float setParam(float p)
+ {
+ m_param = p;
+ return p;
+ }
+
+ float getParam() { return m_param; }
+
+private:
+
+ float m_param;
+};
+
+CK_DLL_QUERY(ABRev)
+{
+ QUERY->setname(QUERY, "ABRev");
+
+ QUERY->begin_class(QUERY, "ABRev", "UGen");
+
+ QUERY->add_ctor(QUERY, abrev_ctor);
+ QUERY->add_dtor(QUERY, abrev_dtor);
+
+ QUERY->add_ugen_func(QUERY, abrev_tick, NULL, 1, 1);
+
+ QUERY->add_mfun(QUERY, abrev_setParam, "float", "param");
+ QUERY->add_arg(QUERY, "float", "arg");
+
+ QUERY->add_mfun(QUERY, abrev_getParam, "float", "param");
+
+ abrev_data_offset = QUERY->add_mvar(QUERY, "int", "@abrev_data", false);
+
+ QUERY->end_class(QUERY);
+
+ return TRUE;
+}
+
+
+CK_DLL_CTOR(abrev_ctor)
+{
+ OBJ_MEMBER_INT(SELF, abrev_data_offset) = 0;
+
+ ABRev * bcdata = new ABRev(API->vm->get_srate());
+
+ OBJ_MEMBER_INT(SELF, abrev_data_offset) = (t_CKINT) bcdata;
+}
+
+CK_DLL_DTOR(abrev_dtor)
+{
+ ABRev * bcdata = (ABRev *) OBJ_MEMBER_INT(SELF, abrev_data_offset);
+ if(bcdata)
+ {
+ delete bcdata;
+ OBJ_MEMBER_INT(SELF, abrev_data_offset) = 0;
+ bcdata = NULL;
+ }
+}
+
+CK_DLL_TICK(abrev_tick)
+{
+ ABRev * c = (ABRev *) OBJ_MEMBER_INT(SELF, abrev_data_offset);
+
+ if(c) *out = c->tick(in);
+
+ return TRUE;
+}
+
+CK_DLL_MFUN(abrev_setParam)
+{
+ ABRev * bcdata = (ABRev *) OBJ_MEMBER_INT(SELF, abrev_data_offset);
+ // TODO: sanity check
+ RETURN->v_float = bcdata->setParam(GET_NEXT_FLOAT(ARGS));
+}
+
+CK_DLL_MFUN(abrev_getParam)
+{
+ ABRev * bcdata = (ABRev *) OBJ_MEMBER_INT(SELF, abrev_data_offset);
+ RETURN->v_float = bcdata->getParam();
+}
+
View
@@ -0,0 +1,110 @@
+
+# chugin name
+CHUGIN_NAME=ABRev
+
+# all of the c/cpp files that compose this chugin
+C_MODULES=
+CXX_MODULES=ABRev.cpp
+
+# where the chuck source code is
+CK_SRC_PATH=../../chuck/trunk/src/
+
+
+# ---------------------------------------------------------------------------- #
+# you won't generally need to change anything below this line for a new chugin #
+# ---------------------------------------------------------------------------- #
+
+# default target: print usage message and quit
+current:
+ @echo "[chuck build]: please use one of the following configurations:"
+ @echo " make linux, make osx, or make win32"
+
+ifneq ($(CK_TARGET),)
+.DEFAULT_GOAL:=$(CK_TARGET)
+ifeq ($(MAKECMDGOALS),)
+MAKECMDGOALS:=$(.DEFAULT_GOAL)
+endif
+endif
+
+.PHONY: osx linux linux-oss linux-jack linux-alsa win32
+osx linux linux-oss linux-jack linux-alsa win32: all
+
+CC=gcc
+CXX=gcc
+LD=g++
+
+CHUGIN_PATH=/usr/lib/chuck
+
+ifneq (,$(strip $(filter osx bin-dist-osx,$(MAKECMDGOALS))))
+include makefile.osx
+endif
+
+ifneq (,$(strip $(filter linux,$(MAKECMDGOALS))))
+include makefile.linux
+endif
+
+ifneq (,$(strip $(filter linux-oss,$(MAKECMDGOALS))))
+include makefile.linux
+endif
+
+ifneq (,$(strip $(filter linux-jack,$(MAKECMDGOALS))))
+include makefile.linux
+endif
+
+ifneq (,$(strip $(filter linux-alsa,$(MAKECMDGOALS))))
+include makefile.linux
+endif
+
+ifneq (,$(strip $(filter win32,$(MAKECMDGOALS))))
+include makefile.win32
+endif
+
+ifneq ($(CHUCK_DEBUG),)
+FLAGS+= -g
+else
+FLAGS+= -O3
+endif
+
+ifneq ($(CHUCK_STRICT),)
+FLAGS+= -Wall
+endif
+
+# default: build a dynamic chugin
+CK_CHUGIN_STATIC?=0
+
+ifeq ($(CK_CHUGIN_STATIC),0)
+SUFFIX=.chug
+else
+SUFFIX=.schug
+FLAGS+= -D__CK_DLL_STATIC__
+endif
+
+C_OBJECTS=$(addsuffix .o,$(basename $(C_MODULES)))
+CXX_OBJECTS=$(addsuffix .o,$(basename $(CXX_MODULES)))
+
+CHUG=$(addsuffix $(SUFFIX),$(CHUGIN_NAME))
+
+all: $(CHUG)
+
+$(CHUG): $(C_OBJECTS) $(CXX_OBJECTS)
+ifeq ($(CK_CHUGIN_STATIC),0)
+ g++ $(LDFLAGS) -o $@ $^
+else
+ ar rv $@ $^
+ ranlib $@
+endif
+
+$(C_OBJECTS): %.o: %.c
+ $(CC) $(FLAGS) -c -o $@ $<
+
+$(CXX_OBJECTS): %.o: %.cpp $(CK_SRC_PATH)/chuck_dl.h
+ $(CXX) $(FLAGS) -c -o $@ $<
+
+install: $(CHUG)
+ mkdir -p $(CHUGIN_PATH)
+ cp $^ $(CHUGIN_PATH)
+ chmod 755 $(CHUGIN_PATH)/$(CHUG)
+
+clean:
+ rm -rf $(C_OBJECTS) $(CXX_OBJECTS) $(CHUG)
+
View
@@ -0,0 +1,8 @@
+
+CHUGIN_PATH=/usr/lib/chuck
+
+FLAGS=-D__LINUX_ALSA__ -I$(CK_SRC_PATH)
+LDFLAGS=-shared -lstdc++
+
+LD=gcc
+CXX=g++
View
@@ -0,0 +1,6 @@
+
+FLAGS=-m32 -D__MACOSX_CORE__ -I$(CK_SRC_PATH)
+LDFLAGS=-m32 -bundle -lstdc++
+
+LD=gcc
+CXX=g++
View
@@ -0,0 +1,6 @@
+
+FLAGS=-D__WINDOWS_DS_ -D__WINDOWS_PTHREAD__ -I$(CK_SRC_PATH)
+LDFLAGS=-shared -lstdc++
+
+CXX=g++
+LD=g++

0 comments on commit 7315040

Please sign in to comment.