From f9e3fe480e7e3c448a626d508f1976f4fec2f759 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 9 Feb 2010 21:05:37 +0000 Subject: convert file layout to libdir style and setup everything with the new template Makefile+debian stuff svn path=/trunk/externals/sigpack/; revision=13153 --- Makefile | 238 ++++++++++++++++++++++++++++++++++++++++++++++-- chop~-help.pd | 32 +++++++ chop~.c | 67 ++++++++++++++ decimate~-help.pd | 32 +++++++ decimate~.c | 76 ++++++++++++++++ diode~-help.pd | 26 ++++++ diode~.c | 78 ++++++++++++++++ foldback~-help.pd | 30 ++++++ foldback~.c | 70 ++++++++++++++ foldover~-help.pd | 30 ++++++ foldover~.c | 71 +++++++++++++++ freqdiv~-help.pd | 27 ++++++ freqdiv~.c | 100 ++++++++++++++++++++ freqshift~-help.pd | 38 ++++++++ freqshift~.c | 197 +++++++++++++++++++++++++++++++++++++++ harmgen~-help.pd | 54 +++++++++++ harmgen~.c | 161 ++++++++++++++++++++++++++++++++ help/chop~-help.pd | 32 ------- help/decimate~-help.pd | 32 ------- help/diode~-help.pd | 26 ------ help/foldback~-help.pd | 30 ------ help/foldover~-help.pd | 30 ------ help/freqdiv~-help.pd | 27 ------ help/freqshift~-help.pd | 38 -------- help/harmgen~-help.pd | 54 ----------- help/rectify~-help.pd | 27 ------ help/round~-help.pd | 26 ------ help/saturate~-help.pd | 29 ------ help/sieve~-help.pd | 28 ------ help/split~-help.pd | 26 ------ help/ustep~-help.pd | 38 -------- help/vowel~-help.pd | 45 --------- rectify~-help.pd | 27 ++++++ rectify~.c | 61 +++++++++++++ round~-help.pd | 26 ++++++ round~.c | 64 +++++++++++++ sIgpAck.c | 58 ++++++++++++ saturate~-help.pd | 29 ++++++ saturate~.c | 83 +++++++++++++++++ sieve~-help.pd | 28 ++++++ sieve~.c | 105 +++++++++++++++++++++ sigpack-meta.pd | 8 ++ source/chop~.c | 67 -------------- source/decimate~.c | 76 ---------------- source/diode~.c | 78 ---------------- source/foldback~.c | 70 -------------- source/foldover~.c | 71 --------------- source/freqdiv~.c | 100 -------------------- source/freqshift~.c | 197 --------------------------------------- source/harmgen~.c | 161 -------------------------------- source/rectify~.c | 61 ------------- source/round~.c | 64 ------------- source/sIgpAck.c | 58 ------------ source/saturate~.c | 83 ----------------- source/sieve~.c | 105 --------------------- source/split~.c | 72 --------------- source/ustep~.c | 83 ----------------- source/vowel~.c | 118 ------------------------ split~-help.pd | 26 ++++++ split~.c | 72 +++++++++++++++ ustep~-help.pd | 38 ++++++++ ustep~.c | 83 +++++++++++++++++ vowel~-help.pd | 45 +++++++++ vowel~.c | 118 ++++++++++++++++++++++++ 64 files changed, 2188 insertions(+), 1962 deletions(-) create mode 100644 chop~-help.pd create mode 100644 chop~.c create mode 100644 decimate~-help.pd create mode 100644 decimate~.c create mode 100644 diode~-help.pd create mode 100644 diode~.c create mode 100644 foldback~-help.pd create mode 100644 foldback~.c create mode 100644 foldover~-help.pd create mode 100644 foldover~.c create mode 100644 freqdiv~-help.pd create mode 100644 freqdiv~.c create mode 100644 freqshift~-help.pd create mode 100644 freqshift~.c create mode 100644 harmgen~-help.pd create mode 100644 harmgen~.c delete mode 100644 help/chop~-help.pd delete mode 100644 help/decimate~-help.pd delete mode 100644 help/diode~-help.pd delete mode 100644 help/foldback~-help.pd delete mode 100644 help/foldover~-help.pd delete mode 100644 help/freqdiv~-help.pd delete mode 100644 help/freqshift~-help.pd delete mode 100644 help/harmgen~-help.pd delete mode 100644 help/rectify~-help.pd delete mode 100644 help/round~-help.pd delete mode 100644 help/saturate~-help.pd delete mode 100644 help/sieve~-help.pd delete mode 100644 help/split~-help.pd delete mode 100644 help/ustep~-help.pd delete mode 100644 help/vowel~-help.pd create mode 100644 rectify~-help.pd create mode 100644 rectify~.c create mode 100644 round~-help.pd create mode 100644 round~.c create mode 100644 sIgpAck.c create mode 100644 saturate~-help.pd create mode 100644 saturate~.c create mode 100644 sieve~-help.pd create mode 100644 sieve~.c create mode 100644 sigpack-meta.pd delete mode 100644 source/chop~.c delete mode 100644 source/decimate~.c delete mode 100644 source/diode~.c delete mode 100644 source/foldback~.c delete mode 100644 source/foldover~.c delete mode 100644 source/freqdiv~.c delete mode 100644 source/freqshift~.c delete mode 100644 source/harmgen~.c delete mode 100644 source/rectify~.c delete mode 100644 source/round~.c delete mode 100644 source/sIgpAck.c delete mode 100644 source/saturate~.c delete mode 100644 source/sieve~.c delete mode 100644 source/split~.c delete mode 100644 source/ustep~.c delete mode 100644 source/vowel~.c create mode 100644 split~-help.pd create mode 100644 split~.c create mode 100644 ustep~-help.pd create mode 100644 ustep~.c create mode 100644 vowel~-help.pd create mode 100644 vowel~.c diff --git a/Makefile b/Makefile index 576ff87..b6be885 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,235 @@ -TARGET := $(shell pwd | sed 's|.*/\(.*\)$$|\1|') -EXTERNALS_ROOT := $(shell pwd | sed 's|^\(/.*externals\).*|\1|') +# To use this Makefile for your project, first put the name of your library in +# LIBRARY_NAME variable. The folder for your project should have the same name +# as your library. +LIBRARY_NAME = sigpack +LIBRARY_VERSION = 0.0.3.1 -default: - make -C $(EXTERNALS_ROOT) $(TARGET) +# Next, add your .c source files to the SOURCES variable. The help files will +# be included automatically +SOURCES = chop~.c decimate~.c diode~.c foldback~.c foldover~.c freqdiv~.c freqshift~.c harmgen~.c rectify~.c round~.c saturate~.c sieve~.c split~.c ustep~.c vowel~.c + + +# For objects that only build on certain platforms, add those to the SOURCES +# line for the right platforms. +SOURCES_android = +SOURCES_cygwin = +SOURCES_macosx = +SOURCES_iphoneos = +SOURCES_linux = +SOURCES_windows = + +# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will +# be included automatically +PDOBJECTS = + +# if you want to include any other files in the source and binary tarballs, +# list them here. This can be anything from header files, READMEs, example +# patches, documentation, etc. +EXTRA_DIST = readme.txt sIgpAck.c LICENSE + + +#------------------------------------------------------------------------------# +# +# you shouldn't need to edit anything below here, if we did it right :) +# +#------------------------------------------------------------------------------# + +# where Pd lives +PD_PATH = ../../pd +# where to install the library +prefix = /usr/local +libdir = $(prefix)/lib +pkglibdir = $(libdir)/pd-externals +objectsdir = $(pkglibdir) + + +INSTALL = install +INSTALL_FILE = $(INSTALL) -p -m 644 +INSTALL_DIR = $(INSTALL) -p -m 755 -d + +CFLAGS = -DPD -I$(PD_PATH)/src -Wall -W -g +LDFLAGS = +LIBS = +ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \ + $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows) + +UNAME := $(shell uname -s) +ifeq ($(UNAME),Darwin) + CPU := $(shell uname -p) + ifeq ($(CPU),arm) # iPhone/iPod Touch + SOURCES += $(SOURCES_macosx) + EXTENSION = pd_darwin + OS = iphoneos + IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin + CC=$(IPHONE_BASE)/gcc + CPP=$(IPHONE_BASE)/cpp + CXX=$(IPHONE_BASE)/g++ + ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk + IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6 + OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer + CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS) + LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT) + LIBS += -lc + STRIP = strip -x + DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) + DISTBINDIR=$(DISTDIR)-$(OS) + else # Mac OS X + SOURCES += $(SOURCES_macosx) + EXTENSION = pd_darwin + OS = macosx + OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast + FAT_FLAGS = -arch i386 -arch ppc -mmacosx-version-min=10.4 + CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include + LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib + # if the 'pd' binary exists, check the linking against it to aid with stripping + LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd) + LIBS += -lc + STRIP = strip -x + DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) + DISTBINDIR=$(DISTDIR)-$(OS) + endif +endif +ifeq ($(UNAME),Linux) + SOURCES += $(SOURCES_linux) + EXTENSION = pd_linux + OS = linux + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += -fPIC + LDFLAGS += -Wl,--export-dynamic -shared -fPIC + LIBS += -lc + STRIP = strip --strip-unneeded -R .note -R .comment + DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME))) + SOURCES += $(SOURCES_cygwin) + EXTENSION = dll + OS = cygwin + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += + LDFLAGS += -Wl,--export-dynamic -shared -L$(PD_PATH)/src + LIBS += -lc -lpd + STRIP = strip --strip-unneeded -R .note -R .comment + DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) + DISTBINDIR=$(DISTDIR)-$(OS) +endif +ifeq (MINGW,$(findstring MINGW,$(UNAME))) + SOURCES += $(SOURCES_windows) + EXTENSION = dll + OS = windows + OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer -march=i686 -mtune=pentium4 + WINDOWS_HACKS = -D'O_NONBLOCK=1' + CFLAGS += -mms-bitfields $(WINDOWS_HACKS) + LDFLAGS += -s -shared -Wl,--enable-auto-import + LIBS += -L$(PD_PATH)/src -L$(PD_PATH)/bin -L$(PD_PATH)/obj -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 + STRIP = strip --strip-unneeded -R .note -R .comment + DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) + DISTBINDIR=$(DISTDIR)-$(OS) +endif + +CFLAGS += $(OPT_CFLAGS) + + +.PHONY = install libdir_install single_install install-doc install-exec clean dist etags + +all: $(SOURCES:.c=.$(EXTENSION)) + +%.o: %.c + $(CC) $(CFLAGS) -o "$*.o" -c "$*.c" + +%.$(EXTENSION): %.o + $(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(LIBS) + chmod a-x "$*.$(EXTENSION)" + +# this links everything into a single binary file +$(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o + $(CC) $(LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(LIBS) + chmod a-x $(LIBRARY_NAME).$(EXTENSION) + + +install: libdir_install + +# The meta and help files are explicitly installed to make sure they are +# actually there. Those files are not optional, then need to be there. +libdir_install: $(SOURCES:.c=.$(EXTENSION)) install-doc + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(SOURCES)" || (\ + $(INSTALL_FILE) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ + $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION)))) + test -z "$(PDOBJECTS)" || \ + $(INSTALL_FILE) $(OBJECTS) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + +# install library linked as single binary +single_install: $(LIBRARY_NAME) install-doc install-exec + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_FILE) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION) + +install-doc: + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(SOURCES)" || \ + $(INSTALL_FILE) $(SOURCES:.c=-help.pd) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(PDOBJECTS)" || \ + $(INSTALL_FILE) $(PDOBJECTS:.pd=-help.pd) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_FILE) readme.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/readme.txt -install: - make -C $(EXTERNALS_ROOT) $(TARGET)_install clean: - make -C $(EXTERNALS_ROOT) $(TARGET)_clean + -rm -f -- $(SOURCES:.c=.o) + -rm -f -- $(SOURCES:.c=.$(EXTENSION)) + -rm -f -- $(LIBRARY_NAME).$(EXTENSION) + +distclean: clean + -rm -f -- $(DISTBINDIR).tar.gz + -rm -rf -- $(DISTBINDIR) + -rm -f -- $(DISTDIR).tar.gz + -rm -rf -- $(DISTDIR) + + +$(DISTBINDIR): + $(INSTALL_DIR) $(DISTBINDIR) + +libdir: all $(DISTBINDIR) + $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) + $(INSTALL_FILE) $(SOURCES) $(DISTBINDIR) + $(INSTALL_FILE) $(SOURCES:.c=-help.pd) $(DISTBINDIR) + test -z "$(EXTRA_DIST)" || \ + $(INSTALL_FILE) $(EXTRA_DIST) $(DISTBINDIR) +# tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR) + +$(DISTDIR): + $(INSTALL_DIR) $(DISTDIR) + +dist: $(DISTDIR) + $(INSTALL_FILE) Makefile $(DISTDIR) + $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd $(DISTDIR) + test -z "$(ALLSOURCES)" || \ + $(INSTALL_FILE) $(ALLSOURCES) $(DISTDIR) + test -z "$(ALLSOURCES)" || \ + $(INSTALL_FILE) $(ALLSOURCES:.c=-help.pd) $(DISTDIR) + test -z "$(PDOBJECTS)" || \ + $(INSTALL_FILE) $(PDOBJECTS) $(DISTDIR) + test -z "$(PDOBJECTS)" || \ + $(INSTALL_FILE) $(PDOBJECTS:.pd=-help.pd) $(DISTDIR) + test -z "$(EXTRA_DIST)" || \ + $(INSTALL_FILE) $(EXTRA_DIST) $(DISTDIR) + tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR) -test_locations: - make -C $(EXTERNALS_ROOT) test_locations etags: - etags *.[ch] ~/cvs/pure-data/pd/src/*.[ch] /usr/include/*.h /usr/include/sys/*.h + etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h + +showpaths: + @echo "PD_PATH: $(PD_PATH)" + @echo "objectsdir: $(objectsdir)" + @echo "LIBRARY_NAME: $(LIBRARY_NAME)" + @echo "SOURCES: $(SOURCES)" + @echo "ALLSOURCES: $(ALLSOURCES)" + @echo "UNAME: $(UNAME)" + @echo "CPU: $(CPU)" + diff --git a/chop~-help.pd b/chop~-help.pd new file mode 100644 index 0000000..e0ccf9e --- /dev/null +++ b/chop~-help.pd @@ -0,0 +1,32 @@ +#N canvas 366 389 462 366 12; +#X obj 155 172 nbx 5 14 -2 2 0 0 empty empty ->factor[-2/2] 60 8 0 +10 -262144 -1 -1 0 256; +#X text 60 35 signal chopping modulator; +#X obj 62 116 osc~ 220; +#X obj 62 312 dac~; +#X obj 156 195 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 +-1 -1 92 256; +#X obj 62 277 *~; +#X obj 156 258 line~; +#X obj 156 235 pack 0 50; +#X obj 156 213 dbtorms; +#X text 156 144 ->signal modulation input; +#X text 155 116 ->signal input; +#X text 60 51 multiplicates incoming signal by factor x; +#X text 59 68 if modulation signal is positive; +#X obj 99 146 osc~ 2; +#X text 300 11 arg; +#X text 252 301 sIgpAck 0.02; +#X obj 62 186 chop~ 0; +#X text 213 316 2003 www.weiss-archiv.de; +#X text 60 13 ---chop~---; +#X connect 0 0 16 2; +#X connect 2 0 16 0; +#X connect 4 0 8 0; +#X connect 5 0 3 0; +#X connect 5 0 3 1; +#X connect 6 0 5 1; +#X connect 7 0 6 0; +#X connect 8 0 7 0; +#X connect 13 0 16 1; +#X connect 16 0 5 0; diff --git a/chop~.c b/chop~.c new file mode 100644 index 0000000..1d8c35a --- /dev/null +++ b/chop~.c @@ -0,0 +1,67 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +// ------------------------ chop~ ----------------------------- +// signal chopping modulator + +static t_class *chop_tilde_class; + +typedef struct _chop_tilde +{ + t_object x_obj; + t_sample x_factor; + float x_f; +} t_chop_tilde; + +static void *chop_tilde_new(t_floatarg factor) +{ + t_chop_tilde *x = (t_chop_tilde *)pd_new(chop_tilde_class); + x->x_factor = factor; + outlet_new(&x->x_obj, gensym("signal")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + floatinlet_new(&x->x_obj, &x->x_factor); + x->x_f = 0; + if(factor) x->x_factor = factor; + else x->x_factor = 0; + return (x); +} + +static t_int *chop_tilde_perform(t_int *w) +{ + t_chop_tilde *x = (t_chop_tilde *)(w[1]); + t_float *in1 = (t_float *)(w[2]); + t_float *in2 = (t_float *)(w[3]); + t_float *out = (t_float *)(w[4]); + int n = (int)(w[5]); + float f, m, value; + while (n--) + { + f = *in1++; + m = *in2++; + if(m > 0.) value = f * x->x_factor; + else value = f; + *out++ = value; + } + return (w+6); +} + +static void chop_tilde_dsp(t_chop_tilde *x, t_signal **sp) +{ + dsp_add(chop_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); +} + +void chop_tilde_setup(void) +{ + chop_tilde_class = class_new(gensym("chop~"), (t_newmethod)chop_tilde_new, 0, + sizeof(t_chop_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(chop_tilde_class, t_chop_tilde, x_f); + class_addmethod(chop_tilde_class, (t_method)chop_tilde_dsp, gensym("dsp"), 0); +} diff --git a/decimate~-help.pd b/decimate~-help.pd new file mode 100644 index 0000000..8ea60ee --- /dev/null +++ b/decimate~-help.pd @@ -0,0 +1,32 @@ +#N canvas 285 400 488 343 12; +#N canvas 0 0 450 300 graph1 0; +#X array deci 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 305 189 graph; +#X msg 8 112 bang; +#X obj 52 105 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 305 102 graph; +#X obj 62 132 tabwrite~ osc; +#X obj 125 172 nbx 5 14 0 1 0 0 empty empty ratio 0 -6 0 10 -262144 +-1 -1 0.02 256; +#X obj 199 172 nbx 5 14 0 32 0 0 empty empty bits[1-32] 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 52 228 tabwrite~ deci; +#X text 51 35 signal decimation; +#X text 51 50 a ratio of 1 is orig. samplerate 0.5 is half; +#X text 273 11 arg; +#X text 51 67 of orig. samplerate etc.; +#X text 260 268 sIgpAck 0.02; +#X obj 52 195 decimate~ 0.5 16; +#X text 222 281 2003 www.weiss-archiv.de; +#X text 51 13 ---decimate~---; +#X connect 1 0 4 0; +#X connect 1 0 7 0; +#X connect 2 0 4 0; +#X connect 2 0 13 0; +#X connect 5 0 13 1; +#X connect 6 0 13 2; +#X connect 13 0 7 0; diff --git a/decimate~.c b/decimate~.c new file mode 100644 index 0000000..6468d20 --- /dev/null +++ b/decimate~.c @@ -0,0 +1,76 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +// ------------------------ decimate~ ----------------------------- +// signal decimation +// code from musicdsp.org posted by tobybear + +static t_class *decimate_tilde_class; + +typedef struct _decimate_tilde +{ + t_object x_obj; + t_sample x_rate; + t_sample x_bits; + float x_f; +} t_decimate_tilde; + +static void *decimate_tilde_new(t_floatarg rate, t_floatarg bits) +{ + t_decimate_tilde *x = (t_decimate_tilde *)pd_new(decimate_tilde_class); + x->x_rate = rate; + x->x_bits = bits; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_rate); + floatinlet_new(&x->x_obj, &x->x_bits); + x->x_f = 0; + if (rate) x->x_rate = rate; + else x->x_rate = 0.5; + if (bits) x->x_bits = bits; + else x->x_bits = 16; + return (x); +} + +static t_int *decimate_tilde_perform(t_int *w) +{ + t_decimate_tilde *x = (t_decimate_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f; + long int m=1<<(int)(x->x_bits-1); + float y=0, cnt=0; + while (n--) + { + f = *in++; + cnt+=x->x_rate; + if (cnt>=1) + { + cnt-=1; + y=(long int)(f*m)/(float)m; + } + *out++ = y; + } + return (w+5); +} + +static void decimate_tilde_dsp(t_decimate_tilde *x, t_signal **sp) +{ + dsp_add(decimate_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void decimate_tilde_setup(void) +{ + decimate_tilde_class = class_new(gensym("decimate~"), (t_newmethod)decimate_tilde_new, 0, + sizeof(t_decimate_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(decimate_tilde_class, t_decimate_tilde, x_f); + class_addmethod(decimate_tilde_class, (t_method)decimate_tilde_dsp, gensym("dsp"), 0); +} diff --git a/diode~-help.pd b/diode~-help.pd new file mode 100644 index 0000000..3d0334e --- /dev/null +++ b/diode~-help.pd @@ -0,0 +1,26 @@ +#N canvas 71 176 480 305 12; +#N canvas 0 0 450 300 graph1 0; +#X array diode 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 163 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X text 60 13 ---diode~---; +#X obj 62 201 tabwrite~ diode; +#X obj 62 168 diode~ 0; +#X floatatom 145 147 5 0 2 2 mode[0-2] - -; +#X text 294 12 arg; +#X text 60 35 diode rectifier network; +#X text 263 240 sIgpAck 0.03; +#X text 223 254 2005 www.weiss-archiv.de; +#X connect 1 0 4 0; +#X connect 1 0 6 0; +#X connect 2 0 4 0; +#X connect 2 0 7 0; +#X connect 7 0 6 0; +#X connect 8 0 7 1; diff --git a/diode~.c b/diode~.c new file mode 100644 index 0000000..546ba27 --- /dev/null +++ b/diode~.c @@ -0,0 +1,78 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ diode~ ----------------------------- */ +/* Mangles the signal as if it had been passed through a diode rectifier network.*/ +/* code from swh_plugins by steve harris www.plugin.org.uk */ + +static t_class *diode_tilde_class; + +typedef struct _diode_tilde +{ + t_object x_obj; + t_sample x_mode;//0=none,1=halfWave,2=fullWave + float x_f; +} t_diode_tilde; + +static void *diode_tilde_new(t_floatarg mode) +{ + t_diode_tilde *x = (t_diode_tilde *)pd_new(diode_tilde_class); + x->x_mode = mode; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_mode); + x->x_f = 0; + if(mode) x->x_mode = mode; + else x->x_mode = 0; + return (x); +} + +static t_int *diode_tilde_perform(t_int *w) +{ + t_diode_tilde *x = (t_diode_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + while (n--) + { + f = *in++; + if(x->x_mode >= 0.0f && x->x_mode < 1.0f) { + value = ((1.0f - x->x_mode) * f + (x->x_mode * (f > 0.0f ? f : 0.0f))); + } + else if (x->x_mode >= 1.0f && x->x_mode < 2.0f) { + float fac = x->x_mode - 1.0f; + value = ((1.0f - fac) * (f > 0 ? f : 0.0)) + (fac * fabs(f)); + } + else if (x->x_mode >= 2) { + float fac = x->x_mode < 3 ? x->x_mode - 2 : 1.0; + value = (1.0 - fac) * fabs(f); + } + else { + value = f; + } + *out++ = value; + } + return (w+5); +} + +static void diode_tilde_dsp(t_diode_tilde *x, t_signal **sp) +{ + dsp_add(diode_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void diode_tilde_setup(void) +{ + diode_tilde_class = class_new(gensym("diode~"), (t_newmethod)diode_tilde_new, 0, + sizeof(t_diode_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(diode_tilde_class, t_diode_tilde, x_f); + class_addmethod(diode_tilde_class, (t_method)diode_tilde_dsp, gensym("dsp"), 0); +} diff --git a/foldback~-help.pd b/foldback~-help.pd new file mode 100644 index 0000000..4a7e944 --- /dev/null +++ b/foldback~-help.pd @@ -0,0 +1,30 @@ +#N canvas 71 176 476 301 12; +#N canvas 0 0 450 300 graph1 0; +#X array fold 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 163 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X obj 143 147 nbx 5 14 -1 0 0 0 empty empty neg 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 225 147 nbx 5 14 0 1 0 0 empty empty pos 0 -6 0 10 -262144 -1 +-1 0 256; +#X obj 62 201 tabwrite~ fold; +#X text 264 240 sIgpAck 0.01; +#X text 299 12 arg; +#X text 60 35 signal mirror; +#X obj 62 168 foldback~ -0.5 0.5; +#X text 224 254 2002 www.weiss-archiv.de; +#X text 60 13 ---foldback~---; +#X connect 1 0 4 0; +#X connect 1 0 7 0; +#X connect 2 0 4 0; +#X connect 2 0 11 0; +#X connect 5 0 11 1; +#X connect 6 0 11 2; +#X connect 11 0 7 0; diff --git a/foldback~.c b/foldback~.c new file mode 100644 index 0000000..a40f408 --- /dev/null +++ b/foldback~.c @@ -0,0 +1,70 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ foldback~ ----------------------------- */ +/* signal mirror */ + +static t_class *foldback_tilde_class; + +typedef struct _foldback_tilde +{ + t_object x_obj; + t_sample x_low; + t_sample x_high; + float x_f; +} t_foldback_tilde; + +static void *foldback_tilde_new(t_floatarg low, t_floatarg high) +{ + t_foldback_tilde *x = (t_foldback_tilde *)pd_new(foldback_tilde_class); + x->x_low = low; + x->x_high = high; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_low); + floatinlet_new(&x->x_obj, &x->x_high); + x->x_f = 0; + if(low) x->x_low = low; + else x->x_low = -1; + if(high) x->x_high = high; + else x->x_high = 1; + return (x); +} + +static t_int *foldback_tilde_perform(t_int *w) +{ + t_foldback_tilde *x = (t_foldback_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + while (n--) + { + f = *in++; + if(f < x->x_low) value = (f - ((f - x->x_low) * 2)); + else if(f > x->x_high) value = (f - ((f - x->x_high) * 2)); + else value = f; + *out++ = value; + } + return (w+5); +} + +static void foldback_tilde_dsp(t_foldback_tilde *x, t_signal **sp) +{ + dsp_add(foldback_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void foldback_tilde_setup(void) +{ + foldback_tilde_class = class_new(gensym("foldback~"), (t_newmethod)foldback_tilde_new, 0, + sizeof(t_foldback_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(foldback_tilde_class, t_foldback_tilde, x_f); + class_addmethod(foldback_tilde_class, (t_method)foldback_tilde_dsp, gensym("dsp"), 0); +} diff --git a/foldover~-help.pd b/foldover~-help.pd new file mode 100644 index 0000000..d52a192 --- /dev/null +++ b/foldover~-help.pd @@ -0,0 +1,30 @@ +#N canvas 71 176 480 305 12; +#N canvas 0 0 450 300 graph1 0; +#X array fold 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 163 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X obj 123 144 nbx 5 14 0 0.1 0 0 empty empty amp[0-0.1] 0 -6 0 10 +-262144 -1 -1 0.1 256; +#X obj 206 154 nbx 5 14 0 1 0 0 empty empty sym[0-1] 0 -6 0 10 -262144 +-1 -1 1 256; +#X obj 62 201 tabwrite~ fold; +#X text 60 35 foldover distortion; +#X text 294 12 arg; +#X text 262 240 sIgpAck 0.02; +#X obj 62 168 foldover~ 0 0; +#X text 223 254 2003 www.weiss-archiv.de; +#X text 60 13 ---foldover~---; +#X connect 1 0 4 0; +#X connect 1 0 7 0; +#X connect 2 0 4 0; +#X connect 2 0 11 0; +#X connect 5 0 11 1; +#X connect 6 0 11 2; +#X connect 11 0 7 0; diff --git a/foldover~.c b/foldover~.c new file mode 100644 index 0000000..9b1c699 --- /dev/null +++ b/foldover~.c @@ -0,0 +1,71 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ foldover~ ----------------------------- */ +/* foldover distortion */ +/* code from swh_plugins by steve harris www.plugin.org.uk */ + +static t_class *foldover_tilde_class; + +typedef struct _foldover_tilde +{ + t_object x_obj; + t_sample x_drive_p; + t_sample x_push; + float x_f; +} t_foldover_tilde; + +static void *foldover_tilde_new(t_floatarg drive_p, t_floatarg push) +{ + t_foldover_tilde *x = (t_foldover_tilde *)pd_new(foldover_tilde_class); + x->x_drive_p = drive_p; + x->x_push = push; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_drive_p); + floatinlet_new(&x->x_obj, &x->x_push); + x->x_f = 0; + if(drive_p) x->x_drive_p = drive_p; + else x->x_drive_p = 0; + if(push) x->x_push = push; + else x->x_push = 0; + return (x); +} + +static t_int *foldover_tilde_perform(t_int *w) +{ + t_foldover_tilde *x = (t_foldover_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value, y; + float drive = x->x_drive_p + 1.0f; + while (n--) + { + f = *in++; + y = f * drive + x->x_push; + value = 1.5f * y - 0.5f * y * y *y; + *out++ = value; + } + return (w+5); +} + +static void foldover_tilde_dsp(t_foldover_tilde *x, t_signal **sp) +{ + dsp_add(foldover_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void foldover_tilde_setup(void) +{ + foldover_tilde_class = class_new(gensym("foldover~"), (t_newmethod)foldover_tilde_new, 0, + sizeof(t_foldover_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(foldover_tilde_class, t_foldover_tilde, x_f); + class_addmethod(foldover_tilde_class, (t_method)foldover_tilde_dsp, gensym("dsp"), 0); +} diff --git a/freqdiv~-help.pd b/freqdiv~-help.pd new file mode 100644 index 0000000..6e5c5f5 --- /dev/null +++ b/freqdiv~-help.pd @@ -0,0 +1,27 @@ +#N canvas 71 176 488 313 12; +#N canvas 0 0 450 300 graph1 0; +#X array div 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 338 163 graph; +#X msg 18 85 bang; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 337 75 graph; +#X obj 72 105 tabwrite~ osc; +#X obj 62 201 tabwrite~ div; +#X floatatom 161 143 5 0 8 1 -->denominate - -; +#X text 315 12 arg; +#X text 60 35 signal frequency divider; +#X obj 62 78 osc~ 4; +#X text 220 157 [(int)0-8]; +#X text 293 239 sIgpAck 0.02; +#X obj 62 168 freqdiv~ 1; +#X text 254 254 2003 www.weiss-archiv.de; +#X text 60 13 ---freqdiv~---; +#X connect 1 0 3 0; +#X connect 1 0 4 0; +#X connect 5 0 11 1; +#X connect 8 0 3 0; +#X connect 8 0 11 0; +#X connect 11 0 4 0; diff --git a/freqdiv~.c b/freqdiv~.c new file mode 100644 index 0000000..0155172 --- /dev/null +++ b/freqdiv~.c @@ -0,0 +1,100 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ freqdiv~ ----------------------------- */ +/* frequency divider */ +/* code from swh_plugins by steve harris www.plugins.org.uk */ + +static t_class *freqdiv_tilde_class; + +typedef struct _freqdiv_tilde +{ + t_object x_obj; + t_sample x_denominate; + t_sample x_amp; + float x_count; + t_sample x_lamp; + t_sample x_last; + t_sample x_out; + int x_zeroxs; + float x_f; +} t_freqdiv_tilde; + +static void *freqdiv_tilde_new(t_floatarg denominate) +{ + t_freqdiv_tilde *x = (t_freqdiv_tilde *)pd_new(freqdiv_tilde_class); + x->x_denominate = denominate; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_denominate); + x->x_f = 0; + x->x_amp = 0; + x->x_count = 0; + x->x_lamp = 0; + x->x_last = 0; + x->x_out = 0; + x->x_zeroxs = 0; + if (denominate) x->x_denominate = denominate; + else x->x_denominate = 1; + return (x); +} + +static t_int *freqdiv_tilde_perform(t_int *w) +{ + t_freqdiv_tilde *x = (t_freqdiv_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f; + int den = (int)x->x_denominate; + while (n--) + { + f = *in++; + x->x_count += 1.0f; + if ((f > 0.0f && x->x_last <= 0.0f) || (f < 0.0f && x->x_last >= 0.0)) + { + x->x_zeroxs++; + if (den == 1) + { + x->x_out = x->x_out > 0.0f ? -1.0f : 1.0f; + x->x_lamp = x->x_amp / x->x_count; + x->x_zeroxs = 0; + x->x_count = 0; + x->x_amp = 0; + } + } + x->x_amp += fabs(f); + if (den > 1 && (x->x_zeroxs % den) == den-1) + { + x->x_out = x->x_out > 0.0f ? -1.0f : 1.0f; + x->x_lamp = x->x_amp / x->x_count; + x->x_zeroxs = 0; + x->x_count = 0; + x->x_amp = 0; + } + x->x_last = f; + *out++ = x->x_out * x->x_lamp; + } + return (w+5); +} + +static void freqdiv_tilde_dsp(t_freqdiv_tilde *x, t_signal **sp) +{ + dsp_add(freqdiv_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void freqdiv_tilde_setup(void) +{ + freqdiv_tilde_class = class_new(gensym("freqdiv~"), (t_newmethod)freqdiv_tilde_new, 0, + sizeof(t_freqdiv_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(freqdiv_tilde_class, t_freqdiv_tilde, x_f); + class_addmethod(freqdiv_tilde_class, (t_method)freqdiv_tilde_dsp, gensym("dsp"), 0); +} diff --git a/freqshift~-help.pd b/freqshift~-help.pd new file mode 100644 index 0000000..c0b5b09 --- /dev/null +++ b/freqshift~-help.pd @@ -0,0 +1,38 @@ +#N canvas 106 78 492 389 12; +#N canvas 0 22 450 300 (subpatch) 0; +#X array downshift 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 337 163 graph; +#X msg 18 105 bang; +#N canvas 0 22 450 300 (subpatch) 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 337 75 graph; +#X obj 112 125 tabwrite~ osc; +#X text 60 13 ---freqshift~---; +#X text 60 35 bode frequency shifter; +#X text 315 12 arg; +#X obj 102 188 freqshift~ 100; +#X obj 102 98 osc~ 110; +#X text 287 334 sIgpAck 0.03; +#X text 248 349 2005 www.weiss-archiv.de; +#X floatatom 233 163 5 0 0 2 shift[hz] - -; +#N canvas 0 22 450 300 (subpatch) 0; +#X array upshift 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 338 252 graph; +#X obj 103 324 tabwrite~ downshift; +#X obj 113 300 tabwrite~ upshift; +#X obj 18 79 metro 250; +#X obj 18 60 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1 +; +#X connect 1 0 3 0; +#X connect 1 0 13 0; +#X connect 1 0 14 0; +#X connect 7 0 13 0; +#X connect 7 1 14 0; +#X connect 8 0 3 0; +#X connect 8 0 7 0; +#X connect 11 0 7 1; +#X connect 15 0 1 0; +#X connect 16 0 15 0; diff --git a/freqshift~.c b/freqshift~.c new file mode 100644 index 0000000..026e4cb --- /dev/null +++ b/freqshift~.c @@ -0,0 +1,197 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#define M_PI 3.14159265358979323846 +#endif + +/* ------------------------ freqshift~ ----------------------------- */ +/* frequency shifter */ +/* code from swh_plugins by steve harris www.plugins.org.uk */ + +#define SIN_T_SIZE 64 +#define D_SIZE 256 +#define NZEROS 200 + +static t_class *freqshift_tilde_class; + +typedef struct _freqshift_tilde +{ + t_object x_obj; + t_float x_shift;//[0 - 5000] + float *x_delay; + unsigned int x_dptr; + t_float x_fs; + t_float x_last_shift; + t_float x_phi; + float *x_sint; + float x_f; +} t_freqshift_tilde; + +static void *freqshift_tilde_new(t_floatarg shift) +{ + unsigned int i; + + t_freqshift_tilde *x = (t_freqshift_tilde *)pd_new(freqshift_tilde_class); + //x->x_shift = shift; + outlet_new(&x->x_obj, gensym("signal")); + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_shift); + x->x_fs = sys_getsr(); + x->x_delay = (float *)getbytes(D_SIZE * sizeof(float)); + x->x_sint = (float *)getbytes(SIN_T_SIZE * sizeof(float)); + x->x_dptr = 0; + x->x_phi = 0.0f; + x->x_last_shift = 0.0f; + x->x_f = 0; + for (i = 0; i < SIN_T_SIZE; i++) { + x->x_sint[i] = sin(2.0f * M_PI * (float)i / (float)SIN_T_SIZE); + } + if (shift) x->x_shift = shift; + else x->x_shift = 0; + return (x); +} + +/* The non-zero taps of the Hilbert transformer */ +static float xcoeffs[] = { + +0.0008103736f, +0.0008457886f, +0.0009017196f, +0.0009793364f, + +0.0010798341f, +0.0012044365f, +0.0013544008f, +0.0015310235f, + +0.0017356466f, +0.0019696659f, +0.0022345404f, +0.0025318040f, + +0.0028630784f, +0.0032300896f, +0.0036346867f, +0.0040788644f, + +0.0045647903f, +0.0050948365f, +0.0056716186f, +0.0062980419f, + +0.0069773575f, +0.0077132300f, +0.0085098208f, +0.0093718901f, + +0.0103049226f, +0.0113152847f, +0.0124104218f, +0.0135991079f, + +0.0148917649f, +0.0163008758f, +0.0178415242f, +0.0195321089f, + +0.0213953037f, +0.0234593652f, +0.0257599469f, +0.0283426636f, + +0.0312667947f, +0.0346107648f, +0.0384804823f, +0.0430224431f, + +0.0484451086f, +0.0550553725f, +0.0633242001f, +0.0740128560f, + +0.0884368322f, +0.1090816773f, +0.1412745301f, +0.1988673273f, + +0.3326528346f, +0.9997730178f, -0.9997730178f, -0.3326528346f, + -0.1988673273f, -0.1412745301f, -0.1090816773f, -0.0884368322f, + -0.0740128560f, -0.0633242001f, -0.0550553725f, -0.0484451086f, + -0.0430224431f, -0.0384804823f, -0.0346107648f, -0.0312667947f, + -0.0283426636f, -0.0257599469f, -0.0234593652f, -0.0213953037f, + -0.0195321089f, -0.0178415242f, -0.0163008758f, -0.0148917649f, + -0.0135991079f, -0.0124104218f, -0.0113152847f, -0.0103049226f, + -0.0093718901f, -0.0085098208f, -0.0077132300f, -0.0069773575f, + -0.0062980419f, -0.0056716186f, -0.0050948365f, -0.0045647903f, + -0.0040788644f, -0.0036346867f, -0.0032300896f, -0.0028630784f, + -0.0025318040f, -0.0022345404f, -0.0019696659f, -0.0017356466f, + -0.0015310235f, -0.0013544008f, -0.0012044365f, -0.0010798341f, + -0.0009793364f, -0.0009017196f, -0.0008457886f, -0.0008103736f, +}; + +static float f_clamp(float x, float a, float b) +{ + const float x1 = fabs(x - a); + const float x2 = fabs(x - b); + + x = x1 + a + b; + x -= x2; + x *= 0.5; + + return x; +} + +// Round float to int using IEEE int* hack +static int f_round(float f) { + f += (3<<22); + return *((int*)&f) - 0x4b400000; +} + +// Cubic interpolation function +static float cube_interp(const float fr, const float inm1, const float + in, const float inp1, const float inp2) +{ + return in + 0.5f * fr * (inp1 - inm1 + + fr * (4.0f * inp1 + 2.0f * inm1 - 5.0f * in - inp2 + + fr * (3.0f * (in - inp1) - inm1 + inp2))); +} + +static t_int *freqshift_tilde_perform(t_int *w) +{ + t_freqshift_tilde *x = (t_freqshift_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out1 = (t_float *)(w[3]); + t_float *out2 = (t_float *)(w[4]); + int n = (int)(w[5]); + float f, hilb, rm1, rm2, frac_p; + float shift_i = x->x_last_shift; + float sample_count = sys_getblksize(); + unsigned int i; + int int_p; + const float shift_c = f_clamp(x->x_shift, 0.0f, 10000.0f); + const float shift_inc = (shift_c - x->x_last_shift) / (float)sample_count; + const float freq_fix = (float)SIN_T_SIZE / x->x_fs; + while (n--) + { + f = *in++; + x->x_delay[x->x_dptr] = f; + /* Perform the Hilbert FIR convolution + * (probably FFT would be faster) */ + hilb = 0.0f; + for (i = 0; i <= NZEROS/2; i++) { + hilb += (xcoeffs[i] * x->x_delay[(x->x_dptr - i*2) & (D_SIZE - 1)]); + } + + /* Calcuate the table positions for the sine modulator */ + int_p = f_round(floor(x->x_phi)); + + /* Calculate ringmod1, the transformed input modulated with a shift Hz + * sinewave. This creates a +180 degree sideband at source-shift Hz and + * a 0 degree sindeband at source+shift Hz */ + frac_p = x->x_phi - int_p; + rm1 = hilb * cube_interp(frac_p, x->x_sint[int_p], x->x_sint[int_p+1], + x->x_sint[int_p+2], x->x_sint[int_p+3]); + + /* Calcuate the table positions for the cosine modulator */ + int_p = (int_p + SIN_T_SIZE / 4) & (SIN_T_SIZE - 1); + + /* Calculate ringmod2, the delayed input modulated with a shift Hz + * cosinewave. This creates a 0 degree sideband at source+shift Hz + * and a -180 degree sindeband at source-shift Hz */ + rm2 = x->x_delay[(x->x_dptr - 100) & (D_SIZE - 1)] * cube_interp(frac_p, + x->x_sint[int_p], x->x_sint[int_p+1], x->x_sint[int_p+2], x->x_sint[int_p+3]); + + /* Output the sum and differences of the ringmods. The +/-180 degree + * sidebands cancel (more of less) and just leave the shifted + * components */ + *out1++ = (rm2 - rm1) * 0.5f; /*downshifting*/ + *out2++ = (rm2 + rm1) * 0.5f; /*upshifting*/ + + x->x_dptr = (x->x_dptr + 1) & (D_SIZE - 1); + x->x_phi += shift_i * freq_fix; + while (x->x_phi > SIN_T_SIZE) { + x->x_phi -= SIN_T_SIZE; + } + shift_i += shift_inc; + } + return (w+6); +} + +static void freqshift_tilde_dsp(t_freqshift_tilde *x, t_signal **sp) +{ + dsp_add(freqshift_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); +} + +static void freqshift_tilde_free(t_freqshift_tilde *x) +{ + if(x->x_delay) + freebytes(x->x_delay, D_SIZE * sizeof(float)); + if(x->x_sint) + freebytes(x->x_sint, SIN_T_SIZE + 4 * sizeof(float)); +} + +void freqshift_tilde_setup(void) +{ + freqshift_tilde_class = class_new(gensym("freqshift~"), (t_newmethod)freqshift_tilde_new, (t_method)freqshift_tilde_free, + sizeof(t_freqshift_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(freqshift_tilde_class, t_freqshift_tilde, x_f); + class_addmethod(freqshift_tilde_class, (t_method)freqshift_tilde_dsp, gensym("dsp"), 0); +} diff --git a/harmgen~-help.pd b/harmgen~-help.pd new file mode 100644 index 0000000..8c4e90a --- /dev/null +++ b/harmgen~-help.pd @@ -0,0 +1,54 @@ +#N canvas 211 248 536 429 12; +#N canvas 0 0 450 300 graph1 0; +#X array harm 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 381 169 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 380 79 graph; +#X obj 72 105 tabwrite~ osc; +#X text 60 35 harmonic generator; +#X text 334 17 arg..; +#X text 337 358 sIgpAck 0.02; +#X obj 62 371 tabwrite~ harm; +#X floatatom 86 132 5 -1 1 0 - - -; +#X floatatom 110 153 5 -1 1 0 - - -; +#X floatatom 134 174 5 -1 1 0 - - -; +#X floatatom 159 195 5 -1 1 0 - - -; +#X floatatom 183 215 5 -1 1 0 - - -; +#X floatatom 207 236 5 -1 1 0 - - -; +#X floatatom 232 257 5 -1 1 0 - - -; +#X floatatom 256 277 5 -1 1 0 - - -; +#X floatatom 280 298 5 -1 1 0 - - -; +#X floatatom 305 319 5 -1 1 0 - - -; +#X text 351 318 ->mag10[-1/1]; +#X text 133 130 ->mag1[-1/1]:fundamental freq; +#X text 158 151 ->mag2[-1/1]; +#X text 181 173 ->mag3[-1/1]; +#X text 210 193 ->mag4[-1/1]; +#X text 229 214 ->mag5[-1/1]; +#X text 255 235 ->mag6[-1/1]; +#X text 280 256 ->mag7[-1/1]; +#X text 305 276 ->mag8[-1/1]; +#X text 327 297 ->mag9[-1/1]; +#X obj 62 342 harmgen~ 0 0 0 0 0 0 0 0 0 0; +#X text 298 372 2003 www.weiss-archiv.de; +#X text 60 13 ---harmgen~---; +#X connect 1 0 4 0; +#X connect 1 0 8 0; +#X connect 2 0 4 0; +#X connect 2 0 29 0; +#X connect 9 0 29 1; +#X connect 10 0 29 2; +#X connect 11 0 29 3; +#X connect 12 0 29 4; +#X connect 13 0 29 5; +#X connect 14 0 29 6; +#X connect 15 0 29 7; +#X connect 16 0 29 8; +#X connect 17 0 29 9; +#X connect 18 0 29 10; +#X connect 29 0 8 0; diff --git a/harmgen~.c b/harmgen~.c new file mode 100644 index 0000000..aea31e1 --- /dev/null +++ b/harmgen~.c @@ -0,0 +1,161 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif +#define HARMONICS 11 + +// ------------------------ harmgen~ ----------------------------- +// harmonic generator +// code from swh_plugins by steve harris www.plugins.org.uk + +static t_class *harmgen_tilde_class; + +typedef struct _harmgen_tilde +{ + t_object x_obj; + t_sample x_mag1; + t_sample x_mag2; + t_sample x_mag3; + t_sample x_mag4; + t_sample x_mag5; + t_sample x_mag6; + t_sample x_mag7; + t_sample x_mag8; + t_sample x_mag9; + t_sample x_mag10; + float x_itm; + float x_otm; + float x_f; +} t_harmgen_tilde; + +static void *harmgen_tilde_new(t_floatarg mag1, t_floatarg mag2, t_floatarg mag3, t_floatarg mag4, t_floatarg mag5, t_floatarg mag6, t_floatarg mag7, t_floatarg mag8, t_floatarg mag9, t_floatarg mag10) +{ + t_harmgen_tilde *x = (t_harmgen_tilde *)pd_new(harmgen_tilde_class); + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_mag1); + floatinlet_new(&x->x_obj, &x->x_mag2); + floatinlet_new(&x->x_obj, &x->x_mag3); + floatinlet_new(&x->x_obj, &x->x_mag4); + floatinlet_new(&x->x_obj, &x->x_mag5); + floatinlet_new(&x->x_obj, &x->x_mag6); + floatinlet_new(&x->x_obj, &x->x_mag7); + floatinlet_new(&x->x_obj, &x->x_mag8); + floatinlet_new(&x->x_obj, &x->x_mag9); + floatinlet_new(&x->x_obj, &x->x_mag10); + x->x_f = 0; + if(mag1) x->x_mag1 = mag1; + else x->x_mag1 = 1; + if(mag2) x->x_mag2 = mag2; + else x->x_mag2 = 1; + if(mag3) x->x_mag3 = mag3; + else x->x_mag3 = 1; + if(mag4) x->x_mag4 = mag4; + else x->x_mag4 = 1; + if(mag5) x->x_mag5 = mag5; + else x->x_mag5 = 1; + if(mag6) x->x_mag6 = mag6; + else x->x_mag6 = 1; + if(mag7) x->x_mag7 = mag7; + else x->x_mag7 = 1; + if(mag8) x->x_mag8 = mag8; + else x->x_mag8 = 1; + if(mag9) x->x_mag9 = mag9; + else x->x_mag9 = 1; + if(mag10) x->x_mag10 = mag10; + else x->x_mag10 = 1; + return (x); +} + +/* Calculate Chebychev coefficents from partial magnitudes, adapted from + * example in Num. Rec. */ +void chebpc(float c[], float d[]) +{ + int k, j; + float sv, dd[HARMONICS]; + + for (j = 0; j < HARMONICS; j++) { + d[j] = dd[j] = 0.0; + } + + d[0] = c[HARMONICS - 1]; + + for (j = HARMONICS - 2; j >= 1; j--) { + for (k = HARMONICS - j; k >= 1; k--) { + sv = d[k]; + d[k] = 2.0 * d[k - 1] - dd[k]; + dd[k] = sv; + } + sv = d[0]; + d[0] = -dd[0] + c[j]; + dd[0] = sv; + } + + for (j = HARMONICS - 1; j >= 1; j--) { + d[j] = d[j - 1] - dd[j]; + } + d[0] = -dd[0] + 0.5 * c[0]; +} + +static t_int *harmgen_tilde_perform(t_int *w) +{ + t_harmgen_tilde *x = (t_harmgen_tilde *)(w[1]); + t_float *in1 = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + unsigned long i; + float mag_fix, y, f, value; + float mag[HARMONICS] = {0.0f, x->x_mag1, x->x_mag2, x->x_mag3, x->x_mag4, x->x_mag5, x->x_mag6, + x->x_mag7, x->x_mag8, x->x_mag9, x->x_mag10}; + float p[HARMONICS]; + + // Normalise magnitudes + mag_fix = (fabs(x->x_mag1) + fabs(x->x_mag2) + fabs(x->x_mag3) + fabs(x->x_mag4) + + fabs(x->x_mag5) + fabs(x->x_mag6) + fabs(x->x_mag7) + fabs(x->x_mag8) + + fabs(x->x_mag9) + fabs(x->x_mag10)); + if (mag_fix < 1.0f) { + mag_fix = 1.0f; + } else { + mag_fix = 1.0f / mag_fix; + } + for (i=0; ix_otm = 0.999f * x->x_otm + y - x->x_itm; + x->x_itm = y; + *out++ = x->x_otm; + } + return (w+5); +} + +static void harmgen_tilde_dsp(t_harmgen_tilde *x, t_signal **sp) +{ + dsp_add(harmgen_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void harmgen_tilde_setup(void) +{ + harmgen_tilde_class = class_new(gensym("harmgen~"), (t_newmethod)harmgen_tilde_new, 0, + sizeof(t_harmgen_tilde), 0, A_GIMME, 0); + CLASS_MAINSIGNALIN(harmgen_tilde_class, t_harmgen_tilde, x_f); + class_addmethod(harmgen_tilde_class, (t_method)harmgen_tilde_dsp, gensym("dsp"), 0); +} diff --git a/help/chop~-help.pd b/help/chop~-help.pd deleted file mode 100644 index e0ccf9e..0000000 --- a/help/chop~-help.pd +++ /dev/null @@ -1,32 +0,0 @@ -#N canvas 366 389 462 366 12; -#X obj 155 172 nbx 5 14 -2 2 0 0 empty empty ->factor[-2/2] 60 8 0 -10 -262144 -1 -1 0 256; -#X text 60 35 signal chopping modulator; -#X obj 62 116 osc~ 220; -#X obj 62 312 dac~; -#X obj 156 195 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 --1 -1 92 256; -#X obj 62 277 *~; -#X obj 156 258 line~; -#X obj 156 235 pack 0 50; -#X obj 156 213 dbtorms; -#X text 156 144 ->signal modulation input; -#X text 155 116 ->signal input; -#X text 60 51 multiplicates incoming signal by factor x; -#X text 59 68 if modulation signal is positive; -#X obj 99 146 osc~ 2; -#X text 300 11 arg; -#X text 252 301 sIgpAck 0.02; -#X obj 62 186 chop~ 0; -#X text 213 316 2003 www.weiss-archiv.de; -#X text 60 13 ---chop~---; -#X connect 0 0 16 2; -#X connect 2 0 16 0; -#X connect 4 0 8 0; -#X connect 5 0 3 0; -#X connect 5 0 3 1; -#X connect 6 0 5 1; -#X connect 7 0 6 0; -#X connect 8 0 7 0; -#X connect 13 0 16 1; -#X connect 16 0 5 0; diff --git a/help/decimate~-help.pd b/help/decimate~-help.pd deleted file mode 100644 index 8ea60ee..0000000 --- a/help/decimate~-help.pd +++ /dev/null @@ -1,32 +0,0 @@ -#N canvas 285 400 488 343 12; -#N canvas 0 0 450 300 graph1 0; -#X array deci 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 305 189 graph; -#X msg 8 112 bang; -#X obj 52 105 osc~ 1.5; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 305 102 graph; -#X obj 62 132 tabwrite~ osc; -#X obj 125 172 nbx 5 14 0 1 0 0 empty empty ratio 0 -6 0 10 -262144 --1 -1 0.02 256; -#X obj 199 172 nbx 5 14 0 32 0 0 empty empty bits[1-32] 0 -6 0 10 -262144 --1 -1 0 256; -#X obj 52 228 tabwrite~ deci; -#X text 51 35 signal decimation; -#X text 51 50 a ratio of 1 is orig. samplerate 0.5 is half; -#X text 273 11 arg; -#X text 51 67 of orig. samplerate etc.; -#X text 260 268 sIgpAck 0.02; -#X obj 52 195 decimate~ 0.5 16; -#X text 222 281 2003 www.weiss-archiv.de; -#X text 51 13 ---decimate~---; -#X connect 1 0 4 0; -#X connect 1 0 7 0; -#X connect 2 0 4 0; -#X connect 2 0 13 0; -#X connect 5 0 13 1; -#X connect 6 0 13 2; -#X connect 13 0 7 0; diff --git a/help/diode~-help.pd b/help/diode~-help.pd deleted file mode 100644 index 3d0334e..0000000 --- a/help/diode~-help.pd +++ /dev/null @@ -1,26 +0,0 @@ -#N canvas 71 176 480 305 12; -#N canvas 0 0 450 300 graph1 0; -#X array diode 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 306 163 graph; -#X msg 18 85 bang; -#X obj 62 78 osc~ 1.5; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 306 75 graph; -#X obj 72 105 tabwrite~ osc; -#X text 60 13 ---diode~---; -#X obj 62 201 tabwrite~ diode; -#X obj 62 168 diode~ 0; -#X floatatom 145 147 5 0 2 2 mode[0-2] - -; -#X text 294 12 arg; -#X text 60 35 diode rectifier network; -#X text 263 240 sIgpAck 0.03; -#X text 223 254 2005 www.weiss-archiv.de; -#X connect 1 0 4 0; -#X connect 1 0 6 0; -#X connect 2 0 4 0; -#X connect 2 0 7 0; -#X connect 7 0 6 0; -#X connect 8 0 7 1; diff --git a/help/foldback~-help.pd b/help/foldback~-help.pd deleted file mode 100644 index 4a7e944..0000000 --- a/help/foldback~-help.pd +++ /dev/null @@ -1,30 +0,0 @@ -#N canvas 71 176 476 301 12; -#N canvas 0 0 450 300 graph1 0; -#X array fold 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 306 163 graph; -#X msg 18 85 bang; -#X obj 62 78 osc~ 1.5; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 306 75 graph; -#X obj 72 105 tabwrite~ osc; -#X obj 143 147 nbx 5 14 -1 0 0 0 empty empty neg 0 -6 0 10 -262144 --1 -1 0 256; -#X obj 225 147 nbx 5 14 0 1 0 0 empty empty pos 0 -6 0 10 -262144 -1 --1 0 256; -#X obj 62 201 tabwrite~ fold; -#X text 264 240 sIgpAck 0.01; -#X text 299 12 arg; -#X text 60 35 signal mirror; -#X obj 62 168 foldback~ -0.5 0.5; -#X text 224 254 2002 www.weiss-archiv.de; -#X text 60 13 ---foldback~---; -#X connect 1 0 4 0; -#X connect 1 0 7 0; -#X connect 2 0 4 0; -#X connect 2 0 11 0; -#X connect 5 0 11 1; -#X connect 6 0 11 2; -#X connect 11 0 7 0; diff --git a/help/foldover~-help.pd b/help/foldover~-help.pd deleted file mode 100644 index d52a192..0000000 --- a/help/foldover~-help.pd +++ /dev/null @@ -1,30 +0,0 @@ -#N canvas 71 176 480 305 12; -#N canvas 0 0 450 300 graph1 0; -#X array fold 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 306 163 graph; -#X msg 18 85 bang; -#X obj 62 78 osc~ 1.5; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 306 75 graph; -#X obj 72 105 tabwrite~ osc; -#X obj 123 144 nbx 5 14 0 0.1 0 0 empty empty amp[0-0.1] 0 -6 0 10 --262144 -1 -1 0.1 256; -#X obj 206 154 nbx 5 14 0 1 0 0 empty empty sym[0-1] 0 -6 0 10 -262144 --1 -1 1 256; -#X obj 62 201 tabwrite~ fold; -#X text 60 35 foldover distortion; -#X text 294 12 arg; -#X text 262 240 sIgpAck 0.02; -#X obj 62 168 foldover~ 0 0; -#X text 223 254 2003 www.weiss-archiv.de; -#X text 60 13 ---foldover~---; -#X connect 1 0 4 0; -#X connect 1 0 7 0; -#X connect 2 0 4 0; -#X connect 2 0 11 0; -#X connect 5 0 11 1; -#X connect 6 0 11 2; -#X connect 11 0 7 0; diff --git a/help/freqdiv~-help.pd b/help/freqdiv~-help.pd deleted file mode 100644 index 6e5c5f5..0000000 --- a/help/freqdiv~-help.pd +++ /dev/null @@ -1,27 +0,0 @@ -#N canvas 71 176 488 313 12; -#N canvas 0 0 450 300 graph1 0; -#X array div 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 338 163 graph; -#X msg 18 85 bang; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 337 75 graph; -#X obj 72 105 tabwrite~ osc; -#X obj 62 201 tabwrite~ div; -#X floatatom 161 143 5 0 8 1 -->denominate - -; -#X text 315 12 arg; -#X text 60 35 signal frequency divider; -#X obj 62 78 osc~ 4; -#X text 220 157 [(int)0-8]; -#X text 293 239 sIgpAck 0.02; -#X obj 62 168 freqdiv~ 1; -#X text 254 254 2003 www.weiss-archiv.de; -#X text 60 13 ---freqdiv~---; -#X connect 1 0 3 0; -#X connect 1 0 4 0; -#X connect 5 0 11 1; -#X connect 8 0 3 0; -#X connect 8 0 11 0; -#X connect 11 0 4 0; diff --git a/help/freqshift~-help.pd b/help/freqshift~-help.pd deleted file mode 100644 index c0b5b09..0000000 --- a/help/freqshift~-help.pd +++ /dev/null @@ -1,38 +0,0 @@ -#N canvas 106 78 492 389 12; -#N canvas 0 22 450 300 (subpatch) 0; -#X array downshift 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 337 163 graph; -#X msg 18 105 bang; -#N canvas 0 22 450 300 (subpatch) 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 337 75 graph; -#X obj 112 125 tabwrite~ osc; -#X text 60 13 ---freqshift~---; -#X text 60 35 bode frequency shifter; -#X text 315 12 arg; -#X obj 102 188 freqshift~ 100; -#X obj 102 98 osc~ 110; -#X text 287 334 sIgpAck 0.03; -#X text 248 349 2005 www.weiss-archiv.de; -#X floatatom 233 163 5 0 0 2 shift[hz] - -; -#N canvas 0 22 450 300 (subpatch) 0; -#X array upshift 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 338 252 graph; -#X obj 103 324 tabwrite~ downshift; -#X obj 113 300 tabwrite~ upshift; -#X obj 18 79 metro 250; -#X obj 18 60 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1 -; -#X connect 1 0 3 0; -#X connect 1 0 13 0; -#X connect 1 0 14 0; -#X connect 7 0 13 0; -#X connect 7 1 14 0; -#X connect 8 0 3 0; -#X connect 8 0 7 0; -#X connect 11 0 7 1; -#X connect 15 0 1 0; -#X connect 16 0 15 0; diff --git a/help/harmgen~-help.pd b/help/harmgen~-help.pd deleted file mode 100644 index 8c4e90a..0000000 --- a/help/harmgen~-help.pd +++ /dev/null @@ -1,54 +0,0 @@ -#N canvas 211 248 536 429 12; -#N canvas 0 0 450 300 graph1 0; -#X array harm 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 381 169 graph; -#X msg 18 85 bang; -#X obj 62 78 osc~ 1.5; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 380 79 graph; -#X obj 72 105 tabwrite~ osc; -#X text 60 35 harmonic generator; -#X text 334 17 arg..; -#X text 337 358 sIgpAck 0.02; -#X obj 62 371 tabwrite~ harm; -#X floatatom 86 132 5 -1 1 0 - - -; -#X floatatom 110 153 5 -1 1 0 - - -; -#X floatatom 134 174 5 -1 1 0 - - -; -#X floatatom 159 195 5 -1 1 0 - - -; -#X floatatom 183 215 5 -1 1 0 - - -; -#X floatatom 207 236 5 -1 1 0 - - -; -#X floatatom 232 257 5 -1 1 0 - - -; -#X floatatom 256 277 5 -1 1 0 - - -; -#X floatatom 280 298 5 -1 1 0 - - -; -#X floatatom 305 319 5 -1 1 0 - - -; -#X text 351 318 ->mag10[-1/1]; -#X text 133 130 ->mag1[-1/1]:fundamental freq; -#X text 158 151 ->mag2[-1/1]; -#X text 181 173 ->mag3[-1/1]; -#X text 210 193 ->mag4[-1/1]; -#X text 229 214 ->mag5[-1/1]; -#X text 255 235 ->mag6[-1/1]; -#X text 280 256 ->mag7[-1/1]; -#X text 305 276 ->mag8[-1/1]; -#X text 327 297 ->mag9[-1/1]; -#X obj 62 342 harmgen~ 0 0 0 0 0 0 0 0 0 0; -#X text 298 372 2003 www.weiss-archiv.de; -#X text 60 13 ---harmgen~---; -#X connect 1 0 4 0; -#X connect 1 0 8 0; -#X connect 2 0 4 0; -#X connect 2 0 29 0; -#X connect 9 0 29 1; -#X connect 10 0 29 2; -#X connect 11 0 29 3; -#X connect 12 0 29 4; -#X connect 13 0 29 5; -#X connect 14 0 29 6; -#X connect 15 0 29 7; -#X connect 16 0 29 8; -#X connect 17 0 29 9; -#X connect 18 0 29 10; -#X connect 29 0 8 0; diff --git a/help/rectify~-help.pd b/help/rectify~-help.pd deleted file mode 100644 index 4ebb2c8..0000000 --- a/help/rectify~-help.pd +++ /dev/null @@ -1,27 +0,0 @@ -#N canvas 149 271 419 288 12; -#N canvas 0 0 450 300 graph1 0; -#X array rect 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 231 159 graph; -#X msg 21 113 bang; -#X obj 62 75 osc~ 1.345; -#X obj 75 133 tabwrite~ osc; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 230 72 graph; -#X text 340 68 1; -#X text 333 124 -1; -#X text 60 35 flips negative values to positive; -#X text 342 153 1; -#X text 334 213 -1; -#X obj 62 201 tabwrite~ rect; -#X text 208 237 sIgpAck 0.01; -#X obj 62 165 rectify~; -#X text 166 250 2002 www.weiss-archiv.de; -#X text 60 13 ---rectify~---; -#X connect 1 0 3 0; -#X connect 1 0 10 0; -#X connect 2 0 3 0; -#X connect 2 0 12 0; -#X connect 12 0 10 0; diff --git a/help/round~-help.pd b/help/round~-help.pd deleted file mode 100644 index 00e11dc..0000000 --- a/help/round~-help.pd +++ /dev/null @@ -1,26 +0,0 @@ -#N canvas 190 492 440 305 12; -#N canvas 0 0 450 300 graph1 0; -#X array round 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 307 162 graph; -#X msg 18 85 bang; -#X obj 62 78 osc~ 1.5; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 306 75 graph; -#X obj 72 105 tabwrite~ osc; -#X floatatom 145 146 5 0 0 2 coarse - -; -#X obj 62 201 tabwrite~ round; -#X text 60 13 ---round~---; -#X text 60 35 simple rounder; -#X text 262 240 sIgpAck 0.03; -#X text 223 254 2005 www.weiss-archiv.de; -#X text 312 12 arg; -#X obj 62 168 round~ 2; -#X connect 1 0 4 0; -#X connect 1 0 6 0; -#X connect 2 0 4 0; -#X connect 2 0 12 0; -#X connect 5 0 12 1; -#X connect 12 0 6 0; diff --git a/help/saturate~-help.pd b/help/saturate~-help.pd deleted file mode 100644 index a576666..0000000 --- a/help/saturate~-help.pd +++ /dev/null @@ -1,29 +0,0 @@ -#N canvas 202 222 476 321 12; -#N canvas 0 0 450 300 graph1 0; -#X array sat 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 306 185 graph; -#X msg 17 109 bang; -#X obj 61 102 osc~ 1.5; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 305 99 graph; -#X obj 71 129 tabwrite~ osc; -#X obj 184 172 nbx 5 14 -1 1 0 0 empty empty thresh 0 -6 0 10 -262144 --1 -1 0 256; -#X obj 61 225 tabwrite~ sat; -#X text 60 35 soft saturation; -#X text 316 12 arg; -#X text 263 264 sIgpAck 0.02; -#X text 60 50 if signal is above threshold; -#X text 60 65 a soft saturation is added; -#X obj 61 193 saturate~ 0.5; -#X text 223 278 2003 www.weiss-archiv.de; -#X text 60 13 ---saturate~---; -#X connect 1 0 4 0; -#X connect 1 0 6 0; -#X connect 2 0 4 0; -#X connect 2 0 12 0; -#X connect 5 0 12 1; -#X connect 12 0 6 0; diff --git a/help/sieve~-help.pd b/help/sieve~-help.pd deleted file mode 100644 index f121e6d..0000000 --- a/help/sieve~-help.pd +++ /dev/null @@ -1,28 +0,0 @@ -#N canvas 71 176 480 305 12; -#N canvas 0 0 450 300 graph1 0; -#X array sieve 44100 float 0; -#X coords 0 1.02 44099 -1.02 100 70 1; -#X restore 306 163 graph; -#X msg 18 85 bang; -#X obj 62 78 osc~ 1.5; -#N canvas 0 0 450 300 graph1 0; -#X array osc 44100 float 0; -#X coords 0 1 44099 -1 100 70 1; -#X restore 306 75 graph; -#X obj 72 105 tabwrite~ osc; -#X floatatom 119 145 1 0 0 2 mode - -; -#X floatatom 191 151 5 0 0 2 samp[-1/1] - -; -#X text 262 240 sIgpAck 0.03; -#X text 223 254 2005 www.weiss-archiv.de; -#X obj 62 201 tabwrite~ sieve; -#X obj 62 168 sieve~ 0 0.5; -#X text 60 13 ---sieve~---; -#X text 60 35 simple sample sifter; -#X text 294 12 arg; -#X connect 1 0 4 0; -#X connect 1 0 9 0; -#X connect 2 0 4 0; -#X connect 2 0 10 0; -#X connect 5 0 10 1; -#X connect 6 0 10 2; -#X connect 10 0 9 0; diff --git a/help/split~-help.pd b/help/split~-help.pd deleted file mode 100644 index 9f4f8b5..0000000 --- a/help/split~-help.pd +++ /dev/null @@ -1,26 +0,0 @@ -#N canvas 343 402 362 261 12; -#X floatatom 208 97 5 0 0 0 - - -; -#X obj 109 96 sig~; -#X floatatom 109 74 5 0 0 0 - - -; -#X obj 208 147 snapshot~; -#X obj 109 147 snapshot~; -#X obj 34 127 metro 20; -#X obj 34 102 loadbang; -#X floatatom 109 174 5 0 0 0 - - -; -#X floatatom 208 175 5 0 0 0 - - -; -#X text 60 35 signal split function; -#X text 164 209 sIgpAck 0.01; -#X text 224 13 arg; -#X obj 109 120 split~ 0.5; -#X text 124 224 2002 www.weiss-archiv.de; -#X text 60 13 ---split~---; -#X connect 0 0 12 1; -#X connect 1 0 12 0; -#X connect 2 0 1 0; -#X connect 3 0 8 0; -#X connect 4 0 7 0; -#X connect 5 0 3 0; -#X connect 5 0 4 0; -#X connect 6 0 5 0; -#X connect 12 0 4 0; -#X connect 12 1 3 0; diff --git a/help/ustep~-help.pd b/help/ustep~-help.pd deleted file mode 100644 index 81cf303..0000000 --- a/help/ustep~-help.pd +++ /dev/null @@ -1,38 +0,0 @@ -#N canvas 194 385 571 387 12; -#X obj 62 318 dac~; -#X obj 95 200 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 --1 -1 0 256; -#X obj 62 283 *~; -#X obj 95 263 line~; -#X obj 95 240 pack 0 50; -#X obj 95 218 dbtorms; -#X floatatom 119 118 1 0 0 0 - - -; -#X obj 177 140 nbx 5 14 0 1 0 0 empty empty empty 0 -6 0 10 -262144 --1 -1 0 256; -#X text 60 35 signal unity step function; -#X text 138 117 Mode[0/1]; -#X text 236 136 Thres[0-1]; -#X text 229 179 Mode0: if signal is above the; -#X text 286 191 specified threshold a unity; -#X text 286 203 step is output \, otherwise zero; -#X text 228 218 Mode1: same as above but if below the; -#X text 283 230 threshold \, the signal passes; -#X text 284 242 unchanged; -#X obj 62 92 osc~ 440; -#X floatatom 62 70 5 0 0 0 - - -; -#X text 301 15 arg; -#X text 308 331 sIgpAck 0.01; -#X obj 62 163 ustep~ 0 0.5; -#X text 269 345 2002 www.weiss-archiv.de; -#X text 60 13 ---ustep~---; -#X connect 1 0 5 0; -#X connect 2 0 0 0; -#X connect 2 0 0 1; -#X connect 3 0 2 1; -#X connect 4 0 3 0; -#X connect 5 0 4 0; -#X connect 6 0 21 1; -#X connect 7 0 21 2; -#X connect 17 0 21 0; -#X connect 18 0 17 0; -#X connect 21 0 2 0; diff --git a/help/vowel~-help.pd b/help/vowel~-help.pd deleted file mode 100644 index 442032f..0000000 --- a/help/vowel~-help.pd +++ /dev/null @@ -1,45 +0,0 @@ -#N canvas 308 311 400 400 12; -#X text 60 35 simple formant filter; -#X text 202 11 arg; -#X obj 62 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 -; -#X obj 62 96 metro 200; -#X obj 62 120 random 440; -#X msg 195 95 0; -#X msg 195 117 1; -#X msg 195 139 2; -#X msg 195 162 3; -#X msg 194 185 4; -#X obj 193 212 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 --1 -1 0 256; -#X obj 62 294 *~; -#X obj 193 275 line~; -#X obj 193 252 pack 0 50; -#X obj 193 230 dbtorms; -#X obj 62 329 dac~; -#X text 232 93 ->a; -#X text 233 117 ->e; -#X text 232 138 ->i; -#X text 231 162 ->o; -#X text 231 184 ->u; -#X obj 62 145 phasor~ 220; -#X text 190 315 sIgpAck 0.02; -#X obj 62 205 vowel~ 0; -#X text 151 330 2003 www.weiss-archiv.de; -#X text 60 13 ---vowel~---; -#X connect 2 0 3 0; -#X connect 3 0 4 0; -#X connect 4 0 21 0; -#X connect 5 0 23 1; -#X connect 6 0 23 1; -#X connect 7 0 23 1; -#X connect 8 0 23 1; -#X connect 9 0 23 1; -#X connect 10 0 14 0; -#X connect 11 0 15 0; -#X connect 11 0 15 1; -#X connect 12 0 11 1; -#X connect 13 0 12 0; -#X connect 14 0 13 0; -#X connect 21 0 23 0; -#X connect 23 0 11 0; diff --git a/rectify~-help.pd b/rectify~-help.pd new file mode 100644 index 0000000..4ebb2c8 --- /dev/null +++ b/rectify~-help.pd @@ -0,0 +1,27 @@ +#N canvas 149 271 419 288 12; +#N canvas 0 0 450 300 graph1 0; +#X array rect 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 231 159 graph; +#X msg 21 113 bang; +#X obj 62 75 osc~ 1.345; +#X obj 75 133 tabwrite~ osc; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 230 72 graph; +#X text 340 68 1; +#X text 333 124 -1; +#X text 60 35 flips negative values to positive; +#X text 342 153 1; +#X text 334 213 -1; +#X obj 62 201 tabwrite~ rect; +#X text 208 237 sIgpAck 0.01; +#X obj 62 165 rectify~; +#X text 166 250 2002 www.weiss-archiv.de; +#X text 60 13 ---rectify~---; +#X connect 1 0 3 0; +#X connect 1 0 10 0; +#X connect 2 0 3 0; +#X connect 2 0 12 0; +#X connect 12 0 10 0; diff --git a/rectify~.c b/rectify~.c new file mode 100644 index 0000000..4e5c3eb --- /dev/null +++ b/rectify~.c @@ -0,0 +1,61 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ rectify~ ----------------------------- */ +/* flips negative signal values to positive */ + +static t_class *rectify_tilde_class; + +typedef struct _rectify_tilde +{ + t_object x_obj; + float x_f; +} t_rectify_tilde; + +static void *rectify_tilde_new(void) +{ + t_rectify_tilde *x = (t_rectify_tilde *)pd_new(rectify_tilde_class); + outlet_new(&x->x_obj, gensym("signal")); + x->x_f = 0; + return (x); +} + +static t_int *rectify_tilde_perform(t_int *w) +{ + t_rectify_tilde *x = (t_rectify_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + while (n--) + { + f = *in++; + if (f < 0) + value = f * -1; + else + value = f; + *out++ = value; + } + return (w+5); +} + +static void rectify_tilde_dsp(t_rectify_tilde *x, t_signal **sp) +{ + dsp_add(rectify_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void rectify_tilde_setup(void) +{ + rectify_tilde_class = class_new(gensym("rectify~"), (t_newmethod)rectify_tilde_new, 0, + sizeof(t_rectify_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(rectify_tilde_class, t_rectify_tilde, x_f); + class_addmethod(rectify_tilde_class, (t_method)rectify_tilde_dsp, gensym("dsp"), 0); +} diff --git a/round~-help.pd b/round~-help.pd new file mode 100644 index 0000000..00e11dc --- /dev/null +++ b/round~-help.pd @@ -0,0 +1,26 @@ +#N canvas 190 492 440 305 12; +#N canvas 0 0 450 300 graph1 0; +#X array round 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 307 162 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X floatatom 145 146 5 0 0 2 coarse - -; +#X obj 62 201 tabwrite~ round; +#X text 60 13 ---round~---; +#X text 60 35 simple rounder; +#X text 262 240 sIgpAck 0.03; +#X text 223 254 2005 www.weiss-archiv.de; +#X text 312 12 arg; +#X obj 62 168 round~ 2; +#X connect 1 0 4 0; +#X connect 1 0 6 0; +#X connect 2 0 4 0; +#X connect 2 0 12 0; +#X connect 5 0 12 1; +#X connect 12 0 6 0; diff --git a/round~.c b/round~.c new file mode 100644 index 0000000..2edd047 --- /dev/null +++ b/round~.c @@ -0,0 +1,64 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ round~ ----------------------------- */ +/* simple rounder */ + +static t_class *round_tilde_class; + +typedef struct _round_tilde +{ + t_object x_obj; + t_sample x_coarse; + float x_f; +} t_round_tilde; + +static void *round_tilde_new(t_floatarg coarse) +{ + t_round_tilde *x = (t_round_tilde *)pd_new(round_tilde_class); + x->x_coarse = coarse; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_coarse); + x->x_f = 0; + if(coarse) x->x_coarse = coarse; + else x->x_coarse = 1; + return (x); +} + +static t_int *round_tilde_perform(t_int *w) +{ + t_round_tilde *x = (t_round_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, mult, value; + while (n--) + { + f = *in++; + mult = f * x->x_coarse; + value = (int)mult / x->x_coarse; + *out++ = value; + } + return (w+5); +} + +static void round_tilde_dsp(t_round_tilde *x, t_signal **sp) +{ + dsp_add(round_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void round_tilde_setup(void) +{ + round_tilde_class = class_new(gensym("round~"), (t_newmethod)round_tilde_new, 0, + sizeof(t_round_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(round_tilde_class, t_round_tilde, x_f); + class_addmethod(round_tilde_class, (t_method)round_tilde_dsp, gensym("dsp"), 0); +} diff --git a/sIgpAck.c b/sIgpAck.c new file mode 100644 index 0000000..e666e75 --- /dev/null +++ b/sIgpAck.c @@ -0,0 +1,58 @@ +#ifndef VERSION +#define VERSION "0.03" +#endif + +#include + + +typedef struct _sigpack +{ + t_object x_obj; +} t_sigpack; + +static t_class* sigpack_class; + +void chop_tilde_setup(); +void decimate_tilde_setup(); +void diode_tilde_setup(); +void foldback_tilde_setup(); +void foldover_tilde_setup(); +void freqdiv_tilde_setup(); +void freqshift_tilde_setup(); +void harmgen_tilde_setup(); +void rectify_tilde_setup(); +void round_tilde_setup(); +void saturate_tilde_setup(); +void sieve_tilde_setup(); +void split_tilde_setup(); +void ustep_tilde_setup(); +void vowel_tilde_setup(); + +static void* sigpack_new(t_symbol* s) { + t_sigpack *x = (t_sigpack *)pd_new(sigpack_class); + return (x); +} + +void sigpack_setup(void) +{ + sigpack_class = class_new(gensym("sIgpAck"), (t_newmethod)sigpack_new, 0, + sizeof(t_sigpack), 0,0); + + chop_tilde_setup(); + decimate_tilde_setup(); + diode_tilde_setup(); + foldback_tilde_setup(); + foldover_tilde_setup(); + freqdiv_tilde_setup(); + freqshift_tilde_setup(); + harmgen_tilde_setup(); + rectify_tilde_setup(); + round_tilde_setup(); + saturate_tilde_setup(); + sieve_tilde_setup(); + split_tilde_setup(); + ustep_tilde_setup(); + vowel_tilde_setup(); + + post("sIgpAck"" "VERSION " weiss www.weiss-archiv.de"); +} diff --git a/saturate~-help.pd b/saturate~-help.pd new file mode 100644 index 0000000..a576666 --- /dev/null +++ b/saturate~-help.pd @@ -0,0 +1,29 @@ +#N canvas 202 222 476 321 12; +#N canvas 0 0 450 300 graph1 0; +#X array sat 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 185 graph; +#X msg 17 109 bang; +#X obj 61 102 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 305 99 graph; +#X obj 71 129 tabwrite~ osc; +#X obj 184 172 nbx 5 14 -1 1 0 0 empty empty thresh 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 61 225 tabwrite~ sat; +#X text 60 35 soft saturation; +#X text 316 12 arg; +#X text 263 264 sIgpAck 0.02; +#X text 60 50 if signal is above threshold; +#X text 60 65 a soft saturation is added; +#X obj 61 193 saturate~ 0.5; +#X text 223 278 2003 www.weiss-archiv.de; +#X text 60 13 ---saturate~---; +#X connect 1 0 4 0; +#X connect 1 0 6 0; +#X connect 2 0 4 0; +#X connect 2 0 12 0; +#X connect 5 0 12 1; +#X connect 12 0 6 0; diff --git a/saturate~.c b/saturate~.c new file mode 100644 index 0000000..9438e8e --- /dev/null +++ b/saturate~.c @@ -0,0 +1,83 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ saturate~ ----------------------------- */ +/* signal soft saturation */ +/* code from www.musicdsp.org posted by bram de jong */ + +static t_class *saturate_tilde_class; + +typedef struct _saturate_tilde +{ + t_object x_obj; + t_sample x_thresh; + float x_f; +} t_saturate_tilde; + +static void *saturate_tilde_new(t_floatarg thresh) +{ + t_saturate_tilde *x = (t_saturate_tilde *)pd_new(saturate_tilde_class); + x->x_thresh = thresh; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_thresh); + x->x_f = 0; + if(thresh) x->x_thresh = thresh; + else x->x_thresh = 1.; + return (x); +} + +static float sigmoid(float x) +{ + if(fabs(x) < 1) + return x * (1.5f - 0.5f * x * x); + else + return x > 0.f ? 1.f : -1.f; +} + +static t_int *saturate_tilde_perform(t_int *w) +{ + t_saturate_tilde *x = (t_saturate_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + float t = x->x_thresh; + while (n--) + { + f = *in++; + if(fabs(f) < t) + value = f; + else + { + if(f > 0.f) + value = t + (1.f - t) * sigmoid((f - t)/((1 - t) * 1.5f)); + else + value = -(t + (1.f - t) * sigmoid((-f - t)/((1 - t) * 1.5f))); + } + *out++ = value; + } + return (w+5); +} + +static void saturate_tilde_dsp(t_saturate_tilde *x, t_signal **sp) +{ + dsp_add(saturate_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void saturate_tilde_setup(void) +{ + saturate_tilde_class = class_new(gensym("saturate~"), (t_newmethod)saturate_tilde_new, 0, + sizeof(t_saturate_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(saturate_tilde_class, t_saturate_tilde, x_f); + class_addmethod(saturate_tilde_class, (t_method)saturate_tilde_dsp, gensym("dsp"), 0); + class_addmethod(saturate_tilde_class, (t_method)saturate_tilde_dsp, gensym("sigmoid"), A_FLOAT, 0); +} diff --git a/sieve~-help.pd b/sieve~-help.pd new file mode 100644 index 0000000..f121e6d --- /dev/null +++ b/sieve~-help.pd @@ -0,0 +1,28 @@ +#N canvas 71 176 480 305 12; +#N canvas 0 0 450 300 graph1 0; +#X array sieve 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 163 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X floatatom 119 145 1 0 0 2 mode - -; +#X floatatom 191 151 5 0 0 2 samp[-1/1] - -; +#X text 262 240 sIgpAck 0.03; +#X text 223 254 2005 www.weiss-archiv.de; +#X obj 62 201 tabwrite~ sieve; +#X obj 62 168 sieve~ 0 0.5; +#X text 60 13 ---sieve~---; +#X text 60 35 simple sample sifter; +#X text 294 12 arg; +#X connect 1 0 4 0; +#X connect 1 0 9 0; +#X connect 2 0 4 0; +#X connect 2 0 10 0; +#X connect 5 0 10 1; +#X connect 6 0 10 2; +#X connect 10 0 9 0; diff --git a/sieve~.c b/sieve~.c new file mode 100644 index 0000000..293d4e2 --- /dev/null +++ b/sieve~.c @@ -0,0 +1,105 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sieve~ ----------------------------- */ +/* sift samples */ + +static t_class *sieve_tilde_class; + +typedef struct _sieve_tilde +{ + t_object x_obj; + t_sample x_mode; + t_sample x_sample; + t_sample x_last; + float x_f; +} t_sieve_tilde; + +static void *sieve_tilde_new(t_floatarg mode, t_floatarg sample) +{ + t_sieve_tilde *x = (t_sieve_tilde *)pd_new(sieve_tilde_class); + x->x_mode = mode; + x->x_sample = sample; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_mode); + floatinlet_new(&x->x_obj, &x->x_sample); + x->x_last = 0; + x->x_f = 0; + x->x_mode = 0; + + if(mode) x->x_mode = mode; + if(x->x_mode > 1) x->x_mode = 1; + if(x->x_mode < 0) x->x_mode = 0; + return (x); +} + +static float round(float in) +{ + float y, round; + int temp; + { + round = in * 10; + temp = round; + y = temp * 0.1; + } + return y; +} + +static t_int *sieve_tilde_perform(t_int *w) +{ + t_sieve_tilde *x = (t_sieve_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f; + int mode = x->x_mode; + while (n--) + { + f = *in++; + switch(mode){ + case(0): + if (round(f) != round(x->x_sample)) + { + *out++ = f; + x->x_last = f; + } + else + { + *out++ = x->x_last; + } + break; + case(1): + if (round(f) == round(x->x_sample)) + { + *out++ = f; + x->x_last = f; + } + else + { + *out++ = x->x_last; + } + } + } + return (w+5); +} + +static void sieve_tilde_dsp(t_sieve_tilde *x, t_signal **sp) +{ + dsp_add(sieve_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void sieve_tilde_setup(void) +{ + sieve_tilde_class = class_new(gensym("sieve~"), (t_newmethod)sieve_tilde_new, 0, + sizeof(t_sieve_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(sieve_tilde_class, t_sieve_tilde, x_f); + class_addmethod(sieve_tilde_class, (t_method)sieve_tilde_dsp, gensym("dsp"), 0); +} diff --git a/sigpack-meta.pd b/sigpack-meta.pd new file mode 100644 index 0000000..f4d23dd --- /dev/null +++ b/sigpack-meta.pd @@ -0,0 +1,8 @@ +#N canvas 10 10 200 200 10; +#N canvas 20 20 420 300 META 0; +#X text 10 10 META this is a prototype of a libdir meta file; +#X text 10 30 NAME sigpack; +#X text 10 50 AUTHOR weiss@weiss-archiv.de; +#X text 10 70 LICENSE GNU GPL 2; +#X text 10 90 VERSION 0.0.3.1; +#X restore 10 10 pd META; diff --git a/source/chop~.c b/source/chop~.c deleted file mode 100644 index 1d8c35a..0000000 --- a/source/chop~.c +++ /dev/null @@ -1,67 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -// ------------------------ chop~ ----------------------------- -// signal chopping modulator - -static t_class *chop_tilde_class; - -typedef struct _chop_tilde -{ - t_object x_obj; - t_sample x_factor; - float x_f; -} t_chop_tilde; - -static void *chop_tilde_new(t_floatarg factor) -{ - t_chop_tilde *x = (t_chop_tilde *)pd_new(chop_tilde_class); - x->x_factor = factor; - outlet_new(&x->x_obj, gensym("signal")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - floatinlet_new(&x->x_obj, &x->x_factor); - x->x_f = 0; - if(factor) x->x_factor = factor; - else x->x_factor = 0; - return (x); -} - -static t_int *chop_tilde_perform(t_int *w) -{ - t_chop_tilde *x = (t_chop_tilde *)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *in2 = (t_float *)(w[3]); - t_float *out = (t_float *)(w[4]); - int n = (int)(w[5]); - float f, m, value; - while (n--) - { - f = *in1++; - m = *in2++; - if(m > 0.) value = f * x->x_factor; - else value = f; - *out++ = value; - } - return (w+6); -} - -static void chop_tilde_dsp(t_chop_tilde *x, t_signal **sp) -{ - dsp_add(chop_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); -} - -void chop_tilde_setup(void) -{ - chop_tilde_class = class_new(gensym("chop~"), (t_newmethod)chop_tilde_new, 0, - sizeof(t_chop_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(chop_tilde_class, t_chop_tilde, x_f); - class_addmethod(chop_tilde_class, (t_method)chop_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/decimate~.c b/source/decimate~.c deleted file mode 100644 index 6468d20..0000000 --- a/source/decimate~.c +++ /dev/null @@ -1,76 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -// ------------------------ decimate~ ----------------------------- -// signal decimation -// code from musicdsp.org posted by tobybear - -static t_class *decimate_tilde_class; - -typedef struct _decimate_tilde -{ - t_object x_obj; - t_sample x_rate; - t_sample x_bits; - float x_f; -} t_decimate_tilde; - -static void *decimate_tilde_new(t_floatarg rate, t_floatarg bits) -{ - t_decimate_tilde *x = (t_decimate_tilde *)pd_new(decimate_tilde_class); - x->x_rate = rate; - x->x_bits = bits; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_rate); - floatinlet_new(&x->x_obj, &x->x_bits); - x->x_f = 0; - if (rate) x->x_rate = rate; - else x->x_rate = 0.5; - if (bits) x->x_bits = bits; - else x->x_bits = 16; - return (x); -} - -static t_int *decimate_tilde_perform(t_int *w) -{ - t_decimate_tilde *x = (t_decimate_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f; - long int m=1<<(int)(x->x_bits-1); - float y=0, cnt=0; - while (n--) - { - f = *in++; - cnt+=x->x_rate; - if (cnt>=1) - { - cnt-=1; - y=(long int)(f*m)/(float)m; - } - *out++ = y; - } - return (w+5); -} - -static void decimate_tilde_dsp(t_decimate_tilde *x, t_signal **sp) -{ - dsp_add(decimate_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void decimate_tilde_setup(void) -{ - decimate_tilde_class = class_new(gensym("decimate~"), (t_newmethod)decimate_tilde_new, 0, - sizeof(t_decimate_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(decimate_tilde_class, t_decimate_tilde, x_f); - class_addmethod(decimate_tilde_class, (t_method)decimate_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/diode~.c b/source/diode~.c deleted file mode 100644 index 546ba27..0000000 --- a/source/diode~.c +++ /dev/null @@ -1,78 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#include -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ diode~ ----------------------------- */ -/* Mangles the signal as if it had been passed through a diode rectifier network.*/ -/* code from swh_plugins by steve harris www.plugin.org.uk */ - -static t_class *diode_tilde_class; - -typedef struct _diode_tilde -{ - t_object x_obj; - t_sample x_mode;//0=none,1=halfWave,2=fullWave - float x_f; -} t_diode_tilde; - -static void *diode_tilde_new(t_floatarg mode) -{ - t_diode_tilde *x = (t_diode_tilde *)pd_new(diode_tilde_class); - x->x_mode = mode; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_mode); - x->x_f = 0; - if(mode) x->x_mode = mode; - else x->x_mode = 0; - return (x); -} - -static t_int *diode_tilde_perform(t_int *w) -{ - t_diode_tilde *x = (t_diode_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f, value; - while (n--) - { - f = *in++; - if(x->x_mode >= 0.0f && x->x_mode < 1.0f) { - value = ((1.0f - x->x_mode) * f + (x->x_mode * (f > 0.0f ? f : 0.0f))); - } - else if (x->x_mode >= 1.0f && x->x_mode < 2.0f) { - float fac = x->x_mode - 1.0f; - value = ((1.0f - fac) * (f > 0 ? f : 0.0)) + (fac * fabs(f)); - } - else if (x->x_mode >= 2) { - float fac = x->x_mode < 3 ? x->x_mode - 2 : 1.0; - value = (1.0 - fac) * fabs(f); - } - else { - value = f; - } - *out++ = value; - } - return (w+5); -} - -static void diode_tilde_dsp(t_diode_tilde *x, t_signal **sp) -{ - dsp_add(diode_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void diode_tilde_setup(void) -{ - diode_tilde_class = class_new(gensym("diode~"), (t_newmethod)diode_tilde_new, 0, - sizeof(t_diode_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(diode_tilde_class, t_diode_tilde, x_f); - class_addmethod(diode_tilde_class, (t_method)diode_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/foldback~.c b/source/foldback~.c deleted file mode 100644 index a40f408..0000000 --- a/source/foldback~.c +++ /dev/null @@ -1,70 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ foldback~ ----------------------------- */ -/* signal mirror */ - -static t_class *foldback_tilde_class; - -typedef struct _foldback_tilde -{ - t_object x_obj; - t_sample x_low; - t_sample x_high; - float x_f; -} t_foldback_tilde; - -static void *foldback_tilde_new(t_floatarg low, t_floatarg high) -{ - t_foldback_tilde *x = (t_foldback_tilde *)pd_new(foldback_tilde_class); - x->x_low = low; - x->x_high = high; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_low); - floatinlet_new(&x->x_obj, &x->x_high); - x->x_f = 0; - if(low) x->x_low = low; - else x->x_low = -1; - if(high) x->x_high = high; - else x->x_high = 1; - return (x); -} - -static t_int *foldback_tilde_perform(t_int *w) -{ - t_foldback_tilde *x = (t_foldback_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f, value; - while (n--) - { - f = *in++; - if(f < x->x_low) value = (f - ((f - x->x_low) * 2)); - else if(f > x->x_high) value = (f - ((f - x->x_high) * 2)); - else value = f; - *out++ = value; - } - return (w+5); -} - -static void foldback_tilde_dsp(t_foldback_tilde *x, t_signal **sp) -{ - dsp_add(foldback_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void foldback_tilde_setup(void) -{ - foldback_tilde_class = class_new(gensym("foldback~"), (t_newmethod)foldback_tilde_new, 0, - sizeof(t_foldback_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(foldback_tilde_class, t_foldback_tilde, x_f); - class_addmethod(foldback_tilde_class, (t_method)foldback_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/foldover~.c b/source/foldover~.c deleted file mode 100644 index 9b1c699..0000000 --- a/source/foldover~.c +++ /dev/null @@ -1,71 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ foldover~ ----------------------------- */ -/* foldover distortion */ -/* code from swh_plugins by steve harris www.plugin.org.uk */ - -static t_class *foldover_tilde_class; - -typedef struct _foldover_tilde -{ - t_object x_obj; - t_sample x_drive_p; - t_sample x_push; - float x_f; -} t_foldover_tilde; - -static void *foldover_tilde_new(t_floatarg drive_p, t_floatarg push) -{ - t_foldover_tilde *x = (t_foldover_tilde *)pd_new(foldover_tilde_class); - x->x_drive_p = drive_p; - x->x_push = push; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_drive_p); - floatinlet_new(&x->x_obj, &x->x_push); - x->x_f = 0; - if(drive_p) x->x_drive_p = drive_p; - else x->x_drive_p = 0; - if(push) x->x_push = push; - else x->x_push = 0; - return (x); -} - -static t_int *foldover_tilde_perform(t_int *w) -{ - t_foldover_tilde *x = (t_foldover_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f, value, y; - float drive = x->x_drive_p + 1.0f; - while (n--) - { - f = *in++; - y = f * drive + x->x_push; - value = 1.5f * y - 0.5f * y * y *y; - *out++ = value; - } - return (w+5); -} - -static void foldover_tilde_dsp(t_foldover_tilde *x, t_signal **sp) -{ - dsp_add(foldover_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void foldover_tilde_setup(void) -{ - foldover_tilde_class = class_new(gensym("foldover~"), (t_newmethod)foldover_tilde_new, 0, - sizeof(t_foldover_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(foldover_tilde_class, t_foldover_tilde, x_f); - class_addmethod(foldover_tilde_class, (t_method)foldover_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/freqdiv~.c b/source/freqdiv~.c deleted file mode 100644 index 0155172..0000000 --- a/source/freqdiv~.c +++ /dev/null @@ -1,100 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#include -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ freqdiv~ ----------------------------- */ -/* frequency divider */ -/* code from swh_plugins by steve harris www.plugins.org.uk */ - -static t_class *freqdiv_tilde_class; - -typedef struct _freqdiv_tilde -{ - t_object x_obj; - t_sample x_denominate; - t_sample x_amp; - float x_count; - t_sample x_lamp; - t_sample x_last; - t_sample x_out; - int x_zeroxs; - float x_f; -} t_freqdiv_tilde; - -static void *freqdiv_tilde_new(t_floatarg denominate) -{ - t_freqdiv_tilde *x = (t_freqdiv_tilde *)pd_new(freqdiv_tilde_class); - x->x_denominate = denominate; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_denominate); - x->x_f = 0; - x->x_amp = 0; - x->x_count = 0; - x->x_lamp = 0; - x->x_last = 0; - x->x_out = 0; - x->x_zeroxs = 0; - if (denominate) x->x_denominate = denominate; - else x->x_denominate = 1; - return (x); -} - -static t_int *freqdiv_tilde_perform(t_int *w) -{ - t_freqdiv_tilde *x = (t_freqdiv_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f; - int den = (int)x->x_denominate; - while (n--) - { - f = *in++; - x->x_count += 1.0f; - if ((f > 0.0f && x->x_last <= 0.0f) || (f < 0.0f && x->x_last >= 0.0)) - { - x->x_zeroxs++; - if (den == 1) - { - x->x_out = x->x_out > 0.0f ? -1.0f : 1.0f; - x->x_lamp = x->x_amp / x->x_count; - x->x_zeroxs = 0; - x->x_count = 0; - x->x_amp = 0; - } - } - x->x_amp += fabs(f); - if (den > 1 && (x->x_zeroxs % den) == den-1) - { - x->x_out = x->x_out > 0.0f ? -1.0f : 1.0f; - x->x_lamp = x->x_amp / x->x_count; - x->x_zeroxs = 0; - x->x_count = 0; - x->x_amp = 0; - } - x->x_last = f; - *out++ = x->x_out * x->x_lamp; - } - return (w+5); -} - -static void freqdiv_tilde_dsp(t_freqdiv_tilde *x, t_signal **sp) -{ - dsp_add(freqdiv_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void freqdiv_tilde_setup(void) -{ - freqdiv_tilde_class = class_new(gensym("freqdiv~"), (t_newmethod)freqdiv_tilde_new, 0, - sizeof(t_freqdiv_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(freqdiv_tilde_class, t_freqdiv_tilde, x_f); - class_addmethod(freqdiv_tilde_class, (t_method)freqdiv_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/freqshift~.c b/source/freqshift~.c deleted file mode 100644 index 026e4cb..0000000 --- a/source/freqshift~.c +++ /dev/null @@ -1,197 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#include -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#define M_PI 3.14159265358979323846 -#endif - -/* ------------------------ freqshift~ ----------------------------- */ -/* frequency shifter */ -/* code from swh_plugins by steve harris www.plugins.org.uk */ - -#define SIN_T_SIZE 64 -#define D_SIZE 256 -#define NZEROS 200 - -static t_class *freqshift_tilde_class; - -typedef struct _freqshift_tilde -{ - t_object x_obj; - t_float x_shift;//[0 - 5000] - float *x_delay; - unsigned int x_dptr; - t_float x_fs; - t_float x_last_shift; - t_float x_phi; - float *x_sint; - float x_f; -} t_freqshift_tilde; - -static void *freqshift_tilde_new(t_floatarg shift) -{ - unsigned int i; - - t_freqshift_tilde *x = (t_freqshift_tilde *)pd_new(freqshift_tilde_class); - //x->x_shift = shift; - outlet_new(&x->x_obj, gensym("signal")); - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_shift); - x->x_fs = sys_getsr(); - x->x_delay = (float *)getbytes(D_SIZE * sizeof(float)); - x->x_sint = (float *)getbytes(SIN_T_SIZE * sizeof(float)); - x->x_dptr = 0; - x->x_phi = 0.0f; - x->x_last_shift = 0.0f; - x->x_f = 0; - for (i = 0; i < SIN_T_SIZE; i++) { - x->x_sint[i] = sin(2.0f * M_PI * (float)i / (float)SIN_T_SIZE); - } - if (shift) x->x_shift = shift; - else x->x_shift = 0; - return (x); -} - -/* The non-zero taps of the Hilbert transformer */ -static float xcoeffs[] = { - +0.0008103736f, +0.0008457886f, +0.0009017196f, +0.0009793364f, - +0.0010798341f, +0.0012044365f, +0.0013544008f, +0.0015310235f, - +0.0017356466f, +0.0019696659f, +0.0022345404f, +0.0025318040f, - +0.0028630784f, +0.0032300896f, +0.0036346867f, +0.0040788644f, - +0.0045647903f, +0.0050948365f, +0.0056716186f, +0.0062980419f, - +0.0069773575f, +0.0077132300f, +0.0085098208f, +0.0093718901f, - +0.0103049226f, +0.0113152847f, +0.0124104218f, +0.0135991079f, - +0.0148917649f, +0.0163008758f, +0.0178415242f, +0.0195321089f, - +0.0213953037f, +0.0234593652f, +0.0257599469f, +0.0283426636f, - +0.0312667947f, +0.0346107648f, +0.0384804823f, +0.0430224431f, - +0.0484451086f, +0.0550553725f, +0.0633242001f, +0.0740128560f, - +0.0884368322f, +0.1090816773f, +0.1412745301f, +0.1988673273f, - +0.3326528346f, +0.9997730178f, -0.9997730178f, -0.3326528346f, - -0.1988673273f, -0.1412745301f, -0.1090816773f, -0.0884368322f, - -0.0740128560f, -0.0633242001f, -0.0550553725f, -0.0484451086f, - -0.0430224431f, -0.0384804823f, -0.0346107648f, -0.0312667947f, - -0.0283426636f, -0.0257599469f, -0.0234593652f, -0.0213953037f, - -0.0195321089f, -0.0178415242f, -0.0163008758f, -0.0148917649f, - -0.0135991079f, -0.0124104218f, -0.0113152847f, -0.0103049226f, - -0.0093718901f, -0.0085098208f, -0.0077132300f, -0.0069773575f, - -0.0062980419f, -0.0056716186f, -0.0050948365f, -0.0045647903f, - -0.0040788644f, -0.0036346867f, -0.0032300896f, -0.0028630784f, - -0.0025318040f, -0.0022345404f, -0.0019696659f, -0.0017356466f, - -0.0015310235f, -0.0013544008f, -0.0012044365f, -0.0010798341f, - -0.0009793364f, -0.0009017196f, -0.0008457886f, -0.0008103736f, -}; - -static float f_clamp(float x, float a, float b) -{ - const float x1 = fabs(x - a); - const float x2 = fabs(x - b); - - x = x1 + a + b; - x -= x2; - x *= 0.5; - - return x; -} - -// Round float to int using IEEE int* hack -static int f_round(float f) { - f += (3<<22); - return *((int*)&f) - 0x4b400000; -} - -// Cubic interpolation function -static float cube_interp(const float fr, const float inm1, const float - in, const float inp1, const float inp2) -{ - return in + 0.5f * fr * (inp1 - inm1 + - fr * (4.0f * inp1 + 2.0f * inm1 - 5.0f * in - inp2 + - fr * (3.0f * (in - inp1) - inm1 + inp2))); -} - -static t_int *freqshift_tilde_perform(t_int *w) -{ - t_freqshift_tilde *x = (t_freqshift_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out1 = (t_float *)(w[3]); - t_float *out2 = (t_float *)(w[4]); - int n = (int)(w[5]); - float f, hilb, rm1, rm2, frac_p; - float shift_i = x->x_last_shift; - float sample_count = sys_getblksize(); - unsigned int i; - int int_p; - const float shift_c = f_clamp(x->x_shift, 0.0f, 10000.0f); - const float shift_inc = (shift_c - x->x_last_shift) / (float)sample_count; - const float freq_fix = (float)SIN_T_SIZE / x->x_fs; - while (n--) - { - f = *in++; - x->x_delay[x->x_dptr] = f; - /* Perform the Hilbert FIR convolution - * (probably FFT would be faster) */ - hilb = 0.0f; - for (i = 0; i <= NZEROS/2; i++) { - hilb += (xcoeffs[i] * x->x_delay[(x->x_dptr - i*2) & (D_SIZE - 1)]); - } - - /* Calcuate the table positions for the sine modulator */ - int_p = f_round(floor(x->x_phi)); - - /* Calculate ringmod1, the transformed input modulated with a shift Hz - * sinewave. This creates a +180 degree sideband at source-shift Hz and - * a 0 degree sindeband at source+shift Hz */ - frac_p = x->x_phi - int_p; - rm1 = hilb * cube_interp(frac_p, x->x_sint[int_p], x->x_sint[int_p+1], - x->x_sint[int_p+2], x->x_sint[int_p+3]); - - /* Calcuate the table positions for the cosine modulator */ - int_p = (int_p + SIN_T_SIZE / 4) & (SIN_T_SIZE - 1); - - /* Calculate ringmod2, the delayed input modulated with a shift Hz - * cosinewave. This creates a 0 degree sideband at source+shift Hz - * and a -180 degree sindeband at source-shift Hz */ - rm2 = x->x_delay[(x->x_dptr - 100) & (D_SIZE - 1)] * cube_interp(frac_p, - x->x_sint[int_p], x->x_sint[int_p+1], x->x_sint[int_p+2], x->x_sint[int_p+3]); - - /* Output the sum and differences of the ringmods. The +/-180 degree - * sidebands cancel (more of less) and just leave the shifted - * components */ - *out1++ = (rm2 - rm1) * 0.5f; /*downshifting*/ - *out2++ = (rm2 + rm1) * 0.5f; /*upshifting*/ - - x->x_dptr = (x->x_dptr + 1) & (D_SIZE - 1); - x->x_phi += shift_i * freq_fix; - while (x->x_phi > SIN_T_SIZE) { - x->x_phi -= SIN_T_SIZE; - } - shift_i += shift_inc; - } - return (w+6); -} - -static void freqshift_tilde_dsp(t_freqshift_tilde *x, t_signal **sp) -{ - dsp_add(freqshift_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); -} - -static void freqshift_tilde_free(t_freqshift_tilde *x) -{ - if(x->x_delay) - freebytes(x->x_delay, D_SIZE * sizeof(float)); - if(x->x_sint) - freebytes(x->x_sint, SIN_T_SIZE + 4 * sizeof(float)); -} - -void freqshift_tilde_setup(void) -{ - freqshift_tilde_class = class_new(gensym("freqshift~"), (t_newmethod)freqshift_tilde_new, (t_method)freqshift_tilde_free, - sizeof(t_freqshift_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(freqshift_tilde_class, t_freqshift_tilde, x_f); - class_addmethod(freqshift_tilde_class, (t_method)freqshift_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/harmgen~.c b/source/harmgen~.c deleted file mode 100644 index aea31e1..0000000 --- a/source/harmgen~.c +++ /dev/null @@ -1,161 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#include -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif -#define HARMONICS 11 - -// ------------------------ harmgen~ ----------------------------- -// harmonic generator -// code from swh_plugins by steve harris www.plugins.org.uk - -static t_class *harmgen_tilde_class; - -typedef struct _harmgen_tilde -{ - t_object x_obj; - t_sample x_mag1; - t_sample x_mag2; - t_sample x_mag3; - t_sample x_mag4; - t_sample x_mag5; - t_sample x_mag6; - t_sample x_mag7; - t_sample x_mag8; - t_sample x_mag9; - t_sample x_mag10; - float x_itm; - float x_otm; - float x_f; -} t_harmgen_tilde; - -static void *harmgen_tilde_new(t_floatarg mag1, t_floatarg mag2, t_floatarg mag3, t_floatarg mag4, t_floatarg mag5, t_floatarg mag6, t_floatarg mag7, t_floatarg mag8, t_floatarg mag9, t_floatarg mag10) -{ - t_harmgen_tilde *x = (t_harmgen_tilde *)pd_new(harmgen_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_mag1); - floatinlet_new(&x->x_obj, &x->x_mag2); - floatinlet_new(&x->x_obj, &x->x_mag3); - floatinlet_new(&x->x_obj, &x->x_mag4); - floatinlet_new(&x->x_obj, &x->x_mag5); - floatinlet_new(&x->x_obj, &x->x_mag6); - floatinlet_new(&x->x_obj, &x->x_mag7); - floatinlet_new(&x->x_obj, &x->x_mag8); - floatinlet_new(&x->x_obj, &x->x_mag9); - floatinlet_new(&x->x_obj, &x->x_mag10); - x->x_f = 0; - if(mag1) x->x_mag1 = mag1; - else x->x_mag1 = 1; - if(mag2) x->x_mag2 = mag2; - else x->x_mag2 = 1; - if(mag3) x->x_mag3 = mag3; - else x->x_mag3 = 1; - if(mag4) x->x_mag4 = mag4; - else x->x_mag4 = 1; - if(mag5) x->x_mag5 = mag5; - else x->x_mag5 = 1; - if(mag6) x->x_mag6 = mag6; - else x->x_mag6 = 1; - if(mag7) x->x_mag7 = mag7; - else x->x_mag7 = 1; - if(mag8) x->x_mag8 = mag8; - else x->x_mag8 = 1; - if(mag9) x->x_mag9 = mag9; - else x->x_mag9 = 1; - if(mag10) x->x_mag10 = mag10; - else x->x_mag10 = 1; - return (x); -} - -/* Calculate Chebychev coefficents from partial magnitudes, adapted from - * example in Num. Rec. */ -void chebpc(float c[], float d[]) -{ - int k, j; - float sv, dd[HARMONICS]; - - for (j = 0; j < HARMONICS; j++) { - d[j] = dd[j] = 0.0; - } - - d[0] = c[HARMONICS - 1]; - - for (j = HARMONICS - 2; j >= 1; j--) { - for (k = HARMONICS - j; k >= 1; k--) { - sv = d[k]; - d[k] = 2.0 * d[k - 1] - dd[k]; - dd[k] = sv; - } - sv = d[0]; - d[0] = -dd[0] + c[j]; - dd[0] = sv; - } - - for (j = HARMONICS - 1; j >= 1; j--) { - d[j] = d[j - 1] - dd[j]; - } - d[0] = -dd[0] + 0.5 * c[0]; -} - -static t_int *harmgen_tilde_perform(t_int *w) -{ - t_harmgen_tilde *x = (t_harmgen_tilde *)(w[1]); - t_float *in1 = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - unsigned long i; - float mag_fix, y, f, value; - float mag[HARMONICS] = {0.0f, x->x_mag1, x->x_mag2, x->x_mag3, x->x_mag4, x->x_mag5, x->x_mag6, - x->x_mag7, x->x_mag8, x->x_mag9, x->x_mag10}; - float p[HARMONICS]; - - // Normalise magnitudes - mag_fix = (fabs(x->x_mag1) + fabs(x->x_mag2) + fabs(x->x_mag3) + fabs(x->x_mag4) + - fabs(x->x_mag5) + fabs(x->x_mag6) + fabs(x->x_mag7) + fabs(x->x_mag8) + - fabs(x->x_mag9) + fabs(x->x_mag10)); - if (mag_fix < 1.0f) { - mag_fix = 1.0f; - } else { - mag_fix = 1.0f / mag_fix; - } - for (i=0; ix_otm = 0.999f * x->x_otm + y - x->x_itm; - x->x_itm = y; - *out++ = x->x_otm; - } - return (w+5); -} - -static void harmgen_tilde_dsp(t_harmgen_tilde *x, t_signal **sp) -{ - dsp_add(harmgen_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void harmgen_tilde_setup(void) -{ - harmgen_tilde_class = class_new(gensym("harmgen~"), (t_newmethod)harmgen_tilde_new, 0, - sizeof(t_harmgen_tilde), 0, A_GIMME, 0); - CLASS_MAINSIGNALIN(harmgen_tilde_class, t_harmgen_tilde, x_f); - class_addmethod(harmgen_tilde_class, (t_method)harmgen_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/rectify~.c b/source/rectify~.c deleted file mode 100644 index 4e5c3eb..0000000 --- a/source/rectify~.c +++ /dev/null @@ -1,61 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ rectify~ ----------------------------- */ -/* flips negative signal values to positive */ - -static t_class *rectify_tilde_class; - -typedef struct _rectify_tilde -{ - t_object x_obj; - float x_f; -} t_rectify_tilde; - -static void *rectify_tilde_new(void) -{ - t_rectify_tilde *x = (t_rectify_tilde *)pd_new(rectify_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *rectify_tilde_perform(t_int *w) -{ - t_rectify_tilde *x = (t_rectify_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f, value; - while (n--) - { - f = *in++; - if (f < 0) - value = f * -1; - else - value = f; - *out++ = value; - } - return (w+5); -} - -static void rectify_tilde_dsp(t_rectify_tilde *x, t_signal **sp) -{ - dsp_add(rectify_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void rectify_tilde_setup(void) -{ - rectify_tilde_class = class_new(gensym("rectify~"), (t_newmethod)rectify_tilde_new, 0, - sizeof(t_rectify_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(rectify_tilde_class, t_rectify_tilde, x_f); - class_addmethod(rectify_tilde_class, (t_method)rectify_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/round~.c b/source/round~.c deleted file mode 100644 index 2edd047..0000000 --- a/source/round~.c +++ /dev/null @@ -1,64 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ round~ ----------------------------- */ -/* simple rounder */ - -static t_class *round_tilde_class; - -typedef struct _round_tilde -{ - t_object x_obj; - t_sample x_coarse; - float x_f; -} t_round_tilde; - -static void *round_tilde_new(t_floatarg coarse) -{ - t_round_tilde *x = (t_round_tilde *)pd_new(round_tilde_class); - x->x_coarse = coarse; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_coarse); - x->x_f = 0; - if(coarse) x->x_coarse = coarse; - else x->x_coarse = 1; - return (x); -} - -static t_int *round_tilde_perform(t_int *w) -{ - t_round_tilde *x = (t_round_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f, mult, value; - while (n--) - { - f = *in++; - mult = f * x->x_coarse; - value = (int)mult / x->x_coarse; - *out++ = value; - } - return (w+5); -} - -static void round_tilde_dsp(t_round_tilde *x, t_signal **sp) -{ - dsp_add(round_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void round_tilde_setup(void) -{ - round_tilde_class = class_new(gensym("round~"), (t_newmethod)round_tilde_new, 0, - sizeof(t_round_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(round_tilde_class, t_round_tilde, x_f); - class_addmethod(round_tilde_class, (t_method)round_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/sIgpAck.c b/source/sIgpAck.c deleted file mode 100644 index e666e75..0000000 --- a/source/sIgpAck.c +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef VERSION -#define VERSION "0.03" -#endif - -#include - - -typedef struct _sigpack -{ - t_object x_obj; -} t_sigpack; - -static t_class* sigpack_class; - -void chop_tilde_setup(); -void decimate_tilde_setup(); -void diode_tilde_setup(); -void foldback_tilde_setup(); -void foldover_tilde_setup(); -void freqdiv_tilde_setup(); -void freqshift_tilde_setup(); -void harmgen_tilde_setup(); -void rectify_tilde_setup(); -void round_tilde_setup(); -void saturate_tilde_setup(); -void sieve_tilde_setup(); -void split_tilde_setup(); -void ustep_tilde_setup(); -void vowel_tilde_setup(); - -static void* sigpack_new(t_symbol* s) { - t_sigpack *x = (t_sigpack *)pd_new(sigpack_class); - return (x); -} - -void sigpack_setup(void) -{ - sigpack_class = class_new(gensym("sIgpAck"), (t_newmethod)sigpack_new, 0, - sizeof(t_sigpack), 0,0); - - chop_tilde_setup(); - decimate_tilde_setup(); - diode_tilde_setup(); - foldback_tilde_setup(); - foldover_tilde_setup(); - freqdiv_tilde_setup(); - freqshift_tilde_setup(); - harmgen_tilde_setup(); - rectify_tilde_setup(); - round_tilde_setup(); - saturate_tilde_setup(); - sieve_tilde_setup(); - split_tilde_setup(); - ustep_tilde_setup(); - vowel_tilde_setup(); - - post("sIgpAck"" "VERSION " weiss www.weiss-archiv.de"); -} diff --git a/source/saturate~.c b/source/saturate~.c deleted file mode 100644 index 9438e8e..0000000 --- a/source/saturate~.c +++ /dev/null @@ -1,83 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#include -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ saturate~ ----------------------------- */ -/* signal soft saturation */ -/* code from www.musicdsp.org posted by bram de jong */ - -static t_class *saturate_tilde_class; - -typedef struct _saturate_tilde -{ - t_object x_obj; - t_sample x_thresh; - float x_f; -} t_saturate_tilde; - -static void *saturate_tilde_new(t_floatarg thresh) -{ - t_saturate_tilde *x = (t_saturate_tilde *)pd_new(saturate_tilde_class); - x->x_thresh = thresh; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_thresh); - x->x_f = 0; - if(thresh) x->x_thresh = thresh; - else x->x_thresh = 1.; - return (x); -} - -static float sigmoid(float x) -{ - if(fabs(x) < 1) - return x * (1.5f - 0.5f * x * x); - else - return x > 0.f ? 1.f : -1.f; -} - -static t_int *saturate_tilde_perform(t_int *w) -{ - t_saturate_tilde *x = (t_saturate_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f, value; - float t = x->x_thresh; - while (n--) - { - f = *in++; - if(fabs(f) < t) - value = f; - else - { - if(f > 0.f) - value = t + (1.f - t) * sigmoid((f - t)/((1 - t) * 1.5f)); - else - value = -(t + (1.f - t) * sigmoid((-f - t)/((1 - t) * 1.5f))); - } - *out++ = value; - } - return (w+5); -} - -static void saturate_tilde_dsp(t_saturate_tilde *x, t_signal **sp) -{ - dsp_add(saturate_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void saturate_tilde_setup(void) -{ - saturate_tilde_class = class_new(gensym("saturate~"), (t_newmethod)saturate_tilde_new, 0, - sizeof(t_saturate_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(saturate_tilde_class, t_saturate_tilde, x_f); - class_addmethod(saturate_tilde_class, (t_method)saturate_tilde_dsp, gensym("dsp"), 0); - class_addmethod(saturate_tilde_class, (t_method)saturate_tilde_dsp, gensym("sigmoid"), A_FLOAT, 0); -} diff --git a/source/sieve~.c b/source/sieve~.c deleted file mode 100644 index 293d4e2..0000000 --- a/source/sieve~.c +++ /dev/null @@ -1,105 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ sieve~ ----------------------------- */ -/* sift samples */ - -static t_class *sieve_tilde_class; - -typedef struct _sieve_tilde -{ - t_object x_obj; - t_sample x_mode; - t_sample x_sample; - t_sample x_last; - float x_f; -} t_sieve_tilde; - -static void *sieve_tilde_new(t_floatarg mode, t_floatarg sample) -{ - t_sieve_tilde *x = (t_sieve_tilde *)pd_new(sieve_tilde_class); - x->x_mode = mode; - x->x_sample = sample; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_mode); - floatinlet_new(&x->x_obj, &x->x_sample); - x->x_last = 0; - x->x_f = 0; - x->x_mode = 0; - - if(mode) x->x_mode = mode; - if(x->x_mode > 1) x->x_mode = 1; - if(x->x_mode < 0) x->x_mode = 0; - return (x); -} - -static float round(float in) -{ - float y, round; - int temp; - { - round = in * 10; - temp = round; - y = temp * 0.1; - } - return y; -} - -static t_int *sieve_tilde_perform(t_int *w) -{ - t_sieve_tilde *x = (t_sieve_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f; - int mode = x->x_mode; - while (n--) - { - f = *in++; - switch(mode){ - case(0): - if (round(f) != round(x->x_sample)) - { - *out++ = f; - x->x_last = f; - } - else - { - *out++ = x->x_last; - } - break; - case(1): - if (round(f) == round(x->x_sample)) - { - *out++ = f; - x->x_last = f; - } - else - { - *out++ = x->x_last; - } - } - } - return (w+5); -} - -static void sieve_tilde_dsp(t_sieve_tilde *x, t_signal **sp) -{ - dsp_add(sieve_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void sieve_tilde_setup(void) -{ - sieve_tilde_class = class_new(gensym("sieve~"), (t_newmethod)sieve_tilde_new, 0, - sizeof(t_sieve_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(sieve_tilde_class, t_sieve_tilde, x_f); - class_addmethod(sieve_tilde_class, (t_method)sieve_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/split~.c b/source/split~.c deleted file mode 100644 index 49b8d82..0000000 --- a/source/split~.c +++ /dev/null @@ -1,72 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ split~ ----------------------------- */ -/* signal splitter */ - -static t_class *split_tilde_class; - -typedef struct _split_tilde -{ - t_object x_obj; - float x_f; - t_sample x_thres; -} t_split_tilde; - -static void *split_tilde_new(t_floatarg thres) -{ - t_split_tilde *x = (t_split_tilde *)pd_new(split_tilde_class); - x->x_thres = thres; - outlet_new(&x->x_obj, gensym("signal")); - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_thres); - x->x_f = 0; - if(thres) x->x_thres = thres; - else x->x_thres = 0; - return (x); -} - -static t_int *split_tilde_perform(t_int *w) -{ - t_split_tilde *x = (t_split_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out1 = (t_float *)(w[3]); - t_float *out2 = (t_float *)(w[4]); - int n = (int)(w[5]); - while (n--) - { - float f = *in++; - if(f < x->x_thres) - { - *out1++ = f; - *out2++ = 0; - } - else if(f >= x->x_thres) - { - *out1++ = 0; - *out2++ = f; - } - } - return (w+6); -} - -static void split_tilde_dsp(t_split_tilde *x, t_signal **sp) -{ - dsp_add(split_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); -} - -void split_tilde_setup(void) -{ - split_tilde_class = class_new(gensym("split~"), (t_newmethod)split_tilde_new, 0, - sizeof(t_split_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(split_tilde_class, t_split_tilde, x_f); - class_addmethod(split_tilde_class, (t_method)split_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/ustep~.c b/source/ustep~.c deleted file mode 100644 index b7ea923..0000000 --- a/source/ustep~.c +++ /dev/null @@ -1,83 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ ustep~ ----------------------------- */ -/* signal unity step function */ - -static t_class *ustep_tilde_class; - -typedef struct _ustep_tilde -{ - t_object x_obj; - t_sample x_mode; - t_sample x_thres; - float x_f; -} t_ustep_tilde; - -static void *ustep_tilde_new(t_floatarg mode, t_floatarg thres) -{ - t_ustep_tilde *x = (t_ustep_tilde *)pd_new(ustep_tilde_class); - x->x_mode = mode; - x->x_thres = thres; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_mode); - floatinlet_new(&x->x_obj, &x->x_thres); - x->x_f = 0; - if(mode) x->x_mode = mode; - else x->x_mode = 0; - if(x->x_mode > 1) x->x_mode = 1; - if(x->x_mode < 0) x->x_mode = 0; - if(thres) x->x_thres = thres; - else x->x_thres = 0.5; - return (x); -} - -static t_int *ustep_tilde_perform(t_int *w) -{ - t_ustep_tilde *x = (t_ustep_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f, value; - int mode = x->x_mode; - while (n--) - { - f = *in++; - switch(mode){ - case(0): - if (f >= x->x_thres) - value = 1; - else - value = 0; - break; - case(1): - if (f >= x->x_thres) - value = 1; - else - value = f; - } - *out++ = value; - } - return (w+5); -} - -static void ustep_tilde_dsp(t_ustep_tilde *x, t_signal **sp) -{ - dsp_add(ustep_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void ustep_tilde_setup(void) -{ - ustep_tilde_class = class_new(gensym("ustep~"), (t_newmethod)ustep_tilde_new, 0, - sizeof(t_ustep_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(ustep_tilde_class, t_ustep_tilde, x_f); - class_addmethod(ustep_tilde_class, (t_method)ustep_tilde_dsp, gensym("dsp"), 0); -} diff --git a/source/vowel~.c b/source/vowel~.c deleted file mode 100644 index 87b8e39..0000000 --- a/source/vowel~.c +++ /dev/null @@ -1,118 +0,0 @@ -/* sIgpAck - * for - * pure-data - * www.weiss-archiv.de */ - -#include "m_pd.h" -#ifdef _MSC_VER -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ vowel~ ----------------------------- */ -/* simple formant filter */ -/* code from musicdsp.org posted by alex@smartelectronix.com */ - -static t_class *vowel_tilde_class; - -typedef struct _vowel_tilde -{ - t_object x_obj; - t_sample x_vowelnum; - float x_f; -} t_vowel_tilde; - -static void *vowel_tilde_new(t_floatarg vowelnum) -{ - t_vowel_tilde *x = (t_vowel_tilde *)pd_new(vowel_tilde_class); - x->x_vowelnum = vowelnum; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_vowelnum); - x->x_f = 0; - if(vowelnum) x->x_vowelnum = vowelnum; - else x->x_vowelnum = 0; - return (x); -} - -const double coeff[5][11]= { - { 8.11044e-06, - 8.943665402, -36.83889529, 92.01697887, -154.337906, 181.6233289, - -151.8651235, 89.09614114, -35.10298511, 8.388101016, -0.923313471 ///A - }, - { 4.36215e-06, - 8.90438318, -36.55179099, 91.05750846, -152.422234, 179.1170248, ///E - -149.6496211,87.78352223, -34.60687431, 8.282228154, -0.914150747 - }, - { 3.33819e-06, - 8.893102966, -36.49532826, 90.96543286, -152.4545478, 179.4835618, - -150.315433, 88.43409371, -34.98612086, 8.407803364, -0.932568035 ///I - }, - { 1.13572e-06, - 8.994734087, -37.2084849, 93.22900521, -156.6929844, 184.596544, ///O - -154.3755513, 90.49663749, -35.58964535, 8.478996281, -0.929252233 - }, - { 4.09431e-07, - 8.997322763, -37.20218544, 93.11385476, -156.2530937, 183.7080141, ///U - -153.2631681, 89.59539726, -35.12454591, 8.338655623, -0.910251753 - } -}; - -static double memory[10] = {0,0,0,0,0,0,0,0,0,0}; - -float formant_filter (float in, int vowelnum) -{ - float res; - res= (float) (coeff[vowelnum][0]*in + - coeff[vowelnum][1]*memory[0] + - coeff[vowelnum][2]*memory[1] + - coeff[vowelnum][3]*memory[2] + - coeff[vowelnum][4]*memory[3] + - coeff[vowelnum][5]*memory[4] + - coeff[vowelnum][6]*memory[5] + - coeff[vowelnum][7]*memory[6] + - coeff[vowelnum][8]*memory[7] + - coeff[vowelnum][9]*memory[8] + - coeff[vowelnum][10]*memory[9]); - - memory[9]=memory[8]; - memory[8]=memory[7]; - memory[7]=memory[6]; - memory[6]=memory[5]; - memory[5]=memory[4]; - memory[4]=memory[3]; - memory[3]=memory[2]; - memory[2]=memory[1]; - memory[1]=memory[0]; - memory[0]=(double)res; - return res; -} - -static t_int *vowel_tilde_perform(t_int *w) -{ - t_vowel_tilde *x = (t_vowel_tilde *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - float f, value; - while (n--) - { - f = *in++; - value = formant_filter(f, (int)x->x_vowelnum); - *out++ = value; - } - return (w+5); -} - -static void vowel_tilde_dsp(t_vowel_tilde *x, t_signal **sp) -{ - dsp_add(vowel_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void vowel_tilde_setup(void) -{ - vowel_tilde_class = class_new(gensym("vowel~"), (t_newmethod)vowel_tilde_new, 0, - sizeof(t_vowel_tilde), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(vowel_tilde_class, t_vowel_tilde, x_f); - class_addmethod(vowel_tilde_class, (t_method)vowel_tilde_dsp, gensym("dsp"), 0); - class_addmethod(vowel_tilde_class, (t_method)formant_filter, gensym("formant_filter"), A_GIMME, A_NULL); -} diff --git a/split~-help.pd b/split~-help.pd new file mode 100644 index 0000000..9f4f8b5 --- /dev/null +++ b/split~-help.pd @@ -0,0 +1,26 @@ +#N canvas 343 402 362 261 12; +#X floatatom 208 97 5 0 0 0 - - -; +#X obj 109 96 sig~; +#X floatatom 109 74 5 0 0 0 - - -; +#X obj 208 147 snapshot~; +#X obj 109 147 snapshot~; +#X obj 34 127 metro 20; +#X obj 34 102 loadbang; +#X floatatom 109 174 5 0 0 0 - - -; +#X floatatom 208 175 5 0 0 0 - - -; +#X text 60 35 signal split function; +#X text 164 209 sIgpAck 0.01; +#X text 224 13 arg; +#X obj 109 120 split~ 0.5; +#X text 124 224 2002 www.weiss-archiv.de; +#X text 60 13 ---split~---; +#X connect 0 0 12 1; +#X connect 1 0 12 0; +#X connect 2 0 1 0; +#X connect 3 0 8 0; +#X connect 4 0 7 0; +#X connect 5 0 3 0; +#X connect 5 0 4 0; +#X connect 6 0 5 0; +#X connect 12 0 4 0; +#X connect 12 1 3 0; diff --git a/split~.c b/split~.c new file mode 100644 index 0000000..49b8d82 --- /dev/null +++ b/split~.c @@ -0,0 +1,72 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ split~ ----------------------------- */ +/* signal splitter */ + +static t_class *split_tilde_class; + +typedef struct _split_tilde +{ + t_object x_obj; + float x_f; + t_sample x_thres; +} t_split_tilde; + +static void *split_tilde_new(t_floatarg thres) +{ + t_split_tilde *x = (t_split_tilde *)pd_new(split_tilde_class); + x->x_thres = thres; + outlet_new(&x->x_obj, gensym("signal")); + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_thres); + x->x_f = 0; + if(thres) x->x_thres = thres; + else x->x_thres = 0; + return (x); +} + +static t_int *split_tilde_perform(t_int *w) +{ + t_split_tilde *x = (t_split_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out1 = (t_float *)(w[3]); + t_float *out2 = (t_float *)(w[4]); + int n = (int)(w[5]); + while (n--) + { + float f = *in++; + if(f < x->x_thres) + { + *out1++ = f; + *out2++ = 0; + } + else if(f >= x->x_thres) + { + *out1++ = 0; + *out2++ = f; + } + } + return (w+6); +} + +static void split_tilde_dsp(t_split_tilde *x, t_signal **sp) +{ + dsp_add(split_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); +} + +void split_tilde_setup(void) +{ + split_tilde_class = class_new(gensym("split~"), (t_newmethod)split_tilde_new, 0, + sizeof(t_split_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(split_tilde_class, t_split_tilde, x_f); + class_addmethod(split_tilde_class, (t_method)split_tilde_dsp, gensym("dsp"), 0); +} diff --git a/ustep~-help.pd b/ustep~-help.pd new file mode 100644 index 0000000..81cf303 --- /dev/null +++ b/ustep~-help.pd @@ -0,0 +1,38 @@ +#N canvas 194 385 571 387 12; +#X obj 62 318 dac~; +#X obj 95 200 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 62 283 *~; +#X obj 95 263 line~; +#X obj 95 240 pack 0 50; +#X obj 95 218 dbtorms; +#X floatatom 119 118 1 0 0 0 - - -; +#X obj 177 140 nbx 5 14 0 1 0 0 empty empty empty 0 -6 0 10 -262144 +-1 -1 0 256; +#X text 60 35 signal unity step function; +#X text 138 117 Mode[0/1]; +#X text 236 136 Thres[0-1]; +#X text 229 179 Mode0: if signal is above the; +#X text 286 191 specified threshold a unity; +#X text 286 203 step is output \, otherwise zero; +#X text 228 218 Mode1: same as above but if below the; +#X text 283 230 threshold \, the signal passes; +#X text 284 242 unchanged; +#X obj 62 92 osc~ 440; +#X floatatom 62 70 5 0 0 0 - - -; +#X text 301 15 arg; +#X text 308 331 sIgpAck 0.01; +#X obj 62 163 ustep~ 0 0.5; +#X text 269 345 2002 www.weiss-archiv.de; +#X text 60 13 ---ustep~---; +#X connect 1 0 5 0; +#X connect 2 0 0 0; +#X connect 2 0 0 1; +#X connect 3 0 2 1; +#X connect 4 0 3 0; +#X connect 5 0 4 0; +#X connect 6 0 21 1; +#X connect 7 0 21 2; +#X connect 17 0 21 0; +#X connect 18 0 17 0; +#X connect 21 0 2 0; diff --git a/ustep~.c b/ustep~.c new file mode 100644 index 0000000..b7ea923 --- /dev/null +++ b/ustep~.c @@ -0,0 +1,83 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ ustep~ ----------------------------- */ +/* signal unity step function */ + +static t_class *ustep_tilde_class; + +typedef struct _ustep_tilde +{ + t_object x_obj; + t_sample x_mode; + t_sample x_thres; + float x_f; +} t_ustep_tilde; + +static void *ustep_tilde_new(t_floatarg mode, t_floatarg thres) +{ + t_ustep_tilde *x = (t_ustep_tilde *)pd_new(ustep_tilde_class); + x->x_mode = mode; + x->x_thres = thres; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_mode); + floatinlet_new(&x->x_obj, &x->x_thres); + x->x_f = 0; + if(mode) x->x_mode = mode; + else x->x_mode = 0; + if(x->x_mode > 1) x->x_mode = 1; + if(x->x_mode < 0) x->x_mode = 0; + if(thres) x->x_thres = thres; + else x->x_thres = 0.5; + return (x); +} + +static t_int *ustep_tilde_perform(t_int *w) +{ + t_ustep_tilde *x = (t_ustep_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + int mode = x->x_mode; + while (n--) + { + f = *in++; + switch(mode){ + case(0): + if (f >= x->x_thres) + value = 1; + else + value = 0; + break; + case(1): + if (f >= x->x_thres) + value = 1; + else + value = f; + } + *out++ = value; + } + return (w+5); +} + +static void ustep_tilde_dsp(t_ustep_tilde *x, t_signal **sp) +{ + dsp_add(ustep_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void ustep_tilde_setup(void) +{ + ustep_tilde_class = class_new(gensym("ustep~"), (t_newmethod)ustep_tilde_new, 0, + sizeof(t_ustep_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(ustep_tilde_class, t_ustep_tilde, x_f); + class_addmethod(ustep_tilde_class, (t_method)ustep_tilde_dsp, gensym("dsp"), 0); +} diff --git a/vowel~-help.pd b/vowel~-help.pd new file mode 100644 index 0000000..442032f --- /dev/null +++ b/vowel~-help.pd @@ -0,0 +1,45 @@ +#N canvas 308 311 400 400 12; +#X text 60 35 simple formant filter; +#X text 202 11 arg; +#X obj 62 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 62 96 metro 200; +#X obj 62 120 random 440; +#X msg 195 95 0; +#X msg 195 117 1; +#X msg 195 139 2; +#X msg 195 162 3; +#X msg 194 185 4; +#X obj 193 212 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 62 294 *~; +#X obj 193 275 line~; +#X obj 193 252 pack 0 50; +#X obj 193 230 dbtorms; +#X obj 62 329 dac~; +#X text 232 93 ->a; +#X text 233 117 ->e; +#X text 232 138 ->i; +#X text 231 162 ->o; +#X text 231 184 ->u; +#X obj 62 145 phasor~ 220; +#X text 190 315 sIgpAck 0.02; +#X obj 62 205 vowel~ 0; +#X text 151 330 2003 www.weiss-archiv.de; +#X text 60 13 ---vowel~---; +#X connect 2 0 3 0; +#X connect 3 0 4 0; +#X connect 4 0 21 0; +#X connect 5 0 23 1; +#X connect 6 0 23 1; +#X connect 7 0 23 1; +#X connect 8 0 23 1; +#X connect 9 0 23 1; +#X connect 10 0 14 0; +#X connect 11 0 15 0; +#X connect 11 0 15 1; +#X connect 12 0 11 1; +#X connect 13 0 12 0; +#X connect 14 0 13 0; +#X connect 21 0 23 0; +#X connect 23 0 11 0; diff --git a/vowel~.c b/vowel~.c new file mode 100644 index 0000000..87b8e39 --- /dev/null +++ b/vowel~.c @@ -0,0 +1,118 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ vowel~ ----------------------------- */ +/* simple formant filter */ +/* code from musicdsp.org posted by alex@smartelectronix.com */ + +static t_class *vowel_tilde_class; + +typedef struct _vowel_tilde +{ + t_object x_obj; + t_sample x_vowelnum; + float x_f; +} t_vowel_tilde; + +static void *vowel_tilde_new(t_floatarg vowelnum) +{ + t_vowel_tilde *x = (t_vowel_tilde *)pd_new(vowel_tilde_class); + x->x_vowelnum = vowelnum; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_vowelnum); + x->x_f = 0; + if(vowelnum) x->x_vowelnum = vowelnum; + else x->x_vowelnum = 0; + return (x); +} + +const double coeff[5][11]= { + { 8.11044e-06, + 8.943665402, -36.83889529, 92.01697887, -154.337906, 181.6233289, + -151.8651235, 89.09614114, -35.10298511, 8.388101016, -0.923313471 ///A + }, + { 4.36215e-06, + 8.90438318, -36.55179099, 91.05750846, -152.422234, 179.1170248, ///E + -149.6496211,87.78352223, -34.60687431, 8.282228154, -0.914150747 + }, + { 3.33819e-06, + 8.893102966, -36.49532826, 90.96543286, -152.4545478, 179.4835618, + -150.315433, 88.43409371, -34.98612086, 8.407803364, -0.932568035 ///I + }, + { 1.13572e-06, + 8.994734087, -37.2084849, 93.22900521, -156.6929844, 184.596544, ///O + -154.3755513, 90.49663749, -35.58964535, 8.478996281, -0.929252233 + }, + { 4.09431e-07, + 8.997322763, -37.20218544, 93.11385476, -156.2530937, 183.7080141, ///U + -153.2631681, 89.59539726, -35.12454591, 8.338655623, -0.910251753 + } +}; + +static double memory[10] = {0,0,0,0,0,0,0,0,0,0}; + +float formant_filter (float in, int vowelnum) +{ + float res; + res= (float) (coeff[vowelnum][0]*in + + coeff[vowelnum][1]*memory[0] + + coeff[vowelnum][2]*memory[1] + + coeff[vowelnum][3]*memory[2] + + coeff[vowelnum][4]*memory[3] + + coeff[vowelnum][5]*memory[4] + + coeff[vowelnum][6]*memory[5] + + coeff[vowelnum][7]*memory[6] + + coeff[vowelnum][8]*memory[7] + + coeff[vowelnum][9]*memory[8] + + coeff[vowelnum][10]*memory[9]); + + memory[9]=memory[8]; + memory[8]=memory[7]; + memory[7]=memory[6]; + memory[6]=memory[5]; + memory[5]=memory[4]; + memory[4]=memory[3]; + memory[3]=memory[2]; + memory[2]=memory[1]; + memory[1]=memory[0]; + memory[0]=(double)res; + return res; +} + +static t_int *vowel_tilde_perform(t_int *w) +{ + t_vowel_tilde *x = (t_vowel_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + while (n--) + { + f = *in++; + value = formant_filter(f, (int)x->x_vowelnum); + *out++ = value; + } + return (w+5); +} + +static void vowel_tilde_dsp(t_vowel_tilde *x, t_signal **sp) +{ + dsp_add(vowel_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void vowel_tilde_setup(void) +{ + vowel_tilde_class = class_new(gensym("vowel~"), (t_newmethod)vowel_tilde_new, 0, + sizeof(t_vowel_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(vowel_tilde_class, t_vowel_tilde, x_f); + class_addmethod(vowel_tilde_class, (t_method)vowel_tilde_dsp, gensym("dsp"), 0); + class_addmethod(vowel_tilde_class, (t_method)formant_filter, gensym("formant_filter"), A_GIMME, A_NULL); +} -- cgit v1.2.1