Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ABRev

  • Loading branch information...
commit 73150401bc8fd40c7c19c5f0cabbd9fe8bafd681 1 parent 337b1ee
Spencer Salazar authored August 24, 2012
113  ABRev/ABRev.cpp
... ...
@@ -0,0 +1,113 @@
  1
+
  2
+
  3
+#include "chuck_dl.h"
  4
+#include "chuck_def.h"
  5
+
  6
+#include <stdio.h>
  7
+#include <limits.h>
  8
+
  9
+
  10
+CK_DLL_CTOR(abrev_ctor);
  11
+CK_DLL_DTOR(abrev_dtor);
  12
+
  13
+CK_DLL_MFUN(abrev_setParam);
  14
+CK_DLL_MFUN(abrev_getParam);
  15
+
  16
+CK_DLL_TICK(abrev_tick);
  17
+
  18
+t_CKINT abrev_data_offset = 0;
  19
+
  20
+
  21
+class ABRev
  22
+{
  23
+public:
  24
+    
  25
+    ABRev(float fs)
  26
+    {
  27
+        m_param = 0;
  28
+    }
  29
+    
  30
+    SAMPLE tick(SAMPLE in)
  31
+    {
  32
+        return in;
  33
+    }
  34
+    
  35
+    float setParam(float p)
  36
+    {
  37
+        m_param = p;
  38
+        return p;
  39
+    }
  40
+    
  41
+    float getParam() { return m_param; }
  42
+    
  43
+private:
  44
+    
  45
+    float m_param;
  46
+};
  47
+
  48
+CK_DLL_QUERY(ABRev)
  49
+{
  50
+    QUERY->setname(QUERY, "ABRev");
  51
+    
  52
+    QUERY->begin_class(QUERY, "ABRev", "UGen");
  53
+    
  54
+    QUERY->add_ctor(QUERY, abrev_ctor);
  55
+    QUERY->add_dtor(QUERY, abrev_dtor);
  56
+    
  57
+    QUERY->add_ugen_func(QUERY, abrev_tick, NULL, 1, 1);
  58
+    
  59
+    QUERY->add_mfun(QUERY, abrev_setParam, "float", "param");
  60
+    QUERY->add_arg(QUERY, "float", "arg");
  61
+    
  62
+    QUERY->add_mfun(QUERY, abrev_getParam, "float", "param");
  63
+    
  64
+    abrev_data_offset = QUERY->add_mvar(QUERY, "int", "@abrev_data", false);
  65
+    
  66
+    QUERY->end_class(QUERY);
  67
+
  68
+    return TRUE;
  69
+}
  70
+
  71
+
  72
+CK_DLL_CTOR(abrev_ctor)
  73
+{
  74
+    OBJ_MEMBER_INT(SELF, abrev_data_offset) = 0;
  75
+    
  76
+    ABRev * bcdata = new ABRev(API->vm->get_srate());
  77
+    
  78
+    OBJ_MEMBER_INT(SELF, abrev_data_offset) = (t_CKINT) bcdata;
  79
+}
  80
+
  81
+CK_DLL_DTOR(abrev_dtor)
  82
+{
  83
+    ABRev * bcdata = (ABRev *) OBJ_MEMBER_INT(SELF, abrev_data_offset);
  84
+    if(bcdata)
  85
+    {
  86
+        delete bcdata;
  87
+        OBJ_MEMBER_INT(SELF, abrev_data_offset) = 0;
  88
+        bcdata = NULL;
  89
+    }
  90
+}
  91
+
  92
+CK_DLL_TICK(abrev_tick)
  93
+{
  94
+    ABRev * c = (ABRev *) OBJ_MEMBER_INT(SELF, abrev_data_offset);
  95
+    
  96
+    if(c) *out = c->tick(in);
  97
+
  98
+    return TRUE;
  99
+}
  100
+
  101
+CK_DLL_MFUN(abrev_setParam)
  102
+{
  103
+    ABRev * bcdata = (ABRev *) OBJ_MEMBER_INT(SELF, abrev_data_offset);
  104
+    // TODO: sanity check
  105
+    RETURN->v_float = bcdata->setParam(GET_NEXT_FLOAT(ARGS));
  106
+}
  107
+
  108
+CK_DLL_MFUN(abrev_getParam)
  109
+{
  110
+    ABRev * bcdata = (ABRev *) OBJ_MEMBER_INT(SELF, abrev_data_offset);
  111
+    RETURN->v_float = bcdata->getParam();
  112
+}
  113
+
110  ABRev/makefile
... ...
@@ -0,0 +1,110 @@
  1
+
  2
+# chugin name
  3
+CHUGIN_NAME=ABRev
  4
+
  5
+# all of the c/cpp files that compose this chugin
  6
+C_MODULES=
  7
+CXX_MODULES=ABRev.cpp
  8
+
  9
+# where the chuck source code is
  10
+CK_SRC_PATH=../../chuck/trunk/src/
  11
+
  12
+
  13
+# ---------------------------------------------------------------------------- #
  14
+# you won't generally need to change anything below this line for a new chugin #
  15
+# ---------------------------------------------------------------------------- #
  16
+
  17
+# default target: print usage message and quit
  18
+current: 
  19
+	@echo "[chuck build]: please use one of the following configurations:"
  20
+	@echo "   make linux, make osx, or make win32"
  21
+
  22
+ifneq ($(CK_TARGET),)
  23
+.DEFAULT_GOAL:=$(CK_TARGET)
  24
+ifeq ($(MAKECMDGOALS),)
  25
+MAKECMDGOALS:=$(.DEFAULT_GOAL)
  26
+endif
  27
+endif
  28
+
  29
+.PHONY: osx linux linux-oss linux-jack linux-alsa win32
  30
+osx linux linux-oss linux-jack linux-alsa win32: all
  31
+
  32
+CC=gcc
  33
+CXX=gcc
  34
+LD=g++
  35
+
  36
+CHUGIN_PATH=/usr/lib/chuck
  37
+
  38
+ifneq (,$(strip $(filter osx bin-dist-osx,$(MAKECMDGOALS))))
  39
+include makefile.osx
  40
+endif
  41
+
  42
+ifneq (,$(strip $(filter linux,$(MAKECMDGOALS))))
  43
+include makefile.linux
  44
+endif
  45
+
  46
+ifneq (,$(strip $(filter linux-oss,$(MAKECMDGOALS))))
  47
+include makefile.linux
  48
+endif
  49
+
  50
+ifneq (,$(strip $(filter linux-jack,$(MAKECMDGOALS))))
  51
+include makefile.linux
  52
+endif
  53
+
  54
+ifneq (,$(strip $(filter linux-alsa,$(MAKECMDGOALS))))
  55
+include makefile.linux
  56
+endif
  57
+
  58
+ifneq (,$(strip $(filter win32,$(MAKECMDGOALS))))
  59
+include makefile.win32
  60
+endif
  61
+
  62
+ifneq ($(CHUCK_DEBUG),)
  63
+FLAGS+= -g
  64
+else
  65
+FLAGS+= -O3
  66
+endif
  67
+
  68
+ifneq ($(CHUCK_STRICT),)
  69
+FLAGS+= -Wall
  70
+endif
  71
+
  72
+# default: build a dynamic chugin
  73
+CK_CHUGIN_STATIC?=0
  74
+
  75
+ifeq ($(CK_CHUGIN_STATIC),0)
  76
+SUFFIX=.chug
  77
+else
  78
+SUFFIX=.schug
  79
+FLAGS+= -D__CK_DLL_STATIC__
  80
+endif
  81
+
  82
+C_OBJECTS=$(addsuffix .o,$(basename $(C_MODULES)))
  83
+CXX_OBJECTS=$(addsuffix .o,$(basename $(CXX_MODULES)))
  84
+
  85
+CHUG=$(addsuffix $(SUFFIX),$(CHUGIN_NAME))
  86
+
  87
+all: $(CHUG)
  88
+
  89
+$(CHUG): $(C_OBJECTS) $(CXX_OBJECTS)
  90
+ifeq ($(CK_CHUGIN_STATIC),0)
  91
+	g++ $(LDFLAGS) -o $@ $^
  92
+else
  93
+	ar rv $@ $^
  94
+	ranlib $@
  95
+endif
  96
+
  97
+$(C_OBJECTS): %.o: %.c
  98
+	$(CC) $(FLAGS) -c -o $@ $<
  99
+
  100
+$(CXX_OBJECTS): %.o: %.cpp $(CK_SRC_PATH)/chuck_dl.h
  101
+	$(CXX) $(FLAGS) -c -o $@ $<
  102
+
  103
+install: $(CHUG)
  104
+	mkdir -p $(CHUGIN_PATH)
  105
+	cp $^ $(CHUGIN_PATH)
  106
+	chmod 755 $(CHUGIN_PATH)/$(CHUG)
  107
+
  108
+clean: 
  109
+	rm -rf $(C_OBJECTS) $(CXX_OBJECTS) $(CHUG)
  110
+
8  ABRev/makefile.linux
... ...
@@ -0,0 +1,8 @@
  1
+
  2
+CHUGIN_PATH=/usr/lib/chuck
  3
+
  4
+FLAGS=-D__LINUX_ALSA__ -I$(CK_SRC_PATH)
  5
+LDFLAGS=-shared -lstdc++
  6
+
  7
+LD=gcc
  8
+CXX=g++
6  ABRev/makefile.osx
... ...
@@ -0,0 +1,6 @@
  1
+
  2
+FLAGS=-m32 -D__MACOSX_CORE__ -I$(CK_SRC_PATH)
  3
+LDFLAGS=-m32 -bundle -lstdc++
  4
+
  5
+LD=gcc
  6
+CXX=g++
6  ABRev/makefile.win32
... ...
@@ -0,0 +1,6 @@
  1
+
  2
+FLAGS=-D__WINDOWS_DS_ -D__WINDOWS_PTHREAD__ -I$(CK_SRC_PATH)
  3
+LDFLAGS=-shared -lstdc++
  4
+
  5
+CXX=g++
  6
+LD=g++

0 notes on commit 7315040

Please sign in to comment.
Something went wrong with that request. Please try again.